Skip to content

test: cover the units #295 listed as shipping untested - #319

Merged
antosubash merged 1 commit into
mainfrom
fix/missing-unit-tests
Sep 5, 2026
Merged

antosubash merged 1 commit into
mainfrom
fix/missing-unit-tests

Conversation

@antosubash

Copy link
Copy Markdown
Owner

Closes #295 — the second half. The first half (the two assertions that never ran) closed in #314. Held until #312 and #313 landed, since both touch these files.

What was untested

Unit Now covered by Tests
scripts/gen_i18n.py scripts/tests/test_gen_i18n.py 3
user_statederiveState modules/users/tests/test_user_state.py + modules/users/tests-js/deriveState.test.ts 9 + 8
packages/ui/…/PasswordInput.tsx PasswordInput.test.tsx 6
host/client_app/pages/Error.tsx (403 branch) Error.test.tsx 5
useLeaveGuard modules/permissions/tests-js/useLeaveGuard.test.tsx 7
file_storage SelectionFooter / showEmpty SelectionFooter.test.tsx + BrowseEmptyState.test.tsx 10 + 6
_clamp out-of-range branch added to test_session_cookie_window.py 9
soft if reissued is not None: tightened in test_remember_me.py

The three worth reading

user_state / deriveState are the same rule in two languages — deriveState exists because disabling an account from the edit page updates local state without a reload, so the pill has to be recomputed rather than read off the prop it was rendered from. Nothing held them together, so the first edit to either would have drifted them silently. They now share one six-row table written out in both suites, and the Python side asserts that table covers every value in USER_STATES, so a new state added without a case is a failure rather than a gap.

useLeaveGuard was stubbed out by both page suites (router: { on: () => () => {} }), so neither the prompt nor its escape hatch ever ran. The escape hatch is the load-bearing half: the page's own save is an Inertia visit too, and prompting on it would ask "discard your changes?" while saving them.

showEmpty keys on pagination.total, not files.length. A page past the last one renders an empty files array while the bucket is full, so the simpler condition would announce "No files yet" over a full bucket — there is a test for exactly that case. The copy also splits on whether a filter is active, because "No files yet" is wrong and discouraging when the filter is merely too narrow.

_clamp gets its other branch: zero, negative, None, a numeric string, and both bools — bool is an int, so True must not read as a one-second window.

Two corrections to the issue's text

Verification

  • uv run pytest -q2973 passed, 60 deselected
  • npx vitest run463 passed in 56 files (+46)
  • ruff format / ruff check / ty check framework modules host / check_file_size.py — pass
  • npx biome check . (344 files), npx tsc --noEmit on packages/ui, host/client_app, modules/{users,permissions,file_storage}, check_untranslated_strings.mjs — pass

Note: tsc -p host/client_app needs make gen-pages first — modules.generated.ts is generated and absent in a fresh worktree. Not a change here, but it bites anyone typechecking that workspace in isolation.

The second half of #295. Its first half — the two assertions that never ran —
closed in #314; these are the units the branch shipped with no test at all,
plus one assertion that could not fail.

`scripts/gen_i18n.py` was the only script in `scripts/` with no test beside it.
What it pins is the property #302 added: the command's exit code has to tell
"wrote the key files" from "wrote nothing", and both halves of the `strict`
flag — the boot path still preferring stale types to a failed start.

`user_state` and `deriveState` are the same rule in two languages, because the
edit page recomputes the status pill after a local change without a reload.
Nothing held them together, so the first edit to either would have drifted them
silently. They now share one six-row table, written out in both suites, and the
Python side asserts the table covers every declared state.

`PasswordInput`'s reveal toggle, `useLeaveGuard`, `Error.tsx`'s 403 branch and
`file_storage`'s `SelectionFooter` and `showEmpty` had no tests. The two worth
naming:

- `useLeaveGuard` was stubbed out by both page suites (`router: { on: () => () => {} }`),
  so neither the prompt nor its escape hatch ran. The escape hatch is the
  load-bearing half: the page's own save is an Inertia visit too, and prompting
  on it would ask "discard your changes?" while saving them.
- `showEmpty` keys on `pagination.total`, not `files.length`. A page past the
  last one renders an empty `files` array while the bucket is full, so the
  simpler condition would announce "No files yet" over a full bucket. Its copy
  also splits on whether a filter is active, because "No files yet" is wrong and
  discouraging when the filter is merely too narrow.

`_clamp`'s out-of-range branch — zero, negative, `None`, a numeric string, and
both bools, since `bool` is an `int` and `True` must not read as one second.

And `test_remember_me.py`'s `if reissued is not None:` becomes an assertion. It
let the test pass when the page wrote no session cookie at all, which is exactly
the case where it has stopped exercising the regression.

Closes #295
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 5, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review Completed 2026-09-05T06:49:49.752229Z db5a103 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying simple-module-python with  Cloudflare Pages  Cloudflare Pages

Latest commit: db5a103
Status: ✅  Deploy successful!
Preview URL: https://1560f82d.simple-module-python.pages.dev
Branch Preview URL: https://fix-missing-unit-tests.simple-module-python.pages.dev

View logs

@antosubash
antosubash merged commit c1ef059 into main Sep 5, 2026
13 checks passed
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.

Two tests only pass in full-suite order, and several new components ship untested

1 participant