import { test, expect } from '@playwright/test' test('team permission defaults off, saves, reloads and revokes in the Agent editor', async ({page},testInfo) => { await page.goto('/conversations') await page.getByRole('textbox',{name:'账号',exact:true}).fill('fixture') await page.getByRole('textbox',{name:'密码',exact:true}).fill('fixture-pass') await page.getByRole('button',{name:'登录',exact:true}).click() await expect(page.getByRole('heading',{name:'还没有聊天'})).toBeVisible() await page.locator('.desktop-sidebar .sidebar-create-trigger').click() await page.getByRole('menuitem',{name:'新建 Bot',exact:true}).click() const dialog=page.getByRole('dialog'), permission=dialog.getByRole('checkbox',{name:'允许组建团队',exact:true}) await dialog.getByRole('textbox',{name:'名称',exact:true}).fill('组队老板') await expect(permission).not.toBeChecked() await permission.check() await permission.scrollIntoViewIfNeeded() await page.screenshot({path:testInfo.outputPath('team-permission-desktop.png')}) const saved=page.waitForResponse(r=>r.request().method()==='POST' && r.url().endsWith('/api/app/agents')) await dialog.getByRole('button',{name:'保存',exact:true}).click() const response=await saved expect(response.ok(),await response.text()).toBe(true) const agent=(await response.json()).agent expect(agent.canManageTeam).toBe(true) await page.reload() await expect(page.getByRole('heading',{name:'组队老板',exact:true})).toBeVisible() const edit=page.getByRole('button',{name:'聊天设置',exact:true}) await edit.click() await expect(permission).toBeChecked() await page.setViewportSize({width:375,height:812}) await page.emulateMedia({colorScheme:'dark',reducedMotion:'reduce'}) await permission.scrollIntoViewIfNeeded() await page.screenshot({path:testInfo.outputPath('team-permission-mobile.png')}) await permission.uncheck() const revoked=page.waitForResponse(r=>r.request().method()==='PATCH' && r.url().endsWith(`/api/app/agents/${agent.id}`)) await dialog.getByRole('button',{name:'保存',exact:true}).click() expect((await (await revoked).json()).agent.canManageTeam).toBe(false) expect((await (await page.request.get('/api/app/agents')).json()).agents.find((a:any)=>a.id===agent.id).canManageTeam).toBe(false) }) test('task plans show owners and keep independent text and attachment drafts when switching tasks',async({page},testInfo)=>{ await page.goto('/conversations') await page.getByRole('textbox',{name:'账号',exact:true}).fill('fixture') await page.getByRole('textbox',{name:'密码',exact:true}).fill('fixture-pass') await page.getByRole('button',{name:'登录',exact:true}).click() await expect(page.locator('.desktop-sidebar .sidebar-create-trigger')).toBeVisible() const seeded=await page.request.post('/__test/task-plan',{data:{}}) expect(seeded.ok()).toBe(true) const ids=await seeded.json() await page.goto(`/conversations/${ids.sourceConversationId}`) await page.getByRole('link',{name:'打开任务',exact:true}).click() await expect(page).toHaveURL(new RegExp(`/conversations/${ids.conversationId}\\?taskId=${ids.firstTaskId}`)) await page.locator('details.task-plan summary').click() await expect(page.locator('.task-plan')).toContainText('研究资料') await expect(page.locator('.task-plan')).toContainText('验收研究员') const composer=page.getByRole('textbox',{name:'输入消息,Enter 发送,Shift + Enter 换行'}) await composer.fill('调研任务的草稿') await page.locator('.composer-area input[type=file]').first().setInputFiles({name:'draft.txt',mimeType:'text/plain',buffer:Buffer.from('待发送附件')}) await page.getByRole('combobox',{name:'当前任务'}).selectOption(ids.secondTaskId) await expect(composer).toHaveValue('') await composer.fill('独立任务的草稿') await page.getByRole('combobox',{name:'当前任务'}).selectOption(ids.firstTaskId) await expect(composer).toHaveValue('调研任务的草稿') await expect(page.locator('.composer-attachments')).toContainText('draft.txt') await page.screenshot({path:testInfo.outputPath('task-plan-drafts.png')}) if(!await page.getByRole('button',{name:'停止任务',exact:true}).isVisible())await page.locator('details.task-plan summary').click() await page.getByRole('button',{name:'停止任务',exact:true}).click() await expect(page.locator('.task-plan')).toContainText('已停止') })