Skip to content

Commit

Permalink
Viewer test
Browse files Browse the repository at this point in the history
  • Loading branch information
eyeseast committed Nov 15, 2023
1 parent 12c3f2e commit 37886d8
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
branches: [master]

jobs:
build:
test:
runs-on: ubuntu-latest

steps:
Expand All @@ -20,7 +20,7 @@ jobs:
with:
node-version: "18.x"
- run: npm ci
- run: npm run build --if-present
- run: npm run build
env:
NODE_ENV: production
- run: npm test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public/assets/
.env.test
.env.sentry-build-plugin
playwright-report
test-results

.vscode

Expand Down
12 changes: 9 additions & 3 deletions plugins/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@

export async function onSuccess({ utils }) {
console.log("Installing Playwright dependencies");
await utils.run("playwright", ["install"]);
await utils.run("playwright", ["install"]).catch((err) => {
utils.build.failBuild(err);
});

console.log("Running Playwright tests");
await utils.run("playwright", ["test"]);
result = await utils.run("playwright", ["test"]).catch((err) => {
utils.build.failBuild(err);
});

console.log("Done.");
utils.status.show({
title: "Playwright tests completed.",
});
}
36 changes: 36 additions & 0 deletions tests/anonymous/viewer/document.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// @ts-check

import { test, expect } from "@playwright/test";

test("test", async ({ page }) => {
// this is on staging; don't delete this document
const title = "FINALSeasonal_allergies_pollen_and_mold_2023__EN_";
const url =
"/documents/20000007-finalseasonal_allergies_pollen_and_mold_2023__en";
await page.goto(url);

await expect(page.locator(".sidebar").getByRole("heading")).toHaveText(title);

await page.getByRole("link", { name: "Original Document (PDF) »" }).click();

await expect(page.locator("h1")).toHaveText(title);

await page.getByRole("link", { name: "p. 1" }).click();

const currentUrl = new URL(page.url());

expect(currentUrl.hash).toEqual("#document/p1");

await page
.locator("div")
.filter({ hasText: /^DocumentPlain TextThumbnailSearch Results$/ })
.getByRole("combobox")
.selectOption("text");

// check that text view loaded
await expect(page.locator(".text").first()).toHaveText(/^MARCH 2023/);

// switch to thumbnail view, click the first image
await page.getByRole("combobox").selectOption("thumbnail");
await page.locator("img").first().click();
});

0 comments on commit 37886d8

Please sign in to comment.