docs(assistant): record provider settings rollout and UI verification
This commit is contained in:
1 parent
528120a088
commit
1747361a1d
8 files changed
+74
-23
No files matched your search
@@ -7,7 +7,7 @@ async function managementFixture(t,{browser=false}={}){
|
||||
const call=(route,body,cookie)=>fetch(base+'/api'+route,{method:body===undefined?'GET':'POST',headers:{...(body===undefined?{}:{Origin:base,'Content-Type':'application/json'}),...(cookie?{Cookie:cookie}:{})},body:body===undefined?undefined:JSON.stringify(body)}),login=async(username='admin')=>(await call('/login',{username,password:'Test-password-123'})).headers.get('set-cookie').split(';')[0];
|
||||
let engine,page;if(browser){const {loadPlaywright,browserOptions}=require('../../src/platform/browser.cjs');engine=await loadPlaywright().chromium.launch(browserOptions());page=await engine.newPage({viewport:{width:1440,height:1000}});page.setDefaultTimeout(10000);}
|
||||
t.after(async()=>{await engine?.close();server.closeAssistantStreams?.();await assistant.stop();server.closeAllConnections();await new Promise(r=>server.close(r));store.close();await fs.rm(dir,{recursive:true,force:true});});
|
||||
async function open(route='#assistant',username='admin'){await page.goto(base+'/'+route);if(await page.getByLabel('账号',{exact:true}).count()){await page.getByLabel('账号',{exact:true}).fill(username);await page.getByLabel('密码',{exact:true}).fill('Test-password-123');await page.getByRole('button',{name:'登录',exact:true}).click();}}
|
||||
async function open(route='#assistant',username='admin'){await page.goto(base+'/'+route);await page.waitForFunction(()=>!!document.querySelector('#username')||!!document.querySelector('#logout'));if(await page.getByLabel('账号',{exact:true}).count()){await page.getByLabel('账号',{exact:true}).fill(username);await page.getByLabel('密码',{exact:true}).fill('Test-password-123');await page.getByRole('button',{name:'登录',exact:true}).click();}}
|
||||
return {base,page,open,store,users,assistant,call,login,calls:()=>calls,lastConfig:()=>lastConfig};
|
||||
}
|
||||
module.exports={managementFixture};
|
||||
@@ -2,7 +2,7 @@
|
||||
const {test}=require('node:test'),assert=require('node:assert/strict');const {managementFixture}=require('./management-fixture.cjs');
|
||||
test('assistant settings manage providers and default models without exposing a saved key',{timeout:120000},async t=>{
|
||||
const {page,open,calls}=await managementFixture(t,{browser:true});await open('#assistant-settings');await page.getByRole('button',{name:'添加供应商',exact:true}).click();await page.getByLabel('供应商类型',{exact:true}).selectOption('openai');await page.getByLabel('供应商名称',{exact:true}).fill('测试供应商');await page.getByLabel('API 根地址',{exact:true}).fill('https://models.example/v1');await page.getByLabel('API 密钥',{exact:true}).fill('TEST_PROVIDER_UI_KEY');await page.getByLabel('模型列表',{exact:true}).fill('test-a|测试模型 A\ntest-b|测试模型 B');await page.getByRole('button',{name:'保存供应商',exact:true}).click();await page.getByText('测试供应商',{exact:true}).waitFor();assert.equal(calls(),0);assert.doesNotMatch(await page.locator('body').innerText(),/TEST_PROVIDER_UI_KEY/);
|
||||
await page.getByLabel('默认模型',{exact:true}).selectOption({label:'测试供应商 / 测试模型 A'});await page.getByRole('button',{name:'保存默认模型',exact:true}).click();await page.getByText('默认模型已保存。',{exact:true}).waitFor();await page.getByLabel('启用 DSH 对话诊断',{exact:true}).check();await page.getByRole('button',{name:'保存助手设置',exact:true}).click();await require('node:fs/promises').mkdir('output/verification/dsh-providers',{recursive:true});await page.screenshot({path:'output/verification/dsh-providers/settings-desktop.png',fullPage:true});await page.goto(new URL('/#assistant',page.url()).href);await page.getByRole('button',{name:/选择模型/}).click();await page.getByRole('option',{name:'测试模型 B',exact:true}).click();await page.getByLabel('发送给 DSH',{exact:true}).fill('分析当前状态');await page.getByRole('button',{name:'发送',exact:true}).click();await page.getByText('使用模型 test-b',{exact:true}).waitFor();assert.equal(calls(),1);await page.screenshot({path:'output/verification/dsh-providers/assistant-model-selected.png',fullPage:true});await page.setViewportSize({width:390,height:844});await page.screenshot({path:'output/verification/dsh-providers/assistant-mobile.png',fullPage:true});
|
||||
await page.getByLabel('默认模型',{exact:true}).selectOption({label:'测试供应商 / 测试模型 A'});await page.getByRole('button',{name:'保存默认模型',exact:true}).click();await page.getByText('默认模型已保存。',{exact:true}).waitFor();await page.getByLabel('启用 DSH 对话诊断',{exact:true}).check();await page.getByRole('button',{name:'保存助手设置',exact:true}).click();await require('node:fs/promises').mkdir('output/verification/dsh-providers',{recursive:true});await page.evaluate(()=>scrollTo(0,0));await page.screenshot({path:'output/verification/dsh-providers/settings-desktop.png',fullPage:true});await page.goto(new URL('/#assistant',page.url()).href);await page.getByRole('button',{name:/选择模型/}).click();await page.getByRole('option',{name:'测试模型 B',exact:true}).click();await page.getByLabel('发送给 DSH',{exact:true}).fill('分析当前状态');await page.getByRole('button',{name:'发送',exact:true}).click();await page.getByText('使用模型 test-b',{exact:true}).waitFor();assert.equal(calls(),1);await page.screenshot({path:'output/verification/dsh-providers/assistant-model-selected.png',fullPage:true});await page.setViewportSize({width:390,height:844});await page.screenshot({path:'output/verification/dsh-providers/assistant-mobile.png',fullPage:true});
|
||||
});
|
||||
test('the tool return button is prominent on desktop and mobile and returns to the tools section',{timeout:90000},async t=>{
|
||||
const {page,open}=await managementFixture(t,{browser:true});await open();for(const width of [1440,390]){await page.setViewportSize({width,height:900});const back=page.getByRole('link',{name:'返回工具',exact:true});await back.waitFor();const box=await back.boundingBox();assert.ok(box.height>=44);assert.ok(box.width>=100);assert.equal(await back.getAttribute('href'),'#tools');}await page.getByRole('link',{name:'返回工具',exact:true}).click();await page.getByRole('navigation',{name:'工具导航'}).waitFor();assert.equal(await page.locator('.assistant-workspace').count(),0);
|
||||
|
||||
Reference in new issue
Block a user