test(supabase): working-copy sandbox case holds on a fresh stack

The first call creates the copy on a fresh sandbox; the second must answer working_copy.exists. Was green only from the second run.
This commit is contained in:
bchanot committed 2026-11-02 22:57:21 +01:00
1 parent 51225cacf6
commit 0499a39389
1 file changed
+8 -2
@@ -181,8 +181,14 @@ describe('administration reads, species and account lookup', () => {
it('the working copy and the catalogue reads answer their closed kinds', async () => {
const source = await sql(`select id from public.anatomical_sheet_versions where sheet_id = '${HISTORICAL}'
order by version_number limit 1`)
expect(['working_copy.exists', 'working_copy.assets_missing'])
.toContain(await kindOf(createSheetWorkingCopy(editorAal2, source, `wc-${randomUUID().slice(0, 8)}`)))
// A fresh sandbox has no working copy yet, so the first call may create it: both outcomes are valid.
const name = () => `wc-${randomUUID().slice(0, 8)}`
const first = await kindOf(createSheetWorkingCopy(editorAal2, source, name()))
if (first === 'no failure') {
expect(await kindOf(createSheetWorkingCopy(editorAal2, source, name()))).toBe('working_copy.exists')
} else {
expect(['working_copy.exists', 'working_copy.assets_missing']).toContain(first)
}
const versions = await listSheetVersions(editorAal2, HISTORICAL)
expect(versions.every((v) => v.status === 'published' || v.status === 'deprecated')).toBe(true)
expect(await kindOf(downloadSheetDrawing(editorAal2, 'f'.repeat(64)))).toBe('not_found')