Files
alighasami 3d5eaf9445
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
first commit
2026-03-17 16:22:57 +03:30

66 lines
2.0 KiB
TypeScript

import type { Page } from '@playwright/test';
import { BaseModal } from './components/BaseModal';
import { FloatingUiHelper } from './components/FloatingUiHelper';
export abstract class BasePage extends FloatingUiHelper {
protected readonly baseModal: BaseModal;
constructor(protected readonly page: Page) {
super(page);
this.baseModal = new BaseModal(this.page);
}
protected async clickByTestId(testId: string) {
await this.page.getByTestId(testId).click();
}
protected async fillByTestId(testId: string, value: string) {
await this.page.getByTestId(testId).fill(value);
}
protected async clickByText(text: string) {
await this.page.getByText(text).click();
}
protected async clickButtonByName(name: string) {
await this.page.getByRole('button', { name }).click();
}
protected async waitForRestResponse(
url: string | RegExp,
method?: 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE',
) {
if (typeof url === 'string') {
return await this.page.waitForResponse((res) => {
const matches = res.url().includes(url);
return matches && (method ? res.request().method() === method : true);
});
}
return await this.page.waitForResponse((res) => {
const matches = url.test(res.url());
return matches && (method ? res.request().method() === method : true);
});
}
/**
* Wait for debounce to complete.
* Respects the N8N_DEBOUNCE_MULTIPLIER sessionStorage setting.
* With multiplier=0 (test mode), returns immediately.
* @param baseTime - Base debounce time in milliseconds (default: 150)
*/
protected async waitForDebounce(baseTime = 150): Promise<void> {
const effectiveTime = await this.page.evaluate((time) => {
const stored = sessionStorage.getItem('N8N_DEBOUNCE_MULTIPLIER');
const multiplier = stored !== null ? parseFloat(stored) : 1;
return Math.round(time * (Number.isNaN(multiplier) ? 1 : multiplier));
}, baseTime);
if (effectiveTime > 0) {
// eslint-disable-next-line playwright/no-wait-for-timeout
await this.page.waitForTimeout(effectiveTime);
}
}
}