refactor: organize E2E tests with page objects

This commit is contained in:
2026-10-07 21:13:40 +09:00
parent 1e03e8f4ff
commit 48ef396ec1
28 changed files with 1494 additions and 834 deletions
+45
View File
@@ -0,0 +1,45 @@
import type { Locator, Page } from "@playwright/test";
export class ResearchPage {
readonly panel: Locator;
readonly conversation: Locator;
readonly composer: Locator;
readonly send: Locator;
readonly newChat: Locator;
readonly unconfiguredNotice: Locator;
readonly bubbles: Locator;
readonly messageLists: Locator;
readonly messageTables: Locator;
constructor(readonly page: Page) {
this.panel = this.page.getByRole("complementary", { name: "Research chat" });
this.conversation = this.page.getByRole("log", { name: "Research conversation" });
this.composer = this.panel.getByRole("textbox", { name: "Message", exact: true });
this.send = this.panel.getByRole("button", { name: "Send", exact: true });
this.newChat = this.page.getByRole("button", { name: "New chat", exact: true });
this.unconfiguredNotice = this.panel.getByText(
"The connection to Codex on your home server is not configured.",
);
this.bubbles = this.conversation.locator('[data-slot="bubble-content"]');
this.messageLists = this.conversation.locator("ul");
this.messageTables = this.conversation.getByRole("table");
}
async goTo(search = "", options?: Parameters<Page["goto"]>[1]) {
await this.page.goto(`/deck${search}`, options);
}
accountPicker(count: number) {
return this.page.getByRole("button", { name: `Connected accounts · ${count}` });
}
account(name: string) {
return this.page.getByRole("checkbox", { name, exact: true });
}
messageHeading(name: string) {
return this.conversation.getByRole("heading", { name, exact: true });
}
emphasis(text: string) {
return this.conversation.locator("strong").filter({ hasText: text });
}
citation(name: string) {
return this.conversation.getByRole("link", { name, exact: true });
}
}