| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- // Keyless assembled-browser coverage for the opt-in Agent Teams Web profiles
- // over the real Host Typert Remote flow.
- import { fileURLToPath } from 'node:url'
- import { join } from 'node:path'
- import { readFileSync } from 'node:fs'
- import type { Browser, Page } from 'playwright'
- import { chromium } from 'playwright'
- import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
- import * as yaml from 'js-yaml'
- import { entryListSchema } from '@deepseek-ai/cordis-plugin-include'
- import { createMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
- import {
- assertFixtureInventory, captureStableAria, compareOrRefreshGolden,
- launchWebScaffold, watchConsole, webSnapshotMode, type WebScaffold,
- } from './scaffold.ts'
- import { connectFreshWorkspace, newEnglishPage, saveFailureShot } from './support.ts'
- const SNAPSHOT_DIR = fileURLToPath(new URL('./snapshots/agent-team-panel', import.meta.url))
- const PANEL_EXPECTED = join(SNAPSHOT_DIR, 'task.expected.md')
- const OVERLAY = fileURLToPath(new URL('./agent-team-panel.overlay.yml', import.meta.url))
- const HOST_PATCH = fileURLToPath(new URL('../../../packages/experimental/agent-team-profile/cordis.patch.yml', import.meta.url))
- const WEB_PATCH = fileURLToPath(new URL('../../../packages/experimental/agent-team-web-profile/cordis.patch.yml', import.meta.url))
- const INSTALL_ANCHORS = [
- fileURLToPath(new URL('../../../packages/experimental/agent-team-profile/package.json', import.meta.url)),
- fileURLToPath(new URL('../../../packages/experimental/agent-team-web-profile/package.json', import.meta.url)),
- ]
- const MODE = webSnapshotMode()
- function profileEntries(path: string): unknown[] {
- const parsed = yaml.load(readFileSync(path, 'utf8'), { schema: entryListSchema })
- if (!Array.isArray(parsed)) throw new Error(`profile layer at ${path} must be a list`)
- return parsed
- }
- describe('Agent Teams panel overlay', () => {
- it('matches the shipped Host and Web profile layers', () => {
- expect(profileEntries(OVERLAY)).toEqual([
- ...profileEntries(HOST_PATCH),
- ...profileEntries(WEB_PATCH),
- ])
- })
- })
- describe('web e2e: Agent Teams panel', () => {
- let scaffold: WebScaffold
- let browser: Browser
- let page: Page
- let tripwire: ReturnType<typeof watchConsole>
- beforeAll(async () => {
- scaffold = await launchWebScaffold({ extraOverlayPath: OVERLAY, extraInstallAnchors: INSTALL_ANCHORS })
- browser = await chromium.launch()
- page = await newEnglishPage(browser)
- tripwire = watchConsole(page)
- await page.goto(scaffold.authenticatedUrl, { waitUntil: 'load' })
- await page.waitForSelector('[class*="frame"]', { timeout: 30_000 })
- await connectFreshWorkspace(page, scaffold.workspaceCwd)
- const agent = scaffold.ctx.agents.list()[0]
- if (agent === undefined) throw new Error('connected Team workspace did not create an Agent')
- agent.session.append('turn/start', { turn: 1 })
- agent.session.append('user/message', createUserMessage({
- content: [{ type: 'text', text: 'Open the Agent Team controls.' }],
- source: { kind: 'user' },
- }), { surfaceOp: 'append' })
- agent.session.append('step/start', { turn: 1, step: 1 })
- agent.session.append('assistant/message', {
- stream: [],
- turn: 1,
- step: 1,
- message: createMessage({
- role: 'assistant',
- content: [{ type: 'text', text: 'Ready.' }],
- source: { kind: 'model', provider: 'fixture', model: 'fixture' },
- }),
- }, { surfaceOp: 'append' })
- agent.session.append('step/end', { turn: 1, step: 1 })
- agent.session.append('turn/end', { turn: 1, reason: { kind: 'completed' } })
- await scaffold.ctx.sessions.flush(agent.session)
- await page.getByText('Ready.').waitFor({ timeout: 10_000 })
- }, 120_000)
- afterAll(async () => {
- await browser?.close()
- await scaffold?.close()
- })
- it('loads the roster and creates one shared task through generated Remote', async () => {
- onTestFailed(() => saveFailureShot(page, 'web-e2e-agent-team-panel'))
- const action = page.locator('[data-team-action]')
- await action.getByRole('button', { name: /Agent Team/iu }).click()
- await action.getByText('No shared tasks yet').waitFor()
- await action.getByText('lead').waitFor()
- await action.getByRole('button', { name: 'New task' }).click()
- await action.getByPlaceholder('Task subject').fill('Browser task')
- await action.getByPlaceholder('Task description').fill('Created through the assembled browser')
- await action.getByPlaceholder(/Write scopes/iu).fill('src/web')
- await action.getByRole('button', { name: 'Save' }).click()
- await action.getByText('Browser task').waitFor()
- const snapshot = await captureStableAria(page, '[data-team-action]', scaffold.workspaceCwd)
- await compareOrRefreshGolden(PANEL_EXPECTED, snapshot, MODE)
- expect(tripwire.pageErrors).toEqual([])
- expect(tripwire.warnings).toEqual([])
- }, 60_000)
- it.skipIf(MODE === 'record')('keeps the fixture inventory closed', async () => {
- await assertFixtureInventory(SNAPSHOT_DIR, ['task.expected.md'])
- })
- })
|