@hmcts/media-viewer 4.2.46 → 4.2.48-5543-rc2

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.
package/README.md CHANGED
@@ -1,618 +1,292 @@
1
- # @hmcts/media-viewer
2
- [![Node.js Package](https://github.com/hmcts/rpx-xui-media-viewer/actions/workflows/npmpublish.yml/badge.svg)](https://github.com/hmcts/rpx-xui-media-viewer/actions/workflows/npmpublish.yml)
1
+ MEDIA VIEWER
2
+ ============
3
3
 
4
- This is an angular library that can be used to view and annotate PDF documents and images
4
+ Overview
5
+ --------
5
6
 
6
- ## Running the demo app locally
7
- For the static local demo:
7
+ @hmcts/media-viewer is an Angular library for viewing and annotating PDF
8
+ documents, images and other supported media. It includes viewer controls for
9
+ navigation, search, zoom, rotation, bookmarks, comments, annotations and
10
+ redactions, together with a standalone demo application.
8
11
 
9
- ```
10
- yarn package
11
- yarn start:ng
12
- ```
12
+ The repository also contains a local Express proxy API, AAT configuration,
13
+ Playwright smoke and functional suites, accessibility checks, cross-browser
14
+ checks and packaged-library build scripts.
13
15
 
14
- For the AAT-connected standalone app, use the runbook below.
16
+ Repository status note
15
17
 
16
- ## Running locally against AAT
17
- The standalone demo can run on your machine while its bundled Express API proxies Media Viewer calls to AAT. This is the local replacement path for the old `em-showcase` media-viewer checks.
18
+ This working tree currently has tracked files marked as deleted. This rewrite
19
+ was created from the committed README and package metadata without restoring or
20
+ changing those files. Restore the working tree through the normal Git process
21
+ before using the commands below.
22
+
23
+
24
+ Prerequisites
25
+ -------------
26
+
27
+ - Node.js 24.x, as required by the repository package configuration.
28
+ - Yarn 4.5.0.
29
+ - Docker when local Redis or other support services are required.
30
+ - Azure CLI with access to the rpx-aat Key Vault for AAT-backed local runs.
31
+ - Network access to AAT internal services and the HMCTS VPN where required.
32
+ - Chromium for smoke and functional tests; Firefox and WebKit for the
33
+ cross-browser smoke suite.
34
+
35
+ Install dependencies from the repository root:
36
+
37
+ corepack enable
38
+ yarn install --immutable
39
+
40
+ On Windows, Git Bash or WSL is recommended for the Bash scripts.
41
+
42
+
43
+ Run the static demo locally
44
+ ---------------------------
45
+
46
+ Build and package the library, then start Angular with its proxy:
47
+
48
+ yarn package
49
+ yarn start:ng
50
+
51
+ The Angular application is available at:
52
+
53
+ http://localhost:3000/
54
+
55
+ The Media Viewer route is:
56
+
57
+ http://localhost:3000/#/media-viewer
58
+
59
+ The retired compatibility route is:
60
+
61
+ http://localhost:3000/#/dm-store
62
+
63
+ The hash routes must be opened in a browser; they are not server-side paths.
64
+
65
+
66
+ Run locally against AAT
67
+ -----------------------
68
+
69
+ The standalone demo can run locally while its bundled Express API proxies
70
+ Media Viewer requests to AAT.
18
71
 
19
72
  Local URLs:
20
- - Angular app: `http://localhost:3000/`
21
- - Media Viewer route: `http://localhost:3000/#/media-viewer`
22
- - Retired DM Store compatibility route: `http://localhost:3000/#/dm-store`
23
- - Local API health: `http://localhost:1337/health`
24
73
 
25
- The local browser talks to Angular on port `3000`. Angular uses `proxy.config.js` to send `/documents`, `/em-anno`, `/api`, `/icp`, `/hearing-recordings`, and `/doc-assembly` to the local API on port `1337`. The local API then connects to AAT services.
74
+ Angular application: http://localhost:3000/
75
+ Local API health: http://localhost:1337/health
76
+
77
+ Angular proxies document, annotation, API, ICP, hearing-recording and document
78
+ assembly requests to the local API on port 1337. The local API then connects
79
+ to configured AAT services.
80
+
81
+ Prerequisites
82
+
83
+ - Install Azure CLI.
84
+ - Run az login with an identity that can read the rpx-aat Key Vault.
85
+ - Install the repository dependencies.
86
+ - Connect to the AAT network or HMCTS VPN as required.
87
+
88
+ Check access without printing a secret:
89
+
90
+ az account show
91
+ az keyvault secret show --vault-name rpx-aat --name show-oauth2-token --query id -o tsv
92
+
93
+ Generate the ignored local .env file:
94
+
95
+ yarn env:populate:aat
96
+
97
+ The population script obtains the approved IDAM and S2S values from Key Vault.
98
+ Do not commit or share the generated .env file.
99
+
100
+ Validate the resolved AAT targets:
101
+
102
+ yarn check:aat-config
103
+
104
+ Start the local API and Angular application:
105
+
106
+ yarn start:aat
107
+
108
+ This command loads .env, enables AAT mode, builds the library assets, compiles
109
+ the local API and starts both local processes.
110
+
111
+ When Angular is already running and only the API needs restarting:
112
+
113
+ yarn start:api:aat
114
+
115
+ Do not use yarn start:api directly for an AAT-backed run unless the local
116
+ configuration has been deliberately prepared; it does not perform the AAT
117
+ environment bootstrap.
118
+
119
+ Smoke-test the running local instance:
120
+
121
+ yarn smoke:local:aat
122
+
123
+ Run the local AAT browser proof:
124
+
125
+ yarn test:local:aat
126
+
127
+ The local proof checks the standalone viewer and proxy wiring. It does not
128
+ create CCD cases or DM Store documents.
129
+
130
+
131
+ Build and package the library
132
+ -----------------------------
133
+
134
+ Build the library, synchronise dependencies and build the demo:
135
+
136
+ yarn build
137
+
138
+ Create the package archive:
139
+
140
+ yarn package
141
+
142
+ Create a local package installation for inspection:
143
+
144
+ yarn package:local
145
+
146
+ The published package is @hmcts/media-viewer. Review the generated dist/
147
+ contents before publishing.
148
+
149
+
150
+ Unit tests and linting
151
+ ----------------------
152
+
153
+ Run Angular unit tests:
154
+
155
+ yarn test
156
+
157
+ Run lint checks:
158
+
159
+ yarn lint
160
+
161
+ Run the dependency audit when required:
162
+
163
+ yarn cve:check
164
+
165
+ Run Sonar analysis when its environment is available:
166
+
167
+ yarn sonar-scan
168
+
169
+
170
+ Playwright tests
171
+ ----------------
172
+
173
+ Install browser dependencies:
174
+
175
+ yarn test:setup:playwright-install-chromium
176
+ yarn test:setup:playwright-install-browsers
177
+
178
+ Current test lanes include:
179
+
180
+ - Smoke: confirms the standalone viewer is ready and can render a PDF.
181
+ - Functional: fixture-backed viewer contracts for documents, annotations,
182
+ navigation, search, redactions, comments and related controls.
183
+ - Support: reusable viewer fixtures, page objects and diagnostics.
184
+ - Accessibility: Axe, WAVE-like and screen-reader-like checks.
185
+ - Cross-browser smoke: Firefox and WebKit readiness checks.
186
+ - External service contracts: opt-in live AAT diagnostics, not a normal pull
187
+ request gate.
188
+
189
+ Run the main lanes:
190
+
191
+ yarn test:playwright:smoke
192
+ yarn test:playwright:functional
193
+ yarn test:playwright:support
194
+ yarn test:a11y
195
+ yarn test:crossbrowser
196
+
197
+ List selected scenarios:
198
+
199
+ yarn test:playwright:smoke:list
200
+ yarn test:playwright:functional:list
201
+
202
+ Run the optional external-service diagnostics only for a deliberate environment
203
+ investigation:
204
+
205
+ yarn test:playwright:external-service-contracts
206
+
207
+ The Playwright wrappers write Odhín, JUnit, screenshots, traces and Perfetto
208
+ evidence below functional-output/tests/. Treat reports as potentially sensitive
209
+ and do not commit them.
210
+
211
+ Set PLAYWRIGHT_SKIP_INSTALL=true when the required browser has already been
212
+ installed. Set FUNCTIONAL_TESTS_WORKERS to an intentional value between 1 and
213
+ 64 when changing local test capacity.
214
+
215
+
216
+ Local service overrides
217
+ -----------------------
218
+
219
+ Common ignored .env overrides include:
220
+
221
+ PORT
222
+ DOCASSEMBLY_URL
223
+ DM_STORE_APP_URL
224
+ HRS_API_URL
225
+ ANNOTATION_API_URL
226
+ NPA_URL
227
+ ICP_API_URL
228
+ IDAM_URL
229
+ REDIRECT_URL
230
+ S2S_URL
231
+
232
+ Only override a service when deliberately testing that integration. The
233
+ redirect URL must match an approved IDAM client registration.
234
+
235
+
236
+ Troubleshooting
237
+ ---------------
238
+
239
+ The viewer is blank or toolbar assets are missing
240
+
241
+ - Restart with yarn start:aat so that the library and assets are rebuilt.
242
+ - Check the browser console and local API logs.
243
+ - Confirm that the selected document is reachable through the configured proxy.
26
244
 
27
- ### Prerequisites
28
- - Azure CLI installed.
29
- - Logged in to the HMCTS Azure tenant with access to `rpx-aat` Key Vault.
30
- - Yarn dependencies installed for this repo.
31
- - Network access to AAT internal service URLs.
245
+ Port 1337 is in use
32
246
 
33
- Check Azure access:
247
+ - Set PORT in the ignored .env file and restart the local API.
248
+ - Keep the Angular proxy target aligned with the chosen port.
34
249
 
35
- ```
36
- az account show
37
- az keyvault secret show --vault-name rpx-aat --name show-oauth2-token --query id -o tsv
38
- ```
250
+ AAT secrets are missing
39
251
 
40
- ### 1. Generate the local `.env`
41
- Generate `.env` from `.env.example` and `rpx-aat` Key Vault:
252
+ - Run yarn env:populate:aat again.
253
+ - Confirm Azure access to rpx-aat without printing secret values.
42
254
 
43
- ```
44
- yarn env:populate:aat
45
- ```
255
+ External service tests fail
46
256
 
47
- The generated `.env` is ignored by git and must not be committed.
257
+ - Confirm VPN and AAT network access.
258
+ - Confirm the relevant service URLs and credentials.
259
+ - Run the standalone smoke or fixture-backed functional suite first.
48
260
 
49
- The script populates:
50
- - `IDAM_SECRET` from `show-oauth2-token`
51
- - `IDAM_PASSWORD` from `password`
52
- - `S2S_KEY` from `microservicekey-em-gw`
261
+ ICP integration fails
53
262
 
54
- To write to a different file:
263
+ - Check ICP_API_URL and the local ICP health endpoint.
264
+ - Keep the other services on AAT unless the test specifically overrides them.
265
+ - Do not send real secrets to logs or make authenticated requests while a known
266
+ secret-logging defect remains.
55
267
 
56
- ```
57
- bash ./scripts/populate-env-from-keyvault.sh aat /tmp/media-viewer.env .env.example
58
- ```
59
268
 
60
- ### 2. Validate the AAT config
61
- Run this before starting the app if you only want to prove the endpoint wiring:
269
+ UK English and technical terminology
270
+ -------------------------------------
62
271
 
63
- ```
64
- yarn check:aat-config
65
- ```
272
+ Use UK English in documentation, test descriptions and user-facing content:
66
273
 
67
- This compiles the local API and checks the resolved AAT targets for document assembly, DM Store, HRS, annotations, NPA, ICP, IdAM, and S2S.
274
+ organisation / organisations
275
+ authorise / authorisation
276
+ behaviour
277
+ centre
278
+ colour
279
+ customise / customisation
280
+ licence (noun) / license (verb)
281
+ analyse / analysed
282
+ catalogue
283
+ prioritise
68
284
 
69
- ### 3. Start Media Viewer against AAT
70
- Start both the local API and Angular app:
285
+ Keep package names, Angular selectors, API routes, environment variables,
286
+ service names and test tags unchanged where they are technical contracts.
71
287
 
72
- ```
73
- yarn start:aat
74
- ```
75
288
 
76
- This command:
77
- - loads `.env`
78
- - sets `MV_USE_AAT=true`
79
- - builds the Media Viewer library assets needed by the demo
80
- - compiles the local API into `dist/api`
81
- - starts the local API on `PORT` or `1337`
82
- - starts Angular with `proxy.config.js`
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
-
93
- Open:
289
+ Licence
290
+ -------
94
291
 
95
- ```
96
- http://localhost:3000/#/media-viewer
97
- ```
98
-
99
- ### 4. Smoke test a running local instance
100
- In another terminal, run:
101
-
102
- ```
103
- yarn smoke:local:aat
104
- ```
105
-
106
- The smoke check verifies:
107
- - `http://localhost:3000/`
108
- - `http://localhost:1337/health` returns `UP`
109
-
110
- Use a browser for route-level checks because `#/media-viewer` and `#/dm-store` are Angular hash routes, not server paths.
111
-
112
- For browser-level proof that the standalone viewer is using AAT-backed services, keep
113
- `yarn start:aat` running, then run:
114
-
115
- ```
116
- yarn test:local:aat
117
- ```
118
-
119
- This executes the Functional Playwright contracts against the local standalone Media
120
- Viewer and AAT-backed proxy configuration while keeping the browser at
121
- `http://localhost:3000/`. It does not create CCD cases or DM Store documents; use
122
- the opt-in external-service contracts for those live service probes. The lightweight
123
- route and health check remains available as `yarn smoke:local:aat`.
124
-
125
- ### Test a local `em-icp-api` change
126
-
127
- The standalone app reaches ICP through its local API. Keep the other services on AAT,
128
- but override only `ICP_API_URL` in the ignored `.env` file:
129
-
130
- ```
131
- ICP_API_URL=http://localhost:8080
132
- ```
133
-
134
- Create an isolated worktree for the ICP branch under test. The example below uses
135
- PR #1546 and leaves the normal ICP checkout untouched:
136
-
137
- ```
138
- cd ../em-icp-api
139
- git fetch origin pull/1546/head
140
- git worktree add --detach /private/tmp/em-icp-pr1546-validation FETCH_HEAD
141
- cd /private/tmp/em-icp-pr1546-validation
142
- yarn install --immutable
143
- docker compose -f docker-compose.yml up -d redis
144
- ```
145
-
146
- Its `config/local-dev.yaml` is ignored by `em-icp-api`; create it and configure the
147
- AAT IdAM URL, local Redis and AAT Web PubSub client URL:
148
-
149
- ```yaml
150
- idam:
151
- url: https://idam-api.aat.platform.hmcts.net
152
- redis:
153
- host: localhost
154
- port: 6379
155
- useTLS: "false"
156
- icp:
157
- wsUrl: wss://em-icp-webpubsub.aat.platform.hmcts.net/client/hubs/localhub
158
- ```
159
-
160
- Check that the active Azure identity can read the approved secret without printing its
161
- value:
162
-
163
- ```
164
- az keyvault secret show \
165
- --vault-name em-icp-aat \
166
- --name em-icp-web-pubsub-primary-connection-string \
167
- --query id -o tsv
168
- ```
169
-
170
- Immediately before starting ICP, load the connection string into `NODE_CONFIG` only for
171
- that process. This command does not echo or write the secret to disk:
172
-
173
- ```
174
- local_webpubsub_secret="$(az keyvault secret show \
175
- --vault-name em-icp-aat \
176
- --name em-icp-web-pubsub-primary-connection-string \
177
- --query value -o tsv)"
178
- export NODE_CONFIG="$(LOCAL_WEBPUBSUB_SECRET="$local_webpubsub_secret" node -e 'console.log(JSON.stringify({secrets: {"em-icp": {"em-icp-web-pubsub-primary-connection-string": process.env.LOCAL_WEBPUBSUB_SECRET}}}))')"
179
- unset local_webpubsub_secret
180
- ```
181
-
182
- For Web PubSub callback testing, make the following local-only edits in the ICP
183
- checkout before starting it. The API currently hard-codes the deployed `Hub`/`hub`
184
- names in three places, whereas the tunnel uses `localhub`; do not commit these edits
185
- with the change being tested:
186
-
187
- ```
188
- app.ts: new WebPubSubServiceClient(primaryConnectionstring, "localhub")
189
- app.ts: new WebPubSubEventHandler("localhub", ...)
190
- api/routes/sessions.ts: new WebPubSubServiceClient(primaryConnectionstring, "localhub")
191
- ```
192
-
193
- Then start ICP and check its health:
194
-
195
- ```
196
- yarn start:local
197
- curl -fsS http://localhost:8080/health
198
- yarn test:unit
199
- ```
200
-
201
- Then tunnel the AAT Web PubSub hub to the local ICP process in another terminal. Use
202
- the AAT Web PubSub endpoint and keep the upstream HTTP URL local:
203
-
204
- ```
205
- npx --yes --package @azure/web-pubsub-tunnel-tool awps-tunnel run \
206
- --hub localhub \
207
- --endpoint https://em-icp-webpubsub-aat.webpubsub.azure.com \
208
- --upstream http://localhost:8080 \
209
- -s 1c4f0704-a29e-403d-b719-b90c34ef14c9 \
210
- -g em-icp-aat
211
- ```
212
-
213
- The tunnel needs an authenticated Azure identity that can read the AAT hub settings.
214
- If it reports `403` after resolving the subscription and resource group, obtain the
215
- required AAT Web PubSub access policy or RBAC permission; that is an Azure access
216
- blocker, not a local ICP or Media Viewer failure.
217
-
218
- Then start Media Viewer from its repository. Populate the ignored AAT `.env` if it
219
- does not already contain the approved AAT settings, then set the ICP override:
220
-
221
- ```
222
- cd ../rpx-xui-media-viewer
223
- yarn env:populate:aat
224
- # In .env set:
225
- # ICP_API_URL=http://localhost:8080
226
- yarn start:aat
227
- ```
228
-
229
- Open `http://localhost:3000/#/media-viewer`, then run the browser regression lane:
230
-
231
- ```
232
- PLAYWRIGHT_REPORTERS=list yarn test:local:aat
233
- ```
234
-
235
- This setup tests local ICP code with AAT authentication and Web PubSub; it does not
236
- recreate the complete retired `em-showcase` Docker stack. The validation run recorded
237
- 19 passing ICP unit tests and 71 passing Media Viewer tests.
238
-
239
- Current ICP source warning: `api/routes/sessions.ts` logs the primary Web PubSub
240
- connection string. Do not make an authenticated `/icp/sessions/...` request with a
241
- real secret until that log statement is removed; this is a source-security blocker,
242
- not a Media Viewer setup failure.
243
-
244
- Stop the local processes with `Ctrl+C`, then clean up Redis from the ICP worktree with
245
- `docker compose -f docker-compose.yml down`.
246
-
247
- ### 5. Run Playwright tests
248
- Media Viewer uses the Playwright runner and reporting shape used in MC and MO.
249
- The CodeceptJS and Protractor/Cucumber runners are retired. New browser coverage
250
- belongs under `playwright_tests/`.
251
-
252
- Current Playwright lanes:
253
-
254
- | Lane | Config/project | Command | Scope |
255
- | --- | --- | --- | --- |
256
- | Standalone smoke | `playwright.config.ts`, project `smoke` | `yarn test:playwright:smoke` or `yarn test:smoke` | One readiness contract: loads a standalone PDF and proves the rendered viewer, first page and canvas are usable. |
257
- | Migrated functional | `playwright.config.ts`, project `functional` | `yarn test:playwright:functional` | 84 default fixture-backed browser contracts across 13 feature files, with 86 discoverable when the two EXUI-5124 image-annotation contracts are explicitly included. Multimedia coverage is Chromium-only; external AAT/CCD contracts are separate diagnostics and are not migration assurance. See [`playwright_tests/functional/README.md`](playwright_tests/functional/README.md). |
258
- | External service diagnostics | `playwright.config.ts`, opt-in project `external-service-contracts` | `yarn test:playwright:external-service-contracts` | Optional live AAT CCD/DM Store/annotation probes for a deliberate environment investigation. The default command executes 6 non-defect service contracts; four CCD browser-route contracts tagged against [EXUI-5122](https://tools.hmcts.net/jira/browse/EXUI-5122) and [EXUI-5123](https://tools.hmcts.net/jira/browse/EXUI-5123) remain discoverable but are excluded by default. Use `PLAYWRIGHT_INCLUDE_KNOWN_DEFECTS=true` to discover and execute all 10. They are never part of normal PR assurance. |
259
- | Cross-browser smoke | `playwright.config.ts`, projects `smoke-firefox` and `smoke-webkit` | `yarn test:crossbrowser` | Runs the same readiness contract in Firefox and WebKit and publishes separate JUnit/Odhín output under `functional-output/tests/playwright-crossbrowser`. |
260
- | 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. |
261
-
262
- The current migration slice is deliberately separated from smoke: smoke proves
263
- the application is ready, functional proves user-facing viewer behaviour and
264
- its deterministic Viewer/service request-response contracts, and support proves
265
- the reusable automation contracts. External service diagnostics
266
- are opt-in and never gate a standalone Media Viewer change. Every Playwright Odhín report includes a capability
267
- inventory that states whether each contract is selected by default or is a
268
- discoverable, ticketed product-defect contract.
269
-
270
- The Playwright config runs tests fully in parallel with seven workers by
271
- default. Set `FUNCTIONAL_TESTS_WORKERS` to a positive integer (up to 64) for an
272
- intentional capacity run. Each test gets its own browser context and page-scoped
273
- route mocks. Tests must not depend on execution order or share mutable
274
- documents; mutation-heavy AAT journeys must provision a document per test or
275
- reset it before reuse.
276
-
277
- Install the Playwright browsers once before local runs when the browser cache is empty:
278
-
279
- ```
280
- yarn test:setup:playwright-install-browsers
281
- ```
282
-
283
- Run the smoke project against a running standalone demo app. Start the app in
284
- one terminal:
285
-
286
- ```
287
- yarn start
288
- ```
289
-
290
- Then run the smoke in another terminal:
291
-
292
- ```
293
- yarn test:playwright:smoke
294
- # unified Playwright accessibility pack (Axe, WAVE-like, screen-reader-like)
295
- yarn test:a11y
296
- # Firefox and WebKit smoke gate
297
- yarn test:crossbrowser
298
- ```
299
-
300
- Override the smoke document and case id with `MV_SMOKE_PDF_DOCUMENT_URL` and
301
- `MV_SMOKE_CASE_ID`. `yarn test:smoke` and `yarn test:local:aat` run the
302
- Playwright smoke, so the standalone and local-AAT PDF loading journeys no longer
303
- use only the Playwright projects.
304
-
305
- The lane wrapper commands write Playwright evidence under `functional-output/tests`:
306
-
307
- | Lane | Odhín | JUnit | Trace and screenshot output |
308
- | --- | --- | --- | --- |
309
- | 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` |
310
- | 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` |
311
- | Migrated functional | `functional-output/tests/playwright-functional/odhin-report/xui-playwright-functional.html` | `functional-output/tests/playwright-functional/playwright-functional-junit.xml` | `functional-output/tests/playwright-functional/test-results` |
312
- | Accessibility | `functional-output/tests/playwright-accessibility/odhin-report/xui-playwright-accessibility.html` | `functional-output/tests/playwright-accessibility/playwright-accessibility-junit.xml` | `functional-output/tests/playwright-accessibility/test-results` |
313
- | Cross-browser smoke | `functional-output/tests/playwright-crossbrowser/odhin-report/xui-playwright-crossbrowser.html` | `functional-output/tests/playwright-crossbrowser/playwright-crossbrowser-junit.xml` | `functional-output/tests/playwright-crossbrowser/test-results` |
314
-
315
- Those are the default lane-specific paths. CNP keeps preview and AAT viewer
316
- support evidence separate under `functional-output/tests/playwright-support/preview`
317
- and `functional-output/tests/playwright-support/aat`. Smoke evidence remains under
318
- `functional-output/tests/playwright-smoke/preview` and
319
- `functional-output/tests/playwright-smoke/aat`.
320
-
321
- The raw aggregate `npx playwright test --config=playwright.config.ts` command
322
- uses `functional-output/tests/playwright` unless the report paths are overridden.
323
-
324
- Reporting behavior follows the MC/MO pattern:
325
-
326
- - Odhín is produced through the patched `odhin-reports-playwright` reporter.
327
- - Each successfully generated Odhín report uses a stable suite title and includes the application
328
- version, branch, target environment, CI or local context, worker count, CPU
329
- count and total RAM in its run information.
330
- - CI logs Odhín finalisation progress using the same progress reporter as MC/MO.
331
- - Odhín is the only standard human-readable report. JUnit is retained for
332
- Jenkins ingestion. Screenshots and traces are kept for failed and timed-out
333
- attempts; videos are disabled.
334
- The standard Playwright HTML reporter is not supported.
335
- - `PLAYWRIGHT_SKIP_INSTALL=true` skips browser installation when Jenkins or a
336
- local setup step has already installed Chromium.
337
- - Jenkins CNP and nightly pipelines publish the Odhín HTML reports, publish
338
- JUnit XML, and archive the full Playwright output folders.
339
- - The classic Jenkins build page exposes viewer-support reports as `PREVIEW
340
- Playwright Viewer Support Test`, `AAT Playwright Viewer Support Test`, or
341
- `Nightly Playwright Viewer Support Test`. Blue Ocean does not reliably show
342
- HTML Publisher links.
343
-
344
- The Jenkins `YarnBuilder` performs its immutable dependency install before the
345
- first setup task. The pipeline installs Puppeteer Chrome for Karma and the
346
- functional preflight, then installs Chromium into the workspace-local
347
- `PLAYWRIGHT_BROWSERS_PATH` and sets `PLAYWRIGHT_SKIP_INSTALL=true` so Playwright
348
- lanes do not reinstall it.
349
-
350
- Useful overrides:
351
- - `PLAYWRIGHT_BASE_URL` or `TEST_URL`: target application URL, default `http://localhost:3000/`
352
- - `PLAYWRIGHT_REPORTERS`: comma-separated reporter list, for example `list,junit,odhin`
353
- - `PLAYWRIGHT_DEFAULT_REPORTER`: terminal reporter when `PLAYWRIGHT_REPORTERS` is not set, default `list` locally and `dot` in CI
354
- - `PLAYWRIGHT_JUNIT_OUTPUT`: JUnit XML path
355
- - `PLAYWRIGHT_REPORT_FOLDER`: Odhín report folder
356
- - `PLAYWRIGHT_REPORT_INDEX_FILENAME`: Odhín report file name
357
- - `PLAYWRIGHT_REPORT_TITLE`: Odhín report title
358
- - `PLAYWRIGHT_REPORT_PROJECT`: Odhín project label
359
- - `PLAYWRIGHT_REPORT_RELEASE`: Odhín release label, default `<version> | branch=<branch>`
360
- - `PLAYWRIGHT_REPORT_BRANCH`: branch override used by the default release label
361
- - `PLAYWRIGHT_REPORT_TEST_ENVIRONMENT` or `PW_ODHIN_ENV`: complete Odhín test-environment label override
362
- - `TEST_TYPE`: target-environment label, otherwise inferred from the test URL
363
- - `PLAYWRIGHT_TEST_OUTPUT_DIR`: traces and screenshots folder
364
- - `FUNCTIONAL_TESTS_WORKERS`: worker-count override from `1` to `64`, default `7`
365
- - `PLAYWRIGHT_SKIP_INSTALL=true`: skip the automatic Chromium install in Playwright scripts
366
-
367
- Use this local proof set before pushing Playwright documentation or pipeline
368
- changes:
369
-
370
- ```
371
- yarn install --immutable
372
- yarn test:setup:playwright-install-chromium
373
- PLAYWRIGHT_SKIP_INSTALL=true yarn test:playwright:smoke:list
374
- PLAYWRIGHT_SKIP_INSTALL=true npx playwright test --config=playwright.config.ts
375
- ```
376
-
377
- For a smoke behavior proof, start the app in one terminal:
378
-
379
- ```
380
- yarn start
381
- ```
382
-
383
- Then run the Playwright smoke in another terminal:
384
-
385
- ```
386
- PLAYWRIGHT_SKIP_INSTALL=true yarn test:smoke
387
- ```
388
-
389
- Migration boundaries:
390
-
391
- - Put new native Playwright specs under `playwright_tests/`.
392
- - Keep screen interactions and reusable locators in page objects under
393
- `playwright_tests/pages/`; keep assertions visible in specs.
394
- - Add stable report output paths for every new Playwright lane so Jenkins can
395
- publish Odhín and JUnit and archive failure diagnostics without bespoke stage
396
- logic.
397
- - Prefer Playwright browser-level assertions for viewer readiness; do not treat
398
- an error page, blank page, wrong route or service-down page as a valid ready
399
- signal.
400
-
401
- ### 6. Run local Playwright lanes
402
- `yarn test:local:aat` is the standalone smoke lane; it does not create a CCD
403
- case or DM Store document. Run the fixture-backed Functional lane locally with:
404
-
405
- ```
406
- yarn test:playwright:functional
407
- ```
408
-
409
- The default local suite is standalone: it needs neither AAT credentials nor
410
- shared CCD, DM Store or annotation-service state. External service diagnostics
411
- are deliberately opt-in and must not be used as normal migration assurance. The
412
- external command runs 6 contracts by default; `PLAYWRIGHT_INCLUDE_KNOWN_DEFECTS=true`
413
- runs the full 10-contract inventory, including the four ticketed CCD browser defects.
414
- Known product-defect contracts are not skipped: they remain discoverable and
415
- run only when explicitly selected:
416
-
417
- ```
418
- PLAYWRIGHT_INCLUDE_KNOWN_DEFECTS=true yarn test:playwright:functional -- --grep @defect-EXUI-5124
419
- ```
420
-
421
- ### Useful overrides
422
- Most developers should use the defaults from `.env.example`. Override only when you are deliberately testing a different endpoint or registered client setting.
423
-
424
- Common overrides:
425
- - `PORT`: local API port, default `1337`
426
- - `DOCASSEMBLY_URL`
427
- - `DM_STORE_APP_URL`
428
- - `HRS_API_URL`
429
- - `ANNOTATION_API_URL`
430
- - `NPA_URL`
431
- - `ICP_API_URL`
432
- - `IDAM_URL`
433
- - `REDIRECT_URL`
434
- - `S2S_URL`
435
-
436
- The default `REDIRECT_URL` uses the registered AAT `xui-media-viewer` callback. Do not change it to a localhost callback unless the IdAM client registration supports that callback.
437
-
438
- ### Troubleshooting
439
- - Missing `IDAM_SECRET`, `IDAM_PASSWORD`, or `S2S_KEY`: run `yarn env:populate:aat` again and confirm Azure access to `rpx-aat`.
440
- - IdAM token errors: confirm `IDAM_URL=https://idam-api.aat.platform.hmcts.net`.
441
- - Blank viewer or missing toolbar assets: restart with `yarn start:aat`; it runs `build:lib`, `copy:lib-js-dependencies`, and `copy:lib-assets` before serving.
442
- - Port conflict on `1337`: set `PORT` in `.env` and restart.
443
- - Service connectivity failures: check VPN/network access to AAT internal service URLs.
444
-
445
- ## Replacing em-showcase media-viewer use
446
- This standalone app replaces `em-showcase` for Media Viewer validation against AAT. It keeps compatible local navigation for `/`, `#/media-viewer`, and `#/dm-store`.
447
-
448
- The `#/dm-store` route is intentionally a retired compatibility route. It points users back to the Media Viewer document ID flow instead of carrying the old DM Store showcase UI.
449
-
450
- Supported Media Viewer checks include document loading, annotations, redactions, redaction search, ICP, multimedia, hearing-recording, and document-assembly proxy paths.
451
-
452
- ## Integrating into your own Angular application
453
- add @hmcts/media-viewer as a dependency in package.json
454
-
455
- ```
456
- npm install --save @hmcts/media-viewer
457
- ```
458
-
459
- import MediaViewerModule and declare it in your NgModule imports together with NGRX store if you don't have it already .
460
-
461
- ```
462
- import { MediaViewerModule } from 'media-viewer';
463
-
464
- @NgModule({
465
- imports: [
466
- ...,
467
- MediaViewerModule,
468
- StoreModule.forRoot({}, {}),
469
- EffectsModule.forRoot([]),
470
- ]
471
- })
472
- ```
473
-
474
- import assets to your angular.json
475
-
476
- ```
477
- {
478
- "glob": "**/*",
479
- "input": "node_modules/@hmcts/media-viewer/assets",
480
- "output": "/assets"
481
- }
482
- ```
483
-
484
- component entry point:
485
-
486
- ```
487
- <mv-media-viewer [url]="'assets/example.pdf'"
488
- [downloadFileName]="'example.pdf'"
489
- [showToolbar]="true"
490
- [contentType]="'pdf'">
491
- </mv-media-viewer>
492
- ```
493
- ### Media Viewer Styles
494
- Add these styles to your component.scss if you need them.
495
- If you're writing your own toolbar styles then do not import those
496
-
497
- ```
498
- // Load GOV.UK Frontend
499
- @use "govuk-frontend/govuk/all" as *;
500
- // Load Media Viewer Styles
501
- @use "media-viewer/src/assets/all"; // use this to load all the styles
502
- ```
503
- Alternatively, it is possible to import file by file as required from ```assets/sass``` directory
504
-
505
- eg. ```media-viewer/assets/sass/toolbar/main```
506
-
507
- ## Customisations
508
- ### Toolbar
509
- The toolbar may be toggled off by setting `showToolbar` to false. The toolbar itself is available as a module that can be included into the DOM at a different location if necessary.
510
-
511
- ### Toolbar buttons
512
- Toolbar buttons can be toggled on or off using the 'toolbarButtonOverrides' input.
513
- Each button can toggled on or off as follows:
514
- ```
515
- toolbarButtons = { showRotate: true, showDownload: false }
516
-
517
- <mv-media-viewer ...
518
- [toolbarButtonOverrides]="toolbarButtons">
519
- </mv-media-viewer>
520
- ```
521
- The full list of buttons is as follows:
522
- ```
523
- showPrint
524
- showDownload
525
- showNavigation
526
- showZoom
527
- showRotate
528
- showHighlightButton
529
- showDrawButton
530
- showSearchBar
531
- showSidebar
532
- ```
533
-
534
- ### Media Viewer Height and Width
535
- You can set height and width of the media viewer otherwise it will be set to default settings of 100%.
536
-
537
- ```
538
- <mv-media-viewer ...
539
- [height]="'500px'"
540
- [width]="'500px'">
541
- </mv-media-viewer>
542
- ```
543
-
544
- ### Annotation API
545
- To override the default Annotation API path (or URL for cross domain calls) use "annotationApiUrl" parameter
546
- ```
547
- <mv-media-viewer annotationApiUrl=""http://my-gateway.com/my-context-path"" ... >
548
- </mv-media-viewer>
549
- ```
550
-
551
- ## Backend setup
552
- - the media-viewer expects calls to the backend to be proxied by the consuming application. This includes the following APIs:
553
- - '/documents', endpoint to be proxied to the 'document-store'
554
- - '/em-anno', endpoint to be proxied to the 'annotations-api', if annotations are turned on
555
- - '/api/markups', endpoint to be proxied to the 'em-native-pdf-annotator-app', if redaction is turned on
556
- - '/api/redaction', endpoint to be proxied to the 'em-native-pdf-annotator-app', if redaction is turned on
557
-
558
- ### Proxying backend Api calls
559
- In order to use annotations/redactions on the media viewer, you need to proxy backend calls.
560
-
561
- Example:
562
- ```
563
- import * as proxy from "http-proxy-middleware";
564
- ```
565
- Annotation Config:
566
- ```
567
- const annotation = {
568
- endpoints: ["/em-anno"],
569
- target: "Enter URL",
570
- pathRewrite: {
571
- "^/em-anno": "/api"
572
- }
573
- }
574
- ```
575
- How to use the proxy:
576
- ```
577
- this.app.use(proxy(annotation.endpoints, { target: annotation.target }));
578
- ```
579
-
580
- ## Viewer Exceptions
581
- The Media Viewer will return load status and provide exceptions if thrown for the host application to consume.
582
- It is up to the consuming application whether or not to notify the user of those exceptions, as the Media-Viewer will not
583
- ```
584
- <mv-media-viewer [url]="'assets/example.pdf'"
585
- [downloadFileName]="'example.pdf'"
586
- [showToolbar]="true"
587
- [contentType]="'pdf'"
588
- [enableAnnotations]="true"
589
- [enableRedactions]="true"
590
- (mediaLoadStatus)="onMediaLoadStatus($event)"
591
- (viewerException)="onMediaLoadException($event)">
592
- </mv-media-viewer>
593
- ```
594
-
595
- When exceptions are thrown by the different Media Viewers, the exception is encapsulated in an object called `ViewerException` and passed up the chain to be used by consuming service.
596
-
597
- The structure of the `ViewerException` exception class can be seen below:
598
-
599
- exceptionType: error.name,
600
- detail: {
601
- httpResponseCode: error.status,
602
- message: error.message
603
- }
604
-
605
- The list of exceptions thrown by the Media Viewer are as follows:
606
- - UnknownErrorException
607
- - MissingPdfException
608
- - InvalidPDFException
609
- - UnexpectedResponseException
610
- - HttpErrorResponse
611
- - PasswordException
612
-
613
- ## Legacy browser tests
614
-
615
- The CodeceptJS and Protractor/Cucumber runners were retired as part of the
616
- Playwright migration. Migration closure was recorded in PR #82; the active
617
- browser test source is now Playwright. Use the Playwright commands above for
618
- supported browser tests. No recurring legacy-parity test is retained.
292
+ This project is licensed under the MIT Licence. See LICENCE for the full text.