fix: fix issue with portfolio click going to undefined #134
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Playwright Visual Checks | |
| on: | |
| pull_request: | |
| branches: [main] | |
| push: | |
| branches: [main] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: playwright-visual-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| visual-check: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| outputs: | |
| snapshots_changed: ${{ steps.detect_changes.outputs.changed }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 24 | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| - name: Install dependencies | |
| run: bun install --frozen-lockfile | |
| - name: Install Playwright browsers | |
| run: bunx playwright install --with-deps | |
| - name: Run Playwright tests | |
| run: bunx playwright test --update-snapshots | |
| env: | |
| CI: true | |
| - name: Detect snapshot updates | |
| id: detect_changes | |
| shell: bash | |
| run: | | |
| if [[ -n "$(git status --porcelain)" ]]; then | |
| echo "changed=true" >> "$GITHUB_OUTPUT" | |
| echo "Playwright update-snapshots modified files." | |
| else | |
| echo "changed=false" >> "$GITHUB_OUTPUT" | |
| echo "No file changes after update-snapshots." | |
| fi | |
| - name: Create snapshot patch | |
| if: steps.detect_changes.outputs.changed == 'true' | |
| shell: bash | |
| run: | | |
| git add -A | |
| git diff --cached --binary > playwright-snapshots.patch | |
| - name: Upload snapshot patch | |
| if: steps.detect_changes.outputs.changed == 'true' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: playwright-snapshot-patch | |
| path: playwright-snapshots.patch | |
| retention-days: 14 | |
| - name: Upload Playwright report | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: playwright-report | |
| path: playwright-report | |
| retention-days: 14 | |
| - name: Upload Playwright test results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: playwright-test-results | |
| path: test-results | |
| retention-days: 14 | |
| require-approval-if-snapshots-changed: | |
| needs: visual-check | |
| if: needs.visual-check.outputs.snapshots_changed == 'true' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| environment: | |
| name: playwright-snapshot-approval | |
| steps: | |
| - name: Resolve target branch | |
| id: resolve_branch | |
| shell: bash | |
| run: | | |
| branch_name="${GITHUB_HEAD_REF:-${GITHUB_REF_NAME}}" | |
| if [[ -z "$branch_name" ]]; then | |
| echo "Unable to determine target branch." | |
| exit 1 | |
| fi | |
| if [[ "$branch_name" == "main" ]]; then | |
| echo "Snapshot updates cannot be auto-committed to main." | |
| exit 1 | |
| fi | |
| echo "branch_name=$branch_name" >> "$GITHUB_OUTPUT" | |
| echo "Snapshot updates approved for branch: $branch_name" | |
| - name: Checkout target branch | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ steps.resolve_branch.outputs.branch_name }} | |
| - name: Download snapshot patch | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: playwright-snapshot-patch | |
| path: ${{ runner.temp }}/playwright-snapshot-patch | |
| - name: Apply snapshot patch | |
| shell: bash | |
| run: git apply --index --reject --whitespace=nowarn "$RUNNER_TEMP/playwright-snapshot-patch/playwright-snapshots.patch" | |
| - name: Commit snapshot updates | |
| id: commit_snapshot_updates | |
| shell: bash | |
| run: | | |
| if [[ -z "$(git status --porcelain)" ]]; then | |
| echo "No snapshot changes to commit after approval." | |
| echo "committed=false" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git add -A | |
| git commit -m "test: update Playwright snapshots" | |
| git push origin "HEAD:${{ steps.resolve_branch.outputs.branch_name }}" | |
| echo "committed=true" >> "$GITHUB_OUTPUT" | |
| echo "commit_sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" |