-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpages.fixture.ts
More file actions
78 lines (67 loc) · 2.6 KB
/
Copy pathpages.fixture.ts
File metadata and controls
78 lines (67 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import type { Page } from "@playwright/test";
import { testWithWildFly } from "./wildfly.fixture.js";
import { MAIN } from "../selectors/ids.js";
import { ouiaSelector } from "../utils/ouia.js";
import { BasePage } from "../pages/base.page.js";
import { ConfigurationPage } from "../pages/configuration.page.js";
import { DashboardPage } from "../pages/dashboard.page.js";
import { ModelBrowserPage } from "../pages/model-browser.page.js";
import { NavigationPage } from "../pages/navigation.page.js";
import { TasksPage } from "../pages/tasks.page.js";
async function enableOuia(page: Page): Promise<void> {
await page.addInitScript(() => {
localStorage.setItem("ouia", "true");
});
}
/** Navigates to halOP with the WildFly connect parameter and waits for the main content. */
async function openHalOp(page: Page, managementUrl: string): Promise<void> {
await page.goto(`/?connect=${managementUrl}`);
await page.locator(ouiaSelector(MAIN)).waitFor({ state: "visible" });
}
/** Test-scoped page object fixtures. */
interface PageFixtures {
basePage: BasePage;
configurationPage: ConfigurationPage;
dashboardPage: DashboardPage;
modelBrowserPage: ModelBrowserPage;
navigationPage: NavigationPage;
tasksPage: TasksPage;
}
/** Test object with WildFly container, OUIA enablement, and page object fixtures. */
export const test = testWithWildFly.extend<PageFixtures>({
page: async ({ page }, use) => {
await enableOuia(page);
await use(page);
},
basePage: async ({ page, wildfly }, use) => {
await openHalOp(page, wildfly.managementUrl);
await use(new BasePage(page));
},
configurationPage: async ({ page, wildfly }, use) => {
await openHalOp(page, wildfly.managementUrl);
const configurationPage = new ConfigurationPage(page);
await configurationPage.navigate();
await use(configurationPage);
},
dashboardPage: async ({ page, wildfly }, use) => {
await openHalOp(page, wildfly.managementUrl);
await use(new DashboardPage(page));
},
modelBrowserPage: async ({ page, wildfly }, use) => {
await openHalOp(page, wildfly.managementUrl);
const modelBrowserPage = new ModelBrowserPage(page);
await modelBrowserPage.navigate();
await use(modelBrowserPage);
},
navigationPage: async ({ page, wildfly }, use) => {
await openHalOp(page, wildfly.managementUrl);
await use(new NavigationPage(page));
},
tasksPage: async ({ page, wildfly }, use) => {
await openHalOp(page, wildfly.managementUrl);
const tasksPage = new TasksPage(page);
await tasksPage.navigate();
await use(tasksPage);
},
});
export { expect } from "@playwright/test";