Since phones get a bottom bar instead of the sidebar (UF-057), the shell wait matched the hidden sidebar first and timed out at 390 px, and the mobile journey clicked the sidebar's workspace button. The wait now takes the first visible shell element, and the journey opens New workspace from All workspaces, as a phone user does.
119 lines
4.0 KiB
TypeScript
119 lines
4.0 KiB
TypeScript
import { test, expect, type Page } from '@playwright/test';
|
|
|
|
const SKIP_PARAMS = 'skipOnboarding=true&skipBoot=true&skipBriefing=true&tier=power';
|
|
|
|
function routeWithSkip(route: string): string {
|
|
const sep = route.includes('?') ? '&' : '?';
|
|
return `${route}${sep}${SKIP_PARAMS}`;
|
|
}
|
|
|
|
async function waitForShell(page: Page): Promise<void> {
|
|
await page.waitForSelector('.waggle-sidebar:visible, [role="navigation"]:visible, main:visible', { timeout: 15_000 });
|
|
await page.waitForTimeout(300);
|
|
}
|
|
|
|
async function gotoLauncher(page: Page): Promise<void> {
|
|
await page.goto(routeWithSkip('/launcher?watch=1'), { waitUntil: 'domcontentloaded' });
|
|
await waitForShell(page);
|
|
await expect(page.getByText('Tool Launcher')).toBeVisible({ timeout: 10_000 });
|
|
}
|
|
|
|
async function mockProcesses(page: Page): Promise<void> {
|
|
await page.route('**/api/tools/processes', route => route.fulfill({
|
|
status: 200,
|
|
contentType: 'application/json',
|
|
body: JSON.stringify({ processes: [], total: 0 }),
|
|
}));
|
|
}
|
|
|
|
test.describe('Launcher rendered states', () => {
|
|
test('sidecar-offline detection shows an inline retry action', async ({ page }) => {
|
|
let detectCalls = 0;
|
|
await mockProcesses(page);
|
|
await page.route('**/api/tools/detect', route => {
|
|
detectCalls += 1;
|
|
if (detectCalls === 1) {
|
|
return route.abort('failed');
|
|
}
|
|
return route.fulfill({
|
|
status: 200,
|
|
contentType: 'application/json',
|
|
body: JSON.stringify({
|
|
platform: 'linux',
|
|
detectedAt: '2026-07-08T00:00:00.000Z',
|
|
tools: [
|
|
{
|
|
id: 'foo-cli',
|
|
displayName: 'Foo CLI',
|
|
launchable: true,
|
|
builtin: false,
|
|
acceptsInlinePrompt: true,
|
|
installed: true,
|
|
installedPath: '/usr/local/bin/foo',
|
|
version: '1.0.0',
|
|
},
|
|
],
|
|
}),
|
|
});
|
|
});
|
|
|
|
await gotoLauncher(page);
|
|
|
|
await expect(page.getByText(/sidecar may be offline/i)).toBeVisible();
|
|
await page.getByRole('button', { name: /retry tool detection/i }).click();
|
|
await expect(page.getByText('Foo CLI')).toBeVisible();
|
|
await expect(page.getByText(/sidecar may be offline/i)).not.toBeVisible();
|
|
});
|
|
|
|
test('third-party adapter renders launch state and sends its prompt', async ({ page }) => {
|
|
let launchPayload: unknown = null;
|
|
await mockProcesses(page);
|
|
await page.route('**/api/tools/detect', route => route.fulfill({
|
|
status: 200,
|
|
contentType: 'application/json',
|
|
body: JSON.stringify({
|
|
platform: 'linux',
|
|
detectedAt: '2026-07-08T00:00:00.000Z',
|
|
tools: [
|
|
{
|
|
id: 'foo-cli',
|
|
displayName: 'Foo CLI',
|
|
launchable: true,
|
|
builtin: false,
|
|
acceptsInlinePrompt: true,
|
|
installed: true,
|
|
installedPath: '/usr/local/bin/foo',
|
|
version: '2.1.0',
|
|
},
|
|
],
|
|
}),
|
|
}));
|
|
await page.route('**/api/tools/launch', async route => {
|
|
launchPayload = route.request().postDataJSON();
|
|
await route.fulfill({
|
|
status: 200,
|
|
contentType: 'application/json',
|
|
body: JSON.stringify({ ok: true, pid: 9876 }),
|
|
});
|
|
});
|
|
|
|
await gotoLauncher(page);
|
|
await expect(page.getByText('Foo CLI', { exact: true })).toBeVisible();
|
|
await expect(page.getByText(/v2\.1\.0/i)).toBeVisible();
|
|
await expect(page.getByText(/Sent to:/i)).not.toBeVisible();
|
|
await expect(page.getByRole('button', { name: /^Launch$/ })).toBeVisible();
|
|
|
|
await page.getByLabel(/optional launch prompt/i).fill('summarize adapter context');
|
|
await expect(page.getByText('Sent to: Foo CLI', { exact: true })).toBeVisible();
|
|
await page.getByRole('button', { name: /^Launch$/ }).click();
|
|
|
|
await expect(page.getByText(/Launched Foo CLI with prompt \(pid 9876\)/i)).toBeVisible();
|
|
expect(launchPayload).toMatchObject({
|
|
id: 'foo-cli',
|
|
installedPath: '/usr/local/bin/foo',
|
|
prompt: 'summarize adapter context',
|
|
observe: true,
|
|
});
|
|
});
|
|
});
|