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

Playwright: Enable Advanced Settings and Capture Full Settings Page #1186

Merged
merged 12 commits into from
Jul 10, 2024
22 changes: 22 additions & 0 deletions test/playwright/visual.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,28 @@ test('visual', async ({page, extensionId}) => {
// Take a screenshot of the settings page with jmdict loaded
await expect.soft(page).toHaveScreenshot('settings-jmdict-loaded.png', {mask: [storage_locator]});

// Enable advanced settings
// Wait for the advanced settings to be visible
await page.locator('input#advanced-checkbox').evaluate((/** @type {HTMLInputElement} */ element) => element.click());

// Get page height by getting the footer and adding height and y position as other methods of calculation don't work for some reason
const footer = /** @type {import('@playwright/test').ElementHandle<HTMLElement>} */ (await page.locator('.footer-padding').elementHandle());
expect(footer).not.toBe(null);
const boundingBox = /** @type {NonNullable<Awaited<ReturnType<import('@playwright/test').ElementHandle<HTMLElement>['boundingBox']>>>} */ (await footer.boundingBox());
expect(boundingBox).not.toBe(null);
const pageHeight = Math.ceil(boundingBox.y + boundingBox.height);

await page.setViewportSize({width: 1280, height: pageHeight});

// Wait for any animations or changes to complete
await page.waitForTimeout(500);

// Take a full page screenshot of the settings page with advanced settings enabled
await expect.soft(page).toHaveScreenshot('settings-fresh-full-advanced.png', {
fullPage: true,
mask: [storage_locator],
});

/**
* @param {number} doc_number
* @param {number} test_number
Expand Down