From deccf95fc0f3d375b58794eeea547f05b0035ef9 Mon Sep 17 00:00:00 2001 From: AlekseyManetov Date: Tue, 28 Jan 2025 17:29:35 +0100 Subject: [PATCH] Add possibility to run e2e test by custom url provided --- uui-e2e-tests/framework/constants.ts | 2 +- .../fixtures/docExamplePage/docExamplePage.ts | 7 ++++++- uui-e2e-tests/framework/fixtures/shared/absPage.ts | 4 ++-- uui-e2e-tests/tests/Integration/testUtils.ts | 11 ++++++++--- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/uui-e2e-tests/framework/constants.ts b/uui-e2e-tests/framework/constants.ts index fd7a5f7ae3..e33199e9b3 100644 --- a/uui-e2e-tests/framework/constants.ts +++ b/uui-e2e-tests/framework/constants.ts @@ -2,7 +2,7 @@ import { PlaywrightTestOptions } from '@playwright/test'; export const PLATFORM = 'linux'; export const PREVIEW_URL = '/preview'; -export const DOC_EXAMPLE_URL = '/docExample'; +export const DOC_EXAMPLE_URL = '/'; export const PlayWrightInterfaceName = '_uui_playwright_interface'; /* diff --git a/uui-e2e-tests/framework/fixtures/docExamplePage/docExamplePage.ts b/uui-e2e-tests/framework/fixtures/docExamplePage/docExamplePage.ts index 90fc3e43f4..b101b259ea 100644 --- a/uui-e2e-tests/framework/fixtures/docExamplePage/docExamplePage.ts +++ b/uui-e2e-tests/framework/fixtures/docExamplePage/docExamplePage.ts @@ -14,7 +14,7 @@ export class DocExamplePage extends AbsPage { }; } - async clientRedirect(params: { examplePath: string }) { + async clientRedirectToExample(params: { examplePath: string }) { await super._clientRedirect({ // As we agreed, "doc example" tests must be always run on "loveship" theme theme: TTheme.loveship, ...params, @@ -22,6 +22,11 @@ export class DocExamplePage extends AbsPage { await this.locators.regionContentNotBusy.waitFor(); } + async clientRedirectTo(url: string) { + await this.openInitialPage(url); + await this.locators.regionContentNotBusy.waitFor(); + } + async expectScreenshot(screenshotName: string) { const screenshotOptions = await super._getScreenshotOptions({ isSlowTest: true }); await expect(this.page).toHaveScreenshot(screenshotName, screenshotOptions); diff --git a/uui-e2e-tests/framework/fixtures/shared/absPage.ts b/uui-e2e-tests/framework/fixtures/shared/absPage.ts index 6c72f5dde2..24ba0024a1 100644 --- a/uui-e2e-tests/framework/fixtures/shared/absPage.ts +++ b/uui-e2e-tests/framework/fixtures/shared/absPage.ts @@ -36,8 +36,8 @@ export abstract class AbsPage { await this.cdpSession.close(); } - async openInitialPage(): Promise { - await this.page.goto(this.initialUrl); + async openInitialPage(url?: string): Promise { + await this.page.goto(url || this.initialUrl); if (this.extraStyles) { await this.page.addStyleTag({ path: this.extraStyles }); } diff --git a/uui-e2e-tests/tests/Integration/testUtils.ts b/uui-e2e-tests/tests/Integration/testUtils.ts index 545c5978a1..49e3322c0e 100644 --- a/uui-e2e-tests/tests/Integration/testUtils.ts +++ b/uui-e2e-tests/tests/Integration/testUtils.ts @@ -7,16 +7,21 @@ export enum DocExamplePath { interface IDocExampleTestSetup { testInfo: TestInfo, - examplePath: DocExamplePath, + examplePath?: DocExamplePath, pageWrapper: DocExamplePage, + testUrl?: string; PageObjectConstructor: new (page: Page) => TPageObject } export async function setupDocExampleTest(params: IDocExampleTestSetup) { - const { pageWrapper, testInfo, examplePath, PageObjectConstructor } = params; + const { pageWrapper, testInfo, examplePath, testUrl, PageObjectConstructor } = params; // The timeout is increased for all doc example tests, because such tests contain many assertions. testInfo.setTimeout(testInfo.timeout * 3); - await pageWrapper.clientRedirect({ examplePath }); + if (params.testUrl) { + await pageWrapper.clientRedirectTo(testUrl!); + } else { + await pageWrapper.clientRedirectToExample({ examplePath: examplePath! }); + } const expectScreenshot = async (stepNumber: number, stepName: string) => { const stepNumberPadded = numberWithLeadingZeros(stepNumber, 2); const screenshotName = `${testInfo.title}_step-${stepNumberPadded}-${stepName}.png`;