[WEB-4629] Show 2FA banner on first workspace load after accepting invite#1972
[WEB-4629] Show 2FA banner on first workspace load after accepting invite#1972clintonium-119 wants to merge 1 commit into
Conversation
After accepting a clinician invite, getClinicsForClinician seeds clinic.clinicians with only the viewer's own record. An admin viewer therefore looked like the sole admin, so the banner's sole-admin exemption suppressed the "Set Up 2FA" banner until a navigation round-trip reloaded the full roster. Fetch the full clinician roster via a skip-gated RTK Query hook when the partial data makes the viewer appear to be the sole admin, and count admins from the fetched roster. The exemption is then decided on complete data and the banner renders on first load. The gate reads the partial count from state.blip, not the query cache, so resolving the query does not flip skip and cannot loop. Add the cliniciansApi mock to the suites that render the app-wide provider.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review (4)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
|
||
| // Stubs the RTK Query hook for suites on redux-mock-store (no api middleware). Defaults to no | ||
| // data; override per-test with useGetCliniciansForClinicQuery.mockReturnValue({ data }). | ||
| export const useGetCliniciansForClinicQuery = jest.fn(() => ({ data: undefined })); |
There was a problem hiding this comment.
I don't think this is used anywhere; should be able to delete the file?
| jest.mock('../../../../../app/redux/features/mfaStatus/mfaStatusApi'); | ||
| import { useGetMfaStatusQuery } from '../../../../../app/redux/features/mfaStatus/mfaStatusApi'; | ||
| jest.mock('../../../../../app/redux/features/clinicians/cliniciansApi'); | ||
| import { useGetCliniciansForClinicQuery } from '../../../../../app/redux/features/clinicians/cliniciansApi'; |
There was a problem hiding this comment.
We can do this for now since this is just for the hotfix, but in the future we should start switching to msw instead of mocking
Small fix for an issue that was noticed for WEB-4629
After accepting a clinician invite, getClinicsForClinician seeds clinic.clinicians with only the viewer's own record. An admin viewer therefore looked like the sole admin, so the banner's sole-admin exemption suppressed the "Set Up 2FA" banner until a navigation round-trip reloaded the full roster.
To fix, we fetch the full clinician roster via a skip-gated RTK Query hook when the partial data makes the viewer appear to be the sole admin, and count admins from the fetched roster. The exemption is then decided on complete data and the banner renders on first load.