diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index a5032d2..cb69618 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -1,9 +1,9 @@ name: Playwright Tests on: - push: + #push: # branches: [main] pull_request: - # branches: [main] + branches: [main] jobs: test: timeout-minutes: 60 diff --git a/tests/tests/links.spec.ts b/tests/tests/links.spec.ts deleted file mode 100644 index 099757f..0000000 --- a/tests/tests/links.spec.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { test, expect } from "@playwright/test"; - -// Source: https://www.checklyhq.com/blog/how-to-detect-broken-links-with-playwright/ -test("front page has no broken links", async ({ page }) => { - test.slow(); - await page.goto("/fi"); - - // Gather all links from page - const links = page.locator("a"); - const allLinks = await links.all(); - const allTargets = await Promise.all( - allLinks.map((link) => link.getAttribute("href")), - ); - - // Filter links - const validTargets = allTargets.reduce((links, link) => { - expect.soft(link).toBeTruthy(); - - if (link && !link?.startsWith("mailto:") && !link?.startsWith("#")) - links.add(new URL(link, page.url()).href); - return links; - }, new Set()); - - // Test links - for (const url of validTargets) { - try { - //console.log(url); - const res = await page.request.get(url); - expect.soft(res.ok(), `${url} is broken`).toBeTruthy(); - } catch { - expect.soft(null, `${url} is broken`).toBeTruthy(); - } - } -});