diff --git a/.github/workflows/links-checker.yml b/.github/workflows/links-checker.yml index 020ce9a5b6..4084b7ced3 100644 --- a/.github/workflows/links-checker.yml +++ b/.github/workflows/links-checker.yml @@ -5,23 +5,22 @@ on: push: branches: - main - - "3.5" jobs: docs: name: maas.io/docs links - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest steps: - - uses: actions/checkout@main - - name: Get branch name - uses: nelonoel/branch-name@v1.0.1 - - name: Run Cypress docs tests - uses: cypress-io/github-action@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: - browser: chrome - config: baseUrl=http://maas.io/docs - spec: "cypress/e2e/docs-links/**/*.spec.ts" - install-command: yarn install + node-version-file: '.nvmrc' + - name: Install dependencies + run: yarn + - name: Install Playwright Browsers + run: npx playwright install --with-deps + - name: Run docs links checks + run: yarn test-docs-links - name: Create issue on failure if: failure() uses: JasonEtco/create-an-issue@v2 diff --git a/cypress/e2e/docs-links/docs-links.spec.ts b/cypress/e2e/docs-links/docs-links.spec.ts deleted file mode 100644 index 18f25fde5d..0000000000 --- a/cypress/e2e/docs-links/docs-links.spec.ts +++ /dev/null @@ -1,46 +0,0 @@ -import docsUrls from "../../../src/app/base/docsUrls"; - -const urls = Object.values(docsUrls); - -beforeEach(() => { - cy.setCookie("_cookies_accepted", "all"); -}); - -context("loads the page", () => { - urls.forEach((url) => { - it(url, () => { - // test that the page loads, can be redirected - cy.visit(url); - }); - }); -}); - -context("is a direct link", () => { - urls.forEach((url) => { - it(url, () => { - cy.visit(url); - - // print warning if the URL is redirected - cy.request({ - url, - followRedirect: false, - }).then((resp) => { - if (resp.redirectedToUrl) { - expect( - resp.redirectedToUrl, - `URL NEEDS TO BE UPDATED - ----------------------------- - - FROM: - ${url} - - TO: - ${resp.redirectedToUrl} - - error` - ).to.eq(url); - } - }); - }); - }); -}); diff --git a/package.json b/package.json index 67949e7d1f..2c03135f5d 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,7 @@ "test:debug": "vitest --inspect-brk test --runInBand --no-cache --testTimeout=100000000", "test": "TZ=UTC yarn vitest", "test-coverage": "yarn test --coverage", + "test-docs-links": "yarn playwright test docs-links.spec.ts", "unlink-components": "yarn unlink react && yarn unlink \"@canonical/react-components\"", "wait-on-ui": "wait-on http-get://0.0.0.0:8400/MAAS/r", "storybook": "storybook dev -p 6006", diff --git a/src/app/base/docsUrls.ts b/src/app/base/docsUrls.ts index 4f0db5f7be..81c05da048 100644 --- a/src/app/base/docsUrls.ts +++ b/src/app/base/docsUrls.ts @@ -1,30 +1,34 @@ const docsUrls = { - aboutNativeTLS: "https://maas.io/docs/how-to-implement-tls#enabling-tls-2", - addMachines: "https://maas.io/docs/how-to-manage-machines", + aboutNativeTLS: + "https://maas.io/docs/how-to-implement-tls#p-9022-enabling-tls", + addMachines: "https://maas.io/docs/how-to-provision-machines", addNodesViaChassis: - "https://maas.io/docs/how-to-manage-machines#add-machines-via-chassis-ui-2", + "https://maas.io/docs/how-to-provision-machines#p-9078-add-machines", autoRenewTLSCert: - "https://maas.io/docs/how-to-implement-tls#auto-renew-certs-8", + "https://maas.io/docs/how-to-implement-tls#p-9022-auto-renew-certs", cloudInit: - "https://maas.io/docs/how-to-customise-machines#pre-seed-cloud-init-2", + "https://maas.io/docs/how-to-customise-machines#p-9014-cloud-init-pre-seeding", configurationJourney: - "https://maas.io/docs/how-to-install-maas#configure-maas-with-the-ui-10", + "https://maas.io/docs/how-to-install-maas#p-9034-maas-ui-setup", customisingDeployedMachines: "https://maas.io/docs/how-to-customise-machines", - dhcp: "https://maas.io/docs/how-to-enable-dhcp", - ipmi: "https://maas.io/docs/reference-power-drivers#ipmi-6", - ipRanges: "https://maas.io/docs/how-to-enable-dhcp#create-an-ip-range-ui-2", - kvmIntroduction: "https://maas.io/docs/about-virtual-machines", + dhcp: "https://maas.io/docs/about-dhcp-in-maas", + ipmi: "https://maas.io/docs/reference-power-drivers#p-17434-ipmi", + ipRanges: + "https://maas.io/docs/how-to-customise-dhcp#p-9038-edit-delete-or-extend-ip-range", + kvmIntroduction: "https://maas.io/docs/how-to-use-lxd-vms", networkDiscovery: - "https://maas.io/docs/about-maas-networks#network-discovery-5", - rackController: "https://maas.io/docs/how-to-configure-controllers", - sshKeys: "https://maas.io/docs/how-to-manage-user-access#add-ssh-keys-5", - tagsAutomatic: "https://maas.io/docs/how-to-manage-tags#automatic-tags-17", + "https://maas.io/docs/how-to-customise-maas-networks#p-9070-manage-network-discovery", + rackController: + "https://maas.io/docs/about-controllers#p-13954-rack-controllers", + sshKeys: "https://maas.io/docs/how-to-manage-user-access#p-9090-add-ssh-keys", + tagsAutomatic: + "https://maas.io/docs/about-device-labels#p-13973-automatic-tags", tagsKernelOptions: - "https://maas.io/docs/how-to-manage-tags#update-tag-kernel-options-22", - tagsXpathExpressions: - "https://maas.io/docs/how-to-manage-tags#automatic-tags-17", + "https://maas.io/docs/how-to-provision-machines#p-9078-set-boot-options", + tagsXpathExpressions: "https://www.w3schools.com/xml/XPath_intro.asp", vaultIntegration: "https://maas.io/docs/how-to-integrate-vault", - windowsImages: "https://maas.io/docs/how-to-build-a-windows-image", + windowsImages: + "https://maas.io/docs/how-to-build-maas-images#p-17423-building-windows-images-with-packer", } as const; export default docsUrls; diff --git a/tests/docs-links.spec.ts b/tests/docs-links.spec.ts new file mode 100644 index 0000000000..6ae3f07b08 --- /dev/null +++ b/tests/docs-links.spec.ts @@ -0,0 +1,24 @@ +import { test, expect } from "@playwright/test"; +import docsUrls from "../src/app/base/docsUrls"; + +const urls = Object.values(docsUrls); + +test.describe("loads the page", () => { + urls.forEach((url) => { + test(`${url}`, async () => { + const docsPage = fetch(url); + const resCode = await docsPage.then((res) => res.status); + expect(resCode).toBe(200); + }); + }); +}); + +test.describe("is a direct link", () => { + urls.forEach((url) => { + test(`${url}`, async () => { + const docsPage = fetch(url, { redirect: "manual" }); + const resCode = await docsPage.then((res) => res.status); + expect(resCode).toBe(200); + }); + }); +});