From bd86d5a4ad09f201a59522f68ca705be5c3a5fa5 Mon Sep 17 00:00:00 2001 From: MarvNC Date: Mon, 8 Jul 2024 15:07:04 -0700 Subject: [PATCH] Set page height better maybe --- test/playwright/visual.spec.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/test/playwright/visual.spec.js b/test/playwright/visual.spec.js index 0eb7ced2af..9288e584a9 100644 --- a/test/playwright/visual.spec.js +++ b/test/playwright/visual.spec.js @@ -50,12 +50,18 @@ test('visual', async ({page, extensionId}) => { // Scroll to the bottom of the page // document.querySelector('.footer-padding').scrollIntoView() - await page.locator('.footer-padding').evaluate((/** @type {HTMLElement} */ element) => element.scrollIntoView()); + await page.locator('.footer…-padding').evaluate((/** @type {HTMLElement} */ element) => element.scrollIntoView()); - // TODO: remove below - // eslint-disable-next-line no-undef - const pageHeight = await page.evaluate(() => document.body.scrollHeight); - console.log('Page height: ' + pageHeight); + // Get page height by getting the footer and adding height and y position + + const footer = /** @type {import('@playwright/test').ElementHandle} */ (await page.locator('.footer…-padding').elementHandle()); + expect(footer).not.toBe(null); + const boundingBox = /** @type {NonNullable['boundingBox']>>>} */ (await footer.boundingBox()); + expect(boundingBox).not.toBe(null); + const pageHeight = Math.ceil(boundingBox.y + boundingBox.height); + console.log('Page height:', pageHeight); + + await page.setViewportSize({width: 1280, height: pageHeight}); // Wait for any animations or changes to complete await page.waitForTimeout(500);