From bf6118217594e023b1e23d5779d40ba2819f7bf0 Mon Sep 17 00:00:00 2001 From: Santoshkumar Nateekar Date: Thu, 6 Jun 2024 08:17:32 -0700 Subject: [PATCH] [Carousel] Update the carousel block wait time for the visibility check (#369) * update carousel block wait time * fix eslint errors * add ignore console error for video block --------- Co-authored-by: nateekar --- selectors/milo/carousel.block.page.js | 16 +++++++--------- tests/milo/carousel.block.test.js | 8 ++++---- tests/milo/video.block.test.js | 1 + 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/selectors/milo/carousel.block.page.js b/selectors/milo/carousel.block.page.js index bba6a565..e121a54d 100644 --- a/selectors/milo/carousel.block.page.js +++ b/selectors/milo/carousel.block.page.js @@ -1,5 +1,3 @@ -import { expect } from '@playwright/test'; - export default class Carousel { constructor(page) { this.page = page; @@ -193,27 +191,27 @@ export default class Carousel { * @return {Promise} 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: @@ -221,4 +219,4 @@ export default class Carousel { } return isDisplayed; } -}; +} diff --git a/tests/milo/carousel.block.test.js b/tests/milo/carousel.block.test.js index 9d1d7822..1c1b3965 100644 --- a/tests/milo/carousel.block.test.js +++ b/tests/milo/carousel.block.test.js @@ -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}`); }); @@ -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}`); }); @@ -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}`); }); diff --git a/tests/milo/video.block.test.js b/tests/milo/video.block.test.js index 9361c296..f3c28b3b 100644 --- a/tests/milo/video.block.test.js +++ b/tests/milo/video.block.test.js @@ -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', () => {