mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-12 22:13:05 +00:00
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:
parent
1d06ec8633
commit
2a5c09fc27
3 changed files with 41 additions and 23 deletions
|
|
@ -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 })))
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -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 })))
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -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 })))
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue