Skip to content

Commit

Permalink
Add possibility to run e2e test by custom url provided
Browse files Browse the repository at this point in the history
  • Loading branch information
AlekseyManetov committed Jan 28, 2025
1 parent a42228b commit deccf95
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion uui-e2e-tests/framework/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,19 @@ export class DocExamplePage extends AbsPage {
};
}

async clientRedirect(params: { examplePath: string }) {
async clientRedirectToExample(params: { examplePath: string }) {
await super._clientRedirect<DocExamplePageParams>({
// As we agreed, "doc example" tests must be always run on "loveship" theme
theme: TTheme.loveship, ...params,
});
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);
Expand Down
4 changes: 2 additions & 2 deletions uui-e2e-tests/framework/fixtures/shared/absPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ export abstract class AbsPage {
await this.cdpSession.close();
}

async openInitialPage(): Promise<void> {
await this.page.goto(this.initialUrl);
async openInitialPage(url?: string): Promise<void> {
await this.page.goto(url || this.initialUrl);
if (this.extraStyles) {
await this.page.addStyleTag({ path: this.extraStyles });
}
Expand Down
11 changes: 8 additions & 3 deletions uui-e2e-tests/tests/Integration/testUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,21 @@ export enum DocExamplePath {

interface IDocExampleTestSetup<TPageObject> {
testInfo: TestInfo,
examplePath: DocExamplePath,
examplePath?: DocExamplePath,
pageWrapper: DocExamplePage,
testUrl?: string;
PageObjectConstructor: new (page: Page) => TPageObject
}

export async function setupDocExampleTest<TPageObject>(params: IDocExampleTestSetup<TPageObject>) {
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`;
Expand Down

0 comments on commit deccf95

Please sign in to comment.