-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathbase-page.ts
38 lines (28 loc) · 1.04 KB
/
base-page.ts
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
import { expect, type Locator, type Page } from '@playwright/test';
export default class BasePage {
public page: Page;
private backToHomePageButton: Locator;
protected viteOverlay: Locator;
readonly lastToast: Locator;
constructor(page: Page) {
this.page = page;
this.backToHomePageButton = page.locator('.mastheader-logo');
this.viteOverlay = page.locator('vite-plugin-checker-error-overlay');
this.lastToast = page.getByTestId('toast-SNCF').last();
}
// Completly remove VITE button & sign
async removeViteOverlay() {
if ((await this.viteOverlay.count()) > 0) {
await this.viteOverlay.evaluate((node) => node.setAttribute('style', 'display:none;'));
}
}
async backToHomePage() {
await this.backToHomePageButton.click();
}
async checkLastToastBody(text: string | RegExp) {
await expect(this.lastToast.locator('.toast-body')).toHaveText(text);
}
async checkLastToastTitle(text: string | RegExp) {
await expect(this.lastToast.getByTestId('toast-SNCF-title')).toHaveText(text);
}
}