Compare commits

..
Author SHA1 Message Date
ohif-bot 8f6947b75d chore(version): Update package versions to 3.13.0-beta.102 [skip ci] 2026-06-24 14:39:34 +00:00
diattamo 79cb2356e1 chore(testing): Playwright tests for contour segmentation create, update, delete interactions (#6091) 2026-06-24 10:36:16 -04:00
ohif-bot 20632f97cf chore(version): Update package versions to 3.13.0-beta.101 [skip ci] 2026-06-23 06:25:18 +00:00
Joe Boccanfuso c205965f87 chore(testing): Flock lock for playwright tests; Pin node version for OHIF; add more workers (#6099)
* update Cypress apt deps for Ubuntu Noble (drop libgconf-2-4, libasound2→libasound2t64)
2026-06-23 02:21:18 -04:00
ohif-bot 75488298cd chore(version): Update package versions to 3.13.0-beta.100 [skip ci] 2026-06-23 05:56:18 +00:00
diattamo b24f039735 test(contour): Add the ContourSegmentToggleLock.spec.ts test file to test contour locking (#6072) 2026-06-23 01:52:35 -04:00
ohif-bot 1f6670c602 chore(version): Update package versions to 3.13.0-beta.99 [skip ci] 2026-06-20 15:33:27 +00:00
diattamo b9cde4981a feat(testing): OHIF Test Agent Skills (#5993) 2026-06-20 11:30:27 -04:00
ohif-bot fc994fe525 chore(version): Update package versions to 3.13.0-beta.98 [skip ci] 2026-06-20 15:17:28 +00:00
diattamoandBill Wallace ada2da34f0 test(contour): contour interactions delete segment (#6069)
---------

Co-authored-by: Bill Wallace <wayfarer3130@gmail.com>
2026-06-20 11:14:07 -04:00
diattamo 5955151ba1 test(contour): contour color change coverage (#6042) 2026-06-20 11:11:57 -04:00
ohif-bot 419366bd25 chore(version): Update package versions to 3.13.0-beta.97 [skip ci] 2026-06-19 16:37:27 +00:00
Bill Wallace b59eb30b0f fix: Release deploy of docs (#6095)
A netlify fix that needs to be verified on master
2026-06-19 12:34:07 -04:00
ohif-bot 57d03fc722 chore(version): Update package versions to 3.13.0-beta.96 [skip ci] 2026-06-19 15:36:51 +00:00
Bill Wallace 17e12d53e5 fix: pnpm related dependency bugs - nothing funcitonal (#6094)
Testing this needs a release and there are no functional changes, only pnpm migration issues, so merging early for test.

* fix: pnpm related dependency bugs - nothing funcitonal

* Undo peer dependency due to non-pnpm integration issues
2026-06-19 11:33:45 -04:00
ohif-bot ffd7884ed1 chore(version): Update package versions to 3.13.0-beta.95 [skip ci] 2026-06-18 15:25:00 +00:00
Joe Boccanfuso 0dd6571505 chore(testing): Setup new self-hosted test runner (#6067) 2026-06-18 11:21:41 -04:00
ohif-bot 6e2d53f280 chore(version): Update package versions to 3.13.0-beta.94 [skip ci] 2026-06-17 14:54:34 +00:00
Joe Boccanfuso 6acbbc0271 fix(security): Update dependencies to fix security vulnerabilities. (#6085) 2026-06-17 10:51:03 -04:00
ohif-bot 780d172201 chore(version): Update package versions to 3.13.0-beta.93 [skip ci] 2026-06-16 16:02:34 +00:00
Bill WallaceandClaude Opus 4.8 256b8347e7 fix(docs): remove stray tool-call tags breaking the MDX build (#6081)
This is a fix to pnpm deployment which needs testing as the final part of origin/master release
No functional changes

* fix(docs): remove stray tool-call tags breaking the MDX build

platform/docs/docs/migration-guide/3p12-to-3p13/build-tooling.md ended with
two orphan closing tags (leftover tool-call serialization artifacts):

  </content>
  </invoke>

Docusaurus compiles Markdown as MDX (JSX-aware), so the orphan closing tag
failed the docs build:

  MDX compilation failed ... Unexpected closing slash in tag, expected an
  open tag first (build-tooling.md line 402)

This was the remaining blocker for build-and-deploy-docs once the
--no-frozen-lockfile change let the install step succeed. A scan of the docs
tree found no other such artifacts. Verified locally: docusaurus build now
generates static files with no MDX errors.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* Update lockfile and avoid freshness check on every command

* fix(release): keep workspace:* in the repo, concretize only at publish

The release flow rewrote internal @ohif/* dependency specifiers to the concrete
version and committed them, so pnpm-lock.yaml (which records workspace links)
drifted from the manifests on every version bump. The resulting
ERR_PNPM_OUTDATED_LOCKFILE broke every frozen install: Netlify (viewer-dev),
the docs deploy, pnpm's pre-run deps check, and post-merge installs.

Keep workspace:* everywhere in the committed repo and move the concrete-version
substitution to publish time only:

- publish-version.mjs: bump each package's own `version` field only; stop
  rewriting @ohif/* dependency/peerDependency specifiers.
- publish-package.mjs: publish with `pnpm publish --no-git-checks` instead of
  `npm publish`. pnpm rewrites workspace:* to the exact version in the published
  tarball; npm would publish the literal "workspace:*", which npm/yarn consumers
  cannot resolve.
- One-time: revert the 25 workspace manifests' @ohif/* specifiers to workspace:*
  (version fields untouched) and regenerate pnpm-lock.yaml to match.

Because internal deps are workspace:* (links, not versions in the lockfile),
version bumps no longer change pnpm-lock.yaml, so it stays in sync and frozen
installs keep working.

Verified: `pnpm install --frozen-lockfile` passes, and `pnpm pack` of @ohif/core
emits a tarball whose @ohif/ui dependency is the exact version (3.13.0-beta.92),
not workspace:*.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* docs(ci): correct build-docs install comment for workspace:* release flow

publish-version.mjs no longer rewrites @ohif/* deps to concrete versions, so
the old comment was stale. Internal deps stay workspace:* and the lockfile
stays consistent; pnpm publish concretizes only the published tarball.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* ci(docs): use --frozen-lockfile now that the lockfile no longer drifts

With internal deps as workspace:* the lockfile stays in sync across version
bumps, so the docs deploy can install frozen -- failing fast on genuine
lockfile drift instead of silently reconciling. The --no-frozen-lockfile
workaround is no longer needed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* ci: use --frozen-lockfile in CI install steps now that the lockfile is stable

Internal @ohif/* deps are workspace:* so pnpm-lock.yaml no longer drifts; the
UNIT_TESTS/BUILD/NPM_PUBLISH installs can run frozen and fail fast on genuine
drift. Kept --no-frozen-lockfile only where it is still required: the Dockerfile
(platform/docs is excluded from the build context) and the playwright CS3D-version
step (mutates @cornerstonejs versions before installing).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* test: stability of seg load mpr test

* Better drag fix for crosshairs

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-16 11:59:04 -04:00
ohif-bot da9fd9057d chore(version): Update package versions to 3.13.0-beta.92 [skip ci] 2026-06-13 01:01:06 +00:00
Bill WallaceandClaude Opus 4.8 5cb2fb41f8 fix: pnpm deploy bugs for docs and viewer-dev (#6077)
Merging for testing since this can't be tested without a merge to master

fix(ci): use --no-frozen-lockfile for docs deploy (pnpm migration)

The Build and Deploy Docs workflow ran `pnpm install --frozen-lockfile` and
failed on every master push after the pnpm migration:

  [ERR_PNPM_OUTDATED_LOCKFILE] pnpm-lock.yaml is not up to date with
  platform/core/package.json
    - @ohif/ui (lockfile: workspace:*, manifest: 3.13.0-beta.90)

publish-version.mjs rewrites @ohif/* workspace deps from "workspace:*" to the
concrete release version and commits that bump to master, so the committed
manifests intentionally drift from pnpm-lock.yaml. Every CircleCI job already
passes --no-frozen-lockfile for exactly this reason (pnpm-workspace.yaml sets
frozenLockfile:true as the default); the docs workflow was the lone job still
using frozen and so broke the docs deploy.

Switch the docs install to --no-frozen-lockfile to match the rest of CI.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@

* fix(ci): write npm auth token to ~/.npmrc so publishes authenticate

NPM_PUBLISH wrote the registry auth token to ~/repo/.npmrc (the repo root),
but publish-package.mjs does process.chdir(packageDirectory) and runs
`npm publish` from inside each package (platform/ui, extensions/*, ...). npm
reads the project .npmrc from that package dir and the user .npmrc from
$HOME -- it never walks up to ~/repo/.npmrc -- so every publish failed with
ENEEDAUTH ("need auth ... requires you to be logged in").

publish-package.mjs catches and swallows per-package publish errors, so
NPM_PUBLISH still exited 0 and reported green; the breakage was silent. As a
result no @ohif/* package newer than 3.13.0-beta.89 (the last publish before
the pnpm migration) reached npm -- beta.90 and beta.91 are missing and the
beta dist-tag is stuck at beta.89.

Write the token to ~/.npmrc (npm per-user config, read regardless of cwd)
instead. This also stops clobbering the committed workspace-config .npmrc
(node-linker=hoisted) at the repo root, which the in-job pnpm install/build
relies on. Applied to all three auth steps for consistency.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix(docker): copy preinstall.js before pnpm install in builder stage

The builder stage copies only the package.json manifests, runs
`pnpm install --no-frozen-lockfile`, and copies the rest of the source
afterward (for layer caching). But the root package.json defines a
"preinstall" lifecycle script (node preinstall.js) that pnpm runs at the
start of install -- before the source copy -- so the script file was absent
and install aborted:

  . preinstall$ node preinstall.js
  Error: Cannot find module '/usr/src/app/preinstall.js' (MODULE_NOT_FOUND)
  ERROR: process "pnpm install --no-frozen-lockfile" did not complete

This surfaced once the .npmrc COPY fix (#6076) let the build advance past
the earlier COPY failure. preinstall.js is self-contained (it no-ops without
GITHUB_TOKEN and guards the AGENTS.md/CLAUDE.md symlink with existsSync), so
copying just the script into the early manifest layer is sufficient.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix(build): declare postcss plugins in platform/app for Docker build

The shared root postcss.config.js (which platform/app re-exports) loads
postcss-import, postcss-preset-env, and cssnano, but none were declared in
platform/app or the root. They only reached node_modules by being hoisted
from platform/docs (postcss-import, postcss-preset-env) and transitively
(cssnano). The Docker image excludes platform/docs via .dockerignore and
libs/@cornerstonejs is not a workspace member, so under pnpm's stricter
node-linker=hoisted the app build failed to resolve the plugins:

  Loading PostCSS "postcss-preset-env" plugin failed:
  Cannot find module 'postcss-preset-env'

(The accompanying "Can't resolve assets/woff2/latin.woff2" error was a
cascade from the broken PostCSS chain and clears with this fix.)

Declare the three plugins the config explicitly loads as devDependencies of
platform/app, pinned to the versions already resolved by working builds
(postcss-import@14.1.0, postcss-preset-env@7.8.3, cssnano@5.1.15), so the
build no longer depends on incidental hoisting from docs.

The lockfile was regenerated against a workspace:* baseline so the only
@ohif change is none -- the diff adds just the postcss plugin trees, keeping
specifiers at workspace:* per the repo's convention. Verified by building the
full Docker image locally: rspack compiles with 0 errors and the image
exports successfully.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-12 20:57:11 -04:00
ohif-bot a219822ad1 chore(version): Update package versions to 3.13.0-beta.91 [skip ci] 2026-06-13 00:10:16 +00:00
Bill WallaceandClaude Opus 4.8 e391e6de5f fix: Fix the deployment to viewer-dev caused by missing .npmrc (#6076)
@
fix(ci): restore committed .npmrc in Docker build jobs (pnpm migration)

The pnpm migration (#6031) made the Dockerfile COPY .npmrc into the
builder stage because pnpm needs the workspace config it carries
(node-linker=hoisted, link-workspace-packages). But the Docker jobs still
ran `rm -f ./.npmrc` immediately before `docker build` -- a leftover from
when .npmrc only held npm credentials. NPM_PUBLISH overwrites the tracked
.npmrc with a publish auth token and persists it to the workspace, so the
Docker jobs deleted the file the Dockerfile requires:

  ERROR [builder 6/13] COPY package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc ./
  failed to compute cache key: "/.npmrc": not found

DEPLOY_MASTER therefore failed at DOCKER_BETA_PUBLISH on every master
build after the migration (NPM_PUBLISH still pushed the version bump first,
so npm packages shipped but the latest-beta image never did -- leaving
viewer-dev.ohif.org stuck on the prior beta).

Replace `rm -f ./.npmrc` with `git checkout -- .npmrc` in the four Docker
*build* jobs so the committed, token-free workspace-config .npmrc is
restored before the build. The two manifest jobs keep `rm` since they do
not build from the Dockerfile.


@

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-12 20:05:44 -04:00
78 changed files with 3156 additions and 477 deletions

No files matched your search

+346
View File
@@ -0,0 +1,346 @@
---
name: ohif-test-agent
description: Generate runnable Playwright E2E tests for the OHIF Viewer using its custom fixture system, page objects, and normalized WebGL viewport coordinates. Use this skill whenever the user asks to write, add, modify, or debug tests in an OHIF/Viewers context — including vague asks like "write a test for X" when working in the OHIF repo, tests touching platform/app/tests/, or anything involving Cornerstone viewports, DICOM studies, measurements, segmentations, or OHIF modes/extensions. Prefer this skill over generic test-writing even if the user doesn't say "Playwright" or "E2E" explicitly.
---
# OHIF Test Agent
This skill teaches you to generate correct, runnable Playwright end-to-end tests for the OHIF Viewer. Follow the workflow below.
## Environment model
This package follows the agentskills.io SKILL.md convention. `SKILL.md` is the entire behavior contract — there is no separate runtime entrypoint.
## Workflow: how to write a new OHIF test
1. **Classify the feature.** What area does the test belong to — a measurement tool, segmentation hydration, contour panel interaction, MPR layout, crosshairs, tag browser, etc.? The area determines the mode, the StudyInstanceUID, and the seed spec you'll read.
2. **Read the seed spec.** Consult [references/patterns-by-feature.md](references/patterns-by-feature.md) to find the canonical existing spec for that area. Read it end-to-end before writing. This is the single most important step — OHIF specs follow consistent idioms that are easier to mimic than to reconstruct from first principles. (This mirrors Playwright's own agent guidance: use seed tests as the example for generated tests.)
3. **Scaffold from the template.** Start from [assets/spec-template.ts](assets/spec-template.ts) — or copy the seed spec and adapt.
4. **Look up specifics in the source, not from memory.** The reference files [page-objects.md](references/page-objects.md) and [utilities.md](references/utilities.md) capture the **stable rules** — fixture keys, import conventions, access idioms, the reasons certain things trip people up. They deliberately do not enumerate methods. For the current method surface or a utility's exact signature, open the relevant file under `tests/pages/` or `tests/utils/` — the source evolves, and the source is always right. The seed spec you picked in step 2 is usually the fastest second source, because it co-evolves with the API.
5. **Run the test when execution is available.** `yarn test:e2e:ci` runs the whole suite, but for iteration use `yarn playwright test tests/YourNew.spec.ts` (or via the Playwright VS Code extension).
6. **If runtime execution is unavailable, do static validation.** Validate import source, fixture keys, normalized viewport usage, UID/mode pairing, and hydration/tracking prompt handling. Then report clearly that execution was not performed.
7. **If it fails, triage before debugging.** Use [references/failure-triage.md](references/failure-triage.md) — most OHIF test failures are timing / hydration, not real regressions.
## Architecture
OHIF uses Playwright with a custom fixture system. Tests are **not** vanilla Playwright — they import `test`, `expect`, and utilities from `./utils`, which re-exports an extended test runner that injects page objects.
```text
playwright.config.ts → Chromium-only, port 3335, data-cy as testId
└─ tests/utils/fixture.ts → Extends playwright-test-coverage, injects page objects
└─ tests/*.spec.ts → Each imports { test, expect, ... } from './utils'
├─ tests/pages/ → Page objects (ViewportPageObject, MainToolbarPageObject, …)
└─ tests/utils/ → Utilities (visitStudy, checkForScreenshot, screenShotPaths, …)
```
Why the custom fixture matters: the page objects are created for each test and bound to the right Playwright `page`. If you `new ViewportPageObject(page)` manually, you skip the fixture wiring and some sub-objects won't resolve correctly.
### Import rule
```ts
// Correct
import { test, expect, visitStudy, checkForScreenshot, screenShotPaths } from './utils';
// Wrong — will compile but fixtures won't be injected
import { test, expect } from '@playwright/test';
```
A few utilities (`press`, `downloadAsString`, the `assert*` helpers) are NOT re-exported from `./utils`. See [references/utilities.md](references/utilities.md) for the correct import path per utility.
## The viewport is WebGL
OHIF renders medical images onto a WebGL canvas. You cannot query *canvas* pixels by CSS selector. Use **normalized coordinates** (0–1 range, top-left is `{x:0, y:0}`) for clicks and drags, and **visual regression** (screenshot comparison) for canvas assertions. (Not everything in the viewport is canvas — some overlays render as SVG you *can* query via DOM, e.g. a vector overlay's color through `getSvgAttribute`. The canvas rule is about raster output painted onto the WebGL surface.)
```ts
const activeViewport = await viewportPageObject.active;
await activeViewport.normalizedClickAt([{ x: 0.5, y: 0.5 }]); // click center
await activeViewport.normalizedClickAt([{ x: 0.3, y: 0.3 }, { x: 0.7, y: 0.7 }]); // draw two points
await activeViewport.normalizedClickAt([{ x: 0.5, y: 0.5 }], 'right'); // right-click
await activeViewport.normalizedDragAt({
start: { x: 0.3, y: 0.3 },
end: { x: 0.7, y: 0.7 },
});
```
Pixel coordinates (`clickAt`, `doubleClickAt`) exist but prefer normalized for portability across viewport sizes.
For DOM-rendered state (panel counts, dialog text, overlay text values, button enabled states), assert directly:
```ts
await expect(activeViewport.overlayText.bottomRight.instanceNumber).toContainText('17/');
const count = await rightPanelPageObject.measurementsPanel.panel.getMeasurementCount();
expect(count).toBe(1);
```
## Study loading lifecycle
Every test follows this sequence. Skipping steps causes flakiness:
```ts
test.beforeEach(async ({ page }) => {
const studyInstanceUID = '1.3.6.1.4.1.25403.345050719074.3824.20170125095438.5';
const mode = 'viewer';
await visitStudy(page, studyInstanceUID, mode, 2000); // 2s delay is the community norm
});
```
`visitStudy` navigates to `/{mode}/ohif?StudyInstanceUIDs={uid}`, waits for `domcontentloaded`, then `networkidle`, then the explicit delay. Default delay is `0`, but most specs pass `2000` to let the first render settle.
Delay by scene type (observed across the current suite, not a rule to apply blindly):
| Scene | Delay |
|-------|-------|
| Default (viewer mode, 2D/MPR/3D layouts, crosshairs) | `2000` |
| `mode: 'tmtv'` | `10000` — PET fusion + SUV calculation takes noticeably longer |
Start at the convention for your scene; ramp only if the test flakes on initial render. 3D layouts in `viewer` mode already stay at `2000` — the stabilization problem there is solved with `attemptAction(() => reduce3DViewportSize(page), 10, 100)`, not with a longer `visitStudy` delay.
If the study has DICOM SEG, RT, or SR data, OHIF asks whether to hydrate. Handle it:
```ts
await leftPanelPageObject.loadSeriesByModality('SEG'); // or 'RTSTRUCT', 'SR'
await page.waitForTimeout(3000); // allow the prompt to appear
await expect(DOMOverlayPageObject.viewport.segmentationHydration.locator).toBeVisible();
await DOMOverlayPageObject.viewport.segmentationHydration.yes.click();
```
The first measurement you create triggers a "start tracking?" prompt:
```ts
await DOMOverlayPageObject.viewport.measurementTracking.confirm.click();
```
For 3D / MPR scenes, wrap stabilization in `attemptAction(() => reduce3DViewportSize(page), 10, 100)` or insert a `page.waitForTimeout(...)` after the layout change before asserting.
## Wait for renders, don't sleep
`page.waitForTimeout(...)` after an action that re-renders the viewport is a smell. The viewports tell us when they're done — use that signal. `tests/utils/waitForViewportsRendered.ts` exposes three helpers, all barrel-exported from `./utils`:
- `waitForViewportRenderCycle(page)` — wait for the next full cycle: a viewport enters `needsRender`, then **all** viewports report `rendered` (and volumes are loaded, by default).
- `waitForViewportsRendered(page)` — only the second half: wait until all viewports are `rendered`. Use this when the action has already requested a render before you started waiting (e.g. a layout change or `loadSeriesByDescription`).
- `waitForAnyViewportNeedsRender(page)` — only the first half. Rarely needed directly.
The canonical idiom — **start the watcher before the action, await it after**:
```ts
// start watching for the next render cycle
const viewportRenderCycle = waitForViewportRenderCycle(page);
await action(); // e.g. segmentationHydration.yes.click(), layoutSelection.MPR.click(), addSegmentation, etc.
// wait for the render to finish
await viewportRenderCycle;
await check(); // e.g. checkForScreenshot, count assertion, overlay text
```
Why "start before"? `waitForViewportRenderCycle` first waits for a viewport to enter `needsRender`. If you start it **after** the action, that transition may already be over and you'll hang until the timeout. Starting it first captures the cycle the action is about to trigger.
When to use which:
| Situation | Helper |
|-----------|--------|
| Click that triggers a re-render and you want to assert after | `waitForViewportRenderCycle(page)` started before the click |
| Layout switch / series load — render already in flight | `await waitForViewportsRendered(page)` after the call |
| Compose with another await (e.g. screenshot the same time as load) | Save the promise, `await` it later |
Replace patterns like this:
```ts
// ❌ Sleep-and-pray
await action();
await page.waitForTimeout(5000);
await checkForScreenshot(...);
// ✅ Wait on the actual signal
const cycle = waitForViewportRenderCycle(page);
await action();
await cycle;
await checkForScreenshot(...);
```
This shaves real wall-clock time off the suite and removes a class of flake (sleep too short → flake; sleep too long → slow). `tests/SEGHydrationFromMPR.spec.ts` is the canonical seed for this pattern.
Caveats:
- These helpers wait on Cornerstone viewport state. They won't help for purely DOM-side state (panel rows appearing, dialogs opening) — for those, prefer `expect(locator).toHaveCount(n)` / `toBeVisible()` which auto-retry, or `expect.toPass({ timeout })`.
- For some actions (hanging-protocol changes are the documented example) the viewport doesn't transition through `needsRender` synchronously — those still need a short `waitForTimeout`. The source comment in `waitForViewportsRendered.ts` calls this out.
## Fixture-injected page objects
Destructure these from the test function argument. **Never `new` them manually.**
```ts
test('my test', async ({
page,
viewportPageObject,
mainToolbarPageObject,
leftPanelPageObject,
rightPanelPageObject,
DOMOverlayPageObject, // note the capital D — this matches the fixture key
notFoundStudyPageObject,
}) => { ... });
```
Two page objects are **not** fixture-injected:
- `DataOverlayPageObject` — reach via `viewportPageObject.getById(id).overlayMenu.dataOverlay`.
- `DicomTagBrowserPageObject` — reach via `DOMOverlayPageObject.dialog.dicomTagBrowser`.
See [references/page-objects.md](references/page-objects.md) for fixture rules and a map of which file covers which concern; read the `.ts` file under `tests/pages/` for the current method surface.
## When the control you need has no page object yet
A spec must not reach for `page.getByTestId(...)` / `getByRole(...)` directly for
application controls. If the button, menu, dialog, or field you need isn't already
exposed by a page object, **add it to one — or create a new page object — instead of
inlining a raw selector.** Raw selectors in a spec are the clearest sign a test was
written without reading the existing suite: they duplicate locators, bypass the
fixture wiring, and rot silently when the DOM changes.
Where new coverage goes:
| What you need | Where it belongs |
|---|---|
| A toolbar button or tool (Zoom, Pan) | a getter on `MainToolbarPageObject`, next to `crosshairs` / `measurementTools` |
| A menu, prompt, context menu, or small dialog | `DOMOverlayPageObject` |
| A substantial dialog with its own fields (User Preferences) | its **own** page object class, reached through `DOMOverlayPageObject` — follow `DicomTagBrowserPageObject` (`DOMOverlayPageObject.dialog.dicomTagBrowser`) |
| Each field/row inside that dialog | a method or sub-object on the dialog's page object — not a raw selector in the spec |
| A side-panel control | `LeftPanelPageObject` / `RightPanelPageObject` |
If the control has no `data-cy`, **add `data-cy` to the source component** and target
it — don't fall back to `getByRole`/text selectors, which are brittle and
locale-sensitive (`testIdAttribute` is `data-cy`, so `getByTestId('Zoom')` resolves
`[data-cy="Zoom"]`). Call out any `data-cy` you add so it ships in the same PR.
**Worked example — "set the Zoom hotkey in User Preferences":** the options menu, the
preferences dialog, each preference field, and the Zoom toolbar button should all be
page-object surface — e.g. `mainToolbarPageObject.zoom`,
`DOMOverlayPageObject.optionsMenu.settings.click()`,
`DOMOverlayPageObject.dialog.userPreferences.hotkey('Zoom').set('q')`. The spec then
reads as intent, not as a pile of `getByTestId` calls.
## Assert the effect, not just the attribute
Prefer asserting the actual rendered result over a proxy attribute. Activating Zoom and
checking `data-active="true"` confirms the *button* toggled — not that zoom works. Drag
on the viewport and assert the image actually zoomed (a viewport-scoped screenshot, or a
measurable state change). Attribute checks are fine as a secondary signal, not the whole
test.
## Visual regression
**Direction:** the suite is moving off *full-app* screenshots — not off screenshots
altogether. "Avoid screenshots" means: don't screenshot the whole page, and don't
screenshot something that has a faithful DOM/state signal. It does **not** mean avoid
screenshots for output that is genuinely canvas-only — for that output a screenshot is
the correct and required tool, and you should use it without apology. Older specs that
screenshot the whole page are the legacy pattern being phased out; viewport-scoped
screenshots are not.
### Screenshot vs. DOM assertion — how to choose
Reach for the cheapest *faithful* signal, in this order:
1. **A faithful DOM/SVG/state signal exists → assert on it.** Panel counts, dialog and
overlay text, enabled/disabled state, and any overlay that renders as SVG (a vector
overlay's color is readable via `getSvgAttribute`) all have a DOM representation — assert
on it directly, no screenshot.
2. **The thing under test is painted onto the WebGL canvas with no DOM representation → a
screenshot is correct and required.** Raster output on the canvas exposes no attribute to
read for a painted pixel. Scope a `checkForScreenshot` to the viewport (pane or grid) and
assert it — this is the right tool, not a last resort, whenever what you're verifying is
the rendered canvas itself.
3. **Never substitute a service/state read for a render assertion.** Reading a service's
state (any `window.services...`) asserts the *data model*, not the pixels the user sees —
it passes even when rendering is broken. `page.evaluate(() => window.services...)` is an
escape hatch for *setup*, not for *appearance* assertions.
For anything drawn onto the WebGL canvas with no DOM signal, compare a screenshot scoped to a specific viewport or the viewport grid:
```ts
await checkForScreenshot({
page,
locator: viewportPageObject.grid, // scope to the viewport grid — not the whole page
screenshotPath: screenShotPaths.length.lengthDisplayedCorrectly,
});
```
`checkForScreenshot` retries up to 10 times at 500 ms intervals. Use `screenShotPaths.<category>.<name>` rather than a hand-typed string — the tree of valid keys lives in `tests/utils/screenShotPaths.ts`.
Rules (apply to all new screenshot assertions):
- **Use the object form.** The positional form is legacy; don't introduce it in new code, and don't treat existing positional-form usage as a pattern to copy.
- **Never screenshot the full app.** Full-page screenshots include panels, toolbars, and dialogs that drift independently of what's under test and make baselines fragile. Scope by passing a `locator` — `viewportPageObject.grid` for the grid, or a specific viewport pane. A bare `normalizedClip: { x: 0, y: 0, width: 1, height: 1 }` with no `locator` is **not** scoping — it clips to the full page. Use `normalizedClip` only to target a sub-region *of a locator* (e.g. a scrollbar strip). If you reach for `fullPage: true`, stop and pick a locator.
- **Do not tune `maxDiffPixelRatio` or `threshold`** to make a screenshot pass. If a baseline mismatches, regenerate it after a human review of the diff, or fix the underlying flake.
## Playwright config facts worth remembering
| Setting | Value | Why |
|---------|-------|-----|
| `baseURL` | `http://localhost:3335` | OHIF e2e uses 3335, not 3000 |
| `testIdAttribute` | `data-cy` | `getByTestId(...)` maps to `[data-cy="..."]` |
| `browser` | Chromium only | Firefox/WebKit disabled (SharedArrayBuffer + stability) |
| `retries` | 3 in CI, 0 locally | Flaky rendering needs CI retries |
| `workers` | 6 in CI, undefined locally | Parallel execution |
| `globalTimeout` / `timeout` | 800_000 ms | Medical image loads are slow |
| `actionTimeout` | 10_000 ms | Per-action cap |
| `webServer.command` | `cross-env APP_CONFIG=config/e2e.js COVERAGE=true OHIF_PORT=3335 nyc yarn start` | e2e config + coverage |
## Test data: which study for which test
| StudyInstanceUID | Mode | Used for |
|------------------|------|----------|
| `1.3.6.1.4.1.25403.345050719074.3824.20170125095438.5` | `viewer` | General measurements, annotations, context menu |
| `1.3.6.1.4.1.14519.5.2.1.1706.8374.643249677828306008300337414785` | `viewer` | 3D, MPR, crosshairs |
| `1.3.6.1.4.1.14519.5.2.1.256467663913010332776401703474716742458` | `viewer` or `segmentation` | Labelmap SEG |
| `1.2.840.113619.2.290.3.3767434740.226.1600859119.501` | `viewer` / `segmentation` / `tmtv` | RTSTRUCT/contour and TMTV |
| `1.3.6.1.4.1.14519.5.2.1.7695.4007.324475281161490036195179843543` | `viewer` | SR hydration |
Full mapping in [references/patterns-by-feature.md](references/patterns-by-feature.md). **Do not invent UIDs** — they must exist on the e2e data server.
## Rules (short, so they're actually read)
1. Import `test`, `expect`, and utilities from `./utils`, not `@playwright/test`.
2. Destructure fixture-injected page objects; don't `new` them.
3. Use normalized coordinates (0–1) for viewport interactions.
4. Use `visitStudy` with a real UID, correct mode, and a non-zero delay (2000 is conventional).
5. Handle hydration and measurement-tracking prompts where applicable.
6. Choose the faithful signal: DOM/SVG assertions where the rendered result has one (panels, dialogs, overlay text, SVG/vector overlays), a viewport-scoped screenshot when what you're verifying is canvas-only raster output, and never a `window.services` state read standing in for a render check. Screenshots use the object form, scoped via a `locator` — never the full app.
7. Use `data-cy` selectors (already wired via `testIdAttribute`).
8. When an assertion needs retry tolerance, wrap it in `expect.toPass({ timeout })`.
9. Test in the correct mode — segmentation tools aren't available in `viewer` mode.
10. If a utility isn't exported from `./utils`, import from the deeper path (see [references/utilities.md](references/utilities.md)).
11. After an action that re-renders the viewport, prefer `waitForViewportRenderCycle(page)` (started before the action) over `page.waitForTimeout(...)`. See the "Wait for renders, don't sleep" section.
12. Don't inline raw `page.getByTestId(...)` / `getByRole(...)` for app controls. If a control has no page object, create or augment one (see "When the control you need has no page object yet"), adding a `data-cy` to the source if needed.
13. Assert the actual effect (e.g. the image zoomed), not just a proxy attribute like `data-active`.
## Pre-output self-check (mandatory)
Before returning a generated OHIF test, confirm all items:
1. Imports `test`/`expect` from `./utils` (not `@playwright/test`).
2. Uses fixture-injected keys and exact casing (especially `DOMOverlayPageObject`).
3. Uses normalized viewport interactions (`normalizedClickAt` / `normalizedDragAt`) unless there is a strong reason otherwise.
4. Uses a valid canonical StudyInstanceUID and compatible mode.
5. Handles hydration or measurement tracking prompts when the workflow requires them.
6. Uses the faithful signal for each assertion — DOM/SVG where the result has a DOM representation, a viewport-scoped screenshot when what's verified is canvas-only raster output, and never a `window.services` state read in place of a render check. Any `checkForScreenshot` call uses the object form, scoped via a `locator` (viewport pane or grid) — no full-app screenshots.
7. Replaces `page.waitForTimeout(...)` after viewport-rendering actions with `waitForViewportRenderCycle(page)` (started before the action) — keeps `waitForTimeout` only for non-render waits like the hydration prompt in `beforeEach`.
8. If execution was skipped, states that explicitly and provides concrete run commands.
9. Every application control is reached through a page object — no raw `getByTestId`/`getByRole` in the spec for buttons, menus, dialogs, or fields. Any control not already covered was added to the right page object (or a new one), with a source `data-cy` if it lacked one.
10. Assertions verify the real effect where feasible (e.g. the image visibly zoomed), not only an attribute toggle.
## Output contract (for non-executing agents)
When execution cannot be performed in the current environment, the response should include:
1. The test code.
2. Assumptions made (if any).
3. Static checks that were verified.
4. What still must be run locally and exact commands to run.
## When to consult each reference
- **Before writing** → [references/patterns-by-feature.md](references/patterns-by-feature.md). Pick the seed spec for the feature area and read it. The seed spec is the closest thing to a live API example because it co-evolves with the code.
- **For a stable rule or idiom** (fixture keys, import paths, panel-access order, capital-D quirk, object-param convention) → [references/page-objects.md](references/page-objects.md), [references/utilities.md](references/utilities.md).
- **For a method name, property, or signature** → read the source under `tests/pages/` or `tests/utils/`. Do not rely on a static table for these; they drift as the code is refactored.
- **When a test fails** → [references/failure-triage.md](references/failure-triage.md).
@@ -0,0 +1,54 @@
import {
checkForScreenshot,
expect,
screenShotPaths,
test,
visitStudy,
waitForViewportRenderCycle,
} from './utils';
test.beforeEach(async ({ page }) => {
// Pick the right UID + mode for your feature (see references/patterns-by-feature.md)
const studyInstanceUID = '1.3.6.1.4.1.25403.345050719074.3824.20170125095438.5';
const mode = 'viewer';
await visitStudy(page, studyInstanceUID, mode, 2000);
});
test.describe('FEATURE NAME', () => {
test('describes the behaviour in one sentence', async ({
page,
viewportPageObject,
mainToolbarPageObject,
rightPanelPageObject,
DOMOverlayPageObject, // capital D on purpose
}) => {
// 1. Arrange — select a tool, open a panel, etc.
// 2. Act — interact with the viewport.
// Prefer normalized (0–1) coordinates:
// const activeViewport = await viewportPageObject.active;
// await activeViewport.normalizedClickAt([{ x: 0.3, y: 0.3 }, { x: 0.7, y: 0.7 }]);
// For actions that re-render the viewport, gate on the render cycle
// instead of sleeping — start the watcher BEFORE the action:
// const cycle = waitForViewportRenderCycle(page);
// await action();
// await cycle;
// 3. Handle prompts (first measurement prompts for tracking; SEG/RT/SR prompts for hydration)
// await DOMOverlayPageObject.viewport.measurementTracking.confirm.click();
// 4. Assert canvas output via visual regression — object form, scoped to the
// viewport via a locator (not the full page). normalizedClip is only for
// clipping to a sub-region of that locator.
// await checkForScreenshot({
// page,
// locator: viewportPageObject.grid,
// screenshotPath: screenShotPaths.YOUR_CATEGORY.YOUR_KEY,
// });
// 5. Assert DOM state directly
// const count = await rightPanelPageObject.measurementsPanel.panel.getMeasurementCount();
// expect(count).toBe(1);
});
});
@@ -0,0 +1,70 @@
# Failure triage
Before debugging, classify. Most OHIF test failures are timing or hydration — not real regressions.
| Category | Symptom | Fix |
|----------|---------|-----|
| Timing | Element not visible, action timeout | Add / increase the `delay` param of `visitStudy`; for actions that re-render viewports, use `waitForViewportRenderCycle(page)` (started before the action) instead of `waitForTimeout`; wrap the assertion in `expect.toPass({ timeout })` |
| Selector | Element not found | Verify `data-cy` on the target; confirm the panel is open (`toggle()` / `select()` before interacting); check for capital `D` in `DOMOverlayPageObject` when destructuring |
| Hydration | Segmentation/RT not interactive | Ensure the `segmentationHydration.yes.click()` fired; add `waitForTimeout(3000)` after `loadSeriesByModality('SEG'\|'RTSTRUCT'\|'SR')` |
| Data | Study not found, empty viewport | Confirm the UID is in the canonical list (see [patterns-by-feature.md](patterns-by-feature.md)); confirm the mode supports the feature (segmentation tools aren't in `viewer` mode) |
| Visual drift | Screenshot mismatch but feature works | Have a human review the diff, then regenerate the baseline with `yarn playwright test --update-snapshots`. Do not adjust `maxDiffPixelRatio` or `threshold` to make a failing screenshot pass. |
| Real regression | Feature is actually broken | Report as a bug — this is the test doing its job |
## Prefer render-cycle waits over sleeps
If you're tempted to add `await page.waitForTimeout(2000)` after an action, ask whether the action re-rendered the viewport. If it did, use:
```ts
const cycle = waitForViewportRenderCycle(page);
await action();
await cycle;
await check();
```
The watcher must be created **before** the action — it waits for `needsRender` first, and that transition is gone by the time the action returns. See the "Wait for renders, don't sleep" section in [SKILL.md](../SKILL.md) and `tests/SEGHydrationFromMPR.spec.ts`.
### When the cycle helper times out at `waitForAnyViewportNeedsRender`
Symptom: the test fails inside `waitForAnyViewportNeedsRender` after 5s, with the action having actually completed in the UI. The action just doesn't transition the viewport through `needsRender` synchronously. Known cases:
- Hanging-protocol changes.
- **RTSTRUCT / contour segmentation hydration confirm.** SEG (labelmap) hydration does fire `needsRender`; contour does not. The fix is to gate on the actual end-state — for hydration in `beforeEach`, `await expect(page.getByTestId('data-row')).toHaveCount(N)` is the right wait.
Don't react by raising the cycle's timeout — the transition isn't coming. Replace the cycle wrapper with an auto-retrying DOM/SVG assertion, or `expect.toPass({ timeout })` around the assertion block.
## The `toPass` pattern
When an assertion needs to wait for async render / propagation:
```ts
await expect(async () => {
await rightPanelPageObject.labelMapSegmentationPanel.panel.segmentByText('Spleen').click();
await expect(activeViewport.overlayText.bottomRight.instanceNumber).toContainText('17/');
}).toPass({ timeout: 10_000 });
```
`toPass` reruns the assertion block until it succeeds or the timeout expires — cleaner than a hand-rolled retry loop and surfaces the last failure reason if it times out.
## Common `DOMOverlayPageObject` mistake
The fixture key is capital-D `DOMOverlayPageObject`, not lowercase. If your destructure is silently `undefined`, check the casing.
## `press` import mistake
`press` is NOT re-exported from `./utils`. `import { press } from './utils'` resolves to `undefined` and fails at runtime. Use:
```ts
import { press } from './utils/keyboardUtils';
await press({ page, key: 'ArrowDown', nTimes: 50 }); // object param, not (page, key)
```
## Visual regression iteration
Screenshots live under `tests/screenshots/chromium/<testFilePath>/`. To accept new output as the baseline:
```sh
yarn playwright test tests/YourSpec.spec.ts --update-snapshots
```
Review the resulting PNGs carefully — an agent-accepted baseline that's subtly wrong is worse than a failing test.
@@ -0,0 +1,120 @@
# OHIF Page Object guide
> This file documents the **stable structural rules** of the page object system. For the current list of methods and properties on any class, **read the source under `tests/pages/`** — it is always authoritative, and it evolves as the product does. A static method table in a reference file goes stale the moment someone refactors; the source does not.
## How to discover the API of a page object
1. Find the relevant class in `tests/pages/`. File names match class names.
2. Read it end-to-end once — most are under a few hundred lines.
3. Some classes compose sub-objects (e.g. `RightPanelPageObject` holds a measurementsPanel, contourSegmentationPanel, labelMapSegmentationPanel, tmtvPanel, etc.). Those sub-objects usually live in the same file or a sibling under `tests/pages/`.
4. To see how a method is actually used, grep `tests/` or open the seed spec listed in [patterns-by-feature.md](patterns-by-feature.md). Real usage beats a synthesized signature every time.
Do not try to memorize a method surface from this file — it intentionally does not list one. It lists only the rules you cannot derive from the source by reading a single file.
---
## Stable rules
### Fixture keys (case-sensitive)
These are injected via `tests/utils/fixture.ts`. Destructure them from the test function's first argument — do not `new` them, because the fixture wires sub-objects to the correct `page` and hand-constructed instances skip that wiring.
- `viewportPageObject`
- `mainToolbarPageObject`
- `leftPanelPageObject`
- `rightPanelPageObject`
- `DOMOverlayPageObject` — **capital D**. A silent `undefined` destructure is almost always a casing typo here.
- `notFoundStudyPageObject`
If the fixture file is updated and new keys are added, they will show up there first — check it if something feels missing.
### Non-fixture page objects
Some page object classes are not fixture-injected. They are reached through an injected fixture:
- `DicomTagBrowserPageObject` → via `DOMOverlayPageObject.dialog.dicomTagBrowser`
- `DataOverlayPageObject` → via `viewportPageObject.getById(viewportId).overlayMenu.dataOverlay`
Both can be constructed manually (`new DataOverlayPageObject(page)`) if a test really needs a fresh instance, but the accessor path is the idiomatic one.
### Viewport wrapper vs. viewport instance
`viewportPageObject` is a **wrapper**. You almost always want a specific viewport out of it first:
- `await viewportPageObject.active` — the currently focused viewport
- `viewportPageObject.getAll()` — every viewport in the grid
- `viewportPageObject.getNth(i)` — zero-indexed
- `viewportPageObject.getById(cornerstoneViewportId)` — e.g. `'default'`, `'ctAXIAL'`
The object these return is the one with `normalizedClickAt`, `normalizedDragAt`, `overlayText`, `nthAnnotation`, etc. Reach for the viewport instance first, then call methods on it.
### Panel access order
Every `rightPanelPageObject` sub-panel follows the same three-step idiom: **open the side panel, `.select()` the sub-panel tab, then interact with `.panel.*`**. Skipping either of the first two is the most common cause of "element not found".
```ts
await rightPanelPageObject.toggle();
await rightPanelPageObject.measurementsPanel.select();
const count = await rightPanelPageObject.measurementsPanel.panel.getMeasurementCount();
```
The exact row/action methods vary by panel — check the source file for the one you need.
### Layout identifiers are camelCase JS properties
`mainToolbarPageObject.layoutSelection.<layout>.click()` — access layouts by camelCase property name (e.g. `threeDFourUp`, `axialPrimary`), not with bracket-escaped DICOM-ish strings like `['3DFourUp']`. This is a convention enforced by how the class exposes its tools.
### Sub-tools auto-open their dropdown
Tools nested inside a toolbar dropdown (measurement tools, more tools, layouts) each expose a `.click()` that opens the parent menu for you. You almost never need to open the menu first. `await mainToolbarPageObject.measurementTools.length.click()` does both the expand and the select.
### When the control you need isn't covered yet — create or augment
The page objects here cover what the suite currently exercises. When your test needs a
control that isn't exposed, **extend the page object system rather than dropping a raw
`page.getByTestId(...)` into the spec.** A raw selector in a spec is the clearest tell
that the author didn't read the existing tests — it duplicates a locator that should
live in one place and bypasses the fixture wiring.
| What you need | Where it goes | Precedent to copy |
|---|---|---|
| A toolbar button/tool (Zoom, Pan) | a getter on `MainToolbarPageObject` | `crosshairs`, `measurementTools` |
| A menu / prompt / context menu / small dialog | `DOMOverlayPageObject` | `viewport.measurementTracking`, `dialog.input` |
| A large dialog with its own fields (User Preferences) | a **new** page object class reached via `DOMOverlayPageObject` | `DicomTagBrowserPageObject` (`DOMOverlayPageObject.dialog.dicomTagBrowser`) |
| Individual fields/rows in that dialog | methods/sub-objects on the dialog's page object | `DicomTagBrowserPageObject.seriesSelect` |
| Side-panel controls | `LeftPanelPageObject` / `RightPanelPageObject` | existing sub-panels |
Two more expectations:
- **Missing `data-cy`?** Add it to the source component and target it; don't fall back
to `getByRole`/text. `testIdAttribute` is `data-cy`, so `getByTestId('Zoom')` resolves
`[data-cy="Zoom"]`. Mention any attribute you added so it ships in the same PR.
- **Mirror the existing shape.** A new getter should look like its neighbors (return a
locator, or a small object with `.click()` etc.) so the new surface is
indistinguishable from what was already there.
Example — a "set the Zoom hotkey" test should make `mainToolbarPageObject.zoom`, an
options-menu accessor on `DOMOverlayPageObject`, and a `userPreferences` dialog page
object (with a per-hotkey field accessor) exist — then the spec reads as steps, not
selectors.
---
## Page object map — what each class is *for*
This table exists to help you pick the right file to open, not to enumerate methods. Source of truth for any specific method remains the `.ts` file.
| Class | File | Covers |
|-------|------|--------|
| ViewportPageObject | `tests/pages/ViewportPageObject.ts` | Cornerstone viewports — clicks, drags, overlays, annotations, crosshairs |
| MainToolbarPageObject | `tests/pages/MainToolbarPageObject.ts` | Top toolbar — measurement tools, more tools, layouts, crosshairs, pan |
| LeftPanelPageObject | `tests/pages/LeftPanelPageObject.ts` | Study browser — thumbnails, load by modality or description |
| RightPanelPageObject | `tests/pages/RightPanelPageObject.ts` | Side panels — measurements, contour seg, labelmap seg, TMTV, microscopy |
| DOMOverlayPageObject | `tests/pages/DOMOverlayPageObject.ts` | DOM overlays — dialogs, hydration/tracking prompts, context menus, tag-browser accessor |
| NotFoundStudyPageObject | `tests/pages/NotFoundStudyPageObject.ts` | Study-not-found error page |
| DicomTagBrowserPageObject | `tests/pages/DicomTagBrowserPageObject.ts` | Tag-browser dialog (non-fixture; reach via `DOMOverlayPageObject.dialog`) |
| DataOverlayPageObject | `tests/pages/DataOverlayPageObject.ts` | Data-overlay menu (non-fixture; reach via `viewport.overlayMenu`) |
If the directory adds or renames a file, that diff is your first clue and this table is your second — trust the directory.
For live usage, the seed spec in [patterns-by-feature.md](patterns-by-feature.md) shows how a class is actually called; the source file tells you everything else that's on it.
@@ -0,0 +1,148 @@
# Seed specs by feature area
> When writing a new OHIF test, find the closest feature area below and read the listed spec in full before writing. Playwright's own guidance says the seed test "serves as an example of all the generated tests" — that applies here.
>
> **If a spec listed below has moved or been renamed**, grep `tests/` for a remaining example (e.g. `grep -rn "loadSeriesByModality('RTSTRUCT')" tests/`). The pattern matters more than the exact filename — specs get renamed, the feature area persists.
>
> **No close match below?** This list only covers areas with a seed worth copying; don't add a stub for every untested area. See [Feature area not listed above?](#feature-area-not-listed-above-no-existing-seed).
## Canonical study UIDs
| UID | Mode(s) | What it has |
|-----|---------|-------------|
| `1.3.6.1.4.1.25403.345050719074.3824.20170125095438.5` | `viewer` | CT — default for measurement/annotation tests |
| `1.3.6.1.4.1.14519.5.2.1.1706.8374.643249677828306008300337414785` | `viewer` | CT volume for 3D/MPR/crosshairs |
| `1.3.6.1.4.1.14519.5.2.1.256467663913010332776401703474716742458` | `viewer` or `segmentation` | CT + SEG for labelmap tests |
| `1.2.840.113619.2.290.3.3767434740.226.1600859119.501` | `viewer` / `segmentation` / `tmtv` | CT + RTSTRUCT + PET, used for contour and TMTV |
| `1.3.6.1.4.1.14519.5.2.1.7695.4007.324475281161490036195179843543` | `viewer` | SR structured report |
Do not invent UIDs — they must exist on the e2e data server.
---
## 1. Simple measurement tools (length, angle, bidirectional, rectangle, ellipse, circle)
**Seed:** `tests/Length.spec.ts`, `tests/Angle.spec.ts`
Pattern: select tool via `mainToolbarPageObject.measurementTools.<tool>.click()`, place N points via `activeViewport.normalizedClickAt([...])`, confirm the tracking prompt, screenshot via `screenShotPaths.<name>.<name>DisplayedCorrectly`.
## 2. Freehand / spline / livewire ROIs
**Seed:** `tests/FreehandROI.spec.ts`, `tests/Livewire.spec.ts`, `tests/Spline.spec.ts`
Pattern: `normalizedDragAt({ start, end, config: { steps: 20, delay: 30 } })` for smooth strokes; `subscribeToMeasurementAdded` to assert the event fires; `activeViewport.nthAnnotation(0)` to reference what was drawn.
## 3. Annotations (arrow, probe)
**Seed:** `tests/ArrowAnnotate.spec.ts`, `tests/Probe.spec.ts`
Arrow annotate opens `DOMOverlayPageObject.dialog.input` for the label. Use `fillAndSave(label)`.
## 4. Measurement panel interactions
**Seed:** `tests/MeasurementPanel.spec.ts`
Panel access: `rightPanelPageObject.toggle()` → `.measurementsPanel.select()` → `.panel.nthMeasurement(i)` → `.actions.rename|delete|toggleLock|duplicate|...`. Also demonstrates `addLengthMeasurement(page)` and panel-row `click()` for jump-to.
## 5. Context menu (right-click on annotation)
**Seed:** `tests/ContextMenu.spec.ts`
Two ways to open: `activeViewport.normalizedClickAt([{...}], 'right')` on an empty area, or `activeViewport.nthAnnotation(0).contextMenu.open()` on a drawn annotation. Then `DOMOverlayPageObject.viewport.annotationContextMenu.addLabel|delete.click()`.
## 6. Labelmap segmentation (SEG) hydration
**Seed:** `tests/SEGHydration.spec.ts`, `tests/SEGHydrationThenMPR.spec.ts`
Flow: `leftPanelPageObject.loadSeriesByModality('SEG')` → `waitForTimeout(3000)` → `DOMOverlayPageObject.viewport.segmentationHydration.yes.click()`. Often pokes Cornerstone state directly via `page.evaluate(() => window.cornerstone...)` for zoom/render.
## 7. Contour segmentation (RTSTRUCT) + interactions
**Seeds:**
- Hydration: `tests/RTHydration.spec.ts`
- Rename: `tests/ContourSegmentRename.spec.ts`
- Navigation between segments: `tests/ContourSegNavigation.spec.ts`
- Duplicate: `tests/ContourSegmentDuplicate.spec.ts`
- Visibility: `tests/ContourSegmentToggleVisibility.spec.ts`
- Locking: `tests/ContourSegLocking.spec.ts`
Pattern: load RTSTRUCT series → hydrate → use `rightPanelPageObject.contourSegmentationPanel.panel.nthSegment(i)` / `.segmentByText('Small Sphere')` and their `.actions.rename|delete`, or the segment's `.click()` to jump.
## 8. Labelmap segmentation editing (brush / eraser / threshold)
**Seed:** `tests/LabelMapSegLocking.spec.ts`, `tests/SEGDrawingToolsResizing.spec.ts`
Pattern: `rightPanelPageObject.labelMapSegmentationPanel.tools.brush.setRadius(n)` / `.click()`, then `activeViewport.normalizedDragAt(...)` to paint.
## 9. TMTV / PET
**Seeds:** `tests/TMTVCSVReport.spec.ts`, `tests/TMTVSUV.spec.ts`, `tests/TMTVAlignment.spec.ts`, `tests/TMTVRendering.spec.ts`
Visit `mode: 'tmtv'` with a longer delay (`10000`). `rightPanelPageObject.tmtvPanel` for the side panel. Exporting a report uses `page.waitForEvent('download')` + `downloadAsString(download)`.
## 10. MPR and 3D layouts
**Seeds:** `tests/MPR.spec.ts`, `tests/3DOnly.spec.ts`, `tests/3DFourUp.spec.ts`, `tests/3DMain.spec.ts`, `tests/AxialPrimary.spec.ts`
Pattern: `mainToolbarPageObject.layoutSelection.<layoutName>.click()`. For 3D, wrap stabilization with `attemptAction(() => reduce3DViewportSize(page), 10, 100)` to settle the render before asserting.
## 11. Crosshairs
**Seed:** `tests/Crosshairs.spec.ts`
Pattern: `initializeMousePositionTracker(page)` in `beforeEach`, `mainToolbarPageObject.crosshairs.click()`, then `viewportPageObject.crosshairs.axial.rotate()` / `.increase()`.
## 12. Overlays — data overlay menu, window/level, orientation
**Seeds:** `tests/DataOverlayMenu.spec.ts`, `tests/WindowLevelOverlayText.spec.ts`, `tests/MultipleSegmentationDataOverlays.spec.ts`
Pattern: `viewportPageObject.getById('default').overlayMenu.dataOverlay.toggle()`, then `.addSegmentation(name)` / `.changeSegmentation(from, to)` / `.remove(name)`. For keyboard navigation, remember `press({ page, key, nTimes })` imports from `./utils/keyboardUtils`.
## 13. DICOM Tag Browser
**Seed:** `tests/DicomTagBrowser.spec.ts`
Open with `mainToolbarPageObject.moreTools.tagBrowser.click()`, then interact via `DOMOverlayPageObject.dialog.dicomTagBrowser.waitVisible()` / `.seriesSelect.selectOption(i)` / `.seriesSelect.getOptionText(i)`.
## 14. Study validation / not-found / worklist
**Seeds:** `tests/StudyValidation.spec.ts`, `tests/Worklist.spec.ts`
These are the rare specs that use `page.goto(...)` directly instead of `visitStudy()` — because they test error states or non-study pages. `notFoundStudyPageObject` gives you `errorMessage`, `returnMessage`, `studyListLink`.
## 15. SR (Structured Report) hydration
**Seeds:** `tests/SRHydration.spec.ts`, `tests/SRHydrationThenReload.spec.ts`
Same shape as SEG hydration but load via `loadSeriesByModality('SR')`.
## Feature area not listed above? (no existing seed)
Don't add a stub section here for an untested area. When your target isn't listed:
1. **Look for an indirect seed.** Grep `tests/` for the controls or flow you need
(`grep -rn "options-menu" tests/`, a related panel/dialog). An adjacent area's seed
usually still shows how the harness is driven.
2. **If genuinely uncovered, you're *creating* page objects.** Read
[page-objects.md](page-objects.md) → "When the control you need isn't covered yet", then:
- One page object per new control. Dialogs follow `DicomTagBrowserPageObject` (reached
through `DOMOverlayPageObject`); toolbar buttons get a getter on `MainToolbarPageObject`.
- Add a `data-cy` to any control that lacks one.
- **Verify the real effect, not a proxy** — drag and screenshot that the image moved via
`locator: viewportPageObject.grid`, not just that a button gained `data-active`.
**Example — user preferences / hotkeys (no seed today):** open the options menu and User
Preferences dialog (options-menu accessor on `DOMOverlayPageObject` + a `userPreferences`
dialog page object reached through it), set the hotkey, save, then trigger it and confirm the
viewport effect (activate Zoom, drag, screenshot the zoom). Add the Zoom button as a getter on
`MainToolbarPageObject`.
---
## Advanced patterns worth knowing
- **`subscribeToMeasurementAdded`** (`tests/FreehandROI.spec.ts`) — for async "was a measurement actually added?" assertions. Always `try { ... } finally { await measurementAdded.unsubscribe() }`.
- **`attemptAction`** (`tests/3DOnly.spec.ts`) — retry flaky setup (3D render, heavy layout change) without silencing real failures.
- **`addOHIFConfiguration`** (`tests/RTHydrationDisableConfirmation.spec.ts`) — pre-load config overrides before `visitStudy`.
- **`page.evaluate(() => window.services...)`** — used in several SEG/SR specs to set customizations or poke viewport state. Treat as an escape hatch, not a default.
- **`expect.toPass({ timeout })`** — wrap flaky assertions (common for jump-to-measurement tests where rendering settles asynchronously).
@@ -0,0 +1,100 @@
# OHIF Test Utility guide
> This file documents the **stable import rules and conventions** around `tests/utils/`. For the current list of exported helpers and their exact signatures, **read `tests/utils/index.ts` and the files it re-exports** — the barrel is always current; a static table here is not. Utilities get added, renamed, and refactored; the rules below change much more slowly.
## How to discover what's available
1. Open `tests/utils/index.ts`. Every symbol exported from the barrel is importable as `import { foo } from './utils'`.
2. If what you need isn't in the barrel, look in the rest of `tests/utils/` — there are a handful of specialized files (`keyboardUtils.ts`, `assertions.ts`, `download.ts`, …). These need the **deeper import path**; see the rule below.
3. For the actual signature, read the utility's `.ts` file. It's one short function per file in most cases.
4. To see a utility in context, grep `tests/` (`grep -rn visitStudy tests/`) — or open the seed spec for the relevant feature area ([patterns-by-feature.md](patterns-by-feature.md)). Existing specs are the most reliable signature reference because they co-evolve with the API.
Do not guess parameter shapes from memory, and do not treat this file as an API catalog — it intentionally isn't one.
---
## Stable rules
### Barrel vs. deep imports
Two import styles exist. They are not interchangeable.
```ts
// Barrel — anything re-exported from tests/utils/index.ts
import { test, expect, visitStudy, checkForScreenshot, screenShotPaths } from './utils';
// Deep — for files NOT re-exported by the barrel
import { press } from './utils/keyboardUtils';
import { assertNumberOfModalityLoadBadges } from './utils/assertions';
import { downloadAsString } from './utils/download';
```
If a symbol isn't in the barrel, `import { x } from './utils'` **compiles**, resolves `x` to `undefined`, and blows up at the first call site. Confirm by opening `tests/utils/index.ts` for your working revision. At the time of this writing, `press`, `downloadAsString`, and the `assert*` helpers live outside the barrel — but maintainers can move things in or out, so treat `index.ts` as the ground truth rather than this note.
### Never import `test` / `expect` from `@playwright/test`
```ts
// ✅ Correct — gets the fixture-extended runner
import { test, expect } from './utils';
// ❌ Wrong — compiles, but every page-object fixture is silently undefined
import { test, expect } from '@playwright/test';
```
If your test function's destructured arguments (like `viewportPageObject`) are `undefined`, this import is almost always why.
### `visitStudy` — 2000 ms is a convention, not a default
```ts
await visitStudy(page, studyInstanceUID, mode, 2000);
```
The function's own default delay is `0`. Nearly every spec passes `2000` to let the first render settle. The one consistent exception is `mode: 'tmtv'`, where the suite uniformly uses `10000` because PET fusion and SUV calculation add real wall-clock cost before the UI is interactive.
Notably, 3D layouts in `viewer` mode (3DOnly, 3DFourUp, 3DMain, 3DPrimary) and MPR also use `2000` — they're not "heavy" in the `visitStudy` sense. Their stabilization problem is solved at the interaction layer with `attemptAction(() => reduce3DViewportSize(page), 10, 100)`, not by a longer visit delay.
So: pick `10000` when the mode is `tmtv`, `2000` otherwise, and only ramp up if a specific test flakes on first-render assertions. The delay is a good first lever for "not visible" flakes, but it's not a universal upgrade.
### `checkForScreenshot` — use the object form, never screenshot the full app
**This is the direction going forward** The suite is being migrated off *full-app* screenshots — not off screenshots altogether. Screenshots are the correct and required tool whenever what you're verifying is canvas-only raster output with no DOM signal; don't avoid them there. Avoid them only where a faithful DOM/SVG signal exists (e.g. a vector overlay's color via `getSvgAttribute`) or where you'd be capturing the whole app. See SKILL.md → "Screenshot vs. DOM assertion — how to choose". Any new spec must follow the rules below, and any modification to an older spec should bring it in line when reasonable.
- **Object form** (required for all new specs): `checkForScreenshot({ page, screenshotPath, normalizedClip?, ... })`
- **Positional form**: legacy. It still appears in older specs because they haven't been migrated yet. **Do not treat existing positional-form usage as a pattern to copy** — those specs are the thing being moved away from. Do not introduce the positional form in new code.
**Hard rules for new screenshots:**
1. Use the object form.
2. Scope by passing a `locator` — `viewportPageObject.grid` for the whole grid, or a specific viewport pane locator. **Never screenshot the full app.** `normalizedClip` is computed *relative to the locator* (and defaults to the full page when no locator is given), so `{ x: 0, y: 0, width: 1, height: 1 }` alone does not scope anything — reserve `normalizedClip` for clipping to a sub-region of a locator. If you find yourself reaching for `fullPage: true`, stop and pass a locator instead.
Do not tune `maxDiffPixelRatio` or `threshold` to make a screenshot pass — those are intentionally rarely touched and not the right knob for flakes. If a baseline mismatches, regenerate it (`--update-snapshots`) after a human review of the diff, or fix the underlying instability. Check the current signature in `tests/utils/checkForScreenshot.ts` if something looks off.
### `screenShotPaths` — use keys, not raw strings
```ts
await checkForScreenshot({
page,
locator: viewportPageObject.grid,
screenshotPath: screenShotPaths.length.lengthDisplayedCorrectly,
});
```
The full tree of categories lives in `tests/utils/screenShotPaths.ts`. When you need a new baseline, **add the key there and reference it by name** rather than typing a raw path. A typo in a key becomes a compile error instead of a silent mismatch, and other tests become discoverable through the object.
### Object-param convention
Many OHIF test utilities take a single **object argument** rather than positional arguments — notably `press({ page, key, nTimes? })`, the `simulate*` helpers, and the `assert*` helpers. If a call looks like it should work but throws "cannot read properties of undefined," check whether you're passing positional args to something that expects `{ page, ... }`.
Read the one-line signature at the top of the utility's source file before calling it — it's faster than guessing, and it's always right.
---
## Utility shapes worth flagging
Most utilities are obvious once you read the source; these earn a mention:
- **`waitForViewportRenderCycle(page, options?)`** — preferred replacement for `page.waitForTimeout(...)` after any viewport-mutating action (hydration confirm, layout change, segmentation add, series load, etc.). Start it **before** the action, await it after — it captures the `needsRender → rendered` transition the action triggers. Use `waitForViewportsRendered(page)` (the second-half-only variant) when the render is already in flight before you can attach a watcher. Source: `tests/utils/waitForViewportsRendered.ts`. Seed: `tests/SEGHydrationFromMPR.spec.ts`. The "Wait for renders, don't sleep" section in [SKILL.md](../SKILL.md) covers the idiom in full.
- **`subscribeToMeasurementAdded(page)`** — returns `{ waitFired(timeout?), unsubscribe() }`. Use in freehand/livewire/spline specs to assert the event fired. Always wrap in `try { ... } finally { await sub.unsubscribe() }` so a failing assertion doesn't leak the listener across tests.
- **`attemptAction(action, attempts?, delay?)`** — retries a flaky async action without masking real failures. Mainly used to stabilize 3D scenes (`attemptAction(() => reduce3DViewportSize(page), 10, 100)`).
For everything else, the pattern is: find a spec that uses it (see [patterns-by-feature.md](patterns-by-feature.md)), copy the shape, adapt.
+47 -15
View File
@@ -8,7 +8,7 @@ orbs:
defaults: &defaults
docker:
- image: cimg/node:24.0.0
- image: cimg/node:24.15.0
environment:
TERM: xterm
QUICK_BUILD: true
@@ -37,7 +37,7 @@ jobs:
- checkout
- run:
name: Install Dependencies
command: pnpm install --no-frozen-lockfile
command: pnpm install --frozen-lockfile
# RUN TESTS
- run:
name: 'JavaScript Test Suite'
@@ -78,7 +78,7 @@ jobs:
- install_pnpm
- run:
name: Install Dependencies
command: pnpm install --no-frozen-lockfile
command: pnpm install --frozen-lockfile
# Build & Test
- run:
name: 'Perform the versioning before build'
@@ -170,7 +170,13 @@ jobs:
git config --global user.name "ohif-bot"
- run:
name: Authenticate with NPM registry
command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/repo/.npmrc
# Write the auth token to npm's per-user config (~/.npmrc), not the
# repo root. publish-package.mjs chdir's into each package dir to run
# `npm publish`, and npm only reads the project .npmrc from that dir
# plus the user .npmrc from $HOME -- it never sees ~/repo/.npmrc, so a
# root-level token yields ENEEDAUTH. Using ~/.npmrc also avoids
# clobbering the committed workspace-config .npmrc (node-linker=hoisted).
command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc
- run:
name: build half of the packages (to avoid out of memory in circleci)
command: |
@@ -191,7 +197,7 @@ jobs:
at: ~/repo
- run:
name: Install Dependencies
command: pnpm install --no-frozen-lockfile
command: pnpm install --frozen-lockfile
- run:
name: Avoid hosts unknown for github
command: |
@@ -202,7 +208,13 @@ jobs:
git config --global user.name "ohif-bot"
- run:
name: Authenticate with NPM registry
command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/repo/.npmrc
# Write the auth token to npm's per-user config (~/.npmrc), not the
# repo root. publish-package.mjs chdir's into each package dir to run
# `npm publish`, and npm only reads the project .npmrc from that dir
# plus the user .npmrc from $HOME -- it never sees ~/repo/.npmrc, so a
# root-level token yields ENEEDAUTH. Using ~/.npmrc also avoids
# clobbering the committed workspace-config .npmrc (node-linker=hoisted).
command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc
- run:
name: build half of the packages (to avoid out of memory in circleci)
command: |
@@ -224,8 +236,14 @@ jobs:
command: |
node ./publish-version.mjs
- run:
name: Again set the NPM registry (was deleted in the version script)
command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/repo/.npmrc
name: Re-assert the NPM auth token before publishing
# Write the auth token to npm's per-user config (~/.npmrc), not the
# repo root. publish-package.mjs chdir's into each package dir to run
# `npm publish`, and npm only reads the project .npmrc from that dir
# plus the user .npmrc from $HOME -- it never sees ~/repo/.npmrc, so a
# root-level token yields ENEEDAUTH. Using ~/.npmrc also avoids
# clobbering the committed workspace-config .npmrc (node-linker=hoisted).
command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc
- run:
name: publish package dist
command: |
@@ -251,8 +269,11 @@ jobs:
if [[ ! -e version.txt ]]; then
exit 0
else
# Remove npm config
rm -f ./.npmrc
# Restore the committed .npmrc (pnpm workspace config such as
# node-linker=hoisted). NPM_PUBLISH overwrote it with a publish
# auth token, but the Dockerfile COPYs .npmrc for the in-image
# pnpm install, so it needs the config file present and token-free.
git checkout -- .npmrc
# Set our version number using vars
export IMAGE_VERSION=$(cat version.txt)
export IMAGE_VERSION_FULL=v$IMAGE_VERSION
@@ -285,8 +306,11 @@ jobs:
if [[ ! -e version.txt ]]; then
exit 0
else
# Remove npm config
rm -f ./.npmrc
# Restore the committed .npmrc (pnpm workspace config such as
# node-linker=hoisted). NPM_PUBLISH overwrote it with a publish
# auth token, but the Dockerfile COPYs .npmrc for the in-image
# pnpm install, so it needs the config file present and token-free.
git checkout -- .npmrc
# Set our version number using vars
export IMAGE_VERSION=$(cat version.txt)
export IMAGE_VERSION_FULL=v$IMAGE_VERSION
@@ -323,7 +347,11 @@ jobs:
exit 0
else
echo "Building and pushing Docker image from the master branch (beta releases)"
rm -f ./.npmrc
# Restore the committed .npmrc (pnpm workspace config such as
# node-linker=hoisted). NPM_PUBLISH overwrote it with a publish
# auth token, but the Dockerfile COPYs .npmrc for the in-image
# pnpm install, so it needs the config file present and token-free.
git checkout -- .npmrc
# Set our version number using vars
export IMAGE_VERSION=$(cat version.txt)
@@ -357,7 +385,11 @@ jobs:
exit 0
else
echo "Building and pushing ARM64 Docker image from the master branch (beta releases)"
rm -f ./.npmrc
# Restore the committed .npmrc (pnpm workspace config such as
# node-linker=hoisted). NPM_PUBLISH overwrote it with a publish
# auth token, but the Dockerfile COPYs .npmrc for the in-image
# pnpm install, so it needs the config file present and token-free.
git checkout -- .npmrc
# Set our version number using vars
export IMAGE_VERSION=$(cat version.txt)
export IMAGE_VERSION_FULL=v$IMAGE_VERSION
@@ -389,7 +421,7 @@ jobs:
-o Acquire::Retries=3 \
-o Acquire::http::Timeout=20 \
-o Acquire::https::Timeout=20
sudo apt-get install -y xvfb libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 libxtst6
sudo apt-get install -y xvfb libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libnss3 libxss1 libasound2t64 libxtst6
- run:
name: Start Xvfb
command: Xvfb :99 -screen 0 1920x1080x24 &
+15 -4
View File
@@ -27,7 +27,7 @@ jobs:
- uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: 24
node-version: 24.15.0
cache: pnpm
- name: Configure git for private repos
@@ -36,6 +36,13 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install dependencies
# Internal @ohif/* deps are workspace:* in the committed manifests and the
# lockfile records them as links, so pnpm-lock.yaml stays in sync across
# version bumps and a frozen install passes. Frozen is the right choice
# for a deploy job: it fails fast if a PR ever changed a real dependency
# without committing the lockfile update, instead of silently reconciling.
# (Exact versions appear only in published tarballs, where pnpm publish
# rewrites workspace:* at pack time -- not publish-version.mjs.)
run: pnpm install --frozen-lockfile
# Removed Playwright tests and coverage generation steps
@@ -105,9 +112,13 @@ jobs:
run: pnpm --filter ohif-docs run build
- name: Deploy to Netlify
run: |
cd platform/docs
npx netlify-cli deploy --dir=./build --prod
# The docs are already built by the "Build docs" step above, so pass
# --no-build: `netlify deploy` runs the build command by default, which
# would otherwise pick up the repo-root netlify.toml (configured for the
# main viewer app) and build the wrong project. --dir is resolved
# relative to the repo root (the netlify.toml base), not the cwd, so it
# must be the full path to the prebuilt docs output.
run: npx netlify-cli deploy --dir=platform/docs/build --prod --no-build
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
+25 -14
View File
@@ -23,23 +23,15 @@ concurrency:
jobs:
playwright-tests:
timeout-minutes: 120
runs-on: self-hosted
runs-on: [self-hosted, nashua]
strategy:
fail-fast: false
matrix:
node-version: [24]
node-version: [24.15.0]
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false
# Self-hosted runner hygiene: wipe any stale/corrupted pnpm self-install
# before action-setup reinstalls it. A prior `cache: pnpm` restore left a
# pnpm install missing dist/worker.js, breaking `pnpm install`. Plain shell
# so it runs even when pnpm itself is broken. Cheap: action-setup reinstalls.
- name: Reset stale pnpm self-install
shell: bash
run: rm -rf "$HOME/setup-pnpm"
- uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: ${{ matrix.node-version }}
@@ -47,6 +39,19 @@ jobs:
# pnpm store on local disk. The Actions cache doesn't preserve the
# pnpm self-install's links faithfully, dropping pnpm/dist/worker.js
# and breaking `pnpm install` with MODULE_NOT_FOUND.
# Install pnpm via Corepack instead of pnpm/action-setup. The action's
# self-installer is a JS action run under the runner's bundled
# externals/node{version} and derives the `npm` path from that runtime — which
# on this self-hosted runner is corrupted (Cannot find module
# '../lib/cli.js'), so it dies regardless of `standalone:true`. Corepack
# ships inside the Node that setup-node just installed, reads the pinned
# `packageManager` (pnpm@11.5.2) from package.json, and fetches pnpm via
# Node's own https — it never invokes the npm CLI.
- name: Enable Corepack (pnpm)
shell: bash
run: |
corepack enable
corepack prepare --activate
# ── CS3D integration: detect label and ref type ──────────────────────
- name: Check for CS3D integration label
@@ -119,11 +124,16 @@ jobs:
# ── Common: run tests ───────────────────────────────────────────────
- name: Install Playwright browsers
run: npx playwright install
# Only chromium is used (see playwright.config.ts and tests/globalSetup.ts);
# firefox/webkit projects are commented out. Scoping the install to chromium
# avoids downloading + dep-validating browsers we never launch (the WebKit
# validation is what surfaces the "missing libwoff1/libflite1/..." error on
# hosts without those libs).
run: npx playwright install chromium
- name: Run Playwright tests
run: |
export NODE_OPTIONS="--max_old_space_size=10192"
pnpm run test:e2e:coverage
bash .scripts/ci/with-nashua-lock.sh pnpm run test:e2e:coverage
# ── Common: collect test results and coverage ───────────────────────
- name: Create directory of test results
@@ -161,7 +171,8 @@ jobs:
fi
node .scripts/log-build-context.mjs
env:
BUILD_TYPE: ${{ steps.cs3d-ref.outputs.type == 'branch' && 'ohif-downstream' || 'ohif-upstream' }}
BUILD_TYPE:
${{ steps.cs3d-ref.outputs.type == 'branch' && 'ohif-downstream' || 'ohif-upstream' }}
CS3D_REF_TYPE: ${{ steps.cs3d-ref.outputs.type }}
- name: Build OHIF viewer (CS3D preview)
@@ -203,7 +214,7 @@ jobs:
# ── Separate job: block merge when using a CS3D branch ─────────────
cs3d-branch-merge-guard:
name: "CS3D Branch Merge Guard"
name: 'CS3D Branch Merge Guard'
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
-2
View File
@@ -61,8 +61,6 @@ tests/playwright-report/
/blob-report/
/playwright/.cache/
**/.claude/settings.local.json
# cornerstone3D local linking
libs/
+1 -1
View File
@@ -1 +1 @@
24
24.15.0
+54
View File
@@ -0,0 +1,54 @@
#!/usr/bin/env bash
#
# Run a command while holding the nashua Playwright mutex.
#
# Only one Playwright run may execute at a time on the shared nashua self-hosted
# runner — across THIS repo (OHIF) AND the cornerstone3D repo. GitHub's
# `concurrency:` is scoped per-repository and cannot coordinate across the two
# orgs, so the mutex lives on the box's filesystem.
#
# This is OHIF's own copy (the script can't be shared across separate repos). It
# MUST use the SAME lock path as cornerstone3D's copy (NASHUA_LOCK_FILE default
# below) — if the paths differ, the mutex silently does nothing.
#
# flock holds the lock via fd 9 and it releases automatically when the wrapped
# command exits — including on job cancel / timeout / SIGKILL — so there are no
# stale locks to clean up.
#
# Usage: .scripts/ci/with-nashua-lock.sh <command> [args...]
# Strict mode: -e abort on any unhandled command failure, -u treat use of an
# unset variable as an error, -o pipefail make a pipeline fail if ANY stage
# fails (not just the last). Catches mistakes early instead of pressing on.
set -euo pipefail
LOCK="${NASHUA_LOCK_FILE:-/var/tmp/nashua-playwright.lock}" # MUST match cornerstone3D's copy
LOCK_WAIT="${NASHUA_LOCK_WAIT:-5400}" # max seconds to wait
# Guard: a command to wrap is required. With no arguments there is nothing to
# run, so print usage and exit instead of silently grabbing and releasing the
# lock for no reason (which would mask a mis-wired workflow step).
if [ "$#" -eq 0 ]; then
echo "usage: $0 <command> [args...]" >&2
exit 2
fi
# Open the lock file on fd 9 (read-write, create if missing, never truncate).
exec 9<>"$LOCK" || { echo "::error::cannot open lock file $LOCK"; exit 1; }
# Try instantly; if busy, report who holds it, then block up to LOCK_WAIT.
if ! flock -n 9; then
echo "nashua Playwright runner busy — held by: $(cat "${LOCK}.info" 2>/dev/null || echo unknown). Waiting up to ${LOCK_WAIT}s…"
if ! flock -w "$LOCK_WAIT" 9; then
echo "::error::Timed out after ${LOCK_WAIT}s waiting for the nashua Playwright lock"
exit 1
fi
fi
# Record the current holder for other jobs' "held by" message (best-effort).
echo "${GITHUB_REPOSITORY:-local}#${GITHUB_RUN_ID:-0} @ $(date -u +%FT%TZ 2>/dev/null || true)" > "${LOCK}.info" 2>/dev/null || true
echo "✅ Acquired nashua Playwright lock ($LOCK); running: $*"
# Replace the shell with the command. fd 9 is inherited (not close-on-exec), so
# the lock is held for the whole command and released when it exits.
exec "$@"
+4
View File
@@ -176,6 +176,10 @@ Always prioritrize pub sub, by calling a services subscribe over useEffects as i
### Never modify core architecture
Do not modify the core and always find a way to implement the solution via the extensions and modes, only modify core as a last resort if all other fail or there's an architectural constraint.
## Skills
The `ohif-test-agent` skill (Playwright E2E test guidance) lives at `.agents/skills/ohif-test-agent/`.
## Configuration
### Plugin Configuration
+10 -5
View File
@@ -23,7 +23,7 @@
# Stage 1: Build the application
# docker build -t ohif/viewer:latest .
# Copy Files
FROM node:24-slim as builder
FROM node:24.15.0-slim as builder
RUN apt-get update && apt-get install -y --no-install-recommends build-essential python3 \
&& rm -rf /var/lib/apt/lists/*
@@ -34,11 +34,16 @@ RUN mkdir /usr/src/app
WORKDIR /usr/src/app
ENV PATH=/usr/src/app/node_modules/.bin:$PATH
# Copy package manifests for install caching
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc ./
# Copy package manifests for install caching. preinstall.js is included because
# the root package.json's "preinstall" lifecycle script (node preinstall.js)
# runs during `pnpm install` below -- before the full source is copied -- so the
# script file must already be present or install fails with MODULE_NOT_FOUND.
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc preinstall.js ./
COPY --parents ./extensions/*/package.json ./modes/*/package.json ./platform/*/package.json ./
# Run the install before copying the rest of the files
# Run the install before copying the rest of the files.
# Keep --no-frozen-lockfile here (unlike CI): .dockerignore excludes
# platform/docs, so the lockfile's docs importer has no manifest in the build
# context and a frozen install would fail. pnpm reconciles (drops docs) instead.
RUN pnpm install --no-frozen-lockfile
# Copy the local directory
COPY --link --exclude=pnpm-lock.yaml --exclude=package.json --exclude=Dockerfile . .
@@ -1,6 +1,6 @@
{
"name": "@ohif/extension-cornerstone-dicom-pmap",
"version": "3.13.0-beta.90",
"version": "3.13.0-beta.102",
"description": "DICOM Parametric Map read workflow",
"author": "OHIF",
"license": "MIT",
@@ -28,10 +28,10 @@
"start": "pnpm run dev"
},
"peerDependencies": {
"@ohif/core": "3.13.0-beta.90",
"@ohif/extension-cornerstone": "3.13.0-beta.90",
"@ohif/extension-default": "3.13.0-beta.90",
"@ohif/i18n": "3.13.0-beta.90",
"@ohif/core": "workspace:*",
"@ohif/extension-cornerstone": "workspace:*",
"@ohif/extension-default": "workspace:*",
"@ohif/i18n": "workspace:*",
"prop-types": "15.8.1",
"react": "18.3.1",
"react-dom": "18.3.1",
+5 -5
View File
@@ -1,6 +1,6 @@
{
"name": "@ohif/extension-cornerstone-dicom-rt",
"version": "3.13.0-beta.90",
"version": "3.13.0-beta.102",
"description": "DICOM RT read workflow",
"author": "OHIF",
"license": "MIT",
@@ -28,10 +28,10 @@
"start": "pnpm run dev"
},
"peerDependencies": {
"@ohif/core": "3.13.0-beta.90",
"@ohif/extension-cornerstone": "3.13.0-beta.90",
"@ohif/extension-default": "3.13.0-beta.90",
"@ohif/i18n": "3.13.0-beta.90",
"@ohif/core": "workspace:*",
"@ohif/extension-cornerstone": "workspace:*",
"@ohif/extension-default": "workspace:*",
"@ohif/i18n": "workspace:*",
"prop-types": "15.8.1",
"react": "18.3.1",
"react-dom": "18.3.1",
@@ -1,6 +1,6 @@
{
"name": "@ohif/extension-cornerstone-dicom-seg",
"version": "3.13.0-beta.90",
"version": "3.13.0-beta.102",
"description": "DICOM SEG read workflow",
"author": "OHIF",
"license": "MIT",
@@ -28,10 +28,10 @@
"start": "pnpm run dev"
},
"peerDependencies": {
"@ohif/core": "3.13.0-beta.90",
"@ohif/extension-cornerstone": "3.13.0-beta.90",
"@ohif/extension-default": "3.13.0-beta.90",
"@ohif/i18n": "3.13.0-beta.90",
"@ohif/core": "workspace:*",
"@ohif/extension-cornerstone": "workspace:*",
"@ohif/extension-default": "workspace:*",
"@ohif/i18n": "workspace:*",
"prop-types": "15.8.1",
"react": "18.3.1",
"react-dom": "18.3.1",
+4 -4
View File
@@ -1,6 +1,6 @@
{
"name": "@ohif/extension-cornerstone-dicom-sr",
"version": "3.13.0-beta.90",
"version": "3.13.0-beta.102",
"description": "OHIF extension for an SR Cornerstone Viewport",
"author": "OHIF",
"license": "MIT",
@@ -29,9 +29,9 @@
"test:unit:ci": "jest --ci --runInBand --collectCoverage --passWithNoTests"
},
"peerDependencies": {
"@ohif/core": "3.13.0-beta.90",
"@ohif/extension-cornerstone": "3.13.0-beta.90",
"@ohif/ui": "3.13.0-beta.90",
"@ohif/core": "workspace:*",
"@ohif/extension-cornerstone": "workspace:*",
"@ohif/ui": "workspace:*",
"dcmjs": "0.49.4",
"dicom-parser": "1.8.21",
"hammerjs": "2.0.8",
@@ -1,6 +1,6 @@
{
"name": "@ohif/extension-cornerstone-dynamic-volume",
"version": "3.13.0-beta.90",
"version": "3.13.0-beta.102",
"description": "OHIF extension for 4D volumes data",
"author": "OHIF",
"license": "MIT",
@@ -32,11 +32,11 @@
"test:unit:ci": "jest --ci --runInBand --collectCoverage --passWithNoTests"
},
"peerDependencies": {
"@ohif/core": "3.13.0-beta.90",
"@ohif/extension-cornerstone": "3.13.0-beta.90",
"@ohif/extension-default": "3.13.0-beta.90",
"@ohif/i18n": "3.13.0-beta.90",
"@ohif/ui": "3.13.0-beta.90",
"@ohif/core": "workspace:*",
"@ohif/extension-cornerstone": "workspace:*",
"@ohif/extension-default": "workspace:*",
"@ohif/i18n": "workspace:*",
"@ohif/ui": "workspace:*",
"dcmjs": "0.49.4",
"dicom-parser": "1.8.21",
"hammerjs": "2.0.8",
+4 -4
View File
@@ -1,6 +1,6 @@
{
"name": "@ohif/extension-cornerstone",
"version": "3.13.0-beta.90",
"version": "3.13.0-beta.102",
"description": "OHIF extension for Cornerstone",
"author": "OHIF",
"license": "MIT",
@@ -39,9 +39,9 @@
"@cornerstonejs/codec-openjpeg": "1.3.0",
"@cornerstonejs/codec-openjph": "2.4.7",
"@cornerstonejs/dicom-image-loader": "5.0.2",
"@ohif/core": "3.13.0-beta.90",
"@ohif/extension-default": "3.13.0-beta.90",
"@ohif/ui": "3.13.0-beta.90",
"@ohif/core": "workspace:*",
"@ohif/extension-default": "workspace:*",
"@ohif/ui": "workspace:*",
"dcmjs": "0.49.4",
"dicom-parser": "1.8.21",
"hammerjs": "2.0.8",
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@ohif/extension-default",
"version": "3.13.0-beta.90",
"version": "3.13.0-beta.102",
"description": "Common/default features and functionality for basic image viewing",
"author": "OHIF Core Team",
"license": "MIT",
@@ -29,8 +29,8 @@
"test:unit:ci": "jest --ci --runInBand --collectCoverage --passWithNoTests"
},
"peerDependencies": {
"@ohif/core": "3.13.0-beta.90",
"@ohif/i18n": "3.13.0-beta.90",
"@ohif/core": "workspace:*",
"@ohif/i18n": "workspace:*",
"dcmjs": "0.49.4",
"dicomweb-client": "0.10.4",
"prop-types": "15.8.1",
@@ -12,7 +12,7 @@ function ColorPickerDialog({ value, hide, onSave }) {
};
return (
<div>
<div data-cy="color-picker-dialog">
<ChromePicker
color={color}
onChange={handleChange}
@@ -21,8 +21,14 @@ function ColorPickerDialog({ value, hide, onSave }) {
/>
<FooterAction>
<FooterAction.Right>
<FooterAction.Secondary onClick={hide}>Cancel</FooterAction.Secondary>
<FooterAction.Secondary
dataCY="color-picker-cancel-btn"
onClick={hide}
>
Cancel
</FooterAction.Secondary>
<FooterAction.Primary
dataCY="color-picker-save-btn"
onClick={() => {
hide();
onSave(color);
+5 -5
View File
@@ -1,6 +1,6 @@
{
"name": "@ohif/extension-dicom-microscopy",
"version": "3.13.0-beta.90",
"version": "3.13.0-beta.102",
"description": "OHIF extension for DICOM microscopy",
"author": "Bill Wallace, md-prog",
"license": "MIT",
@@ -25,10 +25,10 @@
"start": "pnpm run dev"
},
"peerDependencies": {
"@ohif/core": "3.13.0-beta.90",
"@ohif/extension-default": "3.13.0-beta.90",
"@ohif/i18n": "3.13.0-beta.90",
"@ohif/ui": "3.13.0-beta.90",
"@ohif/core": "workspace:*",
"@ohif/extension-default": "workspace:*",
"@ohif/i18n": "workspace:*",
"@ohif/ui": "workspace:*",
"prop-types": "15.8.1",
"react": "18.3.1",
"react-dom": "18.3.1",
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@ohif/extension-dicom-pdf",
"version": "3.13.0-beta.90",
"version": "3.13.0-beta.102",
"description": "OHIF extension for PDF display",
"author": "OHIF",
"license": "MIT",
@@ -28,8 +28,8 @@
"test:unit:ci": "jest --ci --runInBand --collectCoverage --passWithNoTests"
},
"peerDependencies": {
"@ohif/core": "3.13.0-beta.90",
"@ohif/ui": "3.13.0-beta.90",
"@ohif/core": "workspace:*",
"@ohif/ui": "workspace:*",
"dcmjs": "0.49.4",
"dicom-parser": "1.8.21",
"hammerjs": "2.0.8",
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@ohif/extension-dicom-video",
"version": "3.13.0-beta.90",
"version": "3.13.0-beta.102",
"description": "OHIF extension for video display",
"author": "OHIF",
"license": "MIT",
@@ -28,8 +28,8 @@
"test:unit:ci": "jest --ci --runInBand --collectCoverage --passWithNoTests"
},
"peerDependencies": {
"@ohif/core": "3.13.0-beta.90",
"@ohif/ui": "3.13.0-beta.90",
"@ohif/core": "workspace:*",
"@ohif/ui": "workspace:*",
"dcmjs": "0.49.4",
"dicom-parser": "1.8.21",
"hammerjs": "2.0.8",
+6 -6
View File
@@ -1,6 +1,6 @@
{
"name": "@ohif/extension-measurement-tracking",
"version": "3.13.0-beta.90",
"version": "3.13.0-beta.102",
"description": "Tracking features and functionality for basic image viewing",
"author": "OHIF Core Team",
"license": "MIT",
@@ -29,10 +29,10 @@
"peerDependencies": {
"@cornerstonejs/core": "5.0.2",
"@cornerstonejs/tools": "5.0.2",
"@ohif/core": "3.13.0-beta.90",
"@ohif/extension-cornerstone-dicom-sr": "3.13.0-beta.90",
"@ohif/extension-default": "3.13.0-beta.90",
"@ohif/ui": "3.13.0-beta.90",
"@ohif/core": "workspace:*",
"@ohif/extension-cornerstone-dicom-sr": "workspace:*",
"@ohif/extension-default": "workspace:*",
"@ohif/ui": "workspace:*",
"classnames": "2.5.1",
"dcmjs": "0.49.4",
"lodash.debounce": "4.0.8",
@@ -43,7 +43,7 @@
},
"dependencies": {
"@babel/runtime": "7.29.7",
"@ohif/ui": "3.13.0-beta.90",
"@ohif/ui": "workspace:*",
"@xstate/react": "3.2.2",
"xstate": "4.38.3"
},
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@ohif/extension-test",
"version": "3.13.0-beta.90",
"version": "3.13.0-beta.102",
"description": "OHIF extension used inside e2e testing",
"author": "OHIF",
"license": "MIT",
@@ -28,8 +28,8 @@
"test:unit:ci": "jest --ci --runInBand --collectCoverage --passWithNoTests"
},
"peerDependencies": {
"@ohif/core": "3.13.0-beta.90",
"@ohif/ui": "3.13.0-beta.90",
"@ohif/core": "workspace:*",
"@ohif/ui": "workspace:*",
"dcmjs": "0.49.4",
"dicom-parser": "1.8.21",
"hammerjs": "2.0.8",
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@ohif/extension-tmtv",
"version": "3.13.0-beta.90",
"version": "3.13.0-beta.102",
"description": "OHIF extension for Total Metabolic Tumor Volume",
"author": "OHIF",
"license": "MIT",
@@ -28,8 +28,8 @@
"test:unit:ci": "jest --ci --runInBand --collectCoverage --passWithNoTests"
},
"peerDependencies": {
"@ohif/core": "3.13.0-beta.90",
"@ohif/ui": "3.13.0-beta.90",
"@ohif/core": "workspace:*",
"@ohif/ui": "workspace:*",
"dcmjs": "0.49.4",
"dicom-parser": "1.8.21",
"hammerjs": "2.0.8",
+6 -6
View File
@@ -1,6 +1,6 @@
{
"name": "@ohif/extension-ultrasound-pleura-bline",
"version": "3.13.0-beta.90",
"version": "3.13.0-beta.102",
"description": "",
"author": "Rodrigo Basilio",
"license": "MIT",
@@ -38,11 +38,11 @@
"@babel/runtime": "7.29.7",
"@cornerstonejs/core": "5.0.2",
"@cornerstonejs/tools": "5.0.2",
"@ohif/core": "3.13.0-beta.90",
"@ohif/extension-cornerstone": "3.13.0-beta.90",
"@ohif/extension-default": "3.13.0-beta.90",
"@ohif/i18n": "3.13.0-beta.90",
"@ohif/ui-next": "3.13.0-beta.90"
"@ohif/core": "workspace:*",
"@ohif/extension-cornerstone": "workspace:*",
"@ohif/extension-default": "workspace:*",
"@ohif/i18n": "workspace:*",
"@ohif/ui-next": "workspace:*"
},
"devDependencies": {
"@babel/core": "7.29.7",
+7 -7
View File
@@ -1,6 +1,6 @@
{
"name": "@ohif/mode-basic-dev-mode",
"version": "3.13.0-beta.90",
"version": "3.13.0-beta.102",
"description": "Basic OHIF Viewer Using Cornerstone",
"author": "OHIF",
"license": "MIT",
@@ -29,12 +29,12 @@
"test:unit:ci": "jest --ci --runInBand --collectCoverage --passWithNoTests"
},
"peerDependencies": {
"@ohif/core": "3.13.0-beta.90",
"@ohif/extension-cornerstone": "3.13.0-beta.90",
"@ohif/extension-cornerstone-dicom-sr": "3.13.0-beta.90",
"@ohif/extension-default": "3.13.0-beta.90",
"@ohif/extension-dicom-pdf": "3.13.0-beta.90",
"@ohif/extension-dicom-video": "3.13.0-beta.90"
"@ohif/core": "workspace:*",
"@ohif/extension-cornerstone": "workspace:*",
"@ohif/extension-cornerstone-dicom-sr": "workspace:*",
"@ohif/extension-default": "workspace:*",
"@ohif/extension-dicom-pdf": "workspace:*",
"@ohif/extension-dicom-video": "workspace:*"
},
"dependencies": {
"@babel/runtime": "7.29.7",
+9 -9
View File
@@ -1,6 +1,6 @@
{
"name": "@ohif/mode-test",
"version": "3.13.0-beta.90",
"version": "3.13.0-beta.102",
"description": "Basic mode for testing",
"author": "OHIF",
"license": "MIT",
@@ -29,14 +29,14 @@
"test:unit:ci": "jest --ci --runInBand --collectCoverage --passWithNoTests"
},
"peerDependencies": {
"@ohif/core": "3.13.0-beta.90",
"@ohif/extension-cornerstone": "3.13.0-beta.90",
"@ohif/extension-cornerstone-dicom-sr": "3.13.0-beta.90",
"@ohif/extension-default": "3.13.0-beta.90",
"@ohif/extension-dicom-pdf": "3.13.0-beta.90",
"@ohif/extension-dicom-video": "3.13.0-beta.90",
"@ohif/extension-measurement-tracking": "3.13.0-beta.90",
"@ohif/extension-test": "3.13.0-beta.90"
"@ohif/core": "workspace:*",
"@ohif/extension-cornerstone": "workspace:*",
"@ohif/extension-cornerstone-dicom-sr": "workspace:*",
"@ohif/extension-default": "workspace:*",
"@ohif/extension-dicom-pdf": "workspace:*",
"@ohif/extension-dicom-video": "workspace:*",
"@ohif/extension-measurement-tracking": "workspace:*",
"@ohif/extension-test": "workspace:*"
},
"dependencies": {
"@babel/runtime": "7.29.7",
+9 -9
View File
@@ -1,6 +1,6 @@
{
"name": "@ohif/mode-basic",
"version": "3.13.0-beta.90",
"version": "3.13.0-beta.102",
"description": "A basic mode used to build other modes on top of",
"author": "OHIF Contributors",
"license": "MIT",
@@ -25,14 +25,14 @@
"test:unit:ci": "jest --ci --runInBand --collectCoverage --passWithNoTests"
},
"peerDependencies": {
"@ohif/core": "3.13.0-beta.90",
"@ohif/extension-cornerstone": "3.13.0-beta.90",
"@ohif/extension-cornerstone-dicom-rt": "3.13.0-beta.90",
"@ohif/extension-cornerstone-dicom-seg": "3.13.0-beta.90",
"@ohif/extension-cornerstone-dicom-sr": "3.13.0-beta.90",
"@ohif/extension-default": "3.13.0-beta.90",
"@ohif/extension-dicom-pdf": "3.13.0-beta.90",
"@ohif/extension-dicom-video": "3.13.0-beta.90"
"@ohif/core": "workspace:*",
"@ohif/extension-cornerstone": "workspace:*",
"@ohif/extension-cornerstone-dicom-rt": "workspace:*",
"@ohif/extension-cornerstone-dicom-seg": "workspace:*",
"@ohif/extension-cornerstone-dicom-sr": "workspace:*",
"@ohif/extension-default": "workspace:*",
"@ohif/extension-dicom-pdf": "workspace:*",
"@ohif/extension-dicom-video": "workspace:*"
},
"dependencies": {
"@babel/runtime": "7.29.7"
+11 -11
View File
@@ -1,6 +1,6 @@
{
"name": "@ohif/mode-longitudinal",
"version": "3.13.0-beta.90",
"version": "3.13.0-beta.102",
"description": "Longitudinal Workflow",
"author": "OHIF",
"license": "MIT",
@@ -29,16 +29,16 @@
"test:unit:ci": "jest --ci --runInBand --collectCoverage --passWithNoTests"
},
"peerDependencies": {
"@ohif/core": "3.13.0-beta.90",
"@ohif/extension-cornerstone": "3.13.0-beta.90",
"@ohif/extension-cornerstone-dicom-rt": "3.13.0-beta.90",
"@ohif/extension-cornerstone-dicom-seg": "3.13.0-beta.90",
"@ohif/extension-cornerstone-dicom-sr": "3.13.0-beta.90",
"@ohif/extension-default": "3.13.0-beta.90",
"@ohif/extension-dicom-pdf": "3.13.0-beta.90",
"@ohif/extension-dicom-video": "3.13.0-beta.90",
"@ohif/extension-measurement-tracking": "3.13.0-beta.90",
"@ohif/mode-basic": "3.13.0-beta.90"
"@ohif/core": "workspace:*",
"@ohif/extension-cornerstone": "workspace:*",
"@ohif/extension-cornerstone-dicom-rt": "workspace:*",
"@ohif/extension-cornerstone-dicom-seg": "workspace:*",
"@ohif/extension-cornerstone-dicom-sr": "workspace:*",
"@ohif/extension-default": "workspace:*",
"@ohif/extension-dicom-pdf": "workspace:*",
"@ohif/extension-dicom-video": "workspace:*",
"@ohif/extension-measurement-tracking": "workspace:*",
"@ohif/mode-basic": "workspace:*"
},
"dependencies": {
"@babel/runtime": "7.29.7",
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@ohif/mode-microscopy",
"version": "3.13.0-beta.90",
"version": "3.13.0-beta.102",
"description": "OHIF mode for DICOM microscopy",
"author": "OHIF",
"license": "MIT",
@@ -30,8 +30,8 @@
"test:unit:ci": "jest --ci --runInBand --collectCoverage --passWithNoTests"
},
"peerDependencies": {
"@ohif/core": "3.13.0-beta.90",
"@ohif/extension-dicom-microscopy": "3.13.0-beta.90"
"@ohif/core": "workspace:*",
"@ohif/extension-dicom-microscopy": "workspace:*"
},
"dependencies": {
"@babel/runtime": "7.29.7",
+7 -7
View File
@@ -1,6 +1,6 @@
{
"name": "@ohif/mode-preclinical-4d",
"version": "3.13.0-beta.90",
"version": "3.13.0-beta.102",
"description": "4D Workflow",
"author": "OHIF",
"license": "MIT",
@@ -28,12 +28,12 @@
"test:unit:ci": "jest --ci --runInBand --collectCoverage --passWithNoTests"
},
"peerDependencies": {
"@ohif/core": "3.13.0-beta.90",
"@ohif/extension-cornerstone": "3.13.0-beta.90",
"@ohif/extension-cornerstone-dicom-seg": "3.13.0-beta.90",
"@ohif/extension-cornerstone-dynamic-volume": "3.13.0-beta.90",
"@ohif/extension-default": "3.13.0-beta.90",
"@ohif/extension-tmtv": "3.13.0-beta.90"
"@ohif/core": "workspace:*",
"@ohif/extension-cornerstone": "workspace:*",
"@ohif/extension-cornerstone-dicom-seg": "workspace:*",
"@ohif/extension-cornerstone-dynamic-volume": "workspace:*",
"@ohif/extension-default": "workspace:*",
"@ohif/extension-tmtv": "workspace:*"
},
"dependencies": {
"@babel/runtime": "7.29.7"
+10 -10
View File
@@ -1,6 +1,6 @@
{
"name": "@ohif/mode-segmentation",
"version": "3.13.0-beta.90",
"version": "3.13.0-beta.102",
"description": "OHIF segmentation mode which enables labelmap segmentation read/edit/export",
"author": "@ohif",
"license": "MIT",
@@ -30,15 +30,15 @@
"test:unit:ci": "jest --ci --runInBand --collectCoverage --passWithNoTests"
},
"peerDependencies": {
"@ohif/core": "3.13.0-beta.90",
"@ohif/extension-cornerstone": "3.13.0-beta.90",
"@ohif/extension-cornerstone-dicom-rt": "3.13.0-beta.90",
"@ohif/extension-cornerstone-dicom-seg": "3.13.0-beta.90",
"@ohif/extension-cornerstone-dicom-sr": "3.13.0-beta.90",
"@ohif/extension-default": "3.13.0-beta.90",
"@ohif/extension-dicom-pdf": "3.13.0-beta.90",
"@ohif/extension-dicom-video": "3.13.0-beta.90",
"@ohif/mode-basic": "3.13.0-beta.90"
"@ohif/core": "workspace:*",
"@ohif/extension-cornerstone": "workspace:*",
"@ohif/extension-cornerstone-dicom-rt": "workspace:*",
"@ohif/extension-cornerstone-dicom-seg": "workspace:*",
"@ohif/extension-cornerstone-dicom-sr": "workspace:*",
"@ohif/extension-default": "workspace:*",
"@ohif/extension-dicom-pdf": "workspace:*",
"@ohif/extension-dicom-video": "workspace:*",
"@ohif/mode-basic": "workspace:*"
},
"dependencies": {
"@babel/runtime": "7.29.7",
+8 -8
View File
@@ -1,6 +1,6 @@
{
"name": "@ohif/mode-tmtv",
"version": "3.13.0-beta.90",
"version": "3.13.0-beta.102",
"description": "Total Metabolic Tumor Volume Workflow",
"author": "OHIF",
"license": "MIT",
@@ -29,13 +29,13 @@
"test:unit:ci": "jest --ci --runInBand --collectCoverage --passWithNoTests"
},
"peerDependencies": {
"@ohif/core": "3.13.0-beta.90",
"@ohif/extension-cornerstone": "3.13.0-beta.90",
"@ohif/extension-cornerstone-dicom-sr": "3.13.0-beta.90",
"@ohif/extension-default": "3.13.0-beta.90",
"@ohif/extension-dicom-pdf": "3.13.0-beta.90",
"@ohif/extension-dicom-video": "3.13.0-beta.90",
"@ohif/extension-measurement-tracking": "3.13.0-beta.90"
"@ohif/core": "workspace:*",
"@ohif/extension-cornerstone": "workspace:*",
"@ohif/extension-cornerstone-dicom-sr": "workspace:*",
"@ohif/extension-default": "workspace:*",
"@ohif/extension-dicom-pdf": "workspace:*",
"@ohif/extension-dicom-video": "workspace:*",
"@ohif/extension-measurement-tracking": "workspace:*"
},
"dependencies": {
"@babel/runtime": "7.29.7",
+4 -4
View File
@@ -1,6 +1,6 @@
{
"name": "@ohif/mode-ultrasound-pleura-bline",
"version": "3.13.0-beta.90",
"version": "3.13.0-beta.102",
"description": "Allows users to annotate ultrasound images with pleura B-line annotations.",
"author": "OHIF",
"license": "MIT",
@@ -31,9 +31,9 @@
"@babel/runtime": "7.29.7",
"@cornerstonejs/core": "5.0.2",
"@cornerstonejs/tools": "5.0.2",
"@ohif/core": "3.13.0-beta.90",
"@ohif/extension-cornerstone-dicom-sr": "3.13.0-beta.90",
"@ohif/extension-ultrasound-pleura-bline": "3.13.0-beta.90",
"@ohif/core": "workspace:*",
"@ohif/extension-cornerstone-dicom-sr": "workspace:*",
"@ohif/extension-ultrasound-pleura-bline": "workspace:*",
"i18next": "17.3.1"
},
"devDependencies": {
+1 -1
View File
@@ -15,7 +15,7 @@
[build.environment]
# If 'production', `pnpm install` does not install devDependencies
NODE_ENV = "development"
NODE_VERSION = "24"
NODE_VERSION = "24.15.0"
[[headers]]
for = "/*"
+1 -1
View File
@@ -124,5 +124,5 @@
"git add"
]
},
"version": "3.13.0-beta.90"
"version": "3.13.0-beta.102"
}
+8 -5
View File
@@ -1,6 +1,6 @@
{
"name": "@ohif/app",
"version": "3.13.0-beta.90",
"version": "3.13.0-beta.102",
"productVersion": "3.4.0",
"description": "OHIF Viewer",
"author": "OHIF Contributors",
@@ -53,10 +53,10 @@
"@cornerstonejs/codec-openjph": "2.4.7",
"@cornerstonejs/dicom-image-loader": "5.0.2",
"@emotion/serialize": "1.3.3",
"@ohif/core": "3.13.0-beta.90",
"@ohif/i18n": "3.13.0-beta.90",
"@ohif/ui": "3.13.0-beta.90",
"@ohif/ui-next": "3.13.0-beta.90",
"@ohif/core": "workspace:*",
"@ohif/i18n": "workspace:*",
"@ohif/ui": "workspace:*",
"@ohif/ui-next": "workspace:*",
"@svgr/webpack": "8.1.0",
"@types/react": "18.3.23",
"classnames": "2.5.1",
@@ -95,8 +95,11 @@
"@rspack/plugin-react-refresh": "^2.0.0",
"@types/node": "20.19.9",
"cross-env": "7.0.3",
"cssnano": "5.1.15",
"identity-obj-proxy": "3.0.x",
"mini-css-extract-plugin": "2.9.2",
"postcss-import": "14.1.0",
"postcss-preset-env": "7.8.3",
"shx": "0.3.4",
"tailwindcss": "3.2.4"
},
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@ohif/cli",
"version": "3.13.0-beta.90",
"version": "3.13.0-beta.102",
"description": "A CLI to bootstrap new OHIF extension or mode",
"type": "module",
"main": "src/index.js",
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@ohif/core",
"version": "3.13.0-beta.90",
"version": "3.13.0-beta.102",
"description": "Generic business logic for web-based medical imaging applications",
"author": "OHIF Core Team",
"license": "MIT",
@@ -38,7 +38,7 @@
"@cornerstonejs/core": "5.0.2",
"@cornerstonejs/dicom-image-loader": "5.0.2",
"@cornerstonejs/metadata": "5.0.2",
"@ohif/ui": "3.13.0-beta.90",
"@ohif/ui": "workspace:*",
"cornerstone-math": "0.1.10",
"dicom-parser": "1.8.21"
},
@@ -399,5 +399,3 @@ template, do the following:
it is kept on for normal local dev.
- The `dev:no:cache` script is now identical to `dev` — keep it as an
alias if external scripts call it, or delete it.
</content>
</invoke>
+5 -1
View File
@@ -1,6 +1,6 @@
{
"name": "ohif-docs",
"version": "3.13.0-beta.90",
"version": "3.13.0-beta.102",
"private": true,
"scripts": {
"docusaurus": "docusaurus",
@@ -84,6 +84,10 @@
"typescript": "5.5.4",
"url-loader": "4.1.1"
},
"devDependencies": {
"@ohif/core": "workspace:*",
"@ohif/ui-next": "workspace:*"
},
"browserslist": {
"production": [
">0.5%",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@ohif/i18n",
"version": "3.13.0-beta.90",
"version": "3.13.0-beta.102",
"description": "Internationalization library for The OHIF Viewer",
"author": "OHIF",
"license": "MIT",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@ohif/ui-next",
"version": "3.13.0-beta.90",
"version": "3.13.0-beta.102",
"description": "Next version of OHIF Viewers UI, more customizable using shadcn/ui",
"author": "OHIF",
"license": "MIT",
@@ -275,6 +275,7 @@ const DataRowComponent = React.forwardRef<HTMLDivElement, DataRowProps>(
<span
className="ml-2 h-2 w-2 rounded-full"
style={{ backgroundColor: colorHex }}
data-cy="data-row-colorhex"
></span>
</div>
)}
@@ -9,6 +9,17 @@ import React, {
import merge from 'lodash.merge';
import PropTypes from 'prop-types';
// NOTE: `@ohif/core` is intentionally NOT declared in this package's
// package.json (neither as a dependency nor a peerDependency). It is treated as
// an implicit peer, satisfied by the consuming application via the monorepo
// workspace. Declaring it as `"@ohif/core": "workspace:*"` was tried and
// reverted: the release/publish process does not rewrite `workspace:*` ranges
// inside `peerDependencies`, so the published tarball shipped a literal
// `workspace:*` peer that non-pnpm package managers (npm/yarn) cannot resolve.
// A plain `"*"` range would be an acceptable workaround if we ever want it
// declared, but for now it stays undeclared. Note: the docs site (platform/docs)
// must therefore add `@ohif/core` as a devDependency itself, because pulling in
// the ui-next barrel reaches this module and nothing else anchors the import.
import { ViewportGridService, utils } from '@ohif/core';
const DEFAULT_STATE: AppTypes.ViewportGrid.State = {
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@ohif/ui",
"version": "3.13.0-beta.90",
"version": "3.13.0-beta.102",
"description": "A set of React components for Medical Imaging Viewers",
"author": "OHIF Contributors",
"license": "MIT",
+4 -5
View File
@@ -7,23 +7,22 @@ export default defineConfig({
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 1 : 0,
maxFailures: process.env.CI ? 10 : undefined,
workers: process.env.CI ? 6 : undefined,
workers: process.env.CI ? 18 : undefined,
snapshotPathTemplate: './tests/screenshots{/projectName}/{testFilePath}/{arg}{ext}',
outputDir: './tests/test-results',
reporter: [
['html', { outputFolder: './tests/playwright-report' }],
],
reporter: [['html', { outputFolder: './tests/playwright-report' }]],
globalTimeout: 800_000,
timeout: 800_000,
use: {
baseURL: 'http://localhost:3335',
trace: 'on-first-retry',
video: 'on-first-retry',
video: 'retain-on-failure',
testIdAttribute: 'data-cy',
actionTimeout: 10_000,
launchOptions: {
// do not hide the scrollbars so that we can assert their look-and-feel
ignoreDefaultArgs: ['--hide-scrollbars'],
args: ['--use-gl=egl'],
},
},
+811 -137
View File
File diff suppressed because it is too large. Load diff
+14 -8
View File
@@ -16,16 +16,15 @@ minimumReleaseAgeExclude:
- '@cornerstonejs/*'
frozenLockfile: true
# Skip the pre-`pnpm run` frozen deps-check; installs set freshness explicitly.
verifyDepsBeforeRun: false
# Equivalent of the bun `audit --ignore=...` flags. These GHSAs are accepted
# risk: minimatch/picomatch advisories reached only via build/CI tooling, never
# fed user-supplied expressions. Kept in sync with the .circleci SECURITY_AUDIT
# job and the root `audit` script.
auditConfig:
ignoreGhsas:
- GHSA-3ppc-4f35-3m26 # CVE-2026-26996 - minimatch (build/CI only, no CLI use)
- GHSA-7r86-cg39-jmmj # CVE-2026-27903 - minimatch (same)
- GHSA-23c5-xmqv-rm74 # CVE-2026-27904 - minimatch (same)
- GHSA-c2c7-rcm5-vvqj # CVE-2026-33671 - picomatch (build/CI only)
ignoreGhsas: []
allowBuilds:
'@scarf/scarf': true
@@ -67,8 +66,8 @@ overrides:
svgo: 3.3.3
flatted: 3.4.2
handlebars: 4.7.9
protobufjs: 7.5.7
tmp: 0.2.6
protobufjs: 7.6.1
tmp: 0.2.7
shell-quote: 1.8.4
# fast-uri <=3.1.1 reaches the tree only via platform/docs
# (@docusaurus/plugin-pwa > workbox-build > ajv). 3.1.2 patches both
@@ -81,4 +80,11 @@ overrides:
# pulls in tslib@1, which gets hoisted to root node_modules and shadows the
# tslib@2 that modern packages (e.g. react-remove-scroll) need for
# __spreadArray.
tslib: ^2.8.1
tslib: 2.8.1
'ws@>=7.0.0 <7.5.11': 7.5.11
'ws@>=8.0.0 <8.21.0': 8.21.0
form-data: 4.0.6
'minimatch@<3.1.4': 3.1.5
'minimatch@>=10.0.0 <10.2.3': 10.2.5
'picomatch@<2.3.2': 2.3.2
'picomatch@>=4.0.0 <4.0.4': 4.0.4
+54
View File
@@ -32,3 +32,57 @@ try {
} catch (err) {
console.log(`Skipped CLAUDE.md symlink: ${err.message}`);
}
// Mirror every skill under .agents/skills/ into .claude/skills/
try {
const agentsSkillsDir = path.join(__dirname, '.agents', 'skills');
const claudeSkillsDir = path.join(__dirname, '.claude', 'skills');
if (!fs.existsSync(agentsSkillsDir)) {
console.log('No .agents/skills directory found, skipping skill symlinks');
} else {
fs.mkdirSync(claudeSkillsDir, { recursive: true });
const agentsDirectoryEntries = fs.readdirSync(agentsSkillsDir, { withFileTypes: true });
for (const agentFolderEntry of agentsDirectoryEntries) {
if (!agentFolderEntry.isDirectory()) {
continue;
}
const claudeSkillLinkPath = path.join(claudeSkillsDir, agentFolderEntry.name);
const expectedSymlinkTarget = path.join('..', '..', '.agents', 'skills', agentFolderEntry.name);
try {
const existingLinkStats = fs.lstatSync(claudeSkillLinkPath, { throwIfNoEntry: false });
if (existingLinkStats) {
if (!existingLinkStats.isSymbolicLink()) {
console.log(
`Skipped skill symlink ${agentFolderEntry.name}: ${claudeSkillLinkPath} exists and is not a symlink`
);
continue;
}
const existingSymlinkTarget = fs.readlinkSync(claudeSkillLinkPath);
if (existingSymlinkTarget === expectedSymlinkTarget) {
continue;
}
// A symlink pointing somewhere else is treated as a developer
// override (.claude/ is gitignored local config). Leave it alone.
console.log(
`Skipped skill symlink ${agentFolderEntry.name}: ${claudeSkillLinkPath} points to ${existingSymlinkTarget}, not ${expectedSymlinkTarget}`
);
continue;
}
fs.symlinkSync(expectedSymlinkTarget, claudeSkillLinkPath, 'dir');
console.log(`Linked .claude/skills/${agentFolderEntry.name} -> ${expectedSymlinkTarget}`);
} catch (err) {
console.log(`Skipped skill symlink ${agentFolderEntry.name}: ${err.message}`);
}
}
}
} catch (err) {
console.log(`Skipped skill symlink setup: ${err.message}`);
}
+7 -2
View File
@@ -37,13 +37,18 @@ async function run() {
while (retries < MAX_RETRIES) {
try {
console.log(`Tying to publishing package at ${packageDirectory}`);
const publishArgs = ['publish'];
// Use `pnpm publish` (not npm) so the workspace:* specifiers on our
// internal @ohif/* deps are rewritten to the exact version in the
// published tarball. npm would publish the literal "workspace:*",
// which npm/yarn consumers cannot resolve. --no-git-checks because
// the bump commit/tag is created in CI on a possibly-detached ref.
const publishArgs = ['publish', '--no-git-checks'];
if (branchName === 'master') {
publishArgs.push('--tag', 'beta');
}
await execa('npm', publishArgs);
await execa('pnpm', publishArgs);
console.log(`Successfully published package at ${packageDirectory}`);
break;
} catch (error) {
+5 -19
View File
@@ -30,27 +30,13 @@ async function run() {
try {
const packageJson = JSON.parse(await fs.readFile(packageJsonPath, 'utf-8'));
// Update the package version
// Bump only the package's own version. Internal @ohif/* references stay
// as workspace:* in the committed manifests (and therefore the lockfile,
// which records them as links), so pnpm-lock.yaml never drifts on a
// version bump and frozen installs keep working. pnpm publish rewrites
// workspace:* to the exact version in the published tarball only.
packageJson.version = nextVersion;
// Update peerDependencies
if (packageJson.peerDependencies) {
for (const dep of Object.keys(packageJson.peerDependencies)) {
if (dep.startsWith('@ohif/')) {
packageJson.peerDependencies[dep] = nextVersion;
}
}
}
// Update dependencies
if (packageJson.dependencies) {
for (const dep of Object.keys(packageJson.dependencies)) {
if (dep.startsWith('@ohif/')) {
packageJson.dependencies[dep] = nextVersion;
}
}
}
await fs.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2) + '\n');
updatedFiles.push(packageJsonPath);
+7 -4
View File
@@ -24,10 +24,13 @@ test.describe('3D primary Test', async () => {
await attemptAction(() => reduce3DViewportSize(page), 10, 100);
await waitForViewportsRendered(page);
await checkForScreenshot(
await checkForScreenshot({
page,
viewportPageObject.grid,
screenShotPaths.threeDPrimary.threeDPrimaryDisplayedCorrectly
);
locator: viewportPageObject.grid,
// Volume-3D ray-cast output is GPU/driver-noisy run-to-run; match the
// tolerance already used by the sibling 3DOnly test.
maxDiffPixelRatio: 0.03,
screenshotPath: screenShotPaths.threeDPrimary.threeDPrimaryDisplayedCorrectly,
});
});
});
+78 -5
View File
@@ -1,11 +1,52 @@
import {
checkForScreenshot,
expect,
getAnnotationStats,
screenShotPaths,
test,
visitStudy,
waitForViewportRenderCycle,
} from './utils';
/**
* Asserts the arrow annotation text across every surface that should reflect it:
* - the tracked measurements side panel row title,
* - the DOM SVG linked text box rendered in the viewport, and
* - the source-of-truth cornerstone annotation state (`data.label`).
*
* This avoids relying on the screenshot alone (whose font rendering differs
* between systems) to assert the text is correct, mirroring the DOM/state
* assertions in the SCOORD rectangle test.
*/
async function expectArrowText({
page,
activeViewport,
rightPanelPageObject,
annotationUID,
expectedText,
}) {
// Side panel: the measurement row title reflects the arrow text.
await expect(rightPanelPageObject.measurementsPanel.panel.nthMeasurement(0).title).toHaveText(
expectedText
);
// DOM SVG: the arrow's linked text box renders the arrow text, independent of
// any system font differences.
const svgTextLines = activeViewport.getSvgAnnotationStatTextLines(annotationUID);
await expect(svgTextLines).toHaveCount(1);
await expect(svgTextLines.nth(0)).toHaveText(expectedText);
// Source-of-truth annotation state. ArrowAnnotate stores its text on
// `data.label` rather than computed `cachedStats`, so read with requireStats: false.
const arrows = await getAnnotationStats(page, {
toolName: 'ArrowAnnotate',
requireStats: false,
});
const arrow = arrows.find(a => a.annotationUID === annotationUID);
expect(arrow).toBeDefined();
expect(arrow.label).toBe(expectedText);
}
test.beforeEach(async ({ page }) => {
const studyInstanceUID = '1.3.6.1.4.1.25403.345050719074.3824.20170125095438.5';
const mode = 'viewer';
@@ -41,11 +82,28 @@ test('should display the arrow tool and allow free-form text to be entered', asy
await checkForScreenshot({
page,
maxDiffPixelRatio: 0.0075,
screenshotPath: screenShotPaths.arrowAnnotate.arrowAnnotateDisplayedCorrectly0,
});
// Now edit the arrow text and the label should not change.
// Resolve the arrow annotation UID once; it remains stable across subsequent edits.
const arrows = await getAnnotationStats(page, {
toolName: 'ArrowAnnotate',
requireStats: false,
});
expect(arrows.length).toBeGreaterThan(0);
const annotationUID = arrows[0].annotationUID;
await expectArrowText({
page,
activeViewport,
rightPanelPageObject,
annotationUID,
expectedText: 'Ringo Starr was the drummer for The Beatles',
});
// Double-clicking the arrow re-opens the text dialog. ArrowAnnotate stores its
// text on `data.label`, so the new text replaces it across the viewport SVG,
// the side panel and the annotation state.
await activeViewport.doubleClickAt({ x: 164, y: 234 });
@@ -53,11 +111,19 @@ test('should display the arrow tool and allow free-form text to be entered', asy
await checkForScreenshot({
page,
maxDiffPixelRatio: 0.0075,
screenshotPath: screenShotPaths.arrowAnnotate.arrowAnnotateDisplayedCorrectly1,
});
// Now edit the label and the text should not change.
await expectArrowText({
page,
activeViewport,
rightPanelPageObject,
annotationUID,
expectedText: 'Neil Peart was the drummer for Rush',
});
// Renaming from the side panel updates the same `data.label`, so the new text
// is reflected everywhere as well.
await rightPanelPageObject.measurementsPanel.panel
.nthMeasurement(0)
@@ -65,7 +131,14 @@ test('should display the arrow tool and allow free-form text to be entered', asy
await checkForScreenshot({
page,
maxDiffPixelRatio: 0.0075,
screenshotPath: screenShotPaths.arrowAnnotate.arrowAnnotateDisplayedCorrectly2,
});
await expectArrowText({
page,
activeViewport,
rightPanelPageObject,
annotationUID,
expectedText: 'Drummer annotation arrow',
});
});
+9 -12
View File
@@ -1,7 +1,7 @@
import {
expect,
test,
visitStudy,
visitStudyAndHydrate,
getSvgAttribute,
navigateWithViewportArrow,
waitForViewportsRendered,
@@ -10,17 +10,14 @@ import { expectRowSelected } from './utils/assertions';
const studyInstanceUID = '1.2.840.113619.2.290.3.3767434740.226.1600859119.501';
test.beforeEach(async ({
page,
leftPanelPageObject,
DOMOverlayPageObject,
rightPanelPageObject
}) => {
const mode = 'segmentation';
await visitStudy(page, studyInstanceUID, mode, 2000);
await leftPanelPageObject.loadSeriesByModality('RTSTRUCT');
await page.waitForTimeout(5000);
await DOMOverlayPageObject.viewport.segmentationHydration.yes.click();
test.beforeEach(async ({ page, leftPanelPageObject, DOMOverlayPageObject, rightPanelPageObject }) => {
await visitStudyAndHydrate({
page,
leftPanelPageObject,
DOMOverlayPageObject,
studyInstanceUID,
modality: 'RTSTRUCT',
});
// Click segment 0 in the right panel to establish a known starting position
await rightPanelPageObject.contourSegmentationPanel.panel.nthSegment(0).click();
await page.waitForTimeout(5000);
+177
View File
@@ -0,0 +1,177 @@
import {
expect,
test,
visitStudy,
waitForViewportsRendered,
getSvgAttribute,
} from './utils';
const NEW_HEX = '#FF00FF';
const NEW_HEX_CSS_RGB = 'rgb(255, 0, 255)';
const NEW_HEX_CSS_RGBA = 'rgba(255, 0, 255, 1)';
// Default colors baked into the RTSTRUCT in the canonical contour study.
const THRESHOLD_CONTOUR_DEFAULT_HEX = '#00EBEB';
const THRESHOLD_CONTOUR_DEFAULT_CSS_RGBA = 'rgba(0, 235, 235, 1)';
const THRESHOLD_CONTOUR_DEFAULT_CSS_RGB = 'rgb(0, 235, 235)';
const STUDY_UID = '1.2.840.113619.2.290.3.3767434740.226.1600859119.501';
test.beforeEach(async ({ page, leftPanelPageObject, DOMOverlayPageObject }) => {
await visitStudy(page, STUDY_UID, 'segmentation', 2000);
await leftPanelPageObject.loadSeriesByModality('RTSTRUCT');
await waitForViewportsRendered(page);
await expect(DOMOverlayPageObject.viewport.segmentationHydration.locator).toBeVisible();
await DOMOverlayPageObject.viewport.segmentationHydration.yes.click();
});
test('opens the color edit popup when "Change Color" is clicked', async ({
rightPanelPageObject,
DOMOverlayPageObject,
}) => {
const segment = rightPanelPageObject.contourSegmentationPanel.panel.nthSegment(0);
await segment.actions.openChangeColor();
await expect(DOMOverlayPageObject.dialog.colorPicker.locator).toBeVisible();
await expect(DOMOverlayPageObject.dialog.title).toHaveText('Segment Color');
await expect(DOMOverlayPageObject.dialog.colorPicker.saveButton).toBeVisible();
await expect(DOMOverlayPageObject.dialog.colorPicker.cancelButton).toBeVisible();
await expect(DOMOverlayPageObject.dialog.colorPicker.hexInput).toHaveValue(
THRESHOLD_CONTOUR_DEFAULT_HEX
);
});
test('changes the contour color when the user saves the edits', async ({
viewportPageObject,
rightPanelPageObject,
DOMOverlayPageObject,
}) => {
await rightPanelPageObject.contourSegmentationPanel.segmentsVisibilityToggle.click();
const segment = rightPanelPageObject.contourSegmentationPanel.panel.nthSegment(0);
await segment.toggleVisibility();
await segment.click();
await expect(segment.rowDataColorHex).toHaveCSS('background-color',THRESHOLD_CONTOUR_DEFAULT_CSS_RGB);
const svgStrokeAttributeBeforeColorChange = await getSvgAttribute({
viewportPageObject,
svgInnerElement: 'path',
attributeName: 'stroke',
});
expect(svgStrokeAttributeBeforeColorChange, 'Expected SVG stroke attribute to be original threshold color').toBe(
THRESHOLD_CONTOUR_DEFAULT_CSS_RGBA
);
// change color
await segment.actions.changeColor(NEW_HEX);
await expect(DOMOverlayPageObject.dialog.colorPicker.locator).toBeHidden();
await expect(segment.rowDataColorHex).toHaveCSS('background-color', NEW_HEX_CSS_RGB);
//check svg path stroke attribute is updated with new color
const svgStrokeAttributeAfterColorChange = await getSvgAttribute({
viewportPageObject,
svgInnerElement: 'path',
attributeName: 'stroke',
});
expect(svgStrokeAttributeAfterColorChange, 'Expected SVG stroke attribute to be updated with new color').toBe(
NEW_HEX_CSS_RGBA
);
});
test('does not change the contour color when the user cancels', async ({
rightPanelPageObject,
DOMOverlayPageObject,
viewportPageObject
}) => {
await rightPanelPageObject.contourSegmentationPanel.segmentsVisibilityToggle.click();
const segment = rightPanelPageObject.contourSegmentationPanel.panel.nthSegment(0);
await segment.toggleVisibility();
await segment.click();
await expect(segment.rowDataColorHex).toHaveCSS(
'background-color',
THRESHOLD_CONTOUR_DEFAULT_CSS_RGB
);
const svgStrokeAttributeBeforeColorChange = await getSvgAttribute({
viewportPageObject,
svgInnerElement: 'path',
attributeName: 'stroke',
});
expect(svgStrokeAttributeBeforeColorChange, 'Expected SVG stroke attribute to be original threshold color').toBe(
THRESHOLD_CONTOUR_DEFAULT_CSS_RGBA
);
await segment.actions.cancelChangeColor(NEW_HEX);
await expect(DOMOverlayPageObject.dialog.colorPicker.locator).toBeHidden();
await expect(segment.rowDataColorHex).toHaveCSS('background-color', THRESHOLD_CONTOUR_DEFAULT_CSS_RGB);
//check svg path stroke attribute is updated with new color
const svgStrokeAttributeAfterColorChange = await getSvgAttribute({
viewportPageObject,
svgInnerElement: 'path',
attributeName: 'stroke',
});
expect(svgStrokeAttributeAfterColorChange, 'Expected SVG stroke attribute to remain the original color').toBe(
THRESHOLD_CONTOUR_DEFAULT_CSS_RGBA
);
});
test('duplicated contour will be generated with a new color', async ({
viewportPageObject,
rightPanelPageObject,
}) => {
await rightPanelPageObject.contourSegmentationPanel.segmentsVisibilityToggle.click();
const panel = rightPanelPageObject.contourSegmentationPanel.panel;
const segment0 = panel.nthSegment(0);
await segment0.toggleVisibility();
await segment0.click();
await expect(segment0.rowDataColorHex).toHaveCSS(
'background-color',
THRESHOLD_CONTOUR_DEFAULT_CSS_RGB
);
const svgStrokeAttributeBeforeColorChange = await getSvgAttribute({
viewportPageObject,
svgInnerElement: 'path',
attributeName: 'stroke',
});
expect(svgStrokeAttributeBeforeColorChange, 'Expected SVG stroke attribute to be original threshold color').toBe(
THRESHOLD_CONTOUR_DEFAULT_CSS_RGBA
);
// duplicate the segment
const initialCount = await panel.getSegmentCount();
expect(initialCount, 'Expected to start with 4 segments').toBe(4);
await segment0.actions.duplicate();
await segment0.toggleVisibility(); // toggle original segment 0 visibility off to be able to grab the duplicated segment's path
const duplicateSegment = panel.nthSegment(4);
await duplicateSegment.click();
const duplicatedSegmentSvgStrokeAttribute = await getSvgAttribute({
viewportPageObject,
svgInnerElement: 'path',
attributeName: 'stroke',
});
await expect(duplicateSegment.rowDataColorHex).not.toHaveCSS(
'background-color',
THRESHOLD_CONTOUR_DEFAULT_CSS_RGB
);
expect(duplicatedSegmentSvgStrokeAttribute, 'Expected duplicated segment to have a different stroke color').not.toBe(
THRESHOLD_CONTOUR_DEFAULT_CSS_RGBA
);
});
+137
View File
@@ -0,0 +1,137 @@
import { expect, test, visitStudy, waitForViewportsRendered, getSvgAttribute } from './utils';
const studyInstanceUID = '1.2.840.113619.2.290.3.3767434740.226.1600859119.501';
const defaultSegment0Name = 'Threshold';
const defaultSegment1Name = 'Big Sphere';
test.beforeEach(async ({ page, leftPanelPageObject, DOMOverlayPageObject }) => {
const mode = 'segmentation';
await visitStudy(page, studyInstanceUID, mode, 2000);
await leftPanelPageObject.loadSeriesByModality('RTSTRUCT');
await waitForViewportsRendered(page);
await expect(DOMOverlayPageObject.viewport.segmentationHydration.locator).toBeVisible();
await DOMOverlayPageObject.viewport.segmentationHydration.yes.click();
});
test('should delete a contour segment and remove its row from the panel', async ({
rightPanelPageObject,
}) => {
const panel = rightPanelPageObject.contourSegmentationPanel.panel;
const initialCount = await panel.getSegmentCount();
expect(initialCount, 'Expected to load with 4 segments').toBe(4);
const segment0 = panel.nthSegment(0);
await expect(segment0.title).toHaveText(defaultSegment0Name);
await segment0.actions.delete();
const countAfterDelete = await panel.getSegmentCount();
expect(countAfterDelete, 'Expected one fewer segment row after deleting').toBe(3);
// The deleted segment's label should no longer be present anywhere in the panel
await expect(
panel.getSegmentLabels().filter({ hasText: defaultSegment0Name }),
'Expected the deleted segment title to be gone from the panel'
).toHaveCount(0);
// Check that the next segment index is moved up
await expect(
panel.nthSegment(0).title,
'Expected the next segment to take the first row after deletion'
).toHaveText(defaultSegment1Name);
});
test('should delete multiple contour segments sequentially', async ({ rightPanelPageObject }) => {
const panel = rightPanelPageObject.contourSegmentationPanel.panel;
const initialCount = await panel.getSegmentCount();
expect(initialCount, 'Expected to load with 4 segments').toBe(4);
await panel.nthSegment(0).actions.delete();
const countAfterFirstDelete = await panel.getSegmentCount();
expect(countAfterFirstDelete, 'Expected 3 segments after first delete').toBe(3);
await panel.nthSegment(0).actions.delete();
const countAfterSecondDelete = await panel.getSegmentCount();
expect(countAfterSecondDelete, 'Expected 2 segments after second delete').toBe(2);
await expect(
panel.getSegmentLabels().filter({ hasText: defaultSegment0Name }),
'Expected the deleted Threshold segment title to be gone from the panel'
).toHaveCount(0);
await expect(
panel.getSegmentLabels().filter({ hasText: defaultSegment1Name }),
'Expected the deleted Big Sphere segment title to be gone from the panel'
).toHaveCount(0);
});
test('should remove the deleted segment contour from the viewport', async ({
rightPanelPageObject,
viewportPageObject,
}) => {
const panel = rightPanelPageObject.contourSegmentationPanel.panel;
// Hide everything, then show only the segment we are going to delete so the
// viewport renders exactly one contour path we can assert on.
await rightPanelPageObject.contourSegmentationPanel.segmentsVisibilityToggle.click();
const segment0 = panel.nthSegment(0);
await segment0.toggleVisibility();
await segment0.click();
const svgPathLocator = (await viewportPageObject.getById('default')).svg('path');
await expect(
svgPathLocator,
'Expected exactly one visible contour path before delete'
).toHaveCount(1);
// Capture the contour path of the segment we are about to delete
const segmentToBeDeletedSvgPath = await getSvgAttribute({
viewportPageObject,
svgInnerElement: 'path',
attributeName: 'd',
});
expect(
segmentToBeDeletedSvgPath,
'Expected a visible SVG path for the segment to delete'
).not.toBeNull();
await segment0.actions.delete();
await expect(
panel.getSegmentLabels().filter({ hasText: defaultSegment0Name }),
'Expected the Threshold segment title to be gone from the panel'
).toHaveCount(0);
await expect(
svgPathLocator,
'Expected the deleted segment contour to be removed from the viewport'
).toHaveCount(0);
// After deletion, show new segment at the deleted index and verify its contour is a different from the deleted one.
const newSegment0 = panel.nthSegment(0);
await newSegment0.toggleVisibility();
await newSegment0.click();
await expect(
svgPathLocator,
'Expected the new index-0 segment contour to be visible'
).toHaveCount(1);
const newSegmentSvgPath = await getSvgAttribute({
viewportPageObject,
svgInnerElement: 'path',
attributeName: 'd',
});
expect(
newSegmentSvgPath,
'Expected a visible SVG path for the new index-0 segment'
).not.toBeNull();
expect(
newSegmentSvgPath,
'Expected the new index-0 segment contour to differ from the deleted segment'
).not.toBe(segmentToBeDeletedSvgPath);
});
+20 -16
View File
@@ -1,18 +1,23 @@
import { expect, test, visitStudy, waitForViewportsRendered, getSvgAttribute } from './utils';
import {
contourShowOnlyNthSegment,
expect,
getSvgAttribute,
test,
visitStudyAndHydrate,
} from './utils';
const studyInstanceUID = '1.2.840.113619.2.290.3.3767434740.226.1600859119.501';
const defaultSegment0Name = 'Threshold';
const defaultSegment1Name = 'Big Sphere';
test.beforeEach(async ({ page, leftPanelPageObject, DOMOverlayPageObject }) => {
const mode = 'segmentation';
await visitStudy(page, studyInstanceUID, mode, 2000);
await leftPanelPageObject.loadSeriesByModality('RTSTRUCT');
await waitForViewportsRendered(page);
await expect(DOMOverlayPageObject.viewport.segmentationHydration.locator).toBeVisible();
await DOMOverlayPageObject.viewport.segmentationHydration.yes.click();
await visitStudyAndHydrate({
page,
leftPanelPageObject,
DOMOverlayPageObject,
studyInstanceUID,
modality: 'RTSTRUCT',
});
});
test('should duplicate a contour segment and add a new row to the panel', async ({
@@ -79,10 +84,9 @@ test('should render the duplicated contour on the viewport', async ({
const panel = rightPanelPageObject.contourSegmentationPanel.panel;
// Hide everything, to be able to grab only the SVG path of the segment to duplicate
await rightPanelPageObject.contourSegmentationPanel.segmentsVisibilityToggle.click();
const segment0 = panel.nthSegment(0);
await segment0.toggleVisibility();
await segment0.click();
const segment0 = await contourShowOnlyNthSegment({
segmentationPanel: rightPanelPageObject.contourSegmentationPanel,
});
const sourceSvgPath = await getSvgAttribute({
viewportPageObject,
@@ -175,9 +179,9 @@ test('should navigate to the correct instance number when a duplicated contour s
).toHaveText('I:46 (46/47)');
//verify the svg paths are the same for the original and duplicated segments
await rightPanelPageObject.contourSegmentationPanel.segmentsVisibilityToggle.click();
await originalSegment.toggleVisibility();
await originalSegment.click();
await contourShowOnlyNthSegment({
segmentationPanel: rightPanelPageObject.contourSegmentationPanel,
});
const originalSegmentSvgPath = await getSvgAttribute({
viewportPageObject,
svgInnerElement: 'path',
+9 -11
View File
@@ -1,19 +1,17 @@
import { expect, test, visitStudy } from './utils';
import { expect, test, visitStudyAndHydrate } from './utils';
const studyInstanceUID = '1.2.840.113619.2.290.3.3767434740.226.1600859119.501';
const defautSegment0Name = 'Threshold';
const defautSegment1Name = 'Big Sphere';
test.beforeEach(async ({
page,
leftPanelPageObject,
DOMOverlayPageObject
}) => {
const mode = 'segmentation';
await visitStudy(page, studyInstanceUID, mode, 2000);
await leftPanelPageObject.loadSeriesByModality('RTSTRUCT');
await page.waitForTimeout(5000);
await DOMOverlayPageObject.viewport.segmentationHydration.yes.click();
test.beforeEach(async ({ page, leftPanelPageObject, DOMOverlayPageObject }) => {
await visitStudyAndHydrate({
page,
leftPanelPageObject,
DOMOverlayPageObject,
studyInstanceUID,
modality: 'RTSTRUCT',
});
});
test('should rename contour segments', async ({
+130
View File
@@ -0,0 +1,130 @@
import {
contourShowOnlyNthSegment,
expect,
getSvgAttribute,
simulateNormalizedDragOnElement,
test,
visitStudyAndHydrate,
} from './utils';
import { expectRowLocked, expectRowUnlocked } from './utils/assertions';
const studyInstanceUID = '1.2.840.113619.2.290.3.3767434740.226.1600859119.501';
const defaultSegment0Name = 'Threshold';
test.beforeEach(async ({ page, leftPanelPageObject, DOMOverlayPageObject }) => {
await visitStudyAndHydrate({
page,
leftPanelPageObject,
DOMOverlayPageObject,
studyInstanceUID,
modality: 'RTSTRUCT',
});
});
test('should show the lock indicator and flip the menu label between Lock and Unlock', async ({
rightPanelPageObject,
}) => {
const panel = rightPanelPageObject.contourSegmentationPanel.panel;
const segment0 = panel.nthSegment(0);
await expect(segment0.title).toHaveText(defaultSegment0Name);
// The lock icon is only rendered inside the row once locked.
await expectRowUnlocked(segment0);
let lockToggle = await segment0.actions.lockToggleMenuItem();
await expect(lockToggle, 'Expected the menu item to read "Lock" before locking').toHaveText(
'Lock'
);
// Lock the segment by clicking the already-open menu item.
await lockToggle.click();
await expectRowLocked(segment0);
// Reopen the actions menu: the toggle label should now read "Unlock".
lockToggle = await segment0.actions.lockToggleMenuItem();
await expect(lockToggle, 'Expected the menu item to read "Unlock" after locking').toHaveText('Unlock');
// Unlock the segment again by clicking the already-open menu item.
await lockToggle.click();
await expectRowUnlocked(segment0);
lockToggle = await segment0.actions.lockToggleMenuItem();
await expect(
lockToggle,
'Expected the menu item to read "Lock" again after unlocking'
).toHaveText('Lock');
});
test('should stop a locked contour segment from responding to drag edits', async ({
rightPanelPageObject,
viewportPageObject,
}) => {
const panel = rightPanelPageObject.contourSegmentationPanel.panel;
const segment0 = panel.nthSegment(0);
await expect(
segment0.title,
'Expected the first segment to be the Threshold segment'
).toHaveText(defaultSegment0Name);
// Isolate segment 0 so the viewport renders exactly one contour path and it is
// the active segment for the drag edits below.
await contourShowOnlyNthSegment({
segmentationPanel: rightPanelPageObject.contourSegmentationPanel,
});
const svgPath = (await viewportPageObject.getById('default')).svg('path');
await expect(svgPath, 'Expected exactly one visible contour path').toHaveCount(1);
const originalSvgPathDAttribute = await getSvgAttribute({
viewportPageObject,
svgInnerElement: 'path',
attributeName: 'd',
});
expect(originalSvgPathDAttribute, 'Expected a visible SVG path for the unlocked segment').not.toBeNull();
// Lock the segment via the actions menu and confirm the lock state has propagated
// to the row before dragging.
await segment0.actions.toggleLock();
await expectRowLocked(segment0);
// Drag the path while locked.
await simulateNormalizedDragOnElement({
locator: svgPath,
start: { x: 0.8, y: 0.8 },
end: { x: 0.2, y: 0.2 },
});
const svgPathDAttributeAfterDragWhileLocked = await getSvgAttribute({
viewportPageObject,
svgInnerElement: 'path',
attributeName: 'd',
});
// The path should not have changed after the drag attempt while locked.
expect(
svgPathDAttributeAfterDragWhileLocked,
'Expected the contour path to remain unchanged after dragging while locked'
).toBe(originalSvgPathDAttribute);
// Unlock the segment and confirm the lock indicator is gone before dragging again.
await segment0.actions.toggleLock();
await expectRowUnlocked(segment0);
// Drag with the same motion as while locked.
await simulateNormalizedDragOnElement({
locator: svgPath,
start: { x: 0.8, y: 0.8 },
end: { x: 0.2, y: 0.2 },
});
const svgPathDAfterDragWhileUnlocked = await getSvgAttribute({
viewportPageObject,
svgInnerElement: 'path',
attributeName: 'd',
});
// The path should change after dragging while unlocked.
expect(
svgPathDAfterDragWhileUnlocked,
'Expected the contour path to change after dragging while unlocked'
).not.toBe(originalSvgPathDAttribute);
});
+14 -6
View File
@@ -1,14 +1,22 @@
import { expect, test, visitStudy, getSvgAttribute, navigateWithViewportArrow } from './utils';
import {
expect,
test,
visitStudyAndHydrate,
getSvgAttribute,
navigateWithViewportArrow,
} from './utils';
const studyInstanceUID = '1.2.840.113619.2.290.3.3767434740.226.1600859119.501';
test.beforeEach(
async ({ page, leftPanelPageObject, DOMOverlayPageObject, rightPanelPageObject }) => {
const mode = 'segmentation';
await visitStudy(page, studyInstanceUID, mode, 2000);
await leftPanelPageObject.loadSeriesByModality('RTSTRUCT');
await page.waitForTimeout(5000);
await DOMOverlayPageObject.viewport.segmentationHydration.yes.click();
await visitStudyAndHydrate({
page,
leftPanelPageObject,
DOMOverlayPageObject,
studyInstanceUID,
modality: 'RTSTRUCT',
});
await rightPanelPageObject.contourSegmentationPanel.panel.nthSegment(0).click();
await page.waitForTimeout(1000);
}
@@ -0,0 +1,248 @@
import { expect, test, visitStudy, visitStudyAndHydrate, waitForViewportsRendered } from './utils';
import {
expectRowSelected,
expectRowNotSelected,
expectSegmentationLabels,
} from './utils/assertions';
const studyInstanceUID = '1.2.840.113619.2.290.3.3767434740.226.1600859119.501';
test.describe('Contour Segmentation from an empty panel', () => {
test('should add a contour segmentation from the empty panel', async ({
rightPanelPageObject,
page,
}) => {
await visitStudy(page, studyInstanceUID, 'segmentation', 2000);
await waitForViewportsRendered(page);
// Segmentation mode opens on the labelmap tab; switch to the contour tab.
await rightPanelPageObject.contourSegmentationPanel.select();
const { addSegmentationButton, panel, segmentationSelect } =
rightPanelPageObject.contourSegmentationPanel;
// No contour segmentation exists yet.
await expect(panel.rows).toHaveCount(0);
await expect(addSegmentationButton.button).toBeVisible();
await addSegmentationButton.click();
// The segmentation is added and becomes the active selection.
await expect(segmentationSelect.selectedValue).toHaveText('Segmentation 1');
await expect(panel.rows).toHaveCount(1);
const defaultSegment = panel.nthSegment(0);
await expect(defaultSegment.title).toHaveText('Segment 1');
await expectRowSelected(defaultSegment);
});
});
test.describe('Contour Segmentation interactions on RTSTRUCT panel', () => {
test.beforeEach(async ({ page, leftPanelPageObject, DOMOverlayPageObject }) => {
await visitStudyAndHydrate({
page,
leftPanelPageObject,
DOMOverlayPageObject,
studyInstanceUID,
modality: 'RTSTRUCT',
});
});
test('should create a new contour segmentation seeded with a default active segment', async ({
rightPanelPageObject,
}) => {
const { panel, segmentationSelect } = rightPanelPageObject.contourSegmentationPanel;
await expect(panel.rows).toHaveCount(4);
await panel.moreMenu.createNewSegmentation();
await expect(segmentationSelect.selectedValue).toHaveText('Segmentation 2');
await expect(panel.rows).toHaveCount(1);
const defaultSegment = panel.nthSegment(0);
await expect(defaultSegment.title).toHaveText('Segment 1');
await expectRowSelected(defaultSegment);
});
test('should add multiple segments to a newly created contour segmentation', async ({
rightPanelPageObject,
}) => {
const { panel, addSegmentButton } = rightPanelPageObject.contourSegmentationPanel;
await panel.moreMenu.createNewSegmentation();
await expect(panel.rows).toHaveCount(1);
// Each added segment becomes the active one in place of the previous.
await addSegmentButton.click();
await expect(panel.rows).toHaveCount(2);
await expectRowSelected(panel.nthSegment(1));
await expectRowNotSelected(panel.nthSegment(0));
await addSegmentButton.click();
await expect(panel.rows).toHaveCount(3);
await expectRowSelected(panel.nthSegment(2));
await expectRowNotSelected(panel.nthSegment(1));
await expect(panel.getSegmentLabels()).toHaveText(['Segment 1', 'Segment 2', 'Segment 3']);
});
test('should list every created segmentation in the segmentation selector', async ({
rightPanelPageObject,
}) => {
const { panel, segmentationSelect } = rightPanelPageObject.contourSegmentationPanel;
// Only the hydrated RTSTRUCT segmentation exists at first.
await expectSegmentationLabels(segmentationSelect, ['Contours on PET']);
await panel.moreMenu.createNewSegmentation();
await panel.moreMenu.createNewSegmentation();
// The two newly created segmentations are added to the selector.
await expectSegmentationLabels(segmentationSelect, [
'Contours on PET',
'Segmentation 2',
'Segmentation 3',
]);
});
test('should switch between segmentations and show the matching segments', async ({
rightPanelPageObject,
}) => {
const { panel, segmentationSelect } = rightPanelPageObject.contourSegmentationPanel;
// Create two more segmentations alongside the hydrated RTSTRUCT one, so the
// selector lists: [0] Contours on PET, [1] Segmentation 2, [2] Segmentation 3.
await panel.moreMenu.createNewSegmentation();
await panel.moreMenu.createNewSegmentation();
await expect(segmentationSelect.selectedValue).toHaveText('Segmentation 3');
// Select out of listed order (active is 2 → 0 → 2 → 1) to prove the active
// segmentation follows the selection, not the order the options are listed in.
// Index 0: the RTSTRUCT segmentation shows its four segments.
await segmentationSelect.selectNthSegmentation(0);
await expect(segmentationSelect.selectedValue).toHaveText('Contours on PET');
await expect(panel.rows).toHaveCount(4);
await expect(panel.getSegmentLabels()).toHaveText([
'Threshold',
'Big Sphere',
'Small Sphere',
'Large Box',
]);
// Jump to the last-created segmentation (index 2), skipping over index 1.
await segmentationSelect.selectNthSegmentation(2);
await expect(segmentationSelect.selectedValue).toHaveText('Segmentation 3');
await expect(panel.rows).toHaveCount(1);
await expect(panel.nthSegment(0).title).toHaveText('Segment 1');
// Back up to the middle segmentation (index 1).
await segmentationSelect.selectNthSegmentation(1);
await expect(segmentationSelect.selectedValue).toHaveText('Segmentation 2');
await expect(panel.rows).toHaveCount(1);
await expect(panel.nthSegment(0).title).toHaveText('Segment 1');
});
test('should rename a segmentation and reflect the new name in the selector', async ({
rightPanelPageObject,
}) => {
const { panel, segmentationSelect } = rightPanelPageObject.contourSegmentationPanel;
await panel.moreMenu.createNewSegmentation();
await expect(segmentationSelect.selectedValue).toHaveText('Segmentation 2');
await panel.moreMenu.rename('Renamed Segmentation');
await expect(segmentationSelect.selectedValue).toHaveText('Renamed Segmentation');
await expectSegmentationLabels(segmentationSelect, ['Contours on PET', 'Renamed Segmentation']);
});
test('should not rename a segmentation when the rename dialog is cancelled', async ({
rightPanelPageObject,
}) => {
const { panel, segmentationSelect } = rightPanelPageObject.contourSegmentationPanel;
await panel.moreMenu.createNewSegmentation();
await expect(segmentationSelect.selectedValue).toHaveText('Segmentation 2');
// Cancelling with an untouched dialog leaves the name unchanged.
await panel.moreMenu.cancelRename();
await expect(segmentationSelect.selectedValue).toHaveText('Segmentation 2');
// Cancelling after typing a new name also discards it.
await panel.moreMenu.cancelRename('Discarded Name');
await expect(segmentationSelect.selectedValue).toHaveText('Segmentation 2');
});
test('should delete a segmentation and remove it from the selector', async ({
rightPanelPageObject,
}) => {
const { panel, segmentationSelect } = rightPanelPageObject.contourSegmentationPanel;
await panel.moreMenu.createNewSegmentation();
await expect(segmentationSelect.selectedValue).toHaveText('Segmentation 2');
await panel.moreMenu.delete();
// The remaining RTSTRUCT segmentation becomes active and is the only one left.
await expect(segmentationSelect.selectedValue).toHaveText('Contours on PET');
await expectSegmentationLabels(segmentationSelect, ['Contours on PET']);
});
test('should delete every segmentation until none remain', async ({ rightPanelPageObject }) => {
const { panel, addSegmentationButton, segmentationSelect } =
rightPanelPageObject.contourSegmentationPanel;
// Start with the hydrated RTSTRUCT plus two created segmentations.
await panel.moreMenu.createNewSegmentation();
await panel.moreMenu.createNewSegmentation();
// Delete each of the three segmentations one by one.
await panel.moreMenu.delete();
await expect(segmentationSelect.selectedValue).toHaveText('Contours on PET');
await panel.moreMenu.delete();
await expect(segmentationSelect.selectedValue).toHaveText('Segmentation 2');
await panel.moreMenu.delete();
// No segmentation remains, so the panel has no segment rows and the
// "Add segmentation" entry point is shown again.
await expect(panel.rows).toHaveCount(0);
await expect(addSegmentationButton.button).toBeVisible();
});
test('should remove a segmentation from the viewport and drop it from the selector', async ({
rightPanelPageObject,
}) => {
const { panel, segmentationSelect } = rightPanelPageObject.contourSegmentationPanel;
await panel.moreMenu.createNewSegmentation();
await expect(segmentationSelect.selectedValue).toHaveText('Segmentation 2');
await panel.moreMenu.removeFromViewport();
// Removing from the viewport drops it from the selector; the RTSTRUCT one stays active.
await expect(segmentationSelect.selectedValue).toHaveText('Contours on PET');
await expectSegmentationLabels(segmentationSelect, ['Contours on PET']);
});
// KNOWN BUG: the last remaining segmentation cannot be removed from the viewport
// ("Remove from Viewport" is a silent no-op once it is the only one left), so the
// panel keeps its segment row instead of clearing. Skipped until the bug is fixed.
// Tracked in https://github.com/OHIF/Viewers/issues/6090
test.skip('should remove every segmentation from the viewport', async ({
rightPanelPageObject,
}) => {
const { panel, addSegmentationButton } = rightPanelPageObject.contourSegmentationPanel;
// Start with the hydrated RTSTRUCT plus two created segmentations.
await panel.moreMenu.createNewSegmentation();
await panel.moreMenu.createNewSegmentation();
// Remove each segmentation from the viewport one by one.
await panel.moreMenu.removeFromViewport();
await panel.moreMenu.removeFromViewport();
await panel.moreMenu.removeFromViewport();
// The viewport should have no segmentations left: the selector is empty and the
// "Add segmentation" entry point is shown again.
await expect(panel.rows).toHaveCount(0);
await expect(addSegmentationButton.button).toBeVisible();
});
});
@@ -24,7 +24,6 @@ test('should launch MPR with unhydrated RTSTRUCT chosen from the data overlay me
const dataOverlayPageObject = (await viewportPageObject.getById('default')).overlayMenu
.dataOverlay;
await dataOverlayPageObject.toggle();
const viewportRenderCycle = waitForViewportRenderCycle(page);
await dataOverlayPageObject.addSegmentation('ARIA RadOnc Structure Sets');
// Adding an overlay should not show the LOAD button.
@@ -32,8 +31,7 @@ test('should launch MPR with unhydrated RTSTRUCT chosen from the data overlay me
// Hide the overlay menu.
await dataOverlayPageObject.toggle();
await viewportRenderCycle;
await waitForViewportsRendered(page);
await checkForScreenshot(
page,
@@ -43,8 +41,8 @@ test('should launch MPR with unhydrated RTSTRUCT chosen from the data overlay me
await mainToolbarPageObject.layoutSelection.MPR.click();
await waitForViewportsRendered(page, { timeout: 40000 });
// Waiting for the render via waitForViewportRenderCycle appears to wait 'forever', so instead
// we use the baked in wait for screenshot comparisons.
await checkForScreenshot(
page,
viewportPageObject.grid,
+6 -13
View File
@@ -5,7 +5,6 @@ import {
screenShotPaths,
test,
visitStudy,
waitForPaintToSettle,
waitForViewportsRendered,
waitForViewportRenderCycle,
expect,
@@ -44,9 +43,6 @@ test.describe('3D four up SEG hydration', async () => {
await expect(DOMOverlayPageObject.viewport.segmentationHydration.locator).toBeVisible({
timeout: 60000,
});
await waitForViewportsRendered(page, { timeout: 60000 });
await page.waitForTimeout(3000);
await waitForPaintToSettle(page);
await checkForScreenshot(
page,
@@ -58,18 +54,12 @@ test.describe('3D four up SEG hydration', async () => {
// High rendered timeout needed: layout has 4 viewports (3D volume + MPR planes + SEG overlays),
// which can take significantly longer time to fully render
viewportRenderCycle = waitForViewportRenderCycle(page, { renderedTimeout: 180000 });
viewportRenderCycle = waitForViewportRenderCycle(page, { renderedTimeout: 240000 });
await DOMOverlayPageObject.viewport.segmentationHydration.yes.click();
// Wait until all viewports have finished rendering
await viewportRenderCycle;
// 3D volume rendering keeps streaming refined geometry after the load
// status flips; give the GPU a window to present the final frame before
// screenshotting.
await waitForViewportsRendered(page, { timeout: 180000 });
await page.waitForTimeout(3000);
await waitForPaintToSettle(page);
await checkForScreenshot({
page,
@@ -92,12 +82,15 @@ test.describe('3D four up to 3x2 layout SEG hydration', () => {
mainToolbarPageObject,
viewportPageObject,
}) => {
let viewportRenderCycle = waitForViewportRenderCycle(page, { renderedTimeout: 240000 });
await mainToolbarPageObject.layoutSelection.threeDFourUp.click();
await viewportRenderCycle;
let viewportRenderCycle = waitForViewportRenderCycle(page);
// Switch to a manual 3x2 grid layout
await mainToolbarPageObject.layoutSelection.grid(3, 2).click();
await viewportRenderCycle;
// Wait for the 3x2 grid to be rendered.
await expect(viewportPageObject.getNthLocator(5)).toBeVisible();
// Activate the 3rd viewport (index 2) then load the SEG into it
await viewportPageObject.getNthLocator(2).click();
+12 -12
View File
@@ -3,7 +3,6 @@ import {
screenShotPaths,
test,
visitStudy,
waitForPaintToSettle,
waitForViewportRenderCycle,
waitForViewportsRendered,
} from './utils';
@@ -36,11 +35,11 @@ test('should properly display MPR for MR', async ({
await leftPanelPageObject.loadSeriesByDescription('SEG');
// SEG load triggers a progressive labelmap volume upload. waitForViewportsRendered
// (waitVolumeLoad defaults to true) polls the viewport volume actors until the
// labelmap reports loadStatus.loaded, then settles, so the screenshot captures the
// finished upload rather than a mid-stream frame.
await waitForViewportsRendered(page);
// SEG load triggers an additional progressive labelmap upload after the
// viewports first report 'rendered'; let that finish before screenshotting.
await page.waitForTimeout(1500);
await waitForPaintToSettle(page);
await checkForScreenshot(
page,
@@ -54,11 +53,11 @@ test('should properly display MPR for MR', async ({
await DOMOverlayPageObject.viewport.segmentationHydration.yes.click();
await viewportRenderCycle;
// Hydration propagates the labelmap volume to the sagittal/coronal MPR
// viewports asynchronously; wait for that propagation to render before
// capturing.
await page.waitForTimeout(1500);
await waitForPaintToSettle(page);
// Hydration propagates the labelmap volume to the sagittal/coronal MPR viewports
// asynchronously, adding new volume actors after the first render cycle resolves.
// waitForViewportsRendered re-polls every viewport's volume actors until those
// propagated labelmaps report loadStatus.loaded, then settles.
await waitForViewportsRendered(page);
await checkForScreenshot(
page,
@@ -71,8 +70,9 @@ test('should properly display MPR for MR', async ({
await mainToolbarPageObject.layoutSelection.axialPrimary.click();
await viewportRenderAfterLayoutChange;
await page.waitForTimeout(1000);
await waitForPaintToSettle(page);
// The layout change rebuilds the viewports; wait for their volume actors (image
// + labelmap) to report loaded before settling and capturing.
await waitForViewportsRendered(page);
await checkForScreenshot(
page,
+33
View File
@@ -60,6 +60,39 @@ export class DOMOverlayPageObject {
return new DicomTagBrowserPageObject(page);
},
get colorPicker() {
const locator = page.getByTestId('color-picker-dialog');
const hexInput = locator.getByLabel('hex');
const saveButton = locator.getByTestId('color-picker-save-btn');
const cancelButton = locator.getByTestId('color-picker-cancel-btn');
return {
locator,
hexInput,
saveButton,
cancelButton,
fillHex: async (hex: string) => {
await hexInput.fill(hex);
await hexInput.press('Enter');
},
save: async () => {
await saveButton.click();
},
cancel: async () => {
await cancelButton.click();
},
fillHexAndSave: async (hex: string) => {
await hexInput.fill(hex);
await hexInput.press('Enter');
await saveButton.click();
},
fillHexAndCancel: async (hex: string) => {
await hexInput.fill(hex);
await hexInput.press('Enter');
await cancelButton.click();
},
};
},
title: page.locator('[role="dialog"] h2'),
};
}
+94 -6
View File
@@ -2,6 +2,16 @@ import { Locator, Page } from '@playwright/test';
import { DOMOverlayPageObject } from './DOMOverlayPageObject';
/** The segmentation selector (dropdown) returned by the segmentation panels. */
export type SegmentationSelect = {
locator: Locator;
selectedValue: Locator;
getSegmentationLabels: () => Promise<Locator>;
close: () => Promise<void>;
nthSegmentation: (n: number) => Promise<Locator>;
selectNthSegmentation: (n: number) => Promise<void>;
};
export class RightPanelPageObject {
readonly page: Page;
private readonly DOMOverlayPageObject: DOMOverlayPageObject;
@@ -27,16 +37,34 @@ export class RightPanelPageObject {
await button.click();
await page.getByRole('menuitem', { name: 'Delete' }).click();
},
removeFromViewport: async () => {
await button.click();
await page.getByRole('menuitem', { name: 'Remove from Viewport' }).click();
},
rename: async (text: string) => {
await button.click();
await page.getByRole('menuitem', { name: 'Rename' }).click();
await this.DOMOverlayPageObject.dialog.input.fillAndSave(text);
},
cancelRename: async (newName?: string) => {
await button.click();
await page.getByRole('menuitem', { name: 'Rename' }).click();
if (newName) {
await this.DOMOverlayPageObject.dialog.input.fillAndCancel(newName);
} else {
await this.DOMOverlayPageObject.dialog.input.cancel();
}
},
createNewSegmentation: async () => {
await button.click();
await page.getByRole('menuitem', { name: 'Create New Segmentation' }).click();
},
};
}
private getActionsMenu(row: Locator) {
const actionsButton = row.getByTestId('actionsMenuTrigger');
const lockToggle = this.page.getByTestId('LockToggle');
return {
button: actionsButton,
@@ -47,13 +75,14 @@ export class RightPanelPageObject {
await actionsButton.click();
await this.page.getByTestId('Delete').click();
},
// Opens the actions menu and returns the lock/unlock menu item locator
lockToggleMenuItem: async () => {
await actionsButton.click();
return lockToggle;
},
toggleLock: async () => {
await actionsButton.click();
await this.page.getByTestId('LockToggle').click();
},
unlock: async () => {
await actionsButton.click();
await this.page.getByTestId('Unlock').click();
await lockToggle.click();
},
rename: async (text: string) => {
await actionsButton.click();
@@ -73,6 +102,26 @@ export class RightPanelPageObject {
await actionsButton.click();
await this.page.getByTestId('Duplicate').click();
},
openChangeColor: async () => {
await actionsButton.click();
await this.page.getByTestId('Change Color').click();
},
changeColor: async (hex: string) => {
await actionsButton.click();
await this.page.getByTestId('Change Color').click();
await this.DOMOverlayPageObject.dialog.colorPicker.fillHexAndSave(hex);
},
// This function assumes the user opens the change color dialog,
// but then cancels out of it instead of saving a new color.
cancelChangeColor: async (hex?: string) => {
await actionsButton.click();
await this.page.getByTestId('Change Color').click();
if (hex) {
await this.DOMOverlayPageObject.dialog.colorPicker.fillHexAndCancel(hex);
} else {
await this.DOMOverlayPageObject.dialog.colorPicker.cancel();
}
},
};
}
@@ -86,6 +135,12 @@ export class RightPanelPageObject {
get title() {
return row.getByTestId('data-row-title');
},
get lockIcon() {
return row.locator('g#Lock');
},
get rowDataColorHex() {
return row.getByTestId('data-row-colorhex');
},
click: async () => {
await row.getByTestId('data-row-title').click();
},
@@ -168,7 +223,7 @@ export class RightPanelPageObject {
};
}
private getSegmentationSelect(type: string) {
private getSegmentationSelect(type: string): SegmentationSelect {
const page = this.page;
const suffix = type ? `-${type}` : '';
const locator = page.getByTestId(`segmentation-select${suffix}`);
@@ -184,6 +239,15 @@ export class RightPanelPageObject {
locator,
/** The span showing the currently selected segmentation label */
selectedValue,
// Opens the dropdown and returns the option locator; leaves it open, so call close() after.
getSegmentationLabels: async () => {
await locator.click();
return page.getByRole('option');
},
// Click the selected option to dismiss without changing the active segmentation.
close: async () => {
await page.getByRole('option', { selected: true }).click();
},
/** Opens the dropdown and returns a locator for the nth option (0-based) */
nthSegmentation,
/** Opens the dropdown and clicks the nth segmentation (0-based) */
@@ -203,6 +267,17 @@ export class RightPanelPageObject {
};
}
/** The "Add Segment" row button of the active segmentation in the visible panel */
private get addSegmentButton() {
const button = this.page.getByRole('button', { name: 'Add Segment' });
return {
button,
click: async () => {
await button.click();
},
};
}
private getSegmentsVisibilityToggle(type?: string) {
const testId = type
? `all-segments-visibility-toggle-${type}`
@@ -227,9 +302,18 @@ export class RightPanelPageObject {
// Retrying-friendly locator for `expect(...).toHaveCount(n)` — prefer this
// over the one-shot getSegmentCount() when asserting row counts.
rows: page.getByTestId('data-row'),
/**
* @deprecated One-shot count that races the render. Prefer
* `expect(panel.rows).toHaveCount(n)` for assertions. Use this only to
* capture a stable baseline value (e.g. for a delta).
*/
getSegmentCount: async () => {
return await page.getByTestId('data-row').count();
},
// get all the segment titles in the panel
getSegmentLabels: () => {
return page.getByTestId('data-row-title');
},
// No data-cy exists in this panel, using Segmentation header button
locator: page.getByRole('button', { name: 'Segmentations' }),
nthSegment(index: number) {
@@ -244,6 +328,7 @@ export class RightPanelPageObject {
get contourSegmentationPanel() {
const page = this.page;
const addSegmentationButton = this.addSegmentationButton;
const addSegmentButton = this.addSegmentButton;
const panel = this.getSegmentationPanel('Contour');
const menuButton = page.getByTestId('panelSegmentationWithToolsContour-btn');
const segmentationSelect = this.getSegmentationSelect('Contour');
@@ -251,6 +336,7 @@ export class RightPanelPageObject {
return {
addSegmentationButton,
addSegmentButton,
menuButton,
segmentsVisibilityToggle,
panel,
@@ -263,12 +349,14 @@ export class RightPanelPageObject {
get labelMapSegmentationPanel() {
const page = this.page;
const addSegmentationButton = this.addSegmentationButton;
const addSegmentButton = this.addSegmentButton;
const panel = this.getSegmentationPanel('Labelmap');
const menuButton = page.getByTestId('panelSegmentationWithToolsLabelMap-btn');
const segmentationSelect = this.getSegmentationSelect('Labelmap');
return {
addSegmentationButton,
addSegmentButton,
menuButton,
panel,
segmentationSelect,
+26 -18
View File
@@ -1,6 +1,5 @@
import { Locator, Page } from '@playwright/test';
import {
getMousePosition,
simulateClicksOnElement,
simulateDoubleClickOnElement,
simulateNormalizedClicksOnElement,
@@ -362,6 +361,28 @@ export class ViewportPageObject {
throw new Error('Could not find slab thickness handle for crosshairs interaction');
}
// Drive the drag from the handle's own bounding-box center rather than the
// async window.mouseX/Y tracker: the tracker can lag behind the hover, which
// makes the drag start from a stale point and rotate/resize nothing. Stepped
// moves emit intermediate mousemove events so cornerstone registers a real
// drag instead of a single teleport (which can be dropped or mis-deltad).
const DRAG_DISTANCE = 100;
const DRAG_STEPS = 10;
async function dragHandleFromCenter(handle: Locator, dx: number, dy: number) {
const box = await handle.boundingBox();
if (!box) {
throw new Error('Could not resolve crosshairs handle bounding box for drag');
}
const cx = box.x + box.width / 2;
const cy = box.y + box.height / 2;
await page.mouse.move(cx, cy);
await page.mouse.down();
await page.mouse.move(cx + dx, cy + dy, { steps: DRAG_STEPS });
await page.mouse.up();
}
async function increaseSlabThickness(locator: Locator, lineNumber: number, axis: string) {
const lineLocator = locator.locator('line').nth(lineNumber);
await lineLocator.click({ force: true });
@@ -370,18 +391,9 @@ export class ViewportPageObject {
const slabHandleLocator = await getSlabHandleLocator(locator);
await slabHandleLocator.hover({ force: true, timeout: crosshairHoverTimeout });
await page.mouse.down();
const position = await getMousePosition(page);
switch (axis) {
case 'x':
await page.mouse.move(position.x + 100, position.y);
break;
case 'y':
await page.mouse.move(position.x, position.y + 100);
break;
}
await page.mouse.up();
const dx = axis === 'x' ? DRAG_DISTANCE : 0;
const dy = axis === 'y' ? DRAG_DISTANCE : 0;
await dragHandleFromCenter(slabHandleLocator, dx, dy);
}
async function rotateCrosshairs(locator: Locator, lineNumber: number) {
@@ -393,11 +405,7 @@ export class ViewportPageObject {
await circleLocator.waitFor({ state: 'attached', timeout: crosshairHoverTimeout });
await circleLocator.hover({ force: true, timeout: crosshairHoverTimeout });
await page.mouse.down();
const position = await getMousePosition(page);
await page.mouse.move(position.x, position.y + 100);
await page.mouse.up();
await dragHandleFromCenter(circleLocator, 0, DRAG_DISTANCE);
}
function crosshairsFactory(
Binary file not shown.

Before

Width:  |  Height:  |  Size: 248 KiB

After

Width:  |  Height:  |  Size: 243 KiB

+24 -1
View File
@@ -1,7 +1,8 @@
import { Page } from '@playwright/test';
import { Locator, Page } from '@playwright/test';
import { expect } from 'playwright-test-coverage';
import { DOMOverlayPageObject } from '../pages';
import type { SegmentationSelect } from '../pages/RightPanelPageObject';
/**
* Asserts the number of Modality Load Badges present on the page.
@@ -65,3 +66,25 @@ export async function assertBoundingBoxIsContainedWithin({
export async function expectRowSelected(rowObject) {
await expect(rowObject.locator).toContainClass('bg-popover');
}
export async function expectRowLocked(rowObject: { lockIcon: Locator }) {
await expect(rowObject.lockIcon, 'Expected the row to show the lock icon').toHaveCount(1);
}
export async function expectRowUnlocked(rowObject: { lockIcon: Locator }) {
await expect(rowObject.lockIcon, 'Expected the row to not show the lock icon').toHaveCount(0);
}
export async function expectRowNotSelected(rowObject) {
await expect(rowObject.locator).not.toContainClass('bg-popover');
}
// Opens the segmentation selector, asserts its options match `labels`, then closes it.
export async function expectSegmentationLabels(
segmentationSelect: SegmentationSelect,
labels: string[]
) {
const options = await segmentationSelect.getSegmentationLabels();
await expect(options).toHaveText(labels);
await segmentationSelect.close();
}
+16
View File
@@ -0,0 +1,16 @@
import type { RightPanelPageObject } from '../pages';
// Hide all segments, to show only the nth one and makes it the active segment
export async function contourShowOnlyNthSegment({
segmentationPanel,
index = 0,
}: {
segmentationPanel: RightPanelPageObject['contourSegmentationPanel'];
index?: number;
}) {
await segmentationPanel.segmentsVisibilityToggle.click();
const segment = segmentationPanel.panel.nthSegment(index);
await segment.toggleVisibility();
await segment.click();
return segment;
}
+18 -5
View File
@@ -5,6 +5,8 @@ type AnnotationStats = {
toolName: string;
referencedImageId?: string;
FrameOfReferenceUID?: string;
label?: string;
text?: string;
cachedStats: Record<string, TargetStats>;
targetIds: string[];
firstTargetStats: TargetStats | undefined;
@@ -14,10 +16,17 @@ type Options = {
toolName?: string | string[];
attempts?: number;
intervalMs?: number;
/**
* When true (default), only resolves once at least one matching annotation has
* populated `cachedStats`. Set to false for tools whose source of truth is
* `data.label`/`data.text` rather than computed stats (e.g. `ArrowAnnotate`),
* in which case any matching annotation is returned.
*/
requireStats?: boolean;
};
const getAnnotationStats = async (page, options: Options = {}): Promise<AnnotationStats[]> => {
const { toolName, attempts = 20, intervalMs = 500 } = options;
const { toolName, attempts = 20, intervalMs = 500, requireStats = true } = options;
const toolNames =
toolName === undefined ? undefined : Array.isArray(toolName) ? toolName : [toolName];
@@ -38,6 +47,8 @@ const getAnnotationStats = async (page, options: Options = {}): Promise<Annotati
toolName: a.metadata?.toolName,
referencedImageId: a.metadata?.referencedImageId,
FrameOfReferenceUID: a.metadata?.FrameOfReferenceUID,
label: a?.data?.label,
text: a?.data?.text,
cachedStats,
targetIds,
firstTargetStats: targetIds.length ? cachedStats[targetIds[0]] : undefined,
@@ -47,16 +58,18 @@ const getAnnotationStats = async (page, options: Options = {}): Promise<Annotati
{ toolNames }
);
const populated = results.filter(r => r.targetIds.length > 0);
if (populated.length > 0) {
return populated;
const matching = requireStats ? results.filter(r => r.targetIds.length > 0) : results;
if (matching.length > 0) {
return matching;
}
await new Promise(resolve => setTimeout(resolve, intervalMs));
}
throw new Error(
`No annotations${toolNames ? ` for tool(s) ${toolNames.join(',')}` : ''} with populated cachedStats found`
`No annotations${toolNames ? ` for tool(s) ${toolNames.join(',')}` : ''}${
requireStats ? ' with populated cachedStats' : ''
} found`
);
};
+5 -4
View File
@@ -1,8 +1,5 @@
import { visitStudy } from './visitStudy';
import {
addOHIFConfiguration,
addOHIFGlobalCustomizations,
} from './OHIFConfiguration';
import { addOHIFConfiguration, addOHIFGlobalCustomizations } from './OHIFConfiguration';
import { checkForScreenshot } from './checkForScreenshot';
import { screenShotPaths } from './screenShotPaths';
import {
@@ -26,6 +23,8 @@ import { attemptAction } from './attemptAction';
import { addLengthMeasurement } from './addLengthMeasurement';
import { getSvgAttribute } from './getSvgAttribute';
import { navigateWithViewportArrow } from './navigateWithViewportArrow';
import { contourShowOnlyNthSegment } from './contourShowOnlyNthSegment';
import { visitStudyAndHydrate } from './visitStudyAndHydrate';
import { test, expect } from './fixture';
import { subscribeToMeasurementAdded } from './subscribeToMeasurement';
import {
@@ -60,6 +59,8 @@ export {
subscribeToMeasurementAdded,
getSvgAttribute,
navigateWithViewportArrow,
contourShowOnlyNthSegment,
visitStudyAndHydrate,
waitForAnyViewportNeedsRender,
waitForViewportsRendered,
waitForViewportRenderCycle,
+31
View File
@@ -0,0 +1,31 @@
import { Page } from '@playwright/test';
import { expect } from 'playwright-test-coverage';
import type { DOMOverlayPageObject, LeftPanelPageObject } from '../pages';
import { visitStudy } from './visitStudy';
import { waitForViewportsRendered } from './waitForViewportsRendered';
// Visits a study and accepts the segmentation hydration prompt
export async function visitStudyAndHydrate({
page,
leftPanelPageObject,
DOMOverlayPageObject,
studyInstanceUID,
modality,
mode = 'segmentation',
}: {
page: Page;
leftPanelPageObject: LeftPanelPageObject;
DOMOverlayPageObject: DOMOverlayPageObject;
studyInstanceUID: string;
modality: string;
mode?: string;
}) {
await visitStudy(page, studyInstanceUID, mode, 2000);
await leftPanelPageObject.loadSeriesByModality(modality);
await waitForViewportsRendered(page);
await expect(DOMOverlayPageObject.viewport.segmentationHydration.locator).toBeVisible();
await DOMOverlayPageObject.viewport.segmentationHydration.yes.click();
}