Skip to content

Test/shared helpers - #36

Merged
alekswebnet merged 2 commits into
mainfrom
test/shared-helpers
Oct 15, 2026
Merged

alekswebnet merged 2 commits into
mainfrom
test/shared-helpers

Conversation

@alekswebnet

@alekswebnet alekswebnet commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Changes

Verification

  • 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

alekswebnet and others added 2 commits October 15, 2026 13:09
…icated helper

Found by a scan of the whole tree on 2026-10-15, prompted by a test helper that
polled a state array instead of using the element's own event.

Defects:
- The Jobs worker's forward-index publisher was a promise chain that stayed
  rejected after one refused write: every later snapshot was skipped, each
  publish became an unhandled rejection, and the final publish failed a
  download whose every chunk had landed. Each link now catches, warns once,
  and the chain goes on; the index is an early boot, never the download.
- The verifier reported any failure of its ready wait as a timeout, a crashed
  browser included; only Playwright's TimeoutError is one now.
- `h5p-normalize --bogus` printed a Node stack trace; it prints the message and
  the usage and exits 2, as the other two commands do.
- The normalizer never aborted its output stream when an entry threw, so the
  `.part` file stayed open until collection; `StreamingZipWriter.abort` now.

One copy of what was written twice or more:
- `hex` and `randomHex` in pkg-id.ts, for the five hex idioms and the two
  `createNonce`s; `reachableFolder` for the reader's one library-resolution
  rule, written three times; `extensionOf` in place of its re-implementation;
  the local-header constants read from local-header.ts; `entryResponse` for
  the three 200-or-206 blocks in the virtual server; `awaitJob` under
  `runDownload` and `runWarm`; `deferredStream`, `inflated` and `readDataStart`
  in shared/, for the server, the Jobs worker and the warm.
- The runtime's content check and content upgrade parsed library strings
  differently, one taking `H5P.Foo-1.0` and the other only `H5P.Foo 1.0`;
  `library-names.ts` is the one parser and walker. The boot script's three
  bounded reads share `boundedFetch`, and the `upgrades.js` fetch is bounded.
- cmi5's `rejectionReason` reads refusals through the client's `reasonIn`.
- The demo pages' `foreignHost`, message box, log and trust prompt, three
  byte-identical copies, are `demo/page-common.js`; the two hub-reading build
  scripts share `scripts/lib/hub.mjs`; the site's page list lives once, in
  `scripts/lib/pages.mjs`, for the build and the sitemap.

Dead code and stale comments: `readArchiveRange`, the write-only `rejected`
field, four protocol fields nothing read, six dead exports, `escapeHtml`'s
unused parameter, `L10nTable`; the element's account of what emptying the
frame does, the demo content build's note on a constant that no longer exists.
`observedAttributes` lists the two attributes the callback acts on. `resize`
and `statechange` have typed details. Every swallowed error carries its
reason, or fails loudly: the deep dependency check names a `library.json` it
cannot read instead of passing a tree it did not walk; the app's file reads
and Start over report their failure. The dev server's throttled body no longer
parks on a client that went away; the fixture builder checks its two lists
agree; the installed-app screenshots wait for fonts and the first frame.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…lace of polls and sleeps

The player's browser suite: `settle` and `play` in utils for the quartet that
was retyped in eleven tests and two local helpers; `waitForEvent` takes a
filter, so four tests wait on the event they mean rather than polling a list a
listener fills; `inject` says what became of a script and takes its listeners
off; `messageOf` and `pressComplete` for the fixture's message and button;
`waitFor` is `vi.waitUntil`; `requestedUrls` over a `vi.spyOn` in place of two
hand-rolled fetch spies. The Jobs worker test listens for the third `done`
instead of a one-shot wait with a swallowed timeout and an interval poll. Three
100 ms sleeps after `resize` go, since the element writes its height on the
line after it dispatches the event; the frame-empty wait is the iframe's
`load`; the stalling tests wait on extraction progress; the one sleep that
has to stay names the core's save delay. `cacheNameFor` in place of three
hard-coded cache names that would open an empty cache at the next major.

The unit suite: the archive, handle and fake-cache helpers once, in
`helpers/`, in place of copies in seven files; static imports.

The demo's tests: `tests/harness.ts` starts the dev server, the second-origin
package host and waits on the element, in place of four copies of the setup
and two of the host; the app test's repeated waits are `goneHome`,
`recentShown`, `recentGone` and `atDepth`, which replaces the two 100 ms
sleeps with the history state they stood in for; the installed profile is an
option of `openApp`. The cmi5 mock's LRS resolves its waiters as a statement
lands, and answers a throw rather than leaving the request open. The embed
site test's `untrusted`, `started` and `librariesOf` are hoisted; the runtime
test's thirteen casts are `stepsOf`; the verifier test's two quiz fixtures
share `rewrittenQuiz`.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@alekswebnet alekswebnet self-assigned this Oct 15, 2026
@alekswebnet
alekswebnet merged commit 196c11f into main Oct 15, 2026
8 checks passed
@alekswebnet
alekswebnet deleted the test/shared-helpers branch October 15, 2026 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant