Skip to content

id(web): just test is red on a clean checkout — test_load_asset_urls_from_manifest requires a built web/dist manifest #10617

Closed

Description

@dezren39

Problem

just test / just test-unit / just test-rust fail on a clean checkout, before any change is made, on a test that has nothing to do with the change:

id-web  crates/id-web/src/lib.rs:1141  tests::test_load_asset_urls_from_manifest
  main_js should be hashed (name.hash.js): /assets/main.js

The test is not detecting a bug in the code — it is asserting that the build artifact (pkgs/id/web/dist/manifest.json) exists. On a clean checkout pkgs/id/web/dist/ contains only the tracked placeholder .gitkeep, so there is no manifest and no hashed filenames, and the assertion fails deterministically.

Evidence (origin/main 4974e7a8af9e)

  1. Assets are embedded from web/dist at compile time, and the directory is empty on a clean checkout:

    • pkgs/id/crates/id-web/src/assets.rs:24 — #[folder = "../../web/dist"]
    • pkgs/id/web/dist/.gitkeep is the only tracked file in that directory (git ls-tree origin/main -- pkgs/id/web/dist), so Assets::get("manifest.json") is None.
  2. load_asset_urls() documents and implements exactly that fallback, returning the unhashed defaults:

    • pkgs/id/crates/id-web/src/lib.rs:509-525 — let Some(manifest_data) = Assets::get("manifest.json") else { ... return AssetUrls::default(); }
    • pkgs/id/crates/id-web/src/templates.rs:28-33 — Default gives main_js: "/assets/main.js", styles_css: "/assets/styles.css".
  3. The test then asserts the opposite — that the URLs must be hashed:

    • pkgs/id/crates/id-web/src/lib.rs:1141-1160 — assert!(js_dots >= 2, "main_js should be hashed (name.hash.js): {}", urls.main_js); /assets/main.js has one dot, so the assertion fails with its own diagnostic.
  4. The failure contradicts the design intent that a clean checkout can run cargo test. pkgs/id/build.rs:27-30 says a missing/empty dev web/dist is deliberately tolerated (“a dummy dist lets cargo check / cargo test compile on a clean checkout where the frontend has not been built”) and only release builds require real assets (:31-41).

  5. The documented dev recipes never build the frontend first, so they inherit the failure:

    • pkgs/id/justfile:227-228 — test-rust: cargo nextest run --all-features
    • pkgs/id/justfile:239 — test: test-rust test-web-unit test-web-typecheck
    • pkgs/id/justfile:293-294 — test-unit: cargo nextest run --all-features --lib
    • pkgs/id/AGENTS.md:109 lists just test as “All fast tests”, with no built-assets prerequisite.
  6. Observed twice, independently, already tolerated as noise:

    • issue-sweep run 2026-11-16T04:43Z (backlog, item 1): cargo test -p id-web --lib → “676 passed + 1 pre-existing env failure (test_load_asset_urls_from_manifest, needs built web assets)”.
    • That lane recorded it as an accepted environment failure rather than a defect, which is exactly the tolerance this issue asks to remove.

crates/id-web is in the workspace default-members (pkgs/id/Cargo.toml:38-50), so every cargo nextest run --all-features hits this test; the nix test venues pass only because their shared derivation runs (cd web && bun run build) before just <check> (pkgs/id/flake.nix:180-240), which is precisely why nothing catches this locally.

Repro

git clone https://github.com/developing-today/code && cd code/pkgs/id
ls -A web/dist          # .gitkeep only
just test-unit          # or: cargo test -p id-web --lib test_load_asset_urls_from_manifest
# => FAIL id-web ... test_load_asset_urls_from_manifest
#    main_js should be hashed (name.hash.js): /assets/main.js

No web/dist build, no bun, no network: the failure is deterministic and requires nothing but a fresh clone.

Why it matters

  • Every fresh clone, worktree, and contributor's first just test is red before touching anything, and the failure is in a crate unrelated to the change being tested — the classic path to “known red test” blindness where a real id-web regression hides behind the expected one.
  • It also breaks the fast local loop the recipes exist for: just test-unit is advertised as “unit tests only (fast)”, yet it depends on a Bun frontend build that those recipes do not run.
  • The test does not verify what it looks like it verifies. It asserts that a build artifact exists, not that load_asset_urls maps a manifest to URLs correctly; the transformation itself (main.js → main.<hash>.js) has no direct coverage.

Fix shape

Preferred: make the test independent of the build tree.

  • Extract the pure mapping so it can be tested directly, e.g. fn asset_urls_from_manifest(manifest: &serde_json::Value) -> AssetUrls (or from &str), with load_asset_urls() reduced to Assets::get("manifest.json") → parse → asset_urls_from_manifest.
  • Test the mapping with an inline fixture manifest ({"main.js":"main.deadbeef.js","styles.css":"styles.deadbeef.css"}) and assert the /assets/ prefix and hashed name; test the documented fallback separately (absent/invalid manifest → AssetUrls::default()), and keep the “compiles with an empty web/dist” property asserted.
  • Optionally keep one build-artifact assertion for the release variant in a check that actually builds the frontend, rather than in the unit suite.

Acceptable alternative, if the extraction is not wanted: have just test* recipes depend on the web build (e.g. test-unit: web), but that reintroduces the Bun dependency into the “fast” loop, so the extraction is preferred.

Acceptance criteria

  • cargo test -p id-web --lib (and just test-unit / just test-rust) passes on a clean clone with an empty pkgs/id/web/dist (only .gitkeep), with no Bun build.
  • A manifest-to-URLs mapping test exists that covers the hashed-name transformation and the /assets/ prefix from a fixture manifest.
  • The missing-manifest fallback remains covered (defaults returned, no panic), matching load_asset_urls' documented behaviour and pkgs/id/build.rs's clean-checkout intent.
  • Nothing in the release build path is weakened: a release build without real frontend assets still fails as pkgs/id/build.rs:31-41 requires.

Related

Activity

  1. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    kind/testTest coverage, test infrastructure, or test-only fixes
    on Nov 16, 2026
  2. developing-today commented on Nov 16, 2026

    @developing-today
    Contributor
  3. added
    source/creatorFiled by the new-issue-creator job
    priority/normalOrdinary priority (the default)
    app/idPackage/app: id (pkgs/ or apps/ in this repo)
    effort/xsTrivial: expected under 30 minutes of work
    on Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    app/idPackage/app: id (pkgs/ or apps/ in this repo)effort/xsTrivial: expected under 30 minutes of workkind/bugSomething isn't working (prefixed form of the classic bug label)kind/testTest coverage, test infrastructure, or test-only fixespriority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobstatus:done

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions