Skip to content

Commit

Permalink
Categorize screenshots by engine, and require perfect match
Browse files Browse the repository at this point in the history
  • Loading branch information
sockmaster27 committed Jan 3, 2025
1 parent a1b8efc commit 6a3ca9d
Show file tree
Hide file tree
Showing 62 changed files with 109 additions and 25 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
134 changes: 109 additions & 25 deletions tests/test-sites.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,37 @@ test.beforeEach(async ({ page }) => {
*
* @param page
* @param info
* @param browserName
* @param name A name that identifies this test.
* @param api The API used in the test, either `"webgl"` or `"webgpu"`.
* @param number A number identifying the specific screeenshot within the test, if multiple are included.
*/
async function assertScreenshot(
page: Page,
info: TestInfo,
browserName: string,
name: string,
api: "webgl" | "webgpu",
number?: number,
) {
const projectName = info.project.name;
const isMobile = info.project.use.isMobile ?? false;

const mobileString = isMobile ? "-mobile" : "";
const numberString = number !== undefined ? `-${number}` : "";

const isWebGpu = api === "webgpu";
const isWebGpuUnsupported = projectName.includes("<No WebGPU>");
const unsupportedString =
isWebGpu && isWebGpuUnsupported ? "-unsupported" : "";

const fileName = `${name}-${api}${unsupportedString}${mobileString}${numberString}.png`;
const engineString = `-${browserName}`;

const isMobile = info.project.use.isMobile ?? false;
const mobileString = isMobile ? "-mobile" : "";

const numberString = number !== undefined ? `-${number}` : "";

const fileName = `${name}-${api}${unsupportedString}${engineString}${mobileString}${numberString}.png`;

await expect.soft(page).toHaveScreenshot(fileName, {
// Allow for slightly different rendering on different platforms,
// since Chrome and Firefox have slightly different text-rendering and inputs etc.
maxDiffPixelRatio: 0.01,
timeout: 10000,
threshold: 0.1,
});
}

Expand All @@ -56,67 +58,149 @@ builds.forEach(({ name, port }) => {

apis.forEach(api => {
test.describe(api, () => {
test("Hello world", async ({ page }, info) => {
test("Hello world", async ({ page, browserName }, info) => {
const pageName = "hello-world";

await page.goto(`/${pageName}/${api}`);
await assertScreenshot(page, info, pageName, api);
await assertScreenshot(
page,
info,
browserName,
pageName,
api,
);
});

test("Remounting canvas", async ({ page }, info) => {
test("Remounting canvas", async ({
page,
browserName,
}, info) => {
const pageName = "remount";

await page.goto(`/${pageName}/${api}`);
const show = page.getByLabel("Show");
await show.uncheck();
await assertScreenshot(page, info, pageName, api, 1);
await assertScreenshot(
page,
info,
browserName,
pageName,
api,
1,
);
for (let i = 0; i < 10; i++) {
await show.check();
await show.uncheck();
}
await show.check();
await assertScreenshot(page, info, pageName, api, 2);
await assertScreenshot(
page,
info,
browserName,
pageName,
api,
2,
);
});

test("Oversized canvas", async ({ page }, info) => {
test("Oversized canvas", async ({
page,
browserName,
}, info) => {
const pageName = "oversized-canvas";

await page.goto(`/${pageName}/${api}`);
await assertScreenshot(page, info, pageName, api, 1);
await assertScreenshot(
page,
info,
browserName,
pageName,
api,
1,
);
// Scroll to bottom-right corner
await page.evaluate(() =>
window.scrollBy(
document.body.scrollWidth,
document.body.scrollHeight,
),
);
await assertScreenshot(page, info, pageName, api, 2);
await assertScreenshot(
page,
info,
browserName,
pageName,
api,
2,
);
});

test("Landing page with bubbles", async ({ page }, info) => {
test("Landing page with bubbles", async ({
page,
browserName,
}, info) => {
const pageName = "landing-page-bubbles";

await page.goto(`/${pageName}/${api}`);
await assertScreenshot(page, info, pageName, api);
await assertScreenshot(
page,
info,
browserName,
pageName,
api,
);
});

test("Landing page with a halo", async ({ page }, info) => {
test("Landing page with a halo", async ({
page,
browserName,
}, info) => {
const pageName = "landing-page-halo";

await page.goto(`/${pageName}/${api}`);
await assertScreenshot(page, info, pageName, api);
await assertScreenshot(
page,
info,
browserName,
pageName,
api,
);
});

test("Slider component", async ({ page }, info) => {
test("Slider component", async ({
page,
browserName,
}, info) => {
const pageName = "slider";

await page.goto(`/${pageName}/${api}`);
const slider = page.getByRole("slider");
await assertScreenshot(page, info, pageName, api, 1);
await assertScreenshot(
page,
info,
browserName,
pageName,
api,
1,
);
await slider.fill("1");
await assertScreenshot(page, info, pageName, api, 2);
await assertScreenshot(
page,
info,
browserName,
pageName,
api,
2,
);
await slider.fill("0");
await assertScreenshot(page, info, pageName, api, 3);
await assertScreenshot(
page,
info,
browserName,
pageName,
api,
3,
);
});
});
});
Expand Down

0 comments on commit 6a3ca9d

Please sign in to comment.