|
@@ -24,7 +24,7 @@ const root = path.resolve(__dirname, '../html');
|
|
|
return route.fulfill({body:fs.readFileSync(file),contentType:file.endsWith('.js')?'application/javascript':file.endsWith('.css')?'text/css':'text/html'});
|
|
return route.fulfill({body:fs.readFileSync(file),contentType:file.endsWith('.js')?'application/javascript':file.endsWith('.css')?'text/css':'text/html'});
|
|
|
});
|
|
});
|
|
|
await page.goto('http://qa.test/');
|
|
await page.goto('http://qa.test/');
|
|
|
- assert.ok((await page.locator('#chatFrame').getAttribute('src')).includes('20260907-cache'));
|
|
|
|
|
|
|
+ assert.ok((await page.locator('#chatFrame').getAttribute('src')).includes('20260909-timing'));
|
|
|
const frame = await (await page.locator('#chatFrame').elementHandle()).contentFrame();
|
|
const frame = await (await page.locator('#chatFrame').elementHandle()).contentFrame();
|
|
|
await frame.waitForFunction(() => typeof askStream === 'function' && Boolean(window.AnswerCacheUI));
|
|
await frame.waitForFunction(() => typeof askStream === 'function' && Boolean(window.AnswerCacheUI));
|
|
|
await frame.evaluate(async () => {
|
|
await frame.evaluate(async () => {
|
|
@@ -37,9 +37,11 @@ const root = path.resolve(__dirname, '../html');
|
|
|
try {await askStream('员工有多少人',true,true);} finally {window.fetch=original;}
|
|
try {await askStream('员工有多少人',true,true);} finally {window.fetch=original;}
|
|
|
});
|
|
});
|
|
|
assert.equal(requests.length,0,'rendering an answer must not cache it');
|
|
assert.equal(requests.length,0,'rendering an answer must not cache it');
|
|
|
|
|
+ assert.equal(await frame.locator('.answer-timing').last().innerText(),'回答耗时 0.01 秒');
|
|
|
const button=frame.locator('.answer-cache-button').last();
|
|
const button=frame.locator('.answer-cache-button').last();
|
|
|
await button.click();
|
|
await button.click();
|
|
|
await frame.waitForFunction(() => document.querySelector('.answer-cache-button')?.textContent==='撤销缓存');
|
|
await frame.waitForFunction(() => document.querySelector('.answer-cache-button')?.textContent==='撤销缓存');
|
|
|
|
|
+ assert.equal(await frame.locator('.answer-timing').last().innerText(),'回答耗时 0.01 秒');
|
|
|
assert.equal(requests.length,1);
|
|
assert.equal(requests.length,1);
|
|
|
assert.equal(requests[0].method,'POST');
|
|
assert.equal(requests[0].method,'POST');
|
|
|
assert.deepEqual(requests[0].body,{answer_id:'answer1',checkpoint_id:'checkpoint1',entry_id:null});
|
|
assert.deepEqual(requests[0].body,{answer_id:'answer1',checkpoint_id:'checkpoint1',entry_id:null});
|
|
@@ -60,11 +62,12 @@ const root = path.resolve(__dirname, '../html');
|
|
|
// Resume rendering gets the same explicit approval control.
|
|
// Resume rendering gets the same explicit approval control.
|
|
|
await frame.evaluate(async () => {
|
|
await frame.evaluate(async () => {
|
|
|
const original=window.fetch;
|
|
const original=window.fetch;
|
|
|
- window.fetch=async () => new Response(JSON.stringify({status:'ok',answer:'确认后完成',
|
|
|
|
|
|
|
+ window.fetch=async () => new Response(JSON.stringify({status:'ok',answer:'确认后完成',elapsed_sec:1.25,
|
|
|
cache_review:{eligible:true,answer_id:'answer2',checkpoint_id:'checkpoint2',cached:false}}));
|
|
cache_review:{eligible:true,answer_id:'answer2',checkpoint_id:'checkpoint2',cached:false}}));
|
|
|
try {await resumeThread('确认');} finally {window.fetch=original;}
|
|
try {await resumeThread('确认');} finally {window.fetch=original;}
|
|
|
});
|
|
});
|
|
|
assert.equal(await frame.locator('.answer-cache-button').count(),2);
|
|
assert.equal(await frame.locator('.answer-cache-button').count(),2);
|
|
|
|
|
+ assert.deepEqual(await frame.locator('.answer-timing').allTextContents(),['回答耗时 0.01 秒','回答耗时 1.25 秒']);
|
|
|
await frame.evaluate(() => {
|
|
await frame.evaluate(() => {
|
|
|
const bubble=appendMessage('assistant','历史确认答案');
|
|
const bubble=appendMessage('assistant','历史确认答案');
|
|
|
AnswerCacheUI.attach(bubble,{cache_review:{eligible:true,answer_id:'hit',checkpoint_id:'cphit',
|
|
AnswerCacheUI.attach(bubble,{cache_review:{eligible:true,answer_id:'hit',checkpoint_id:'cphit',
|