diff --git a/tests/int/archiveIntegrity.int.spec.ts b/tests/int/archiveIntegrity.int.spec.ts index b0795e46..c589fd11 100644 --- a/tests/int/archiveIntegrity.int.spec.ts +++ b/tests/int/archiveIntegrity.int.spec.ts @@ -104,11 +104,22 @@ const statusOf = async (id: number): Promise => { } const approve = async (id: number): Promise => { - await payload.update({ - collection: ARCHIVE_PHOTO_SLUG, - id, - data: { publicationStatus: 'approved' }, - overrideAccess: true, + // The approval guard reads the shared global; set the channel and approve + // under the global's exclusive lease, so a parallel spec's teardown cannot + // flip the channel between the two writes (the flake the C248 spec exposed + // when the album specs grew). + await withExclusiveTestDatabaseLease(payload, PHOTO_ALBUM_LEASE_KEY, async () => { + await payload.updateGlobal({ + slug: 'photoAlbum', + data: { published: true, removalChannelUrl: CHANNEL }, + overrideAccess: true, + }) + await payload.update({ + collection: ARCHIVE_PHOTO_SLUG, + id, + data: { publicationStatus: 'approved' }, + overrideAccess: true, + }) }) } @@ -136,7 +147,10 @@ describe('archive photo integrity (C246)', () => { overrideAccess: true, }) } - await setChannel(null) + // The channel is left configured on purpose (the face specs' pattern): + // tearing it down here would race the approvals of every sibling album + // spec sharing the global; the specs that exercise the absent-channel + // state restore it themselves. await Promise.all(tempDirs.map((dir) => rm(dir, { recursive: true, force: true }))) }) diff --git a/tests/int/archivePhotoPublicRead.int.spec.ts b/tests/int/archivePhotoPublicRead.int.spec.ts index 7fad230f..0fd92909 100644 --- a/tests/int/archivePhotoPublicRead.int.spec.ts +++ b/tests/int/archivePhotoPublicRead.int.spec.ts @@ -161,7 +161,10 @@ describe('public photo album reads (C233)', () => { overrideAccess: true, }) } - await closeAlbumAndClearChannel() + // The channel is left configured on purpose (the face specs' pattern): + // tearing it down here would race the approvals of every sibling album + // spec sharing the global; the tests that exercise the closed/absent + // states restore the open state themselves. await Promise.all(tempDirs.map((dir) => rm(dir, { recursive: true, force: true }))) }) diff --git a/tests/int/archivePhotoThumbnails.int.spec.ts b/tests/int/archivePhotoThumbnails.int.spec.ts index bc3577b9..210eb889 100644 --- a/tests/int/archivePhotoThumbnails.int.spec.ts +++ b/tests/int/archivePhotoThumbnails.int.spec.ts @@ -102,22 +102,22 @@ const setChannel = async (removalChannelUrl: string): Promise => { ) } -const closeAlbumAndClearChannel = async (): Promise => { - await withExclusiveTestDatabaseLease(payload, PHOTO_ALBUM_LEASE_KEY, () => - payload.updateGlobal({ - slug: 'photoAlbum', - data: { published: false, removalChannelUrl: null }, - overrideAccess: true, - }), - ) -} - const approve = async (id: number): Promise => { - await payload.update({ - collection: ARCHIVE_PHOTO_SLUG, - id, - data: { publicationStatus: 'approved' }, - overrideAccess: true, + // The approval guard reads the shared global; set the channel and approve + // under the global's exclusive lease, so a parallel spec's teardown cannot + // flip the channel between the two writes. + await withExclusiveTestDatabaseLease(payload, PHOTO_ALBUM_LEASE_KEY, async () => { + await payload.updateGlobal({ + slug: 'photoAlbum', + data: { published: true, removalChannelUrl: CHANNEL }, + overrideAccess: true, + }) + await payload.update({ + collection: ARCHIVE_PHOTO_SLUG, + id, + data: { publicationStatus: 'approved' }, + overrideAccess: true, + }) }) } @@ -167,7 +167,8 @@ describe('archive photo grade thumbnails (C248)', () => { overrideAccess: true, }) } - await closeAlbumAndClearChannel() + // The channel is left open on purpose: tearing it down here would race the + // approvals of the sibling album specs (the shared global). await Promise.all(tempDirs.map((dir) => rm(dir, { recursive: true, force: true }))) })