Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,8 @@ jobs:
echo "no plain #[test] in any wasm-compiled test module"

# `build:wasm`, not `build:web`. The release profile — lto,
# codegen-units=1, opt-level="s", strip — is what actually ships, and
# codegen-units=1, strip — plus the wasm-only opt-level=3 override in
# `build:wasm` is what actually ships (desktop stays at "s"), and
# `wasm-pack test` above only ever compiles a dev profile, so this is the
# one step that proves the shipped artefact builds at all. The Vite half
# of `build:web` is deliberately not repeated here: the frontend job
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,27 @@ jobs:
- name: Install frontend dependencies
run: bun install --frozen-lockfile

# The bridge is only built in the `build-web` job, but a tag push does
# not trigger CI's `push` gate (main only), so this verify job is the
# release's own WASM check. Build the package first or the parity spec
# silently skips on the missing pkg directory.
- name: Install wasm-pack
uses: taiki-e/install-action@v2
with:
tool: wasm-pack

- name: Build release WASM package
env:
RUSTFLAGS: "--remap-path-prefix=/home/runner=/U"
run: bun run build:wasm

- name: Run Vitest
run: bun run test

- name: Run WASM tests
working-directory: src-tauri
run: wasm-pack test --node

- name: Lint frontend
run: bun x biome check .

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "flashspan",
"private": true,
"version": "2.9.0",
"version": "2.9.1",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "Flashspan"
version = "2.9.0"
version = "2.9.1"
description = "Mental Maths training simulator"
authors = ["you"]
repository = ""
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "Ascent Flash",
"version": "2.9.0",
"version": "2.9.1",
"identifier": "com.divijg19.ascentflash",
"build": {
"frontendDist": "../dist",
Expand Down
13 changes: 3 additions & 10 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,9 @@ function isEscapeKey(event: KeyboardEvent): boolean {
}

/**
* Enter or leave fullscreen, best-effort.
*
* Never throws and never blocks a caller on a refusal: the Fullscreen API is
* simply absent on some targets (iOS Safari has no element `requestFullscreen`,
* as do cross-origin iframes and some WebViews) and can be refused by policy.
* Treating a refusal as fatal left the Start button permanently dead there, so
* a failure is swallowed and the session runs windowed; the countdown tick
* retries the request, which is the mechanism that actually matters. An absent
* `requestFullscreen` is not special-cased — calling it throws `TypeError`,
* which the same handler catches.
* Enter or leave fullscreen, best-effort. The API is absent on some targets and
* can be refused by policy; a failure is swallowed so the session still runs
* windowed. The countdown tick retries the request.
*/
async function setFullscreen(enabled: boolean): Promise<void> {
if (typeof document === "undefined") {
Expand Down
17 changes: 3 additions & 14 deletions src/__tests__/App.accessibility.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,20 +170,9 @@ describe("App accessibility tests", () => {
});

/**
* Opening the advanced settings moves focus into the panel and traps Tab
* inside it.
*
* The trap is driven by a ref on the overlay element that lives in
* `AdvancedSettings` but is read by a `createEffect` in `App.tsx`. Those two
* are in different components now, and `App` holds the element in a plain
* (non-reactive) variable rather than a signal — so the effect depends only
* on `showAdvanced()`, and nothing re-runs it if the ref is assigned late or
* not at all. That failure is silent: the panel still renders and every other
* assertion here passes, while keyboard users tab straight out of the dialog
* into the page behind it.
*
* So assert the focus actually moved, which is the observable consequence of
* the ref having been wired up.
* Opening advanced settings must move focus into the panel. Assert the
* observable consequence: the overlay ref being wired up silently is easy
* to miss otherwise.
*/
/**
* An interruption while the tab is hidden must return the app to idle and
Expand Down
13 changes: 3 additions & 10 deletions src/__tests__/answerValidation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,16 +194,9 @@ describe("validateAnswer", () => {
});

/**
* `deterministicFallback` must agree with `next_distinct_value` in
* `core/engine.rs`: rotate the magnitude one step inside the digit-width domain,
* and carry the previous value's sign while the running sum can still fund it.
*
* This block previously pinned the opposite rule. It asserted that a negative
* predecessor comes back positive ("strips minus") and that an affordable
* positive duplicate becomes negative — the two halves of the divergence
* `src/__tests__/generatorFallback.test.ts` now pins against. Its comments also
* referred to a `maxExclusive` the implementation no longer had, so the values
* they claimed to explain were stale.
* `deterministicFallback` must mirror `next_distinct_value` in `core/engine.rs`:
* rotate the magnitude within the digit width, carry the previous sign while
* the sum funds it. Parity is pinned by `generatorFallback.test.ts`.
*/
describe("deterministicFallback", () => {
it("keeps a negative payload negative while the sum funds it", () => {
Expand Down
16 changes: 4 additions & 12 deletions src/__tests__/audioPlayback.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,18 +148,10 @@ describe("browser audio playback", () => {
});

/**
* Warmup's whole job is to have the bytes decoded before the countdown
* ends, and it used to also mark the device ready from a muted play-through
* that was rewound straight away — so one early "success" silenced every
* later failure, including a device that died mid-session.
*
* It also runs on the only cold cache a page ever gets, which is where the
* two claims meet: the ticks that arrive while the first decode is still in
* flight are waiting on the same promise, so when it lands they would both
* sound. Only the newest may — a beep that fires a tick late is a beep
* attached to the wrong number. That is why this is the first test in the
* file to touch the buffers: a load that *succeeds* is cached for the life
* of the page, and no later test can be slow again.
* Warmup decodes bytes without claiming device readiness. This is the only
* cold cache a page gets, so it is also where the slow-load race is tested:
* ticks waiting on the same promise must not both sound. It runs first
* because a successful load is cached for the page's lifetime.
*/
it("decodes on warmup without claiming anything, and lets only the newest tick sound", async () => {
const started = mark();
Expand Down
35 changes: 5 additions & 30 deletions src/__tests__/autoRepeat.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { browserRuntime } from "../runtime/browser";
import { normalizeAutoRepeat } from "../runtime/localPlanner";
import type { StartSessionResponse } from "../runtime/types";
import { startedOrFail } from "./helpers";

/**
* Auto-repeat must terminate after the requested number of repeats.
Expand All @@ -22,24 +22,11 @@ const BASE_CONFIG = {
allow_negative_numbers: false,
} as const;

// A 2-number session is 3.1s of countdown plus 2 x (500ms + 100ms) = 4.3s.
// A 2-number session is 3.1s of countdown plus 2 x 500ms exposure = 5.1s;
// 6000ms leaves slack for timer delivery.
const SESSION_MS = 6000;

describe("auto-repeat", () => {
/**
* None of these cases exercise the superseded-stop path, so a null response
* here would mean the runtime broke its own contract rather than declined.
*/
function startedOrFail(
response: Awaited<ReturnType<typeof browserRuntime.startSession>>,
): StartSessionResponse {
expect(response).not.toBeNull();
if (!response) {
throw new Error("startSession unexpectedly returned null");
}
return response;
}

beforeEach(() => {
vi.useFakeTimers();
vi.setSystemTime(0);
Expand Down Expand Up @@ -157,20 +144,8 @@ describe("auto-repeat", () => {
});

/**
* Leaving the end screen must destroy the pending restart.
*
* This is the property that makes a manual Start safe. The end screen shows
* the auto-repeat countdown bar, and its only way back to the home screen is
* the "Home" button, which calls `stop()`. `stopSession` cancels
* `pendingAutoRepeat` and bumps `sessionEpoch`, so by the time the user can
* press Start again there is no repeat left to race them.
*
* If that ever stops holding — a new route off the end screen that skips
* `stop`, or a `stopSession` that stops clearing the timer — the manual Start
* and the pending restart both reach `startSession`, the loser throws
* "A session is already starting", and `App.tsx`'s catch sets the phase to
* idle while a session is live and flashing numbers. So pin the cancellation
* rather than the UI layout: the layout is easy to read, the invariant is not.
* Leaving the end screen must cancel the pending restart, so a manual Start
* cannot race it. Pin the cancellation rather than the UI route.
*/
it("cancels the pending restart when the user leaves the end screen", async () => {
await browserRuntime.setSoundEnabled(false);
Expand Down
22 changes: 4 additions & 18 deletions src/__tests__/flashExposure.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,10 @@ import {
import { startedOrFail } from "./helpers";

/**
* Every flashed number must stay on screen for at least its full exposure.
*
* This is the "first flash number is short lived" bug. The driver used to
* schedule each event against an absolute grid anchored at session start, so
* whatever lateness the *previous* event was delivered with was subtracted from
* this one's window. The first show is the only one delivered alongside the
* countdown's paint tail and the countdown->flashing view transition, so its
* lateness truncated the first number's exposure while later numbers flashed
* for the full duration.
*
* The driver now chains fixed intervals, which makes exposure exact by
* construction: a late delivery can only delay when an event lands, never
* shorten how long the previous one stayed up.
*
* Lateness is injected where a browser creates it — the timer fires later than
* asked — by padding the delay the runtime requests. Exposure is then measured
* from the payloads' own `emitted_at_ms` rather than from the test's tick
* positions, so the assertion is about what a user would actually see.
* Every flashed number must stay on screen for at least its full exposure. The
* driver chains fixed intervals so lateness delays an event without shortening
* the previous exposure; tests inject lateness into timer delays and measure
* exposure from payload timestamps.
*/

const CONFIG = {
Expand Down
19 changes: 3 additions & 16 deletions src/__tests__/splashSkip.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,22 +105,9 @@ describe("skipping the splash", () => {
});

/**
* The splash must not move after it appears, and its fade-out must never be cut
* short.
*
* Two independent defects produced the stutter:
*
* 1. The banner declared no intrinsic size, so its box had zero height until the
* 278KB PNG decoded and the flex column re-centred mid-fade. The
* width/height attributes below are what fix that; if they are ever dropped,
* the layout jump comes straight back.
* 2. The fade lived in CSS while the schedule lived in JS as separate literals,
* so the unmount could land before the transition finished (cutting the last
* frames) or long after it (an invisible, click-through overlay). Unmount now
* hangs off the opacity transition ending, with a timer as the backstop.
*
* Honest caveat: jsdom does not run CSS transitions, so the lifecycle test
* exercises the JS schedule and the backstop, not real fade timing.
* The splash must not shift when its PNG decodes (hence the width/height
* attributes) and its JS unmount schedule must outlast the CSS fade. jsdom does
* not run transitions, so these tests cover the schedule and backstop only.
*/
describe("splash presentation", () => {
afterEach(async () => {
Expand Down
116 changes: 0 additions & 116 deletions src/__tests__/wasm.integration.test.ts

This file was deleted.

Loading
Loading