From 4aab74089542f64ee428cd40c10720cd063974d9 Mon Sep 17 00:00:00 2001 From: Francisco Solla Date: Fri, 2 Oct 2026 17:16:56 -0300 Subject: [PATCH] =?UTF-8?q?test(int):=20estabiliza=20os=20specs=20do=20?= =?UTF-8?q?=C3=A1lbum=20no=20global=20photoAlbum=20compartilhado?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Aprovações passam a setar o canal e aprovar sob o lease exclusivo do global (fecha a corrida com o teardown de specs irmãos) e os afterAll não fecham mais o canal — o padrão que os specs de face já seguiam. --- tests/int/archiveIntegrity.int.spec.ts | 26 +++++++++++---- tests/int/archivePhotoPublicRead.int.spec.ts | 5 ++- tests/int/archivePhotoThumbnails.int.spec.ts | 33 ++++++++++---------- 3 files changed, 41 insertions(+), 23 deletions(-) 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 }))) })