From d69b9976b31ac5dcd2850ff45e7e7250de154028 Mon Sep 17 00:00:00 2001 From: Lam Nguyen Date: Tue, 1 Jul 2025 16:17:48 -0700 Subject: [PATCH] Tests: Added new UI smoke tests --- .github/workflows/playwright.yml | 18 ++- .github/workflows/update-screenshot.yml | 58 --------- layouts/404.html | 23 ++-- layouts/_default/baseof.html | 36 +++--- layouts/_default/list.html | 4 +- layouts/_default/single.html | 5 +- layouts/partials/api.html | 2 +- layouts/partials/footer-v2.html | 4 +- layouts/partials/header.html | 158 ++++++++++++++++++------ layouts/partials/sidebar-list.html | 9 +- layouts/partials/sidebar-v2.html | 14 ++- layouts/redoc/single.html | 10 +- tests/playwright.config.js | 8 -- tests/src/footer.spec.js | 16 +++ tests/src/header.spec.js | 46 +++++++ tests/src/product-landing.spec.js | 13 ++ tests/src/sidebar.spec.js | 66 ++++++++++ tests/src/util.js | 12 ++ tests/src/visual-regression.spec.js | 18 --- 19 files changed, 332 insertions(+), 188 deletions(-) delete mode 100644 .github/workflows/update-screenshot.yml create mode 100644 tests/src/footer.spec.js create mode 100644 tests/src/header.spec.js create mode 100644 tests/src/product-landing.spec.js create mode 100644 tests/src/sidebar.spec.js create mode 100644 tests/src/util.js delete mode 100644 tests/src/visual-regression.spec.js diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 1ab7830..e6d09fe 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -1,4 +1,4 @@ -name: Testing for visual regression on old theme +name: Running Playwright test on UI # Run the workflow when code is pushed or when a pull request is created on: @@ -25,19 +25,16 @@ jobs: - name: Install dependencies and playwright browsers run: cd tests && npm ci && npx playwright install --with-deps - name: Run Playwright tests - id: test-visual + id: test-ui run: | make tests | tee output.log - if grep -q -e "Error: A snapshot doesn't exist at" -e "Screenshot comparison failed" output.log; then - echo "Playwright tests failed due to a snapshot issue." - exit 1 - elif grep -q "failed" output.log; then - echo "Playwright tests failed due to a non-snapshot issue." + if grep -q "failed" output.log; then + echo "Playwright tests failed. Please view the Playwright report to see full error." exit 1 fi - uses: actions/upload-artifact@v4 id: artifact-upload - if: ${{ !cancelled() && failure() && steps.test-visual.conclusion == 'failure' }} + if: ${{ !cancelled() && failure() && steps.test-ui.conclusion == 'failure' }} with: name: playwright-report path: tests/playwright-report/ @@ -47,10 +44,9 @@ jobs: if: ${{ failure() }} with: script: | - const body = `### Playwright visual snapshot differences were detected. + const body = `### Playwright differences were detected. - View the [Playwright report](${{ steps.artifact-upload.outputs.artifact-url }}) - **To approve the snapshot changes and update the snapshots, please comment:** /approve-snapshots`; + View the [Playwright report](${{ steps.artifact-upload.outputs.artifact-url }})`; await github.rest.issues.createComment({ issue_number: context.issue.number, diff --git a/.github/workflows/update-screenshot.yml b/.github/workflows/update-screenshot.yml deleted file mode 100644 index 30f7f39..0000000 --- a/.github/workflows/update-screenshot.yml +++ /dev/null @@ -1,58 +0,0 @@ -name: Update screenshot on comment -on: - issue_comment: - types: [created] -jobs: - update-screenshots: - name: Update Screenshot - if: github.event.issue.pull_request && contains(github.event.comment.body, '/approve-snapshots') - runs-on: ubuntu-latest - permissions: - contents: write - pull-requests: write - steps: - - uses: xt0rted/pull-request-comment-branch@v3 - id: comment-branch - - uses: actions/checkout@v4 - if: success() - with: - ref: ${{ steps.comment-branch.outputs.head_ref }} - - name: Comment on PR with Playwright updates - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 - with: - script: | - const body = `### Updating snapshots. Click [here](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) to see the status.`; - - await github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: body, - }); - - name: Setup Hugo - uses: peaceiris/actions-hugo@75d2e84710de30f6ff7268e08f310b60ef14033f # v3.0.0 - with: - hugo-version: "0.147.8" - extended: true - - name: Install dependencies and Playwright browsers - run: cd tests && npm ci && npx playwright install --with-deps - - name: Run Playwright update snapshots - id: test-visual - run: make tests-update-screenshots - - uses: actions/upload-artifact@v4 - id: artifact-upload - with: - name: screenshots - path: tests/src/__screenshots__ - - name: Comment on PR with success - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 - with: - script: | - const body = `### Please download the artifacts [here](${{ steps.artifact-upload.outputs.artifact-url }}) and commit your updated screenshots.`; - - await github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: body, - }); \ No newline at end of file diff --git a/layouts/404.html b/layouts/404.html index b038511..905d4ad 100644 --- a/layouts/404.html +++ b/layouts/404.html @@ -1,19 +1,14 @@ {{ define "main"}} -
-

-

Page not found

- -
-
-
-
-
- -
-

Uh oh! We couldn't find the page you were looking for.

-

Return to the NGINX Docs Home page.

-
+
+
+

+ HTTP 404 - Page not found +

+
+

Uh oh! We couldn't find the page/path you were looking for.

+ Return to the {{ .Site.Title }} homepage. +
diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 54e5c04..e89991f 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -166,30 +166,26 @@ {{ if or ( not hugo.IsServer ) ( not ( in .Site.Params.buildtype "package" ) ) }} {{ partial "universal-tag.html" . }} {{ end }} - -
- {{ block "header" . }}{{end}} -
- -
- - -
+ +
+ + +
+ {{ block "header" . }}{{end}} +
+ {{ block "main" . }}{{ end }}
-
- {{ block "footer" . }} - {{ partial "footer.html" . }} - {{ end }} -
+
+ {{ block "footer-v2" . }} + {{ partial "footer-v2.html" . }} + {{ end }} +
+
{{ block "footer-v2" . }} diff --git a/layouts/_default/list.html b/layouts/_default/list.html index 3130840..6fdde4b 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -8,9 +8,7 @@
-{{/* mf list page */}} - -
+