Skip to content

fix(frontend/tests): update users.test for invite flow + allowed_accounts#358

Merged
cristim merged 1 commit into
feat/multicloud-web-frontendfrom
fix/users-test-stale-invite
May 13, 2026
Merged

fix(frontend/tests): update users.test for invite flow + allowed_accounts#358
cristim merged 1 commit into
feat/multicloud-web-frontendfrom
fix/users-test-stale-invite

Conversation

@cristim
Copy link
Copy Markdown
Member

@cristim cristim commented May 13, 2026

Summary

Four cases in users.test.ts are stale on feat/multicloud-web-frontend and failing on every PR-merge ref against the base — see https://github.com/LeanerCloud/CUDly/actions/runs/25825557119 (PR #336) and the same failure on https://github.com/LeanerCloud/CUDly/actions/runs/25825131269 (PR #352). Blocks the frontend-build-sentinel workflow across every open PR. Same shape as #337 (the factory_test.go merge glitch): pre-existing on base, every PR inherits it.

Failures and fixes

Test Cause Fix
loadUsers › should load users and groups (L1023) mockGroups is missing allowed_accounts: [] that the backend now ships on every group Add allowed_accounts: [] to both fixture entries
loadUsers › should render groups after loading (L1036) Same mockGroups shape mismatch Same fix
openCreateUserModal › should make password required (L1464) Issue #348 ("invite users without a password") made password optional; userModals.ts now sets passwordInput.required = false so the form-level HTML validation doesn't block the invite flow Invert the assertion: rename to "should not mark password as required (blank invites the user)" and assert required === false
saveUser › should validate empty password for new user (L1666) Empty password used to be a validation error; after #348 it triggers the invite flow (api.createUser is called with empty password, backend emails a set-password link) Rename to "should allow empty password for new user (invite flow)" and assert api.createUser is called with password: '' and no error toast renders

No production code changes — this is a test-only catch-up for behavior that already shipped in #347 (allowed_accounts) and #348 (invite-without-password).

Test plan

Notes

  • The "invite flow" assertion is intentionally a positive check (api.createUser was called with empty password) rather than just removing the test, so a future regression that re-introduces the empty-password block would still fail this case.

Summary by CodeRabbit

  • Tests
    • Updated test coverage for user management and authentication workflows to reflect current system behavior.

Review Change Stack

Four users.test.ts cases were stale on `feat/multicloud-web-frontend`
and are failing on every PR-merge ref against it (including #336, #352,
others). The tests assert the pre-#348 / pre-#347 behaviour:

1. `loadUsers › should load users and groups`
2. `loadUsers › should render groups after loading`
   `mockGroups` is missing the `allowed_accounts: []` field that the
   backend now ships on every group (multi-cloud account-scoping work).
   The actual groups from `api.listGroups` carry the field, so the
   deep-equal assertion against the fixture diverges.

3. `openCreateUserModal › should make password required`
4. `saveUser › should validate empty password for new user`
   Issue #348 ("invite users without a password and let them set it on
   first login") made password optional on create. userModals.ts now
   explicitly sets `passwordInput.required = false` (line 36) so the
   form-level HTML validation doesn't block the invite flow, and
   saveUser intentionally calls `api.createUser` with an empty password
   to trigger the backend invite-email path. Both old tests asserted
   the opposite behaviour and now fail.

Fix:
- Add `allowed_accounts: []` to the two `mockGroups` entries.
- Invert "should make password required" → "should not mark password
  as required (blank invites the user)" asserting `required === false`.
- Replace "should validate empty password" → "should allow empty
  password for new user (invite flow, issue #348)" asserting
  createUser was called with an empty password and no error toast was
  rendered.

Unblocks the frontend-build-sentinel workflow on PRs against
`feat/multicloud-web-frontend`. 1633 frontend tests pass.
@cristim cristim added triaged Item has been triaged priority/p0 Drop everything; same-day fix severity/high Significant harm urgency/now Drop other things impact/all-users Affects every user effort/xs Trivial / one-liner type/bug Defect labels May 13, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 13, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: aed69635-5c75-494d-87d1-ca6a1c5eea18

📥 Commits

Reviewing files that changed from the base of the PR and between e2d97ee and d3e31c2.

📒 Files selected for processing (1)
  • frontend/src/__tests__/users.test.ts

📝 Walkthrough

Walkthrough

Test suite updated to reflect invite-based user creation: group fixtures now include allowed_accounts: [] field, create-user modal password input is not marked required, and empty-password user creation triggers an invite flow via api.createUser without validation error.

Changes

User Invite Flow Tests

Layer / File(s) Summary
Test fixtures and create modal assertions
frontend/src/__tests__/users.test.ts
mockGroups fixture updated to include allowed_accounts: [] on each group. openCreateUserModal tests now assert that the password input field is not marked as required (passwordInput.required === false), validating invite-flow behavior.
User creation with empty password
frontend/src/__tests__/users.test.ts
saveUser test updated to expect invite-flow behavior when password is empty: api.createUser is called with password: '' and no error toast is shown on success, replacing the prior validation-error expectation.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • LeanerCloud/CUDly#348: Introduces the invite-users-without-password feature that these test updates validate, including password not required in create modal and empty-password user creation via api.createUser.

Suggested labels

type/test, type/chore, impact/internal

Poem

🐰 The tests hop forward, fixtures aligned,
No password required—invites by design,
Groups gain their accounts, modals adapt,
Empty passwords welcomed, the invite flow wrapped. ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main changes: updating test fixtures to add allowed_accounts field and adjusting assertions for the invite flow behavior.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/users-test-stale-invite

Comment @coderabbitai help to get the list of available commands and usage tips.

@cristim
Copy link
Copy Markdown
Member Author

cristim commented May 13, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 13, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cristim
Copy link
Copy Markdown
Member Author

cristim commented May 13, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 13, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cristim cristim merged commit 94b4f96 into feat/multicloud-web-frontend May 13, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/xs Trivial / one-liner impact/all-users Affects every user priority/p0 Drop everything; same-day fix severity/high Significant harm triaged Item has been triaged type/bug Defect urgency/now Drop other things

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant