46 行
1.3 KiB
TypeScript
46 行
1.3 KiB
TypeScript
import { expect, type Page } from "@playwright/test";
|
|
|
|
import { openBackupModulesIfNeeded, openNavLink, openProfileSettings } from "../navigation";
|
|
import { TEST_IDS } from "../testIds";
|
|
|
|
export class AppShell {
|
|
readonly page: Page;
|
|
|
|
constructor(page: Page) {
|
|
this.page = page;
|
|
}
|
|
|
|
get sidebar() {
|
|
return this.page.locator("nav").first();
|
|
}
|
|
|
|
get topbarProfileTrigger() {
|
|
return this.page.getByTestId(TEST_IDS.topbar.profileTrigger).first();
|
|
}
|
|
|
|
async navigate(name: string | RegExp) {
|
|
return openNavLink(this.page, name);
|
|
}
|
|
|
|
async openBackupModules() {
|
|
return openBackupModulesIfNeeded(this.page);
|
|
}
|
|
|
|
async openProfile(userDisplayName?: string) {
|
|
return openProfileSettings(this.page, userDisplayName);
|
|
}
|
|
|
|
async assertMainNavVisible() {
|
|
await expect(this.page.getByRole("link", { name: "工作台" }).or(this.page.getByRole("link", { name: "Portal" })).first()).toBeVisible();
|
|
await expect(this.page.getByRole("link", { name: /项目/ }).first()).toBeVisible();
|
|
}
|
|
|
|
async assertBackupModulesCollapsed() {
|
|
const summary = this.page.locator("summary").filter({ hasText: "备用模块" }).first();
|
|
if (await summary.count()) {
|
|
const details = summary.locator("xpath=ancestor::details[1]");
|
|
await expect(details).not.toHaveAttribute("open", "");
|
|
}
|
|
}
|
|
}
|