Initial import of streamline
This commit is contained in:
@@ -0,0 +1,96 @@
|
||||
import {createRequire} from 'node:module';
|
||||
import {writeFile,mkdir} from 'node:fs/promises';
|
||||
import {tmpdir} from 'node:os';
|
||||
import {join} from 'node:path';
|
||||
import assert from 'node:assert/strict';
|
||||
const require = createRequire(process.env.EDDY_HISTORY_PLAYWRIGHT_PACKAGE || import.meta.url);
|
||||
const {chromium} = require('playwright');
|
||||
const out = process.env.EDDY_HISTORY_OUTPUT_DIR || join(tmpdir(), 'eddy-history-browser');
|
||||
await mkdir(out, {recursive:true});
|
||||
const base = process.argv[2];
|
||||
if (!['127.0.0.1', 'localhost'].includes(new URL(base).hostname)) throw new Error('Only the local synthetic fixture is allowed');
|
||||
const source = 'b'.repeat(64), otherSource = 'd'.repeat(64);
|
||||
const deep = base + '/eddy/tasks?machine=' + 'a'.repeat(16) + '&task=browser-main&source=' + source;
|
||||
const browser = await chromium.launch({channel:'chrome',headless:true});
|
||||
const checks=[], errors=[], external=[];
|
||||
let debugPage;
|
||||
try {
|
||||
const context = await browser.newContext({viewport:{width:1370,height:1000}});
|
||||
await context.addInitScript(() => {
|
||||
localStorage.setItem('light:ttuae2:local-session','history-browser');
|
||||
localStorage.setItem('streamline.sso.user',JSON.stringify({email:'history-browser@example.com',name:'Synthetic user'}));
|
||||
});
|
||||
const page = await context.newPage();debugPage=page;page.setDefaultTimeout(8000);page.on('pageerror',e=>errors.push(e.message));
|
||||
page.on('request',r=>{if(!r.url().startsWith(base))external.push(r.url())});
|
||||
const mode = async value => { const r=await page.request.post(base+'/fixture/mode',{data:{mode:value}});assert(r.ok()); };
|
||||
const tasks = page.locator('.eh-task');
|
||||
await page.goto(base+'/eddy/tasks');await tasks.first().waitFor();assert.equal(await tasks.count(),30);
|
||||
await page.getByRole('button',{name:'加载更多任务',exact:true}).click();await page.waitForFunction(()=>document.querySelectorAll('.eh-task').length===35);
|
||||
checks.push('Task metadata pages through 35 synthetic tasks from authenticated HTTP/Postgres without loading transcript bodies.');
|
||||
await tasks.filter({hasText:'Inbox · Story 天窗放大 2 倍'}).first().click();
|
||||
await page.getByLabel('历史会话记录').getByText('把 Inbox 的 Story 天窗放大 2 倍,其他逻辑保持不变。',{exact:true}).waitFor();
|
||||
await page.locator('.eh-partial').waitFor();
|
||||
assert.equal(await page.getByText('继续验证',{exact:true}).count(),2);
|
||||
assert.equal(await page.locator('.eh-message img').count(),0);
|
||||
assert.equal(await page.evaluate(()=>window.historyXss),undefined);
|
||||
await page.getByText('工具调用 · inspect_view',{exact:true}).click();
|
||||
await page.getByText('{"view":"StorySkylight","scale":2}',{exact:true}).waitFor();
|
||||
await page.getByText('工具结果 · inspect_view',{exact:true}).click();
|
||||
await page.getByText('已隐藏可识别的敏感字段',{exact:true}).waitFor();
|
||||
checks.push('Messages, repeated prompts and collapsed tool calls/results render as inert text; masking and incomplete fragments are explicit.');
|
||||
await page.getByRole('button',{name:'加载更多记录',exact:true}).click();
|
||||
await page.getByText('长消息前半🧪后半🧪',{exact:true}).waitFor();assert.equal(await page.locator('.eh-partial').count(),0);
|
||||
await page.getByText('已读到当前已上传记录的末尾',{exact:true}).waitFor();
|
||||
checks.push('A message split across the 200-record page boundary reconstructs completely after loading more.');
|
||||
await page.getByLabel('选择 Agent 会话').selectOption(otherSource);
|
||||
await page.getByText('Claude 会话的独立消息',{exact:true}).waitFor();assert.equal(await page.getByText('继续验证',{exact:true}).count(),0);
|
||||
await page.goBack();await page.getByLabel('历史会话记录').getByText('把 Inbox 的 Story 天窗放大 2 倍,其他逻辑保持不变。',{exact:true}).waitFor();
|
||||
assert(page.url().includes('source='+source));
|
||||
await page.reload();await page.getByLabel('历史会话记录').getByText('把 Inbox 的 Story 天窗放大 2 倍,其他逻辑保持不变。',{exact:true}).waitFor();
|
||||
checks.push('Session choice is in the URL; back/forward and reloading a deep link preserve the correct session.');
|
||||
await page.getByText('任务信息与产物',{exact:true}).click();
|
||||
await page.getByText('首条用户消息(需求参考)',{exact:true}).waitFor();
|
||||
await page.getByText('工具结果 · inspect_view',{exact:true}).click();
|
||||
await page.locator('.eh-main').evaluate(e=>e.scrollTop=0);
|
||||
await page.screenshot({path:out+'/history-light.png'});
|
||||
await page.evaluate(()=>document.documentElement.dataset.theme='dark');
|
||||
await page.waitForTimeout(200); // Let the existing app-wide color transitions settle.
|
||||
assert(await page.locator('.eh-task').first().evaluate(e=>getComputedStyle(e).color===getComputedStyle(document.querySelector('.eh-page')).color));
|
||||
await page.screenshot({path:out+'/history-dark.png'});
|
||||
await page.evaluate(()=>document.documentElement.dataset.theme='light');
|
||||
await page.waitForTimeout(200);
|
||||
await tasks.filter({hasText:'Inbox · Story 天窗放大 2 倍'}).nth(1).click();
|
||||
await page.getByText('第二台设备的独立消息',{exact:true}).waitFor();assert.equal(await page.getByText('继续验证',{exact:true}).count(),0);
|
||||
checks.push('Two Macs sharing the same task id display separate transcripts.');
|
||||
await mode('slow');
|
||||
await tasks.filter({hasText:'Inbox · Story 天窗放大 2 倍'}).first().click();
|
||||
await tasks.filter({hasText:'Story · 长按主体抠图'}).click();
|
||||
await page.getByLabel('历史会话记录').getByText('仅抠图任务的消息',{exact:true}).waitFor();await page.waitForTimeout(550);
|
||||
assert.equal(await page.getByLabel('历史会话记录').getByText('把 Inbox 的 Story 天窗放大 2 倍,其他逻辑保持不变。',{exact:true}).count(),0);
|
||||
await mode('ok');checks.push('Rapid task changes abort/ignore stale responses and never replace the current task with delayed data.');
|
||||
await page.getByLabel('搜索 Eddy 任务').fill('does-not-exist');await page.getByText('没有匹配的任务。',{exact:true}).waitFor();
|
||||
await page.getByLabel('搜索 Eddy 任务').fill('');await tasks.first().waitFor();
|
||||
await mode('unavailable');await page.getByLabel('刷新任务列表').click();await page.getByRole('alert').waitFor();assert.equal(await tasks.count(),0);
|
||||
await mode('ok');await page.getByRole('button',{name:'重试',exact:true}).click();await tasks.first().waitFor();
|
||||
await mode('old');await page.getByLabel('刷新任务列表').click();await page.getByText('当前服务尚未提供历史会话,请稍后重试。',{exact:true}).waitFor();
|
||||
await mode('ok');await page.getByRole('button',{name:'重试',exact:true}).click();await tasks.first().waitFor();
|
||||
await page.evaluate(()=>localStorage.removeItem('light:ttuae2:local-session'));await page.getByLabel('刷新任务列表').click();
|
||||
await page.getByRole('button',{name:'重新登录',exact:true}).click();assert.equal(await page.evaluate(()=>document.documentElement.dataset.relogin),'requested');
|
||||
await page.evaluate(()=>localStorage.setItem('light:ttuae2:local-session','history-browser'));await page.getByLabel('刷新任务列表').click();await tasks.first().waitFor();
|
||||
checks.push('Search, unavailable service, older server and expired SSO show actionable states and recover; private stale task rows are cleared.');
|
||||
await mode('empty');await page.getByLabel('刷新任务列表').click();await page.getByText('还没有已同步的任务。',{exact:true}).waitFor();
|
||||
await mode('ok');await page.goto(deep);await page.getByLabel('历史会话记录').getByText('把 Inbox 的 Story 天窗放大 2 倍,其他逻辑保持不变。',{exact:true}).waitFor();
|
||||
await page.setViewportSize({width:390,height:844});
|
||||
assert(await page.evaluate(()=>document.documentElement.scrollWidth<=innerWidth));
|
||||
assert(await page.locator('.eh-main').evaluate(e=>e.scrollWidth<=e.clientWidth));
|
||||
await page.screenshot({path:out+'/history-mobile.png'});
|
||||
await page.getByRole('button',{name:'任务列表',exact:true}).click();await tasks.first().waitFor({state:'visible'});
|
||||
await page.screenshot({path:out+'/history-mobile-list.png'});
|
||||
checks.push('Light/dark and 390px layouts render; task list and transcript remain scrollable, narrow task/back navigation works without horizontal overflow.');
|
||||
assert.deepEqual(errors,[]);assert.deepEqual(external,[]);
|
||||
const result={passed:true,checks,errors,external,scope:'Synthetic browser → authenticated HTTP → isolated Postgres. No production access.'};
|
||||
await writeFile(out+'/browser-validation.json',JSON.stringify(result,null,2));process.stdout.write(JSON.stringify(result));
|
||||
} catch (error) {
|
||||
if(debugPage){await debugPage.screenshot({path:out+'/failure.png'}).catch(()=>{});console.error(JSON.stringify({errors,external,text:(await debugPage.locator('body').innerText().catch(()=>'')).slice(0,1200),url:debugPage.url()}));}
|
||||
throw error;
|
||||
} finally {await browser.close();}
|
||||
Reference in New Issue
Block a user