Q183: unsaved input is kept across pages, and leaving or closing asks before losing it
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3f8832702e
commit
2790d88186
27 files changed
+351
-41
No files matched your search
@@ -4,6 +4,7 @@ import { tmpdir } from "node:os";
|
||||
import { join, resolve } from "node:path";
|
||||
import { randomUUID } from "node:crypto";
|
||||
import { seedBuiltinSkillsFixture } from "./builtin-skills-fixture";
|
||||
import { closeApp } from "./onboard";
|
||||
|
||||
/**
|
||||
* The founder's direct line to the CEO: onboarding leaves a pinned CEO
|
||||
@@ -418,6 +419,6 @@ test("the pinned CEO conversation is the Messages front door", async () => {
|
||||
await expect(doomed).toHaveCount(0);
|
||||
await expect(page.getByRole("button", { name: /Operationalize goal: Ship the FlowPilot MVP\./ })).toHaveCount(0);
|
||||
} finally {
|
||||
await app.close();
|
||||
await closeApp(app);
|
||||
}
|
||||
});
|
||||
@@ -136,7 +136,13 @@ test("onboards, hires, and creates work in the Electron shell", async () => {
|
||||
await expect(toast).toContainText('An agent named "Alex Turing" is already on staff');
|
||||
await toast.getByRole("button", { name: "Dismiss" }).click();
|
||||
await expect(toast).toHaveCount(0);
|
||||
// Closing a dialog with typed input asks before discarding it.
|
||||
await page.locator(".modal").getByRole("button", { name: "Cancel" }).click();
|
||||
await page.getByRole("alertdialog", { name: "Discard your changes?" }).getByRole("button", { name: "Keep editing" }).click();
|
||||
await expect(page.locator(".modal").getByLabel("Name", { exact: true })).toHaveValue("Alex Turing");
|
||||
await page.locator(".modal-backdrop").click({ position: { x: 5, y: 5 } });
|
||||
await page.getByRole("alertdialog", { name: "Discard your changes?" }).getByRole("button", { name: "Discard" }).click();
|
||||
await expect(page.locator(".modal")).toHaveCount(0);
|
||||
|
||||
// The operator edits their own name and avatar from the sidebar foot.
|
||||
await page.getByRole("button", { name: "Edit profile" }).click();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { expect, type Page } from "@playwright/test";
|
||||
import { expect, type ElectronApplication, type Page } from "@playwright/test";
|
||||
|
||||
/** Runs the setup wizard with a fake OpenAI key and enters the app. */
|
||||
export async function onboard(page: Page, company: string): Promise<void> {
|
||||
@@ -17,3 +17,11 @@ export async function onboard(page: Page, company: string): Promise<void> {
|
||||
await page.getByRole("button", { name: "Finish" }).click();
|
||||
await expect(page.getByRole("button", { name: "Settings" })).toBeVisible();
|
||||
}
|
||||
|
||||
/** Closes the app, answering the unsaved-input question (a native dialog Playwright cannot click) with "discard". */
|
||||
export async function closeApp(app: ElectronApplication): Promise<void> {
|
||||
await app.evaluate(({ dialog }) => {
|
||||
dialog.showMessageBoxSync = () => 0;
|
||||
});
|
||||
await app.close();
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
import { _electron as electron, expect, test } from "@playwright/test";
|
||||
import { mkdirSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join, resolve } from "node:path";
|
||||
import { randomUUID } from "node:crypto";
|
||||
import { seedBuiltinSkillsFixture } from "./builtin-skills-fixture";
|
||||
import { closeApp, onboard } from "./onboard";
|
||||
|
||||
test("typed input survives page switches, and leaving or closing asks before it is lost", async () => {
|
||||
const profileDir = join(tmpdir(), `agentcompany-new-e2e-unsaved-${randomUUID()}`);
|
||||
mkdirSync(profileDir, { recursive: true });
|
||||
const builtinDir = seedBuiltinSkillsFixture(join(tmpdir(), `agentcompany-new-e2e-unsaved-builtin-${randomUUID()}`));
|
||||
const app = await electron.launch({
|
||||
args: [resolve("out/main/index.js")],
|
||||
env: { ...process.env, AGENTCOMPANY_NEW_PROFILE_DIR: profileDir, AGENTCOMPANY_NEW_AUTORUN: "0", AGENTCOMPANY_NEW_BUILTIN_SKILLS_DIR: builtinDir },
|
||||
});
|
||||
try {
|
||||
const page = await app.firstWindow();
|
||||
await onboard(page, "Unsaved Co");
|
||||
const composer = page.getByRole("textbox", { name: "Message" });
|
||||
|
||||
// An unsent message is kept when another page is opened and comes back with the conversation.
|
||||
await page.getByRole("button", { name: "Messages" }).click();
|
||||
await composer.fill("hello team");
|
||||
await page.getByRole("button", { name: "Send" }).click();
|
||||
await expect(composer).toHaveValue("");
|
||||
await composer.fill("unsent words");
|
||||
await page.getByRole("button", { name: "Home" }).click();
|
||||
await page.getByRole("button", { name: "Messages" }).click();
|
||||
await expect(composer).toHaveValue("unsent words");
|
||||
|
||||
// Closing the window with it asks first; staying keeps the app running.
|
||||
await app.evaluate(({ dialog }) => {
|
||||
(globalThis as unknown as { asked: number }).asked = 0;
|
||||
dialog.showMessageBoxSync = () => {
|
||||
(globalThis as unknown as { asked: number }).asked += 1;
|
||||
return 1;
|
||||
};
|
||||
});
|
||||
await page.evaluate(() => void (window as unknown as { agentCompany: { windowClose: () => Promise<unknown> } }).agentCompany.windowClose());
|
||||
await expect.poll(() => app.evaluate(() => (globalThis as unknown as { asked: number }).asked)).toBe(1);
|
||||
await expect(composer).toHaveValue("unsent words");
|
||||
|
||||
// An edit in progress is lost by leaving the page, so leaving asks.
|
||||
await page.getByRole("button", { name: "Edit message" }).first().click();
|
||||
await page.getByRole("textbox", { name: "Edit message" }).fill("hello team, edited");
|
||||
await page.getByRole("button", { name: "Home" }).click();
|
||||
const leave = page.getByRole("alertdialog", { name: "Leave this page?" });
|
||||
await leave.getByRole("button", { name: "Stay" }).click();
|
||||
await expect(page.getByRole("textbox", { name: "Edit message" })).toHaveValue("hello team, edited");
|
||||
await page.getByRole("button", { name: "Home" }).click();
|
||||
await leave.getByRole("button", { name: "Leave" }).click();
|
||||
await expect(leave).toHaveCount(0);
|
||||
await expect(page.getByRole("textbox", { name: "Edit message" })).toHaveCount(0);
|
||||
|
||||
// A command picked from the menu is unsent input too, though no key was typed.
|
||||
const asked = () => app.evaluate(() => (globalThis as unknown as { asked: number }).asked);
|
||||
await page.getByRole("button", { name: "Messages" }).click();
|
||||
await composer.fill("");
|
||||
await page.getByRole("button", { name: "Commands" }).click();
|
||||
await page.getByRole("button", { name: "/handoff" }).click();
|
||||
await expect(composer).toHaveValue("/handoff ");
|
||||
await page.evaluate(() => void (window as unknown as { agentCompany: { windowClose: () => Promise<unknown> } }).agentCompany.windowClose());
|
||||
await expect.poll(asked).toBe(2);
|
||||
|
||||
// Settings sections are left like pages: an edited limit is not dropped silently.
|
||||
await page.getByRole("button", { name: "Settings" }).click();
|
||||
await page.getByRole("button", { name: "Providers" }).click();
|
||||
await page.getByLabel("OpenAI monthly request limit").fill("77");
|
||||
await page.getByRole("button", { name: "General" }).click();
|
||||
await leave.getByRole("button", { name: "Stay" }).click();
|
||||
await expect(page.getByLabel("OpenAI monthly request limit")).toHaveValue("77");
|
||||
await page.getByRole("button", { name: "General" }).click();
|
||||
await leave.getByRole("button", { name: "Leave" }).click();
|
||||
await expect(page.getByLabel("OpenAI monthly request limit")).toHaveCount(0);
|
||||
|
||||
// Starting another company replaces the screen, so it asks too.
|
||||
await page.getByRole("button", { name: "Providers" }).click();
|
||||
await page.getByLabel("OpenAI monthly request limit").fill("78");
|
||||
await page.getByRole("button", { name: "Unsaved Co — switch organization" }).click();
|
||||
await page.getByRole("menuitem", { name: "New organization" }).click();
|
||||
await leave.getByRole("button", { name: "Stay" }).click();
|
||||
await expect(page.getByLabel("OpenAI monthly request limit")).toHaveValue("78");
|
||||
} finally {
|
||||
await closeApp(app);
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user