test(journeys): the six remaining content types, as their scripts run them

Merged
AL
1d ago
+821-5

Summary

Closes the content types still open in #314: Drag and Drop, Column, Interactive Book, Image Hotspots, Accordion and Dialog Cards, one commit each. Each journey is written from the type's own script, read first at the pack's version. 38 cases; the suite now holds 94.

Changes

Drag and Drop 1.15 (drag-and-drop.test.ts, 10 cases; h5p/h5p-drag-question src/ at 1.15.37):

  • a point for each element in a zone it belongs in; at full score no Retry, and the statements a drop and a check send;
  • a point off for each element in a wrong zone, never below nothing, and one off for an element that belongs in no zone, wherever it is dropped;
  • Retry puts every element back; nothing off with penalties turned off; no Retry where the author turned it off;
  • one point for the whole task, and only for all of it;
  • an element with endless copies leaves another behind, and counts once for each zone it belongs in;
  • a zone made for one element sends a second back; a zone's own words for a right and a wrong match; resume.

Column 1.22 (column.test.ts, 5 cases; scripts/h5p-column.js):

  • it reports the sum of its tasks once each has a result, saying how far the learner is on the way, with text counted as no task;
  • it reports again each time a task is checked after that; never for a page with no task;
  • a task in a row counts beside the page's own; resume.

Interactive Book 1.15 (interactive-book.test.ts, 7 cases; h5p/h5p-interactive-book src/scripts/ at 1.15.1):

  • a chapter is done once each of its tasks has an answer, checked or not, and one with no task on moving on;
  • the book reports itself only from Submit Report on its summary, once, and offers that only where the host takes reports;
  • Restart starts every chapter over, from the first;
  • with automatic progress off, the learner says when a page is finished;
  • a cover, and the first chapter from Read; resume on the chapter being read.

Image Hotspots 1.11 (image-hotspots.test.ts, 6 cases; scripts/hotspot.js, popup.js at 1.11.6):

  • a spot's words under its header, with the focus moved into them; Close;
  • one popup at a time: it lies over the other spots, and a press on the picture closes it;
  • Enter and Space; a popup over the whole picture where the author asked;
  • nothing reported, nothing kept.

Accordion 1.0 (accordion.test.ts, 4 cases; h5p-accordion.js at 1.0.47):

  • every panel shut at first; one open at a time; shut on a second press;
  • the arrow keys between titles, with Enter and Space;
  • no result and nothing kept.

Dialog Cards 1.9 (dialog-cards.test.ts, 6 cases; h5p/h5p-dialogcards src/scripts/ at 1.9.40):

  • Turn; Next and Previous with the count; Retry once the last card is turned;
  • in repetition: knew-it buttons only once a card is turned; a round's summary; the next round brings every card got wrong and half of those got right; a card completed after as many rounds known as the author set, then only Retry; resume in the round and on the card reached.

design/testing.md: what only these scripts said, what a case waits for, and the six types in the covered list.

Found on the way, not fixed here: the page never hears a statement a content type sends as it starts. Accordion's only statement (consumed, with completion: true) and the attempted most types send are lost, because the frame's boot script starts listening after H5P.init(). The same statement sent later arrives. The Accordion journey therefore asserts no statement of its own.

Verification

  • In apps/journeys, each new file three times in Chromium and once each in Firefox and WebKit: all pass (10, 5, 7, 6, 4 and 6 cases).

  • The whole journeys suite in Chromium: 13 files, 94 passed, 114 s.

  • pnpm typecheck for the journeys, pnpm lint, pnpm comments: pass.

  • Not covered: a Drag and Drop on a background picture, its keyboard way of placing an element and its score explanation; a book's table of contents and its links to a section; pictures, audio and tips on a dialog card, and quick progression.

  • Tests added or updated where behavior changed

  • Documentation updated where public behavior or deployment changed

  • Relevant type checks, tests, and builds pass

  • No security-sensitive details or credentials are included

Screenshots or reproduction

cd apps/journeys && pnpm test

Summary by cubic

Adds journey tests for the six content types still open in #314: Drag and Drop, Column, Interactive Book, Image Hotspots, Accordion, and Dialog Cards. Each journey is written from the type's own script, read at the pack's version, and verified against it rather than the editor's fields. 38 cases; the suite now holds 94.

  • Ten Drag and Drop cases verify scoring rules, Retry and penalty settings, single-point mode, zone-specific feedback, infinite element copies, one-element zones, resume, and the statements each interaction sends.
  • Five Column cases verify it reports the sum of its tasks' results once each has one, again each time one is checked, never for a page with no task, counts a task inside a row, and resumes.
  • Seven Interactive Book cases verify each chapter completes once its tasks have answers, the book reports only from Submit Report where the host takes them, Restart, manual progress, the cover, and resume.
  • Six Image Hotspots cases verify opening a spot's words, focus, Close, one popup at a time, keyboard access, full-picture popups, and that nothing is reported or kept.
  • Four Accordion cases verify panels shut at first, one open at a time, arrow-key navigation, and no result or saved state.
  • Six Dialog Cards cases verify Turn, leafing with the count, Retry, and repetition rounds: knew-it buttons, round summaries, cards brought back, a mastered card, and resume.
  • design/testing.md records behaviors only the scripts state, including a lost statement the frame's boot script misses, and lists all six types among the covered pack types.