Skip to content

fix(tests): skip web-bundle assertion when the frontend is not built - #31

Open
rajathpi wants to merge 1 commit into
AMAP-ML:mainfrom
rajathpi:fix/skip-web-bundle-test-without-frontend
Open

fix(tests): skip web-bundle assertion when the frontend is not built#31
rajathpi wants to merge 1 commit into
AMAP-ML:mainfrom
rajathpi:fix/skip-web-bundle-test-without-frontend

Conversation

@rajathpi

Copy link
Copy Markdown

Problem

On a fresh clone, pip install -e '.[test]' && pytest fails with one error:

FAILED tests/webapi/test_webapi.py::test_legacy_static_dashboard_routes_are_not_registered
assert 404 == 200

Cause

The test asserts that GET / serves the SPA, but the web bundle lives at src/lh_harness/_frontend/web/dist, which is git-ignored and only produced by npm run build --prefix frontend/web. create_app already tolerates the missing bundle (server.py: if _STATIC_DIR.is_dir(): app.mount(...)) — packaging deliberately treats it as a build artifact so a checkout without a Node toolchain still installs — but the test did not. CI never hits this because release.yml builds the frontend before running pytest, and no workflow runs on pull_request, so nothing catches it for contributors.

Fix

  • The legacy-route assertions (what the test's name is about) need no bundle, so they now always run.
  • The SPA-serving assertions move to a new test, test_built_web_bundle_is_served_at_root, guarded by @pytest.mark.skipif(not _STATIC_DIR.is_dir(), ...) with an actionable skip reason. The condition mirrors create_app's own guard, so the test and production behavior cannot drift.

Verification

  • Without the bundle: 169 passed, 1 skipped, with the skip reason printed under -rs.
  • With the bundle (CI-equivalent, after npm ci --prefix frontend/web --no-audit --no-fund && npm run build --prefix frontend/web): 170 passed — the new test genuinely runs when the bundle exists.

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