-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmodal.ts
More file actions
52 lines (47 loc) · 1.43 KB
/
modal.ts
File metadata and controls
52 lines (47 loc) · 1.43 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
import type { Page } from "@playwright/test";
/**
* Wait for the ModifyNodeModal to appear.
*/
export const waitForModal = async (page: Page): Promise<void> => {
await page.waitForSelector(".modal-container", { timeout: 5_000 });
};
/**
* Select a node type from the dropdown in the modal.
*/
export const selectNodeType = async (
page: Page,
label: string,
): Promise<void> => {
const nodeTypeSelect = page.locator(".modal-container select").first();
await nodeTypeSelect.selectOption({ label });
await page.waitForTimeout(300);
};
/**
* Fill the content/title input field in the modal.
*/
export const fillNodeContent = async (
page: Page,
content: string,
): Promise<void> => {
const contentInput = page
.locator(".modal-container input[type='text']")
.first();
await contentInput.click();
await contentInput.fill(content);
await page.waitForTimeout(300);
};
/**
* Click the Confirm button (mod-cta) in the modal.
*/
export const confirmModal = async (page: Page): Promise<void> => {
// Use force: true to bypass any suggestion/autocomplete overlay that may cover the button
await page.locator(".modal-container button.mod-cta").click({ force: true });
await page.waitForTimeout(2_000);
};
/**
* Click the Cancel button in the modal.
*/
export const cancelModal = async (page: Page): Promise<void> => {
await page.locator(".modal-container button:not(.mod-cta)").click();
await page.waitForTimeout(500);
};