-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathViewPage.ts
More file actions
53 lines (41 loc) · 2.08 KB
/
Copy pathViewPage.ts
File metadata and controls
53 lines (41 loc) · 2.08 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
import { expect, type Locator, type Page } from '@playwright/test';
import { type Organism } from '../src/types/Organism.ts';
export async function expectToSeeNoComponentErrors(page: Page) {
await expect(page.getByText('Error -', { exact: false })).not.toBeVisible();
await expect(page.getByText('Something went wrong', { exact: false })).not.toBeVisible();
}
export abstract class ViewPage {
constructor(public readonly page: Page) {}
public abstract goto(organism: Organism): Promise<void>;
public async submitFilters() {
await this.page.getByRole('button', { name: 'Apply filters' }).click();
}
public diagramTitle(title: string) {
return this.page.getByRole('link', { name: title });
}
public async expectToSeeNoComponentErrors() {
await expectToSeeNoComponentErrors(this.page);
}
public async selectDateRange(dateRangeOption: string) {
await this.page.locator('gs-date-range-filter').getByRole('combobox').first().selectOption(dateRangeOption);
}
public async fillLineageField(locator: Locator, lineage: string) {
await locator.fill(lineage);
const option = this.page.getByRole('listbox').getByRole('option', { name: lineage, exact: false }).first();
// Filling the field opens the autocomplete menu, but each filter field fetches its options
// from LAPIS independently and a re-render triggered by another field settling can close the
// menu again. When that happens the option never appears and a plain click would wait out the
// whole test timeout. Retry "ensure the menu is open, then click the option" together so a
// transient close cannot wedge the test.
await expect(async () => {
if (!(await option.isVisible())) {
await locator.click(); // re-open the menu
}
await option.click({ timeout: 2_000 });
}).toPass();
}
public async fillMutationField(locator: Locator, mutation: string) {
await locator.first().fill(mutation);
await locator.first().press('Enter');
}
}