feat(supabase): admin sheet summary carries last_modified_at

Schema requires last_modified_at as an ISO 8601 timestamp with offset. Fixtures in routes.admin.test.tsx and editorRoute.tsx gain the key.
This commit is contained in:
bchanot committed 2026-11-16 15:47:54 +01:00
1 parent f5e92dc5a9
commit d9a5846d0d
4 files changed
+12

No files matched your search

+1
View File
@@ -38,6 +38,7 @@ export function adminAnswer(patch: Record<string, unknown> = {}) {
archived_at: null,
created_at: '2026-11-01T10:00:00Z',
updated_at: '2026-11-01T10:00:00Z',
last_modified_at: '2026-11-01T10:00:00.000000+00:00',
name: {
fr: 'Cheval, squelette et rachis',
en: 'Horse, skeleton and spine',
@@ -64,6 +64,7 @@ function summary(patch: Record<string, unknown> = {}) {
archived_at: null,
created_at: '2026-11-01T10:00:00Z',
updated_at: '2026-11-01T10:00:00Z',
last_modified_at: '2026-11-01T10:00:00.000000+00:00',
name: {
fr: 'Cheval, squelette et rachis',
en: 'Horse, skeleton and spine',
+2
View File
@@ -386,6 +386,8 @@ const OfficialSheetAdminSummarySchema = z.object({
archived_at: z.string().nullable(),
created_at: z.string(),
updated_at: z.string(),
/** The newest of the sheet's and its versions' `updated_at` (M9): what « dernière modification » sorts and shows. */
last_modified_at: z.string().datetime({ offset: true }),
name: LocalizedSchema,
historical: z.boolean(),
working_copy: z.boolean(),
@@ -81,6 +81,7 @@ const summary = {
archived_at: null,
created_at: '2026-11-02T10:00:00Z',
updated_at: '2026-11-02T10:00:00Z',
last_modified_at: '2026-11-09T11:06:00.123456+00:00',
name: { fr: 'Cheval', en: 'Horse' },
historical: true,
working_copy: false,
@@ -201,6 +202,13 @@ describe('sheet admin wrappers: answers', () => {
expect(await kindOf(listCatalogSpecies(answer([{ id: 'x' }])))).toBe('unavailable')
})
it('refuses a summary without last_modified_at, or with one that is no timestamp, as unavailable', async () => {
const answer = (data: unknown) => stubClient({ rpc: { data } }).client
const before = Object.fromEntries(Object.entries(summary).filter(([key]) => key !== 'last_modified_at'))
expect(await kindOf(listOfficialSheetsAdmin(answer([before])))).toBe('unavailable')
expect(await kindOf(listOfficialSheetsAdmin(answer([{ ...summary, last_modified_at: 'nope' }])))).toBe('unavailable')
})
it('folds the server refusals into their kinds', async () => {
const refused = (message: string, code = '42501') =>
stubClient({ rpc: { error: { code, message }, status: 403 } }).client