HEL-822: land HEL-821 A1+A2 source onto PR#4 base (db571ba)
- 13 modified / 8 added / 1 deleted per CHANGES.json (author package 76bc120b) - docs/requirements v1.10 + prototypes/hel-799 + PROVENANCE from bundle, verified byte-identical to63799f0- AGENTS.md + scripts/check_requirements.py restored from governance commit63799f0Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
@@ -103,7 +103,7 @@ try:
|
||||
click(page, '看那段聊天')
|
||||
expect(page.locator('.log-panel')).to_be_visible()
|
||||
shot(page, f'{width}-talk-{theme}')
|
||||
click(page, '返回日子')
|
||||
click(page, '结束交谈 · 回到日子')
|
||||
expect(page.get_by_role('heading', name='读到了书里的那片海')).to_be_visible()
|
||||
nav(page, '设置')
|
||||
page.get_by_role('navigation', name='设置分区').get_by_role('button', name='关系', exact=True).click()
|
||||
@@ -131,7 +131,7 @@ try:
|
||||
expect(page.locator('body')).not_to_contain_text('秘密散步')
|
||||
nav(page, '交谈')
|
||||
composer=page.get_by_role('textbox', name='想和她说的话')
|
||||
composer.fill('第一轮'); click(page, '发送'); click(page, '取消本轮回复')
|
||||
composer.fill('第一轮'); click(page, '发送'); click(page, '停止回复')
|
||||
page.wait_for_timeout(1700)
|
||||
click(page, '完整记录')
|
||||
expect(page.locator('.log-panel')).not_to_contain_text('我听见了。')
|
||||
@@ -153,16 +153,16 @@ try:
|
||||
passed(f'{width}: private deep-link guard, cancel/exit isolation, IME/Shift+Enter and XSS text')
|
||||
scenario(page, '下次操作模拟失败'); click(page, '演示场景 · 非真实能力')
|
||||
composer.fill('失败重试'); click(page, '发送')
|
||||
expect(page.locator('.dialog .failed')).to_be_visible()
|
||||
expect(page.locator('.talk-status .retry')).to_be_visible()
|
||||
shot(page, f'{width}-send-failure')
|
||||
scenario(page, '关闭操作失败'); click(page, '演示场景 · 非真实能力')
|
||||
click(page, '重试'); page.wait_for_timeout(1600)
|
||||
expect(page.locator('.dialog .failed')).to_have_count(0)
|
||||
expect(page.locator('.talk-status .retry')).to_have_count(0)
|
||||
click(page, '开始模拟语音'); click(page, '开始模拟')
|
||||
expect(page.get_by_role('button', name='结束语音', exact=True)).to_be_in_viewport()
|
||||
shot(page, f'{width}-voice')
|
||||
click(page, '结束语音')
|
||||
expect(page.locator('.voicebar .end')).to_have_count(0)
|
||||
expect(page.locator('.voice-row')).to_have_count(0)
|
||||
click(page, '视觉观察'); click(page, '开始模拟')
|
||||
expect(page.locator('.observe')).to_contain_text('未采集影像')
|
||||
click(page, '视觉观察')
|
||||
|
||||
@@ -75,7 +75,7 @@ try:
|
||||
click(page,'看更早的日子');expect(page.locator('.ev')).to_have_count(30)
|
||||
page.locator('.ev').nth(10).click()
|
||||
scroll=page.locator('.list').evaluate('el=>el.scrollTop')
|
||||
click(page,'看那段聊天');click(page,'返回日子')
|
||||
click(page,'看那段聊天');click(page,'结束交谈 · 回到日子')
|
||||
assert page.locator('.list').evaluate('el=>el.scrollTop')==scroll
|
||||
checks.append('Long timeline paginates 18 then 12 and retains exact scroll position after chat return')
|
||||
ctx.close()
|
||||
@@ -93,7 +93,7 @@ try:
|
||||
expect(page.locator('.who .name')).to_have_text('初夏')
|
||||
page.get_by_role('navigation',name='主导航').get_by_role('button',name='交谈',exact=True).click()
|
||||
page.get_by_role('textbox',name='想和她说的话').fill('HTTP 预览兼容')
|
||||
click(page,'发送');expect(page.locator('.dialog .her')).to_contain_text('我听见了',timeout=7000)
|
||||
click(page,'发送');expect(page.locator('.stage .line[data-role="companion"]')).to_contain_text('我听见了',timeout=7000)
|
||||
checks.append('Creation and chat work when secure-context randomUUID is unavailable')
|
||||
plain.close();browser.close()
|
||||
finally:
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { anchorOf, chunks, cursorAt, graphemes, groupTurns, pagesOf, type ShownMessage } from '../src/chat/reading';
|
||||
import { Camera, FACE, springStep } from '../src/stage/camera';
|
||||
|
||||
const desk = { width: 900, font: 23, compact: false }, phone = { width: 370, font: 18, compact: false }, squat = { width: 300, font: 16, compact: true };
|
||||
const LONG = '今天望着窗外的雨,想到小时候放学回家的那条路。那时候总觉得路很长,下雨时又不舍得走快,想听雨落在不同屋檐上的声音。后来搬到高一点的地方,雨声变远了,能看见的灯却多了。我还是会在这种时候把手边的事放一放,看看窗外,给自己泡一杯热茶。\n\n有时候,一天里也没有发生什么大事。可能只是花店换了橱窗,或者听到一首特别喜欢的歌。但如果能把这些细小的事情讲给你听,这一天就像多了一盏亮着的灯。\n\n最后这一句也完整保留:愿今晚的雨声让你睡得安稳。';
|
||||
const NOPUNCT = '没有标点的长句'.repeat(40) + '🌙👩👩👧';
|
||||
const msg = (id: string, role: ShownMessage['role'], text: string, extra: Partial<ShownMessage> = {}): ShownMessage => ({ id, role, text, lifeIds: [], ...extra });
|
||||
|
||||
describe('one or two lines at a time', () => {
|
||||
it('keeps every character, never yields an empty line and respects the line budget', () => {
|
||||
for (const metrics of [desk, phone, squat]) for (const text of [LONG, NOPUNCT, '好。', '」开头的标点']) {
|
||||
const parts = chunks(text, metrics);
|
||||
expect(parts.join('')).toBe(text.replace(/\n/g, ''));
|
||||
expect(parts.every(p => p.trim().length > 0)).toBe(true);
|
||||
const max = Math.max(14, Math.min(60, Math.floor(Math.floor(Math.max(220, Math.min(metrics.width, 900) - 24) / metrics.font) * (metrics.compact ? 1.6 : 2))));
|
||||
expect(Math.max(...parts.map(p => graphemes(p).length))).toBeLessThanOrEqual(max + 2);
|
||||
}
|
||||
});
|
||||
it('never splits an emoji or a joined grapheme', () => {
|
||||
const parts = chunks(NOPUNCT, squat);
|
||||
expect(parts.at(-1)).toContain('👩👩👧');
|
||||
});
|
||||
it('a growing stream only ever appends lines: shown lines never change or re-key', () => {
|
||||
const final = pagesOf({ key: 't', items: [msg('u', 'user', '慢慢讲'), msg('c', 'companion', LONG)] }, desk);
|
||||
const units = graphemes(LONG);
|
||||
for (let n = 1; n < units.length; n += 3) {
|
||||
const growing = pagesOf({ key: 't', items: [msg('u', 'user', '慢慢讲'), msg('live', 'companion', units.slice(0, n).join(''), { live: 'generating' })] }, desk);
|
||||
growing.forEach((p, i) => { expect(p.key).toBe(final[i].key); expect(p.text).toBe(final[i].text); });
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('turns follow the real record', () => {
|
||||
it('groups by server turn id, starts a new turn at your message or when she speaks on her own', () => {
|
||||
const turns = groupTurns([
|
||||
msg('1', 'companion', '旧记录没有轮次'), msg('2', 'user', '你好', { turnId: 'a' }), msg('3', 'companion', '你好呀', { turnId: 'a' }),
|
||||
msg('4', 'companion', '雨停了', { proactive: true }), msg('5', 'user', '真的?', { turnId: 'b' }), msg('6', 'companion', '嗯', { turnId: 'b' }), msg('7', 'companion', '迟到的旧轮', { turnId: 'a' }),
|
||||
]);
|
||||
expect(turns.map(t => t.items.map(m => m.id))).toEqual([['1'], ['2', '3'], ['4'], ['5', '6'], ['7']]);
|
||||
expect(turns[1].key).toBe('a');
|
||||
});
|
||||
it('a stopped reply keeps what was said, in its own turn and marked as not finished', () => {
|
||||
const turns = groupTurns([msg('2', 'user', '多说一会儿', { turnId: 'a', status: 'cancelled' }), msg('cut', 'companion', '今天望着窗外的雨,', { turnId: 'a', live: 'cancelled' })]);
|
||||
const pages = pagesOf(turns[0], desk);
|
||||
expect(pages.at(-1)).toMatchObject({ last: true, text: '今天望着窗外的雨,' });
|
||||
expect(pages.at(-1)?.message.live).toBe('cancelled');
|
||||
});
|
||||
});
|
||||
|
||||
describe('reading position survives a re-chunk', () => {
|
||||
it('keeps the same message and place in the text when the width changes', () => {
|
||||
const turn = { key: 't', items: [msg('u', 'user', '慢慢讲'), msg('c', 'companion', LONG)] };
|
||||
const wide = pagesOf(turn, desk), narrow = pagesOf(turn, squat);
|
||||
for (let i = 0; i < wide.length; i++) {
|
||||
const a = anchorOf(wide, i)!, j = cursorAt(narrow, a), start = narrow.slice(0, j).filter(p => p.mi === a.mi).reduce((n, p) => n + p.text.length, 0);
|
||||
expect(narrow[j].mi).toBe(wide[i].mi);
|
||||
expect(start).toBeLessThanOrEqual(a.offset);
|
||||
expect(start + narrow[j].text.length).toBeGreaterThan(a.offset);
|
||||
}
|
||||
expect(cursorAt(wide, null)).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('one room, one camera', () => {
|
||||
it('starts on the room still and lands exactly on the approved talk composition', () => {
|
||||
for (const [w, h] of [[1600, 1000], [1024, 768], [390, 844], [320, 568]]) {
|
||||
const cam = new Camera(w, h), A = cam.rest('room'), B = cam.rest('talk'), start = cam.at(0), end = cam.at(1);
|
||||
expect(start.room.s).toBeCloseTo(A.s, 6); expect(start.room.o[0]).toBeCloseTo(A.o[0], 3); expect(start.room.o[1]).toBeCloseTo(A.o[1], 3);
|
||||
expect(end.talk.s).toBeCloseTo(B.s, 6);
|
||||
expect(end.talk.o[0] + end.talk.s * FACE.talk[0]).toBeCloseTo(B.o[0] + B.s * FACE.talk[0], 2);
|
||||
expect(end.talk.o[1] + end.talk.s * FACE.talk[1]).toBeCloseTo(B.o[1] + B.s * FACE.talk[1], 2);
|
||||
}
|
||||
});
|
||||
it('the spring settles, and reversing mid-way keeps its velocity (no jump)', () => {
|
||||
let s = { t: 0, v: 0, settled: false }, n = 0;
|
||||
while (!s.settled && n++ < 600) s = springStep(s.t, s.v, 1, 1 / 60);
|
||||
expect(s.t).toBe(1); expect(n).toBeLessThan(120);
|
||||
let r = { t: 0, v: 0, settled: false };
|
||||
for (let i = 0; i < 20; i++) r = springStep(r.t, r.v, 1, 1 / 60);
|
||||
const before = r.t, back = springStep(r.t, r.v, 0, 1 / 60);
|
||||
expect(Math.abs(back.t - before)).toBeLessThan(.05);
|
||||
});
|
||||
});
|
||||
@@ -39,9 +39,9 @@ def shot(page, name):
|
||||
def send(page, text, source='real gateway'):
|
||||
page.get_by_role('textbox', name='想和她说的话').fill(text)
|
||||
click(page, '发送')
|
||||
expect(page.get_by_role('button', name='取消本轮回复')).not_to_be_visible(timeout=65000)
|
||||
assert not page.locator('.dialog .failed').count(), page.locator('.dialog').inner_text()
|
||||
reply = page.locator('.dialog .her .current-text').inner_text()
|
||||
expect(page.get_by_role('button', name='停止回复')).not_to_be_visible(timeout=65000)
|
||||
assert not page.locator('.talk-status .retry').count(), page.locator('.conversation').inner_text()
|
||||
reply = page.locator('.log-panel .message[data-role="companion"] p').last.text_content()
|
||||
results['real_dialogue'].append({'input':text,'reply':reply,'source':'controlled provider' if CONTROLLED else source})
|
||||
print('CONTROLLED_REPLY' if CONTROLLED else 'REAL_REPLY', reply, flush=True)
|
||||
return reply
|
||||
@@ -91,11 +91,11 @@ try:
|
||||
passed('controlled provider: two complete streamed turns' if CONTROLLED else 'real gateway: complete streamed reply and second turn recalls 蓝色风铃 from server context')
|
||||
if CONTROLLED: initial_provider.mode='slow'
|
||||
composer.fill('请用中文写一段较长的故事,约800字。'); click(page,'发送')
|
||||
expect(page.get_by_role('button',name='取消本轮回复')).to_be_visible()
|
||||
expect(page.locator('.dialog .her')).not_to_contain_text('她在想',timeout=35000)
|
||||
click(page,'取消本轮回复')
|
||||
expect(page.get_by_role('button',name='停止回复')).to_be_visible()
|
||||
expect(page.locator('.talk-status')).to_contain_text('正在回应',timeout=35000)
|
||||
click(page,'停止回复')
|
||||
# This finite local wait lets the HTTP disconnect reach the isolated service.
|
||||
expect(page.get_by_role('button',name='取消本轮回复')).not_to_be_visible()
|
||||
expect(page.get_by_role('button',name='停止回复')).not_to_be_visible()
|
||||
deadline=time.monotonic()+2
|
||||
while real_app.state.active and time.monotonic()<deadline: time.sleep(.01)
|
||||
assert real_app.state.active is None
|
||||
@@ -126,20 +126,20 @@ try:
|
||||
provider.mode='error'
|
||||
composer=page.get_by_role('textbox',name='想和她说的话')
|
||||
composer.fill('保留的失败草稿'); click(page,'发送')
|
||||
expect(page.locator('.dialog .failed')).to_be_visible()
|
||||
expect(page.locator('.talk-status .retry')).to_be_visible()
|
||||
expect(composer).to_have_value('保留的失败草稿')
|
||||
shot(page,'desktop-model-error')
|
||||
count=app.state.store.query_one('SELECT count(*) n FROM chat_message')['n']
|
||||
provider.mode='normal'; click(page,'重试')
|
||||
expect(page.locator('.dialog .failed')).not_to_be_visible()
|
||||
expect(page.get_by_role('button',name='取消本轮回复')).not_to_be_visible()
|
||||
expect(page.locator('.talk-status .retry')).not_to_be_visible()
|
||||
expect(page.get_by_role('button',name='停止回复')).not_to_be_visible()
|
||||
expect(composer).to_have_value('')
|
||||
assert app.state.store.query_one('SELECT count(*) n FROM chat_message')['n']==count+1
|
||||
passed('controlled SSE model error: Chinese notice, draft retained, same-turn retry without duplicate user row')
|
||||
provider.mode='slow'
|
||||
composer.fill('取消并紧接新问题'); click(page,'发送')
|
||||
expect(page.locator('.dialog .her')).to_contain_text('答')
|
||||
click(page,'取消本轮回复')
|
||||
expect(page.locator('.talk-status')).to_contain_text('正在回应')
|
||||
click(page,'停止回复')
|
||||
provider.mode='normal'; send(page,'新轮不会串台','controlled provider')
|
||||
passed('controlled blocked upstream: immediate cancellation/new question isolation')
|
||||
nav(mp,'设置')
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"""HEL-783 foreground Chromium checks. Only temporary SQLite + controlled LLM.
|
||||
"""HEL-783 foreground Chromium checks (chat parts moved to the HEL-821 stage/reader). Only temporary SQLite + controlled LLM.
|
||||
|
||||
PYTHONPATH=src <python with playwright> web/tests/rework_browser_check.py
|
||||
No deployed service or user data is read or written. Every server/context closes.
|
||||
@@ -69,6 +69,18 @@ def send(page, text):
|
||||
click(page, '发送')
|
||||
|
||||
|
||||
# HEL-821 stage: lines are keyed by turn/position. A shown line must never change its text, and her ink-in plays
|
||||
# at most once per line (re-presenting, status changes and the growing stream never replay it).
|
||||
TRACK = """() => { const seen = window.lineSeen = {}, inked = window.lineInked = {}; window.lineChanged = [];
|
||||
const note = n => { if (!(n instanceof HTMLElement) || !n.matches('.line')) return; const k = n.dataset.key, t = n.querySelector('p').textContent;
|
||||
if (k in seen && seen[k] !== t) window.lineChanged.push([k, seen[k], t]); seen[k] = t;
|
||||
if (n.querySelector('p.ink')) inked[k] = (inked[k] || 0) + 1; };
|
||||
document.querySelectorAll('.stage .line').forEach(note);
|
||||
new MutationObserver(list => list.forEach(r => r.addedNodes.forEach(note))).observe(document.querySelector('.stage'), {childList: true}); }"""
|
||||
STILL = "() => [...document.querySelectorAll('.stage .line:not(.leaving)')].every(n => n.getAnimations().length === 0)"
|
||||
CURRENT = '.stage .line.is-current:not(.leaving)'
|
||||
|
||||
|
||||
try:
|
||||
with tempfile.TemporaryDirectory(prefix='cg-rework-') as directory, sync_playwright() as pw:
|
||||
provider = ReworkLLM()
|
||||
@@ -84,12 +96,6 @@ try:
|
||||
if(key === 'cybergril.demo.v1' && !location.search.includes('demo=1')) throw new Error('real read demo');
|
||||
return get.call(this, key);
|
||||
};
|
||||
window.motionStarts = [];
|
||||
const animate = Element.prototype.animate;
|
||||
Element.prototype.animate = function(...args) {
|
||||
if (this.matches('.her .current-text')) window.motionStarts.push({text:this.textContent, duration:args[1].duration});
|
||||
return animate.apply(this, args);
|
||||
};
|
||||
"""
|
||||
)
|
||||
page.goto(url)
|
||||
@@ -109,39 +115,36 @@ try:
|
||||
|
||||
nav(page, '交谈')
|
||||
provider.mode = 'long'
|
||||
before = page.evaluate('motionStarts.length')
|
||||
page.evaluate(TRACK)
|
||||
send(page, USER)
|
||||
expect(page.locator('.her .current-text')).to_contain_text('开头:')
|
||||
page.evaluate("window.streamNode = document.querySelector('.her .current-text')")
|
||||
# Pause the actual animation and inspect deterministic frames, then resume.
|
||||
frames = []
|
||||
for time in (0, 80, 200):
|
||||
values = page.evaluate("""t => {const el=window.streamNode;const a=el.getAnimations()[0];if(a){a.pause();a.currentTime=t;}const s=getComputedStyle(el);return {time:t,opacity:s.opacity,transform:s.transform};}""", time)
|
||||
frames.append(values)
|
||||
shot(page, f'motion-enter-{time}')
|
||||
page.evaluate('window.streamNode.getAnimations().forEach(a=>a.play())')
|
||||
expect(page.get_by_role('button', name='取消本轮回复')).not_to_be_visible()
|
||||
expect(page.locator('.her .current-text')).to_have_text(LONG)
|
||||
assert page.evaluate("window.streamNode === document.querySelector('.her .current-text')")
|
||||
assert page.evaluate('motionStarts.length') - before == 1
|
||||
assert float(frames[0]['opacity']) < float(frames[1]['opacity']) < float(frames[2]['opacity'])
|
||||
report['motion']['entry_frames'] = frames
|
||||
expect(page.locator('.you .current-text')).to_have_text(USER)
|
||||
passed('Long Chinese stream: entire user/reply retained; final keeps same DOM; one entrance across all chunks and final')
|
||||
|
||||
# Replace a completed sentence; retain its exit DOM until the animation ends.
|
||||
send(page, '再讲一次')
|
||||
outgoing = page.locator('.her .outgoing-text')
|
||||
expect(outgoing).to_have_count(1)
|
||||
assert outgoing.text_content() == LONG
|
||||
exit_frames = page.evaluate("""() => {const el=document.querySelector('.her .outgoing-text');const a=el.getAnimations()[0];a.pause();return [0,80,159].map(t=>{a.currentTime=t;return {time:t,opacity:getComputedStyle(el).opacity,retained:el.isConnected}});} """)
|
||||
assert float(exit_frames[0]['opacity']) > float(exit_frames[-1]['opacity'])
|
||||
report['motion']['exit_frames'] = exit_frames
|
||||
page.evaluate("document.querySelector('.her .outgoing-text').getAnimations().forEach(a=>a.play())")
|
||||
expect(outgoing).to_have_count(0)
|
||||
expect(page.get_by_role('button', name='取消本轮回复')).not_to_be_visible()
|
||||
passed('Old sentence stays mounted during a visible 160ms fade-out, then leaves')
|
||||
# The turn starts at your line, then her reply flows on by itself one or two lines at a time.
|
||||
expect(page.locator(CURRENT)).to_have_attribute('data-role', 'user')
|
||||
expect(page.locator(CURRENT + '[data-role="companion"]')).to_contain_text('开头:', timeout=10000)
|
||||
expect(page.get_by_role('button', name='停止回复')).not_to_be_visible(timeout=15000)
|
||||
# Pause, then review: keyboard lands at once (no slide, no replayed ink), "back to where I was" returns.
|
||||
click(page, '暂停')
|
||||
page.evaluate('document.activeElement.blur()')
|
||||
before = page.locator(CURRENT).get_attribute('data-key')
|
||||
page.keyboard.press('ArrowLeft')
|
||||
expect(page.locator(CURRENT)).not_to_have_attribute('data-key', before)
|
||||
assert page.evaluate(STILL)
|
||||
page.keyboard.press('ArrowRight')
|
||||
expect(page.locator(CURRENT)).to_have_attribute('data-key', before)
|
||||
assert page.evaluate(STILL)
|
||||
click(page, '上一句')
|
||||
page.locator('.reader-bar .latest').click()
|
||||
expect(page.locator(CURRENT)).to_have_attribute('data-key', before)
|
||||
assert page.evaluate('window.lineChanged') == [], page.evaluate('window.lineChanged')
|
||||
assert max(page.evaluate('Object.values(window.lineInked)') or [1]) == 1
|
||||
report['motion']['inked_lines'] = page.evaluate('window.lineInked')
|
||||
click(page, '完整记录')
|
||||
for part in ('长句开头', '用户长句末尾', '开头:', '第5段。', '故事没有被截掉'):
|
||||
expect(page.locator('.log-panel')).to_contain_text(part)
|
||||
click(page, '关闭记录')
|
||||
click(page, '继续')
|
||||
passed('Long Chinese stream: shown lines never change or re-key, ink plays once per line; pause/keyboard review is instant; record keeps everything')
|
||||
|
||||
click(page, '暂停')
|
||||
for width, height in [(1440, 900), (360, 640), (390, 700), (390, 844), (390, 420), (844, 390)]:
|
||||
page.set_viewport_size({'width': width, 'height': height})
|
||||
for theme, label in [('moon', '靛蓝月光'), ('fog', '蓝紫雾光')]:
|
||||
@@ -149,42 +152,49 @@ try:
|
||||
expect(page.locator('html')).to_have_attribute('data-theme', theme)
|
||||
page.get_by_role('textbox', name='想和她说的话').focus()
|
||||
metrics = page.evaluate("""() => {
|
||||
const box=s=>{const b=document.querySelector(s).getBoundingClientRect();return {top:b.top,bottom:b.bottom,height:b.height}};
|
||||
const scroll=document.querySelector('.dialog-scroll');return {dialog:box('.dialog'),composer:box('.composer'),nav:box('.nav'),stage:box('.portal'),scrollHeight:scroll.scrollHeight,clientHeight:scroll.clientHeight,width:innerWidth,overflow:document.documentElement.scrollWidth>innerWidth};
|
||||
const box=el=>{const b=el.getBoundingClientRect();return {top:b.top,bottom:b.bottom,left:b.left,right:b.right,height:b.height}};
|
||||
const q=s=>box(document.querySelector(s));
|
||||
return {stage:q('.stage'),reader:q('.reader-bar'),composer:q('.composer'),nav:q('.nav'),
|
||||
lines:[...document.querySelectorAll('.stage .line:not(.leaving) p')].filter(p=>p.offsetParent).map(box),
|
||||
width:innerWidth,height:innerHeight,overflow:document.documentElement.scrollWidth>innerWidth};
|
||||
}""")
|
||||
assert not metrics['overflow'], metrics
|
||||
assert metrics['stage']['bottom'] <= metrics['dialog']['top'] + 1, metrics
|
||||
assert metrics['dialog']['bottom'] <= metrics['composer']['top'] + 1, metrics
|
||||
assert metrics['lines'], metrics
|
||||
for line in metrics['lines']:
|
||||
assert line['left'] >= 0 and line['right'] <= metrics['width'] + .5, metrics
|
||||
assert line['bottom'] <= metrics['reader']['top'] + 1, metrics
|
||||
assert metrics['stage']['bottom'] <= metrics['reader']['top'] + 1, metrics
|
||||
assert metrics['reader']['bottom'] <= metrics['composer']['top'] + 1, metrics
|
||||
assert metrics['composer']['bottom'] < metrics['nav']['top'], metrics
|
||||
assert metrics['clientHeight'] >= 60, metrics
|
||||
assert metrics['scrollHeight'] > metrics['clientHeight'], metrics
|
||||
report['viewports'].append({'width': width, 'height': height, 'theme': theme, **metrics})
|
||||
page.locator('.dialog-scroll').evaluate('el=>el.scrollTop=0')
|
||||
expect(page.locator('.you .current-text')).to_have_text('再讲一次')
|
||||
if width in (360, 390) and height in (640, 420, 844): shot(page, f'long-start-{width}-{height}-{theme}')
|
||||
page.locator('.dialog-scroll').evaluate('el=>el.scrollTop=el.scrollHeight')
|
||||
if width in (360, 390) and height in (640, 420, 844): shot(page, f'long-end-{width}-{height}-{theme}')
|
||||
if width in (360, 390) and height in (640, 420, 844): shot(page, f'long-line-{width}-{height}-{theme}')
|
||||
click(page, '全文')
|
||||
expect(page.locator('.record.full')).to_be_visible()
|
||||
page.keyboard.press('Escape')
|
||||
expect(page.locator('.record.full')).to_have_count(0)
|
||||
expect(page.get_by_role('button', name='全文', exact=True)).to_be_focused()
|
||||
click(page, '完整记录')
|
||||
expect(page.locator('.log-panel')).to_contain_text('长句开头')
|
||||
expect(page.locator('.log-panel')).to_contain_text('故事没有被截掉')
|
||||
if width == 390 and height == 844: shot(page, f'full-history-{theme}')
|
||||
click(page, '关闭记录')
|
||||
passed('12 viewport/theme combinations: long text scrolls, stage/dialog/composer/navigation never overlap; full history reachable')
|
||||
click(page, '继续')
|
||||
passed('12 viewport/theme combinations: lines stay inside the stage, stage/reader/composer/navigation never overlap; Esc closes full text with focus back; full history reachable')
|
||||
|
||||
page.set_viewport_size({'width': 390, 'height': 700})
|
||||
provider.mode = 'slow'; send(page, '取消并重发')
|
||||
expect(page.locator('.her .current-text')).to_have_text('答')
|
||||
click(page, '取消本轮回复')
|
||||
expect(page.get_by_role('button', name='停止回复')).to_be_visible()
|
||||
click(page, '停止回复')
|
||||
provider.mode = 'normal'; send(page, '新轮')
|
||||
expect(page.get_by_role('button', name='取消本轮回复')).not_to_be_visible()
|
||||
expect(page.locator('.her .current-text')).to_have_text('答复')
|
||||
expect(page.get_by_role('button', name='停止回复')).not_to_be_visible()
|
||||
expect(page.locator(CURRENT + '[data-role="companion"]')).to_have_text('答复', timeout=8000)
|
||||
provider.mode = 'error'; send(page, '失败再试')
|
||||
expect(page.locator('.dialog .failed')).to_be_visible()
|
||||
expect(page.locator('.talk-status .retry')).to_be_visible()
|
||||
expect(page.get_by_role('textbox', name='想和她说的话')).to_have_value('失败再试')
|
||||
count = app.state.store.query_one('SELECT count(*) n FROM chat_message')['n']
|
||||
provider.mode = 'normal'; page.locator('.dialog .retry').click()
|
||||
expect(page.locator('.dialog .failed')).not_to_be_visible()
|
||||
expect(page.get_by_role('button', name='取消本轮回复')).not_to_be_visible()
|
||||
provider.mode = 'normal'; page.locator('.talk-status .retry').click()
|
||||
expect(page.locator('.talk-status .retry')).not_to_be_visible()
|
||||
expect(page.get_by_role('button', name='停止回复')).not_to_be_visible()
|
||||
assert app.state.store.query_one('SELECT count(*) n FROM chat_message')['n'] == count + 1
|
||||
passed('Cancel then immediate new turn, model error and same-turn retry preserve roles and avoid duplicate user messages')
|
||||
|
||||
@@ -228,11 +238,14 @@ try:
|
||||
page.reload(); nav(page, '交谈')
|
||||
assert page.locator('html').evaluate("el=>el.classList.contains('reduced')")
|
||||
provider.mode = 'normal'; send(page, '减少动效检查')
|
||||
expect(page.get_by_role('button', name='取消本轮回复')).not_to_be_visible()
|
||||
assert page.evaluate('motionStarts.at(-1).duration') == 120
|
||||
expect(page.get_by_role('button', name='停止回复')).not_to_be_visible()
|
||||
expect(page.locator(CURRENT + '[data-role="companion"]')).to_have_text('答复', timeout=8000)
|
||||
assert page.evaluate(STILL) and page.locator('.stage p.ink').count() == 0
|
||||
reduced = browser.new_context(viewport={'width': 390, 'height': 700}, reduced_motion='reduce')
|
||||
rp = reduced.new_page(); rp.goto(url); nav(rp, '交谈'); send(rp, '系统减少动效')
|
||||
expect(rp.get_by_role('button', name='取消本轮回复')).not_to_be_visible()
|
||||
expect(rp.get_by_role('button', name='停止回复')).not_to_be_visible()
|
||||
expect(rp.locator(CURRENT + '[data-role="companion"]')).to_have_text('答复', timeout=8000)
|
||||
assert rp.evaluate(STILL) and rp.locator('.stage p.ink').count() == 0
|
||||
reduced.close()
|
||||
passed('Escape navigation; browser display preference survives reload; settings/system reduced motion uses gentle opacity')
|
||||
|
||||
@@ -247,7 +260,7 @@ try:
|
||||
dp.get_by_role('checkbox').check(); click(dp, '确认创建'); click(dp, '去看看她')
|
||||
nav(dp, '交谈'); click(dp, '开始模拟语音'); click(dp, '开始模拟')
|
||||
expect(dp.get_by_role('button', name='结束语音')).to_be_visible()
|
||||
assert dp.locator('.voicebar').bounding_box()['y'] > dp.locator('.dialog').bounding_box()['y']
|
||||
assert dp.locator('.voice-row').bounding_box()['y'] + dp.locator('.voice-row').bounding_box()['height'] <= dp.locator('.composer').bounding_box()['y'] + 1
|
||||
shot(dp, 'demo-voice-390')
|
||||
click(dp, '结束语音')
|
||||
dp.locator('.demo > button').click(); click(dp, '载入三天记录')
|
||||
|
||||
Reference in New Issue
Block a user