Skip to content

Commit

Permalink
[Carousel] Update the carousel block wait time for the visibility che…
Browse files Browse the repository at this point in the history
…ck (#369)

* update carousel block wait time

* fix eslint errors

* add ignore console error for video block

---------

Co-authored-by: nateekar <[email protected]>
  • Loading branch information
skumar09 and nateekar committed Jun 6, 2024
1 parent 1b0ccb7 commit bf61182
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
16 changes: 7 additions & 9 deletions selectors/milo/carousel.block.page.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { expect } from '@playwright/test';

export default class Carousel {
constructor(page) {
this.page = page;
Expand Down Expand Up @@ -193,32 +191,32 @@ export default class Carousel {
* @return {Promise<boolean>} Returns a Promise that resolves to true or false.
* @throws {Error} Throws an error if an invalid carousel type is provided.
*/
async isCarouselDisplayed(type) {
async isCarouselDisplayed(type, timeout = 3000) {
let isDisplayed;
switch (type) {
case 'carouselLightbox':
await this.carouselLightbox.waitFor({ state: 'visible' });
await this.carouselLightbox.waitFor({ state: 'visible', timeout });
isDisplayed = await this.carouselLightbox.isVisible();
break;
case 'carouselFullpage':
await this.carouselFullpage.waitFor({ state: 'visible' });
await this.carouselFullpage.waitFor({ state: 'visible', timeout });
isDisplayed = await this.carouselFullpage.isVisible();
break;
case 'carouselContainer':
await this.carouselContainer.waitFor({ state: 'visible' });
await this.carouselContainer.waitFor({ state: 'visible', timeout });
isDisplayed = await this.carouselContainer.isVisible();
break;
case 'carouselShow-2':
await this.carouselContainerShow2.waitFor({ state: 'visible' });
await this.carouselContainerShow2.waitFor({ state: 'visible', timeout });
isDisplayed = await this.carouselContainerShow2.isVisible();
break;
case 'carousel':
await this.carouselDefault.waitFor({ state: 'visible' });
await this.carouselDefault.waitFor({ state: 'visible', timeout });
isDisplayed = await this.carouselDefault.isVisible();
break;
default:
throw new Error(`Invalid carousel type: ${type}`);
}
return isDisplayed;
}
};
}
8 changes: 4 additions & 4 deletions tests/milo/carousel.block.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ const miloLibs = process.env.MILO_LIBS || '';
test.describe('Milo Carousel Block test suite', () => {
test.beforeEach(async ({ page }) => {
carousel = new CarouselBlock(page);
});
});

test(`${features[0].name},${features[0].tags}`, async ({ page, baseURL }) => {
console.info(`[Test Page]: ${baseURL}${features[0].path}${miloLibs}`);

await test.step('step-1: Go to Carousel block test page', async () => {
await page.goto(`${baseURL}${features[0].path}${miloLibs}`);
await page.waitForLoadState('domcontentloaded');
await page.waitForLoadState('networkidle');
await expect(page).toHaveURL(`${baseURL}${features[0].path}${miloLibs}`);
});

Expand Down Expand Up @@ -56,7 +56,7 @@ test.describe('Milo Carousel Block test suite', () => {

await test.step('step-1: Go to Carousel lightbox block test page', async () => {
await page.goto(`${baseURL}${features[1].path}${miloLibs}`);
await page.waitForLoadState('domcontentloaded');
await page.waitForLoadState('networkidle');
await expect(page).toHaveURL(`${baseURL}${features[1].path}${miloLibs}`);
});

Expand Down Expand Up @@ -89,7 +89,7 @@ test.describe('Milo Carousel Block test suite', () => {

await test.step('step-1: Go to Carousel multi-slide show-2 block test page', async () => {
await page.goto(`${baseURL}${features[2].path}${miloLibs}`);
await page.waitForLoadState('domcontentloaded');
await page.waitForLoadState('networkidle');
await expect(page).toHaveURL(`${baseURL}${features[2].path}${miloLibs}`);
});

Expand Down
1 change: 1 addition & 0 deletions tests/milo/video.block.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const knownConsoleErrors = [
'Failed to load resource: net::ERR_FAILED',
'Invalid request',
'Access to XMLHttpRequest',
'Attstation check for Topics',
];

test.describe('Milo Video Block test suite', () => {
Expand Down

0 comments on commit bf61182

Please sign in to comment.