Files
AgentCompany/tests/e2e/desktop.smoke.spec.ts
T
2026-03-18 17:49:10 -04:00

65 lines
3.0 KiB
TypeScript

import { existsSync } from "node:fs";
import { mkdtemp, rm } from "node:fs/promises";
import { join } from "node:path";
import { tmpdir } from "node:os";
import { _electron as electron, expect, test } from "@playwright/test";
import { getElectronExecutablePath, getMainEntryPath } from "./launch";
test("first launch onboarding creates a company and opens the desktop shell", async () => {
const entry = getMainEntryPath();
expect(existsSync(entry)).toBeTruthy();
const profileDir = await mkdtemp(join(tmpdir(), "agentcompany-e2e-"));
const workspaceDir = await mkdtemp(join(tmpdir(), "agentcompany-workspace-"));
const app = await electron.launch({
executablePath: getElectronExecutablePath(),
args: [entry],
cwd: process.cwd(),
env: {
...process.env,
AGENTCOMPANY_PROFILE_DIR: profileDir,
AGENTCOMPANY_DISABLE_UPDATES: "true",
AGENTCOMPANY_DISABLE_SINGLE_INSTANCE: "true",
},
});
try {
const page = await app.firstWindow();
await expect(page.getByText("AgentCompany Desktop")).toBeVisible();
await page.getByLabel("Company name").fill("Orbit Foundry");
await page.getByLabel("Workspace folder").fill(workspaceDir);
const continueButton = page.getByRole("button", { name: /^Continue$/i });
if (await continueButton.isEnabled()) {
await continueButton.click();
await page.getByLabel("Goal").fill("Launch the company");
await page.getByRole("button", { name: /Launch Company/i }).click();
await expect(page.getByRole("heading", { name: /Orbit Foundry is live/i })).toBeVisible();
await expect(page.getByText("Initial run")).toBeVisible();
await page.getByRole("button", { name: /Open control center/i }).click();
await expect(page.getByRole("heading", { name: "Runs" })).toBeVisible();
// Company name is rendered in a custom dropdown trigger button in the sidebar.
await expect(page.locator("aside button", { hasText: "Orbit Foundry" }).first()).toBeVisible();
const showConsoleButton = page.getByRole("button", { name: /show console/i });
const hideConsoleButton = page.getByRole("button", { name: /hide console/i });
if (await hideConsoleButton.isVisible().catch(() => false)) {
await expect(page.getByText("Console", { exact: true })).toBeVisible();
await hideConsoleButton.click();
await expect(page.getByText("Console", { exact: true })).toBeHidden();
} else {
await expect(showConsoleButton).toBeVisible();
}
await showConsoleButton.click();
await expect(page.getByText("Console", { exact: true })).toBeVisible();
} else {
await expect(page.getByText(/Install, authenticate, and fully validate at least one supported CLI runtime/i)).toBeVisible();
await expect(page.getByText(/cannot be used for autonomous execution/i).first()).toBeVisible();
}
} finally {
await app.close();
await rm(profileDir, { recursive: true, force: true });
await rm(workspaceDir, { recursive: true, force: true });
}
});