Skip to content

Commit

Permalink
fix last bit of tests and go full test again
Browse files Browse the repository at this point in the history
  • Loading branch information
mudhoney committed Jan 21, 2025
1 parent 4eaa9f8 commit affcecf
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 40 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand Down
68 changes: 31 additions & 37 deletions tests/desktop/normal/urlsharing.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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();
Expand Down Expand Up @@ -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);
});

0 comments on commit affcecf

Please sign in to comment.