fix(app): a failed account load no longer leaves own grants loading

Delta verifier: when the profile or roles read failed, the grant read never ran and the creation page waited forever; the catch now marks the grants failed (form shown, server decides). Store transition tests (ready, loading on change and sign-out, failed), red without the fix. Contract clarification states the failed-read behaviour for the owner.
This commit is contained in:
bchanot committed 2026-11-02 18:41:32 +01:00
1 parent f04bfdd040
commit e39f69ee6d
3 files changed
+30 -3

No files matched your search

@@ -72,9 +72,12 @@ the equine working copy content work (V1-2.8), any DEV operation (§16.11), reco
- Skips: `apps/app/e2e/shell/admin.spec.ts` skips A0, A1 and S1 on the `chromium-375` project only (three
`test.skip(isPhone(info))`). These journeys run on desktop; every admin page at 375 px is covered by the
unskipped screens test and the access-per-right test. Deliberate, not a reduction.
- C4 gap fixed: `/app/admin/sheets/new` shows « Accès non autorisé » to any account without an active
`sheet_editor` grant (display rule; the server refuses creation anyway); unit tests for a reviewer, a
publisher and an owner without the capability.
- C4 gap fixed: `/app/admin/sheets/new` shows « Accès non autorisé » to any account whose own grants, once
read, hold no active `sheet_editor` grant (display rule; the server refuses creation anyway); unit tests for
a reviewer, a publisher and an owner without the capability. While the grants load the page waits; when
their read failed (or the account itself could not be read) it shows the form and the server decides,
rather than denying an editor for good: a reviewer may then see the form and be refused on submit.
Submitted for the owner's acknowledgement at the checkpoint.
- Security MEDIUM fixed: M7 restates the grants of the redefined `get_sheet_version`. LOW fixed: the e2e
enrolment check no longer prints the throwaway setup key on failure.
- Run evidence for the criteria a read-only verifier cannot run (orchestrator runs, sandbox only):
+2
View File
@@ -210,6 +210,8 @@ function applyAuthEvent(
profile: null,
roles: [],
workspace: { status: 'error', failure: classifyRecordError(error) },
// The grant read never ran: no page waits on it forever.
catalogGrantsStatus: 'failed',
})
})
}, 0)
@@ -105,13 +105,16 @@ describe('authStore', () => {
await flush()
await flush()
expect(useAuthStore.getState().catalogGrants).toEqual([grant])
expect(useAuthStore.getState().catalogGrantsStatus).toBe('ready')
fake.emit('SIGNED_IN', fakeSession(fakeUser({ id: 'user-2' })))
expect(useAuthStore.getState().catalogGrants).toEqual([])
expect(useAuthStore.getState().catalogGrantsStatus).toBe('loading')
await flush()
await flush()
expect(useAuthStore.getState().catalogGrants).toEqual([])
fake.emit('SIGNED_OUT', null)
expect(useAuthStore.getState().catalogGrants).toEqual([])
expect(useAuthStore.getState().catalogGrantsStatus).toBe('loading')
})
it('updateProfile writes the row and keeps the store in sync', async () => {
@@ -220,6 +223,25 @@ describe('authStore', () => {
})
})
it('marks the own grants failed when the account itself cannot be read', async () => {
const from = fake.client.from.bind(fake.client)
// Any chain on profile_roles answers an error, as a dropped request would.
const failed: unknown = new Proxy(() => undefined, {
get: (_, key) =>
key === 'then'
? (resolve: (v: unknown) => void) =>
resolve({ data: null, error: { code: '', message: 'FetchError' }, status: 0 })
: () => failed,
})
;(fake.client as unknown as { from: (t: string) => unknown }).from = (table: string) =>
table === 'profile_roles' ? failed : from(table as never)
stop = useAuthStore.getState().start()
fake.emit('SIGNED_IN', fakeSession())
await flush()
await flush()
expect(useAuthStore.getState().catalogGrantsStatus).toBe('failed')
})
it('reports a failed read as an error kind and reads again on refresh', async () => {
const from = fake.client.from.bind(fake.client)
let failing = true