88 description : " Frontend URL of the application"
99 required : true
1010 type : string
11- external-api-base-url :
11+ external-api-base-url :
1212 description : " Base URL to the external service API"
1313 required : true
1414 type : string
1919 type : string
2020 timeout-minutes :
2121 description : ' Timeout minutes'
22- default : 12
22+ default : 20
2323 required : false
2424 type : number
2525 workflow_call :
4040 required : false
4141 default : dev
4242 type : string
43- external-api-base-url :
43+ external-api-base-url :
4444 description : " Base URL to the external service API"
4545 required : true
4646 type : string
4747 timeout-minutes :
4848 description : ' Timeout minutes'
49- default : 12
49+ default : 20
5050 required : false
5151 type : number
5252
5959 working-directory : frontend
6060 runs-on : ubuntu-24.04
6161 timeout-minutes : ${{ fromJson(inputs.timeout-minutes) }}
62- strategy :
63- fail-fast : false # Don't fail fast - we need all browsers to generate screenshots
64- max-parallel : 1 # Run all browsers in parallel for faster screenshot generation
65- matrix :
66- project : [chrome-visual, firefox-visual, safari-visual, edge-visual]
6762 steps :
6863 - uses : actions/checkout@v6
6964 name : Checkout
@@ -77,67 +72,89 @@ jobs:
7772 npm ci
7873 npx playwright install --with-deps
7974
80- - name : Run Visual Regression Tests
81- id : playwright-visual-tests
75+ - name : Create blob reports directory
76+ run : mkdir -p all-blob-reports
77+
78+ - name : Run Visual Tests - All Browsers
79+ id : visual-tests
8280 env :
8381 E2E_BASE_URL : ${{ inputs.frontend-url }}
8482 E2E_USERNAME : ${{ secrets.E2E_USERNAME }}
8583 E2E_PASSWORD : ${{ secrets.E2E_PASSWORD }}
8684 EXTERNAL_CONSUMER_DELETE_REPORTS_API_KEY : ${{ secrets.EXTERNAL_CONSUMER_DELETE_REPORTS_API_KEY }}
8785 EXTERNAL_API_BASE_URL : ${{ inputs.external-api-base-url }}
8886 run : |
89- npx playwright test --project="${{ matrix.project }}"
87+ for browser in chrome-visual firefox-visual safari-visual edge-visual; do
88+ echo "::group::Running tests for $browser"
89+ npx playwright test --project="$browser" || true
90+ if [ -d "blob-report" ] && [ -n "$(ls -A blob-report/*.zip 2>/dev/null)" ]; then
91+ cp blob-report/*.zip all-blob-reports/
92+ rm -rf blob-report
93+ fi
94+ echo "::endgroup::"
95+ done
9096 continue-on-error : true
9197
98+ - name : Merge blob reports and generate outputs
99+ if : always()
100+ env :
101+ PLAYWRIGHT_JSON_OUTPUT_NAME : test-results.json
102+ PLAYWRIGHT_HTML_OPEN : never
103+ run : |
104+ echo "Merging blob reports..."
105+ npx playwright merge-reports --reporter json ./all-blob-reports
106+ npx playwright merge-reports --reporter html ./all-blob-reports
107+
108+ # Rename HTML report directory
109+ if [ -d "playwright-report" ]; then
110+ mv playwright-report playwright-report-diffs
111+ fi
112+
92113 - name : Check for visual regression issues
93- if : ${{ always() }}
114+ if : always()
94115 id : check-visual-regression
95116 run : |
96- if [ -d "./test-results" ]; then
97- mv ./test-results ./test-results-diffs
98- fi
99- if [ -d "./playwright-report" ]; then
100- mv ./playwright-report ./playwright-report-diffs
101- fi
102117 differences=false
103- if [ -f "./ test-results.json" ]; then
104- unexpected=$(jq '.stats.unexpected' ./ test-results.json)
118+ if [ -f "test-results.json" ]; then
119+ unexpected=$(jq '.stats.unexpected' test-results.json)
105120 if [ "$unexpected" -gt 0 ]; then
106121 differences=true
122+ echo "::warning::Found $unexpected unexpected visual regression(s)"
107123 fi
108124 fi
109125 echo "has_visual_issues=$differences" >> $GITHUB_OUTPUT
110126
111127 - name : Generate updated screenshots
112- if : ${{ always() && steps.check-visual-regression.outputs.has_visual_issues == 'true' }}
113- id : generate-updated-screenshots
128+ if : always() && steps.check-visual-regression.outputs.has_visual_issues == 'true'
114129 env :
115130 E2E_BASE_URL : ${{ inputs.frontend-url }}
116131 E2E_USERNAME : ${{ secrets.E2E_USERNAME }}
117132 E2E_PASSWORD : ${{ secrets.E2E_PASSWORD }}
118133 EXTERNAL_CONSUMER_DELETE_REPORTS_API_KEY : ${{ secrets.EXTERNAL_CONSUMER_DELETE_REPORTS_API_KEY }}
119134 EXTERNAL_API_BASE_URL : ${{ inputs.external-api-base-url }}
120135 run : |
121- echo "::notice::Generating updated screenshots for comparison..."
122- npx playwright test --update-snapshots --project="${{ matrix.project }}"
136+ echo "::notice::Generating updated screenshots for all browsers..."
137+ npx playwright test --update-snapshots --project="chrome-visual"
138+ npx playwright test --update-snapshots --project="firefox-visual"
139+ npx playwright test --update-snapshots --project="safari-visual"
140+ npx playwright test --update-snapshots --project="edge-visual"
123141
124142 - uses : actions/upload-artifact@v6
125143 if : always()
126- name : Upload Playwright visual test artifacts with screenshots
144+ name : Upload Playwright visual test artifacts
127145 with :
128- name : playwright-visual-report-${{ matrix.project }}
146+ name : playwright-visual-report-all-browsers
129147 path : |
130148 ./frontend/playwright-report-diffs
131- ./frontend/test-results-diffs
132149 ./frontend/test-results.json
133- ./frontend/e2e/snapshots.ci/**/*${{ matrix.project }}*
150+ ./frontend/e2e/snapshots.ci/**/*
134151 retention-days : 7
135152
136153 - name : Review and Commit Approved Screenshots
137- if : ${{ steps.check-visual-regression.outputs.has_visual_issues == 'true' }}
154+ if : steps.check-visual-regression.outputs.has_visual_issues == 'true'
138155 run : |
139156 echo "::error::Visual regression differences were detected."
140- echo "::notice::Download the artifacts for each browser (this one is 'playwright-visual-report-${{ matrix.project }}') ."
141- echo "::notice::Review the new screenshots in test-results -diffs."
142- echo "::notice::Manually copy and commit the screenshots you approve from 'e2e/snapshots.ci/' to the repository."
157+ echo "::notice::Download the artifact 'playwright-visual-report-all-browsers' to review all browser results ."
158+ echo "::notice::Review the differences in 'playwright-report -diffs' HTML report ."
159+ echo "::notice::Review the new screenshots and manually copy/commit approved ones from 'e2e/snapshots.ci/' to the repository."
143160 exit 1
0 commit comments