@hmcts/media-viewer 4.2.23 → 4.2.25-tar-upgrade

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
package/README.md CHANGED
@@ -81,6 +81,15 @@ This command:
81
81
  - starts the local API on `PORT` or `1337`
82
82
  - starts Angular with `proxy.config.js`
83
83
 
84
+ When Angular is already running and only the local API needs restarting, use:
85
+
86
+ ```
87
+ yarn start:api:aat
88
+ ```
89
+
90
+ Do not use `yarn start:api` directly for an AAT-backed run. It deliberately has no
91
+ environment bootstrap and will otherwise target the non-AAT local proxy defaults.
92
+
84
93
  Open:
85
94
 
86
95
  ```
@@ -112,8 +121,144 @@ This opens `http://localhost:3000/#/media-viewer`, loads
112
121
  and first page. If `MV_SMOKE_PDF_DOCUMENT_ID` is blank, the smoke uses the demo app's
113
122
  default AAT PDF document id.
114
123
 
115
- ### 5. Create isolated AAT test documents
116
- For mutation-heavy functional tests, do not share one document across parallel workers.
124
+ ### 5. Run Playwright tests
125
+ Media Viewer is starting its Playwright migration with the same runner and
126
+ reporting shape used in MC and MO, scaled to the current smoke coverage. The
127
+ legacy Protractor and CodeceptJS functional packs still exist; new browser
128
+ coverage should be added under `playwright_tests/`.
129
+
130
+ Current Playwright lanes:
131
+
132
+ | Lane | Config/project | Command | Scope |
133
+ | --- | --- | --- | --- |
134
+ | Standalone smoke | `playwright.config.ts`, project `smoke` | `yarn test:playwright:smoke` or `yarn test:smoke` | Loads standalone PDF and image fixtures and verifies rendered-document readiness, PDF zoom and navigation, image rotation and deterministic PDF search. |
135
+ | Viewer support | `playwright.config.ts`, project `support` | `yarn test:playwright:support` | Proves the reusable PDF, image and unsupported-media fixtures, component objects and response diagnostics. |
136
+
137
+ The Playwright config runs tests fully in parallel with seven workers. Each test
138
+ gets its own browser context and page-scoped route mocks. Tests must not depend
139
+ on execution order or share mutable documents; mutation-heavy AAT journeys must
140
+ provision a document per test or reset it before reuse.
141
+
142
+ Install Chromium once before local runs when the browser cache is empty:
143
+
144
+ ```
145
+ yarn test:setup:playwright-install-chromium
146
+ ```
147
+
148
+ Run the smoke project against a running standalone demo app. Start the app in
149
+ one terminal:
150
+
151
+ ```
152
+ yarn start
153
+ ```
154
+
155
+ Then run the smoke in another terminal:
156
+
157
+ ```
158
+ yarn test:playwright:smoke
159
+ ```
160
+
161
+ Override the smoke document and case id with `MV_SMOKE_PDF_DOCUMENT_URL` and
162
+ `MV_SMOKE_CASE_ID`. `yarn test:smoke` now runs the Playwright smoke so Jenkins
163
+ CNP uses the same smoke entrypoint style as MC/MO. The previous CodeceptJS smoke
164
+ remains available as `yarn test:smoke:legacy` while migration work continues.
165
+
166
+ The lane wrapper commands write Playwright evidence under `functional-output/tests`:
167
+
168
+ | Lane | Odhín | JUnit | Trace, screenshot and video output |
169
+ | --- | --- | --- | --- |
170
+ | Viewer support | `functional-output/tests/playwright-support/odhin-report/xui-playwright-support.html` | `functional-output/tests/playwright-support/playwright-support-junit.xml` | `functional-output/tests/playwright-support/test-results` |
171
+ | Smoke | `functional-output/tests/playwright-smoke/odhin-report/xui-playwright-smoke.html` | `functional-output/tests/playwright-smoke/playwright-smoke-junit.xml` | `functional-output/tests/playwright-smoke/test-results` |
172
+
173
+ Those are the default lane-specific paths. CNP keeps preview and AAT viewer
174
+ support evidence separate under `functional-output/tests/playwright-support/preview`
175
+ and `functional-output/tests/playwright-support/aat`. Smoke evidence remains under
176
+ `functional-output/tests/playwright-smoke/preview` and
177
+ `functional-output/tests/playwright-smoke/aat`.
178
+
179
+ The raw aggregate `npx playwright test --config=playwright.config.ts` command
180
+ uses `functional-output/tests/playwright` unless the report paths are overridden.
181
+
182
+ Reporting behavior follows the MC/MO pattern:
183
+
184
+ - Odhín is produced through the patched `odhin-reports-playwright` reporter.
185
+ - Each successfully generated Odhín report uses a stable suite title and includes the application
186
+ version, branch, target environment, CI or local context, worker count, CPU
187
+ count and total RAM in its run information.
188
+ - CI logs Odhín finalisation progress using the same progress reporter as MC/MO.
189
+ - Odhín is the only standard human-readable report. JUnit is retained for
190
+ Jenkins ingestion. Screenshots and videos are kept on failure; traces are
191
+ captured on the first retry.
192
+ The standard Playwright HTML reporter is not supported.
193
+ - `PLAYWRIGHT_SKIP_INSTALL=true` skips browser installation when Jenkins or a
194
+ local setup step has already installed Chromium.
195
+ - Jenkins CNP and nightly pipelines publish the Odhín HTML reports, publish
196
+ JUnit XML, and archive the full Playwright output folders.
197
+ - The classic Jenkins build page exposes viewer-support reports as `PREVIEW
198
+ Playwright Viewer Support Test`, `AAT Playwright Viewer Support Test`, or
199
+ `Nightly Playwright Viewer Support Test`. Blue Ocean does not reliably show
200
+ HTML Publisher links.
201
+
202
+ The Jenkins `YarnBuilder` performs its immutable dependency install before the
203
+ first setup task. The pipeline then installs Puppeteer Chrome once for legacy
204
+ tests and Chromium into the workspace-local `PLAYWRIGHT_BROWSERS_PATH`, and sets
205
+ `PLAYWRIGHT_SKIP_INSTALL=true` so Playwright lanes do not reinstall it.
206
+
207
+ Useful overrides:
208
+ - `PLAYWRIGHT_BASE_URL` or `TEST_URL`: target application URL, default `http://localhost:3000/`
209
+ - `PLAYWRIGHT_REPORTERS`: comma-separated reporter list, for example `list,junit,odhin`
210
+ - `PLAYWRIGHT_DEFAULT_REPORTER`: terminal reporter when `PLAYWRIGHT_REPORTERS` is not set, default `list` locally and `dot` in CI
211
+ - `PLAYWRIGHT_JUNIT_OUTPUT`: JUnit XML path
212
+ - `PLAYWRIGHT_REPORT_FOLDER`: Odhín report folder
213
+ - `PLAYWRIGHT_REPORT_INDEX_FILENAME`: Odhín report file name
214
+ - `PLAYWRIGHT_REPORT_TITLE`: Odhín report title
215
+ - `PLAYWRIGHT_REPORT_PROJECT`: Odhín project label
216
+ - `PLAYWRIGHT_REPORT_RELEASE`: Odhín release label, default `<version> | branch=<branch>`
217
+ - `PLAYWRIGHT_REPORT_BRANCH`: branch override used by the default release label
218
+ - `PLAYWRIGHT_REPORT_TEST_ENVIRONMENT` or `PW_ODHIN_ENV`: complete Odhín test-environment label override
219
+ - `TEST_TYPE`: target-environment label, otherwise inferred from the test URL
220
+ - `PLAYWRIGHT_TEST_OUTPUT_DIR`: traces, screenshots and videos folder
221
+ - `FUNCTIONAL_TESTS_WORKERS`: worker-count override from `1` to `64`, default `7`
222
+ - `PLAYWRIGHT_SKIP_INSTALL=true`: skip the automatic Chromium install in Playwright scripts
223
+
224
+ Use this local proof set before pushing Playwright documentation or pipeline
225
+ changes:
226
+
227
+ ```
228
+ yarn install --immutable
229
+ yarn test:setup:playwright-install-chromium
230
+ PLAYWRIGHT_SKIP_INSTALL=true yarn test:playwright:smoke:list
231
+ PLAYWRIGHT_SKIP_INSTALL=true npx playwright test --config=playwright.config.ts
232
+ ```
233
+
234
+ For a smoke behavior proof, start the app in one terminal:
235
+
236
+ ```
237
+ yarn start
238
+ ```
239
+
240
+ Then run the Playwright smoke in another terminal:
241
+
242
+ ```
243
+ PLAYWRIGHT_SKIP_INSTALL=true yarn test:smoke
244
+ ```
245
+
246
+ Migration boundaries:
247
+
248
+ - Put new native Playwright specs under `playwright_tests/`.
249
+ - Keep screen interactions and reusable locators in page objects under
250
+ `playwright_tests/pages/`; keep assertions visible in specs.
251
+ - Keep legacy Protractor and CodeceptJS coverage until replacement coverage and
252
+ Jenkins evidence are agreed.
253
+ - Add stable report output paths for every new Playwright lane so Jenkins can
254
+ publish Odhín and JUnit and archive failure diagnostics without bespoke stage
255
+ logic.
256
+ - Prefer Playwright browser-level assertions for viewer readiness; do not treat
257
+ an error page, blank page, wrong route or service-down page as a valid ready
258
+ signal.
259
+
260
+ ### 6. Create isolated AAT test documents
261
+ For mutation-heavy functional tests, do not share one document across parallel tests.
117
262
  Create fresh AAT DM Store documents through the local API proxy while `yarn start:aat`
118
263
  is running:
119
264
 
@@ -130,7 +275,7 @@ This writes:
130
275
  The upload path mirrors em-showcase: multipart `files`, `classification=PUBLIC`,
131
276
  and civil/probate metadata are posted to `/documents`.
132
277
 
133
- ### 6. Run isolated local functional tests
278
+ ### 7. Run isolated local functional tests
134
279
  With `yarn start:aat` still running, execute the functional groups with separate
135
280
  documents and separate reports:
136
281