From affcecfbdf1b7217c0a2c6653b4fbec9b28a83ac Mon Sep 17 00:00:00 2001 From: Kasim Necdet Percinel Date: Tue, 21 Jan 2025 20:58:57 +0000 Subject: [PATCH] fix last bit of tests and go full test again --- .github/workflows/ci.yml | 6 +-- tests/desktop/normal/urlsharing.spec.ts | 68 +++++++++++-------------- 2 files changed, 34 insertions(+), 40 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a4f8ee66f..6a845491f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -56,8 +56,8 @@ jobs: playwright-e2e-tests: strategy: matrix: - shardIndex: [1] - shardTotal: [1] + shardIndex: [1, 2, 3, 4, 5] + shardTotal: [5] # If one of the shards fails, continue running the remaining tests fail-fast: false @@ -114,7 +114,7 @@ jobs: - name: Run Playwright tests run: | cd helioviewer.org - npx playwright test --shard=${{matrix.shardIndex}}/${{matrix.shardTotal}} tests/desktop/normal/urlsharing.spec.ts + npx playwright test --shard=${{matrix.shardIndex}}/${{matrix.shardTotal}} - uses: actions/upload-artifact@v4 if: always() with: diff --git a/tests/desktop/normal/urlsharing.spec.ts b/tests/desktop/normal/urlsharing.spec.ts index 239631f13..ee95e258d 100644 --- a/tests/desktop/normal/urlsharing.spec.ts +++ b/tests/desktop/normal/urlsharing.spec.ts @@ -3,37 +3,37 @@ import { Helioviewer } from "../../page_objects/helioviewer"; import * as fs from "fs"; // loading of wrong url , is creating problems -// test("Non-Existing Shared URLs Should Be Reported To User", async ({ page, context }, info) => { -// let hv = new Helioviewer(page); -// -// const response = await hv.Load("/load/DONOTEXIST"); -// await hv.CloseAllNotifications(); -// await expect(page).toHaveScreenshot(); -// }); +test("Non-Existing Shared URLs Should Be Reported To User", async ({ page, context }, info) => { + let hv = new Helioviewer(page); + + const response = await hv.Load("/load/DONOTEXIST"); + await hv.CloseAllNotifications(); + await expect(page).toHaveScreenshot(); +}); /** - * This test plays through creating a short url and makes a test for short url should exactly resolved what is shared + * This test checks if shortURLs are correctly being overwritten by .htacces */ -// test("Shared URLs redirection should be done correctly", async ({ page }, info) => { -// let hv = new Helioviewer(page); -// -// await hv.Load(); -// await hv.CloseAllNotifications(); -// -// await page.locator("#share-button").click(); -// -// await page.waitForTimeout(1000); -// -// await expect(page.locator("#hv-drawer-share")).toBeVisible(); -// -// const shortURL = await page.locator("#helioviewer-share-url").inputValue(); -// await hv.Load(shortURL); -// -// const loadURL = shortURL.split("/load/")[0]; -// const loadID = shortURL.split("/load/")[1]; -// -// await expect(`${loadURL}/?loadState=${loadID}`).toBe(page.url()); -// }); +test("Shared URLs redirection should be done correctly", async ({ page }, info) => { + let hv = new Helioviewer(page); + + await hv.Load(); + await hv.CloseAllNotifications(); + + await page.locator("#share-button").click(); + + await page.waitForTimeout(1000); + + await expect(page.locator("#hv-drawer-share")).toBeVisible(); + + const shortURL = await page.locator("#helioviewer-share-url").inputValue(); + await hv.Load(shortURL); + + const loadURL = shortURL.split("/load/")[0]; + const loadID = shortURL.split("/load/")[1]; + + await expect(`${loadURL}/?loadState=${loadID}`).toBe(page.url()); +}); /** * This test plays through creating a short url and makes a test for short url should exactly resolved what is shared @@ -43,7 +43,7 @@ test("Shared URLs should produce pages, exactly like they shared", async ({ page browserName === "webkit", "We couldn't be able to trigger download event for webkit, skipping this test now" ); - let hv = new Helioviewer(page); + let hv = new Helioviewer(page, info); await hv.Load(); await hv.CloseAllNotifications(); @@ -77,20 +77,14 @@ test("Shared URLs should produce pages, exactly like they shared", async ({ page // turn off screenshare await page.locator("#share-button").click(); await page.mouse.move(100, 0); - const myScreenshot = (await page.screenshot()).toString("base64"); - const before_file = info.outputPath("before_share.png"); - await fs.promises.writeFile(before_file, Buffer.from(myScreenshot, "base64")); - await info.attach("before-share", { path: before_file }); + await hv.saveScreenshot("before-url-sharing-screenshot.png"); await hv.Load(shortURL); await hv.CloseAllNotifications(); const afterScreenshot = (await page.screenshot()).toString("base64"); - const after_file = info.outputPath("after_share.png"); - await fs.promises.writeFile(after_file, Buffer.from(afterScreenshot, "base64")); - await info.attach("after-share", { path: after_file }); + expect(Buffer.from(afterScreenshot, "base64")).toMatchSnapshot("before-url-sharing-screenshot.png",{ maxDiffPixelRatio: 0.01 } ); - await expect(afterScreenshot).toBe(myScreenshot); });