test(int): estabiliza os specs do álbum no global photoAlbum compartilhado

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.
This commit is contained in:
Francisco Solla 2026-10-02 17:16:56 -03:00
parent 53f8e4a3cd
commit 4aab740895
3 changed files with 41 additions and 23 deletions

View file

@ -104,11 +104,22 @@ const statusOf = async (id: number): Promise<string> => {
}
const approve = async (id: number): Promise<void> => {
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 })))
})

View file

@ -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 })))
})

View file

@ -102,22 +102,22 @@ const setChannel = async (removalChannelUrl: string): Promise<void> => {
)
}
const closeAlbumAndClearChannel = async (): Promise<void> => {
await withExclusiveTestDatabaseLease(payload, PHOTO_ALBUM_LEASE_KEY, () =>
payload.updateGlobal({
slug: 'photoAlbum',
data: { published: false, removalChannelUrl: null },
overrideAccess: true,
}),
)
}
const approve = async (id: number): Promise<void> => {
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 })))
})