For the complete documentation index, see llms.txt. This page is also available as Markdown.

Testing Strategy

← Back to Index

Priority: Automated tests FIRST, manual testing as supplementary safety net.

Philosophy: Automated Tests Are Primary

Before writing ANY refactoring code:

  1. Write comprehensive automated tests for current behaviour

  2. Verify tests pass (establish baseline)

  3. Make refactoring changes

  4. Tests still pass (green to green refactoring)

  5. (Optional) Run manual testing checklist for extra confidence

Why automated tests first?

  • Immediate feedback on every change

  • No manual clicking through scenarios

  • Runs in CI/CD on every commit

  • Documents expected behaviour

  • Prevents regressions permanently

Required Automated Test Coverage

Before Starting Any Phase

You MUST have automated tests covering:

Context Unit Tests

File: content/webapp/contexts/ItemViewerContextV2/ItemViewerContextV2.test.tsx

Test ALL derived values:

Test all edge cases:

New (from restricted-images merge):

Component Integration Tests

Files: Component .refactored.test.tsx files

Test that components actually consume context values:

Download Options Hook Tests (Phase 2)

File: content/webapp/hooks/useDownloadOptions.test.ts

Test download option calculations:

Test edge cases:

Mock Utilities

File: content/webapp/contexts/ItemViewerContextV2/test-utils.ts

Test Examples

See refactoring-iiif-viewer-context-testing.md for complete TypeScript test examples.

Quick example:

Manual Testing Checklist

Use this AFTER automated tests pass as an extra safety net.

For Each Phase: Core Functionality

Different Work Types

Test with these specific work types:

User Scenarios Matrix

The table below lists key combinations of work types, authentication states, and access restrictions. Test coverage should span these scenarios to ensure the viewer handles all cases correctly.

Authentication States:

  • Logged out - no authentication

  • Logged in (regular user) - standard library member

  • Logged in (restricted access) - user with restricted content access (same UI, different access level)

Access Types:

  • ✓ Open access - no restrictions

  • 🔒 Restricted - requires authentication with restricted access role

  • ⚠️ Content advisory - requires clicking through warning modal (any auth state)

Work Type
Logged Out
Logged In (Regular)
Logged In (Restricted)
Example Work ID
Notes

Multi-canvas images

✓ Open

✓ Open

✓ Open

a55dcp3h

Grid view, navigation

Single canvas image

✓ Open

✓ Open

✓ Open

b5kqccbb

No grid/nav controls

Archive items

✓ Open

✓ Open

✓ Open

a222zvge

Tree navigation

Video/audio

✓ Open

✓ Open

✓ Open

a9w3qy3j

In-viewer playback

PDF

✓ Open

✓ Open

✓ Open

ndx5vuhy

In-viewer rendering

Mixed content (born digital)

✓ Open

✓ Open

✓ Open

dn9jwck6

Multiple media types

Content advisory

⚠️ Modal

⚠️ Modal

⚠️ Modal

pnud3fzb

Warning modal required

Restricted whole item

🔒 Blocked

🔒 Blocked

✓ Access granted

rp9jnamu

Auth + role required

Restricted audio

🔒 Blocked

🔒 Blocked

✓ Access granted

esd6gs3s

Auth + role required

Restricted video

🔒 Blocked

🔒 Blocked

✓ Access granted

zsgh5y3z

Auth + role required

Restricted born digital

🔒 Blocked

🔒 Blocked

✓ Access granted

my6bzerr

Auth + role required

Note: The "logged in (restricted)" authentication state only affects access (whether content is granted), not which component renders — the viewer always renders regardless of auth state.

Specific Test Works

The following works provide comprehensive coverage for all scenarios from the matrix above.

Unrestricted Works (Open Access)

Multi-Canvas Image Work

  • Type: Multi-canvas images (unrestricted)

  • What to test: Grid view, canvas navigation, thumbnails, all accessible to everyone

  • Work page: prod | dev

  • Items page: prod | dev

Test with: Logged out | Logged in (regular) | Logged in (restricted)

Single Canvas Image Work

  • Type: Single canvas image (unrestricted)

  • What to test: No grid/nav controls, single image display, all accessible to everyone

  • Work page: prod | dev

  • Images page: prod | dev

Test with: Logged out | Logged in (regular) | Logged in (restricted)

Archive Items

  • Type: Archive with tree navigation (unrestricted)

  • What to test: Archive tree, breadcrumbs, canvas selection from tree, all accessible to everyone

  • Work page: prod | dev

Test with: Logged out | Logged in (regular) | Logged in (restricted)

PDF Work

  • Type: PDF document (unrestricted)

  • What to test: PDF rendering in viewer, download options, all accessible to everyone

  • Work page: prod | dev

  • Items page: prod | dev

Test with: Logged out | Logged in (regular) | Logged in (restricted)

Mixed Media (Born Digital)

  • Type: Mixed content with multiple media types (unrestricted)

  • What to test: Multiple media types in same viewer, navigation between media, all accessible to everyone

  • Work page: prod | dev

  • Items page: prod | dev

Test with: Logged out | Logged in (regular) | Logged in (restricted)

Regular Video (Unrestricted)

  • Type: Open access video

  • What to test: Video player accessible to all users

  • Work page: prod | dev

  • Items page: prod | dev

Test with: Logged out | Logged in (regular) | Logged in (restricted)

Restricted/Special Access Works

Content Advisory (Clickthrough Warning Modal)

  • Type: Restricted/Clickthrough Mix

  • What to test: Modal warning appears for all users before accessing items

  • Work page: prod | dev

  • Items page: prod | dev

Test with: Logged out | Logged in (regular) | Logged in (restricted)

Restricted Whole Item

  • Type: Fully restricted content

  • What to test: Blocked for logged out + regular users; accessible for restricted role

  • Work page: prod | dev

  • Items page: prod | dev

Test with: Logged out | Logged in (regular) | Logged in (restricted)

Restricted Audio

  • Type: Restricted audio content

  • What to test: Audio player only appears for restricted role users

  • Work page: prod | dev

  • Items page: prod | dev

Test with: Logged out | Logged in (regular) | Logged in (restricted)

Restricted Video

  • Type: Restricted video content

  • What to test: Video player only appears for restricted role users

  • Work page: prod | dev

  • Items page: prod | dev

Test with: Logged out | Logged in (regular) | Logged in (restricted)

Restricted Born Digital

  • Type: Restricted born digital/mixed content

  • What to test: Mixed media (PDF/video/audio) only accessible for restricted role

  • Work page: prod | dev

  • Items page: prod | dev

Test with: Logged out | Logged in (regular) | Logged in (restricted)

Edge Cases

Normalisation-Specific Tests

These are critical when normalising variant implementations:

Test currentCanvas Normalisation

Different components previously calculated currentCanvas differently. Verify they all work:

Component
Previous Implementation
What to Test

ViewerTopBar

canvases?.[index]

Download options appear, canvas title shows

ZoomedImage

transformedManifest?.canvases[index]

Zoom shows correct canvas image

MainViewer

May calculate independently

Canvas scrolling works, canvas displays correctly

Thumbnails

Used queryParamToArrayIndex directly

Correct thumbnail highlighted

Key question: Verify the || '' fallback only exists where genuinely needed.

Component
Previous Implementation
What to Test

IIIFViewer

No || '' fallback

iiifImageTemplate handles undefined correctly

ZoomedImage

Had || '' fallback

Verify convertRequestUriToInfoUri still works

Test both:

  1. Canvas WITH imageServiceId - zoom should work

  2. Canvas WITHOUT imageServiceId - should fall back gracefully, no errors

Critical: Test on all supported browsers BEFORE releasing.

Performance Testing

Comparison Testing (Legacy vs Refactored)

Most important test: Side-by-side comparison.

For each work type listed above:

  1. Test with iiifViewerRefactored flag OFF (legacy)

  2. Note behaviour, take screenshots

  3. Test with iiifViewerRefactored flag ON (refactored)

  4. Verify IDENTICAL behaviour and appearance

  5. Document any differences (should be zero)

Test Work IDs

See the User Scenarios Matrix and Specific Test Works sections above for a comprehensive list of test works covering the scenarios listed in this document.

All test scenarios now have example work IDs:

  • ✅ Multi-canvas images: a55dcp3h

  • ✅ Single canvas: b5kqccbb

  • ✅ Archive items: a222zvge

  • ✅ PDF: ndx5vuhy

  • ✅ Mixed media (born digital): dn9jwck6

  • ✅ Video/audio: a9w3qy3j

  • ✅ Content advisory: pnud3fzb

  • ✅ Restricted works: rp9jnamu, esd6gs3s, zsgh5y3z, my6bzerr

When Manual Testing Finds Issues

If manual testing reveals a bug that automated tests didn't catch:

  1. Write an automated test for the bug FIRST

  2. Verify the test fails (reproduces the bug)

  3. Fix the bug

  4. Verify the test passes

  5. Add test to permanent test suite

This prevents the bug from reoccurring and improves test coverage.

Success Criteria

Before marking a phase complete:

Required:

Highly Recommended:


See also:


Next: Risks & Success Metrics

Last updated