Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vp test: eslint fix #764

Merged
merged 1 commit into from
Dec 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 21 additions & 23 deletions test/e2e/components/BaseComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,36 +14,34 @@ import { Locator, Page } from '@playwright/test';
* }
*/
export interface IBaseComponent {
page: Page;
selector: string;
parentSelector?: string;
iframeSelector?: string;
page: Page;
selector: string;
parentSelector?: string;
iframeSelector?: string;
}
/**
* Base class for an POM component class
* such as buttons, dropList, etc
*/
export class BaseComponent {
get locator(): Locator {
return this._locator;
}
get locator(): Locator {
return this._locator;
}

get props(): IBaseComponent {
return this._props;
}
get props(): IBaseComponent {
return this._props;
}

private readonly _locator: Locator;
private readonly _props: IBaseComponent;
private readonly _locator: Locator;
private readonly _props: IBaseComponent;

constructor(basePageProps: IBaseComponent) {
if (!basePageProps.selector) {
throw Error(`Missing selector in basePageProps`);
}
const elementSelector: string = basePageProps.parentSelector ? `${basePageProps.parentSelector}${basePageProps.selector}` : basePageProps.selector;
constructor(basePageProps: IBaseComponent) {
if (!basePageProps.selector) {
throw Error(`Missing selector in basePageProps`);
}
const elementSelector: string = basePageProps.parentSelector ? `${basePageProps.parentSelector}${basePageProps.selector}` : basePageProps.selector;

this._props = basePageProps;
this._locator = basePageProps.iframeSelector
? basePageProps.page.frameLocator(basePageProps.iframeSelector).locator(elementSelector)
: basePageProps.page.locator(elementSelector);
}
}
this._props = basePageProps;
this._locator = basePageProps.iframeSelector ? basePageProps.page.frameLocator(basePageProps.iframeSelector).locator(elementSelector) : basePageProps.page.locator(elementSelector);
}
}
3 changes: 1 addition & 2 deletions test/e2e/components/videoComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import { BaseComponent } from './BaseComponent';
/**
* Video component
*/
export class VideoComponent extends BaseComponent{

export class VideoComponent extends BaseComponent {
constructor(page: Page, videoSelector: string) {
super({ page, selector: videoSelector });
}
Expand Down
34 changes: 17 additions & 17 deletions test/e2e/specs/audioPlayerPage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ const link = getLinkByName(ExampleLinkName.AudioPlayer);
* Testing if videos on audio player page are playing by checking that is pause return false.
*/
vpTest(`Test if 2 videos on audio player page are playing as expected`, async ({ page, pomPages }) => {
await test.step('Navigate to audio player page by clicking on link', async () => {
await pomPages.mainPage.clickLinkByName(link.name);
await waitForPageToLoadWithTimeout(page, 5000);
});
await test.step('Click on play button of first video player to play video', async () => {
return pomPages.audioPlayerPage.audioPlayerVideoComponent.clickPlay();
});
await test.step('Validating that the first video is playing (in case isPause is false)', async () => {
expect(await pomPages.audioPlayerPage.audioPlayerVideoComponent.isPaused()).toEqual(false);
});
await test.step('Click on play button of second video player to play video', async () => {
return pomPages.audioPlayerPage.audioPlayerWithTransformationVideoComponent.clickPlay();
});
await test.step('Validating that the second video is playing (in case isPause is false)', async () => {
expect(await pomPages.audioPlayerPage.audioPlayerWithTransformationVideoComponent.isPaused()).toEqual(false);
});
});
await test.step('Navigate to audio player page by clicking on link', async () => {
await pomPages.mainPage.clickLinkByName(link.name);
await waitForPageToLoadWithTimeout(page, 5000);
});
await test.step('Click on play button of first video player to play video', async () => {
return pomPages.audioPlayerPage.audioPlayerVideoComponent.clickPlay();
});
await test.step('Validating that the first video is playing (in case isPause is false)', async () => {
expect(await pomPages.audioPlayerPage.audioPlayerVideoComponent.isPaused()).toEqual(false);
});
await test.step('Click on play button of second video player to play video', async () => {
return pomPages.audioPlayerPage.audioPlayerWithTransformationVideoComponent.clickPlay();
});
await test.step('Validating that the second video is playing (in case isPause is false)', async () => {
expect(await pomPages.audioPlayerPage.audioPlayerWithTransformationVideoComponent.isPaused()).toEqual(false);
});
});
30 changes: 15 additions & 15 deletions test/e2e/specs/autoplayOnScrollPage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ const link = getLinkByName(ExampleLinkName.AutoplayOnScroll);
* Then, scroll until video element is visible and make sure video is playing by checking that is pause return false.
*/
vpTest(`Test if video on autoplay on scroll page is playing as expected`, async ({ page, pomPages }) => {
await test.step('Navigate to autoplay on scroll page by clicking on link', async () => {
await pomPages.mainPage.clickLinkByName(link.name);
await waitForPageToLoadWithTimeout(page, 5000);
});
await test.step('Validating that the video is not playing before scrolling (in case isPause is true)', async () => {
expect(await pomPages.autoplayOnScrollPage.autoplayOnScrollVideoComponent.isPaused()).toEqual(true);
});
await test.step('Scroll until the video element is visible', async () => {
await pomPages.autoplayOnScrollPage.autoplayOnScrollVideoComponent.locator.scrollIntoViewIfNeeded();
});
await test.step('Validating that the video is auto playing after scrolling (in case isPause is false)', async () => {
await expect(async () => {
expect(await pomPages.autoplayOnScrollPage.autoplayOnScrollVideoComponent.isPaused()).toEqual(false);
}).toPass({ intervals: [500], timeout: 3000 });
})
await test.step('Navigate to autoplay on scroll page by clicking on link', async () => {
await pomPages.mainPage.clickLinkByName(link.name);
await waitForPageToLoadWithTimeout(page, 5000);
});
await test.step('Validating that the video is not playing before scrolling (in case isPause is true)', async () => {
expect(await pomPages.autoplayOnScrollPage.autoplayOnScrollVideoComponent.isPaused()).toEqual(true);
});
await test.step('Scroll until the video element is visible', async () => {
await pomPages.autoplayOnScrollPage.autoplayOnScrollVideoComponent.locator.scrollIntoViewIfNeeded();
});
await test.step('Validating that the video is auto playing after scrolling (in case isPause is false)', async () => {
await expect(async () => {
expect(await pomPages.autoplayOnScrollPage.autoplayOnScrollVideoComponent.isPaused()).toEqual(false);
}).toPass({ intervals: [500], timeout: 3000 });
});
});
16 changes: 8 additions & 8 deletions test/e2e/src/pom/audioPlayerPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ const AUDIO_PLAYER_WITH_TRANSFORMATION_VIDEO_SELECTOR = '//*[@id="player-t_html5
* Video player examples audio player page object
*/
export class AudioPlayerPage extends BasePage {
public audioPlayerVideoComponent: VideoComponent;
public audioPlayerWithTransformationVideoComponent: VideoComponent;
public audioPlayerVideoComponent: VideoComponent;
public audioPlayerWithTransformationVideoComponent: VideoComponent;

constructor(page: Page) {
super(page);
this.audioPlayerVideoComponent = new VideoComponent(page, AUDIO_PLAYER_VIDEO_SELECTOR);
this.audioPlayerWithTransformationVideoComponent = new VideoComponent(page, AUDIO_PLAYER_WITH_TRANSFORMATION_VIDEO_SELECTOR);
}
}
constructor(page: Page) {
super(page);
this.audioPlayerVideoComponent = new VideoComponent(page, AUDIO_PLAYER_VIDEO_SELECTOR);
this.audioPlayerWithTransformationVideoComponent = new VideoComponent(page, AUDIO_PLAYER_WITH_TRANSFORMATION_VIDEO_SELECTOR);
}
}
12 changes: 6 additions & 6 deletions test/e2e/src/pom/autoplayOnScrollPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ const AUTOPLAY_ON_SCROLL_PAGE_VIDEO_SELECTOR = '//*[@id="player_html5_api"]';
* Video player examples autoplay on scroll page object
*/
export class AutoplayOnScrollPage extends BasePage {
public autoplayOnScrollVideoComponent: VideoComponent;
public autoplayOnScrollVideoComponent: VideoComponent;

constructor(page: Page) {
super(page);
this.autoplayOnScrollVideoComponent = new VideoComponent(page, AUTOPLAY_ON_SCROLL_PAGE_VIDEO_SELECTOR);
}
}
constructor(page: Page) {
super(page);
this.autoplayOnScrollVideoComponent = new VideoComponent(page, AUTOPLAY_ON_SCROLL_PAGE_VIDEO_SELECTOR);
}
}
Loading