From 2f8fc3ca3b23fff3aa99e66f228ca972cba30791 Mon Sep 17 00:00:00 2001 From: Lam Nguyen Date: Tue, 1 Jul 2025 16:17:48 -0700 Subject: [PATCH 1/2] Tests: Added new UI smoke tests --- .github/workflows/playwright.yml | 18 +++---- .github/workflows/update-screenshot.yml | 58 ---------------------- layouts/404.html | 4 +- layouts/_default/baseof.html | 6 +-- layouts/_default/list.html | 2 +- layouts/_default/single.html | 2 +- layouts/partials/api.html | 2 +- layouts/partials/footer-v2.html | 4 +- layouts/partials/header.html | 14 +++--- layouts/partials/sidebar-list.html | 9 ++-- layouts/partials/sidebar-v2.html | 4 +- layouts/redoc/single.html | 2 +- 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, 185 insertions(+), 119 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 4fdced6..a50e27c 100644 --- a/layouts/404.html +++ b/layouts/404.html @@ -1,7 +1,7 @@ {{ define "main"}} -
-
+
+

HTTP 404 - Page not found

diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 4046f38..28b399d 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -43,17 +43,17 @@ {{ end }}
-