Test evidence: fiesta.js: menus, switch drag, touch press and a scheme switch that remembers on a static site open
On branch fiesta-1
Test evidence for Task 4 of the Fiesta packaging, copied from the implementer's report so it sits on the branch.
Commits
- 3e1b1d8 fiesta.js: menus, switch drag, touch press and a scheme switch that remembers on a static site
RED: the smoke test before any js/fiesta.js existed
$ go test -tags browser -run 'TestTheFixturePageLoadsEveryAsset' ./check/ -count=1
--- FAIL: TestTheFixturePageLoadsEveryAsset (0.64s)
rig_browser_test.go:663: GET http://localhost:45739/fiesta.js answered 404, want 200
rig_browser_test.go:672: fiesta.js did not run on the page: window.fiestaShim is not set
rig_browser_test.go:674: harness: the smoke page with every asset: the page reported problems:
HTTP 404 GET http://localhost:45739/fiesta.jsAgainst the stub (SEED's file) it still failed, on window.fiestaShim is not set alone.
RED: the untagged tests against the stub (SEED's rastrillo.js copied unchanged, 19,434 bytes)
--- FAIL: TestShimContract (0.00s)
scripts_test.go:72: shim does not mention "\"rst-scheme\""
scripts_test.go:72: shim does not mention "\"fiesta-scheme\""
scripts_test.go:72: shim does not mention "data-rst-scheme-store"
scripts_test.go:72: shim does not mention "localStorage"
--- FAIL: TestFiestaJSHasNoServerBehaviour (0.00s)
scripts_test.go:165: fiesta.js mentions "data-poll"; the server half stays in rastrillo
scripts_test.go:165: fiesta.js mentions "EventSource"; the server half stays in rastrillo
scripts_test.go:165: fiesta.js mentions "Rastrillo-"; the server half stays in rastrillo
scripts_test.go:165: fiesta.js mentions "document.cookie"; the server half stays in rastrillo
scripts_test.go:165: fiesta.js mentions "fetch("; the server half stays in rastrillo
--- FAIL: TestFiestaJSIsSmall (0.00s)
scripts_test.go:177: fiesta.js is 19434 bytes; the point is that a reader can take it in one sitting, trim it
--- FAIL: TestFiestaJSIsIdempotent (0.03s)
scripts_test.go:221: two evaluations registered 24 listeners, one registered 12; the second copy is not inert
--- FAIL: TestAStandaloneSubmitStoresTheScheme (0.03s)
scripts_test.go:233: after Dark: theme "dark", prevented true, stored "", cookie writes 1; want dark, true, dark, 0
scripts_test.go:236: rst-scheme events [], want one with detail.scheme dark
--- FAIL: TestSystemClearsTheStoredScheme (0.03s)
scripts_test.go:251: after System: theme "", 1 keys in storage, stored "dark"; want none, 0, none
--- FAIL: TestABrokenStorageStillSwitches (0.02s)
scripts_test.go:269: after Dark on broken storage: theme "dark", prevented true, events []; want dark, true, one
--- FAIL: TestAServerOwnedSubmitStoresNothing (0.03s)
scripts_test.go:284: a server-owned submit made 0 storage calls, left 0 keys and wrote 1 cookies; want none
--- FAIL: TestTheStoredSchemeIsAppliedOnLoad (0.03s)
scripts_test.go:295: after evaluating the script, data-theme is "", want dark
scripts_test.go:298: once the DOM is ready, aria-current is on "system", want dark
FAILTestShimContract failed on exactly the four replaced needles and on none of the kept ones. TestTheLightDismissGateReadsTheMenuList passed on its first run, as a preservation test must. TestAServerOwnedPageIgnoresTheStoredScheme also passed on the stub, which is the honest result: SEED's file never reads storage. Its control is below.
RED: the browser drives against the stub
--- FAIL: TestAStandaloneSchemeSurvivesAReload (0.66s)
scheme_browser_test.go:155: after choosing Dark in place: {Theme:dark Stored: Cookie:rastrillo_scheme=dark Current:dark Open:false Mark:true Early:}
--- FAIL: TestTheStoredSchemeIsSetBeforeTheBodyRuns (0.65s)
scheme_browser_test.go:177: the body's script saw data-theme ""; the restore did not run before the body
--- FAIL: TestAServerOwnedSchemeSurvivesAStandalonePage (0.63s)
scheme_browser_test.go:199: the standalone page did not store Dark: {Theme:dark Stored: Cookie:rastrillo_scheme=dark Current:dark Open:false Mark:true Early:}GREEN
First run of the new file: every behaviour test passed; only TestFiestaJSIsSmall failed, at 13,954 bytes, until two rounds of comment trimming took it to 12,144 with the code untouched.
$ FIESTA_TEST_REQUIRE_NODE=1 go test -run 'Shim|FiestaJS|Scheme|Stored|Standalone|ServerOwned|Broken|LightDismiss' ./check/ -count=1 -v
--- PASS: TestShimContract ... TestAServerOwnedPageIgnoresTheStoredScheme (eleven tests)
ok amadan.net/rastrillo/fiesta/check 0.200s
$ go test -tags browser -run '...|FixturePage' ./check/ -count=1 -v
--- PASS: TestTheFixturePageLoadsEveryAsset (0.94s)
--- PASS: TestAStandaloneSchemeSurvivesAReload (1.17s)
--- PASS: TestTheStoredSchemeIsSetBeforeTheBodyRuns (1.08s)
--- PASS: TestAServerOwnedSchemeSurvivesAStandalonePage (0.82s)
ok amadan.net/rastrillo/fiesta/check 4.282smake ci: gofmt, no-rastrillo, root, staticcheck, govulncheck, gitleaks (9 commits), browser.internal.harness (7.556s), browser.check (5.429s). Exit 0.
Negative control for the test the stub could not fail
A scratch mutation of js/fiesta.js dropped if (!remembers) return null; from stored():
--- FAIL: TestAServerOwnedSubmitStoresNothing (0.03s)
scripts_test.go:284: a server-owned submit made 1 storage calls, left 0 keys and wrote 0 cookies; want none
--- FAIL: TestAServerOwnedPageIgnoresTheStoredScheme (0.03s)
scripts_test.go:308: a server-owned page took data-theme "dark" from storage; want none
scripts_test.go:311: a server-owned page read storage 1 times on load; want neverReverted from a copy under $TMPDIR, byte count back to 12,144.