Fix e2e daemon isolation and fast model defaults

This commit is contained in:
Mohamed Boudra
2026-01-20 13:36:06 +07:00
parent facd99ab13
commit 513138ac13
8 changed files with 144 additions and 23 deletions
+5
View File
@@ -15,6 +15,11 @@ test('create agent in a temp repo', async ({ page }) => {
// Verify user message is shown in the stream
await expect(page.getByText(prompt, { exact: true })).toBeVisible();
// Verify we used a fast model (do not fall back to a default like Sonnet).
await page.getByTestId('agent-overflow-menu').click();
await expect(page.getByText('Model', { exact: true })).toBeVisible();
await expect(page.getByText(/haiku/i)).toBeVisible();
// Wait for agent response containing "Hello" within an assistant message
const assistantMessage = page.getByTestId('assistant-message').filter({ hasText: 'Hello' });
await expect(assistantMessage).toBeVisible({ timeout: 30000 });
+4 -2
View File
@@ -2,12 +2,14 @@ import { test, expect } from './fixtures';
import { gotoHome, openSettings } from './helpers/app';
test('daemon is connected in settings', async ({ page }) => {
const daemonPort = process.env.E2E_DAEMON_PORT ?? '6767';
const daemonPort = process.env.E2E_DAEMON_PORT;
if (!daemonPort) {
throw new Error('E2E_DAEMON_PORT is not set (expected from globalSetup).');
}
await gotoHome(page);
await openSettings(page);
await expect(page.getByText('localhost', { exact: true })).toBeVisible();
await expect(page.getByText(`ws://localhost:${daemonPort}/ws`)).toBeVisible();
await expect(page.getByText('Online', { exact: true })).toBeVisible();
});
+37 -13
View File
@@ -3,6 +3,14 @@ import { test, expect, type Page } from '@playwright/test';
const consoleEntries = new WeakMap<Page, string[]>();
test.beforeEach(async ({ page }) => {
const daemonPort = process.env.E2E_DAEMON_PORT;
if (!daemonPort) {
throw new Error(
'E2E_DAEMON_PORT is not set. Refusing to run e2e against the default daemon (e.g. localhost:6767). ' +
'Ensure Playwright `globalSetup` starts the e2e daemon and exports E2E_DAEMON_PORT.'
);
}
const entries: string[] = [];
consoleEntries.set(page, entries);
@@ -14,20 +22,36 @@ test.beforeEach(async ({ page }) => {
entries.push(`[pageerror] ${error.message}`);
});
// Set up test daemon connection if available
const daemonPort = process.env.E2E_DAEMON_PORT;
if (daemonPort) {
const testDaemon = {
id: 'e2e-test-daemon',
label: 'localhost',
wsUrl: `ws://localhost:${daemonPort}/ws`,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
};
await page.addInitScript((daemon) => {
const nowIso = new Date().toISOString();
const testDaemon = {
id: 'e2e-test-daemon',
label: 'localhost',
wsUrl: `ws://localhost:${daemonPort}/ws`,
restUrl: `http://localhost:${daemonPort}/`,
createdAt: nowIso,
updatedAt: nowIso,
};
const createAgentPreferences = {
// Ensure create flow never uses a remembered host from the developer's real app.
serverId: testDaemon.id,
// Keep e2e fast/cheap by default.
provider: 'claude',
providerPreferences: {
claude: { model: 'haiku' },
codex: { model: 'gpt-5.1-codex-mini' },
},
};
await page.addInitScript(
({ daemon, preferences }) => {
// Hard-reset anything that could point to a developer's real daemon.
localStorage.setItem('@paseo:daemon-registry', JSON.stringify([daemon]));
}, testDaemon);
}
localStorage.removeItem('@paseo:settings');
localStorage.setItem('@paseo:create-agent-preferences', JSON.stringify(preferences));
},
{ daemon: testDaemon, preferences: createAgentPreferences }
);
});
test.afterEach(async ({ page }, testInfo) => {
@@ -0,0 +1,54 @@
import { test, expect } from './fixtures';
import { createAgent, ensureHostSelected, gotoHome, setWorkingDirectory } from './helpers/app';
import { createTempGitRepo } from './helpers/workspace';
test('sidebar New Agent clones the selected agent settings (not last created)', async ({ page }) => {
const repoA = await createTempGitRepo();
const repoB = await createTempGitRepo();
try {
await gotoHome(page);
await ensureHostSelected(page);
await setWorkingDirectory(page, repoA.path);
await createAgent(page, 'Agent A: respond with exactly A');
await expect(page).toHaveURL(/\/agent\//);
const urlA = new URL(page.url());
const agentPathA = urlA.pathname;
await gotoHome(page);
await ensureHostSelected(page);
await setWorkingDirectory(page, repoB.path);
await createAgent(page, 'Agent B: respond with exactly B');
await expect(page).toHaveURL(/\/agent\//);
const urlB = new URL(page.url());
const agentPathB = urlB.pathname;
expect(agentPathA).not.toEqual(agentPathB);
// Navigate back to agent A via URL to ensure it's the selected agent.
await page.goto(agentPathA);
await expect(page).toHaveURL(agentPathA);
await expect(page.getByText('Agent A: respond with exactly A', { exact: true })).toBeVisible();
// Click sidebar New Agent and assert it clones agent A's directory (not agent B's).
await page.getByTestId('sidebar-new-agent').click();
await expect(page).toHaveURL(new RegExp(encodeURIComponent(repoA.path)));
await expect(page).not.toHaveURL(new RegExp(encodeURIComponent(repoB.path)));
await expect(page.getByText(repoA.path, { exact: true })).toBeVisible();
// Now navigate to agent B and assert cloning uses repo B.
await page.goto(agentPathB);
await expect(page).toHaveURL(agentPathB);
await expect(page.getByText('Agent B: respond with exactly B', { exact: true })).toBeVisible();
await page.getByTestId('sidebar-new-agent').click();
await expect(page).toHaveURL(new RegExp(encodeURIComponent(repoB.path)));
await expect(page).not.toHaveURL(new RegExp(encodeURIComponent(repoA.path)));
await expect(page.getByText(repoB.path, { exact: true })).toBeVisible();
} finally {
await repoA.cleanup();
await repoB.cleanup();
}
});