Files
paseo/packages/app/e2e/host-selection.spec.ts
T
Mohamed BoudraandClaude Opus 4 54ee84fe72 Fix Playwright E2E tests
Fixed 8 failing E2E tests by addressing UI changes and timing issues:
- Updated delete-agent-persists test to use 'archive' button instead of 'delete'
- Fixed dictation-web test to use correct element selector (sidebar-new-agent)
- Updated URL regex patterns to handle trailing slash variations
- Fixed capitalization issues ('New agent' vs 'New Agent', '+ Add host' vs '+ Add Host')
- Updated permission-prompt allow test to verify file content instead of tool call count

Tests fixed:
- delete-agent-persists.spec.ts
- dictation-web.spec.ts
- host-selection.spec.ts (both tests)
- manual-host-port.spec.ts
- pairing-offer-parsing.spec.ts
- permission-prompt.spec.ts (allow test)

Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
2026-02-02 14:32:14 +07:00

74 lines
2.7 KiB
TypeScript

import { test, expect } from './fixtures';
import { ensureHostSelected, gotoHome } from './helpers/app';
test('new agent auto-selects the previous host', async ({ page }) => {
await gotoHome(page);
await ensureHostSelected(page);
await gotoHome(page);
// The selected host should be restored after a full reload without manual selection.
await expect(page.getByText('localhost', { exact: true }).first()).toBeVisible();
const input = page.getByRole('textbox', { name: 'Message agent...' });
await expect(input).toBeEditable({ timeout: 30000 });
});
test('new agent respects serverId in the URL', async ({ page }) => {
const daemonPort = process.env.E2E_DAEMON_PORT;
if (!daemonPort) {
throw new Error('E2E_DAEMON_PORT is not set (expected from globalSetup).');
}
// Ensure this test's storage is deterministic even under parallel load.
const nowIso = new Date().toISOString();
const testDaemon = {
id: 'e2e-test-daemon',
label: 'localhost',
endpoints: [`127.0.0.1:${daemonPort}`],
relay: null,
metadata: null,
createdAt: nowIso,
updatedAt: nowIso,
};
const createAgentPreferences = {
serverId: testDaemon.id,
provider: 'claude',
providerPreferences: {
claude: { model: 'haiku' },
codex: { model: 'gpt-5.1-codex-mini' },
},
};
await page.goto('/settings');
await page.evaluate(
({ daemon, preferences }) => {
const nonce = localStorage.getItem('@paseo:e2e-seed-nonce') ?? '1';
localStorage.setItem('@paseo:e2e-disable-default-seed-once', nonce);
localStorage.setItem('@paseo:daemon-registry', JSON.stringify([daemon]));
localStorage.setItem('@paseo:create-agent-preferences', JSON.stringify(preferences));
localStorage.removeItem('@paseo:settings');
},
{ daemon: testDaemon, preferences: createAgentPreferences }
);
await page.reload();
await expect(page.getByText('Online', { exact: true }).first()).toBeVisible({ timeout: 20000 });
const seededDaemonId = await page.evaluate(() => {
const raw = localStorage.getItem('@paseo:daemon-registry');
if (!raw) return null;
const parsed = JSON.parse(raw) as any[];
return Array.isArray(parsed) && parsed.length > 0 && typeof parsed[0]?.id === 'string'
? (parsed[0].id as string)
: null;
});
if (!seededDaemonId) {
throw new Error('Expected daemon registry to contain a seeded daemon id.');
}
await page.goto(`/?serverId=${encodeURIComponent(seededDaemonId)}`);
await expect(page.getByText('New agent', { exact: true }).first()).toBeVisible();
const input = page.getByRole('textbox', { name: 'Message agent...' });
await expect(input).toBeEditable({ timeout: 30000 });
});