fix(cms): remove unpublished content fallbacks
This commit is contained in:
@@ -202,11 +202,11 @@ describe('public route hydration', () => {
|
||||
const publicDocs = await findFixtureDocs('preistraeger', ids, false)
|
||||
const previewDocs = await findFixtureDocs('preistraeger', ids, true)
|
||||
|
||||
expect(resolveHomeWinners(selection, publicDocs, []).map((doc) => doc.id)).toEqual([
|
||||
expect(resolveHomeWinners(selection, publicDocs).map((doc) => doc.id)).toEqual([
|
||||
third.id,
|
||||
first.id,
|
||||
])
|
||||
expect(resolveHomeWinners(selection, previewDocs, []).map((doc) => doc.id)).toEqual([
|
||||
expect(resolveHomeWinners(selection, previewDocs).map((doc) => doc.id)).toEqual([
|
||||
third.id,
|
||||
unpublished.id,
|
||||
first.id,
|
||||
@@ -221,7 +221,7 @@ describe('public route hydration', () => {
|
||||
})
|
||||
const republishedDocs = await findFixtureDocs('preistraeger', ids, false)
|
||||
|
||||
expect(resolveHomeWinners(selection, republishedDocs, []).map((doc) => doc.id)).toEqual([
|
||||
expect(resolveHomeWinners(selection, republishedDocs).map((doc) => doc.id)).toEqual([
|
||||
third.id,
|
||||
unpublished.id,
|
||||
first.id,
|
||||
@@ -297,6 +297,43 @@ describe('public route hydration', () => {
|
||||
expect(previewDocs.map((doc) => doc.id)).toEqual([first.id, unpublished.id, third.id])
|
||||
})
|
||||
|
||||
it('leaves no event row after the final /presse event is unpublished', async () => {
|
||||
const event = await payload.create({
|
||||
collection: 'events',
|
||||
context: { disableRevalidate: true },
|
||||
data: {
|
||||
_status: 'published',
|
||||
slug: `${fixtureKey}-event-final`,
|
||||
title: `${fixtureKey} event final`,
|
||||
},
|
||||
draft: false,
|
||||
})
|
||||
cleanup.push(() =>
|
||||
payload.delete({
|
||||
collection: 'events',
|
||||
context: { disableRevalidate: true },
|
||||
id: event.id,
|
||||
}),
|
||||
)
|
||||
|
||||
expect((await findFixtureDocs('events', [event.id], false)).map((doc) => doc.id)).toEqual([
|
||||
event.id,
|
||||
])
|
||||
|
||||
await payload.update({
|
||||
collection: 'events',
|
||||
context: { disableRevalidate: true },
|
||||
id: event.id,
|
||||
data: { _status: 'draft' },
|
||||
draft: false,
|
||||
})
|
||||
|
||||
expect(await findFixtureDocs('events', [event.id], false)).toEqual([])
|
||||
expect((await findFixtureDocs('events', [event.id], true)).map((doc) => doc.id)).toEqual([
|
||||
event.id,
|
||||
])
|
||||
})
|
||||
|
||||
it('omits an unpublished event previously rendered on /presse', async () => {
|
||||
const published = await payload.create({
|
||||
collection: 'events',
|
||||
@@ -341,6 +378,44 @@ describe('public route hydration', () => {
|
||||
expect(previewDocs.map((doc) => doc.id).sort()).toEqual(ids.sort())
|
||||
})
|
||||
|
||||
it('leaves no news card after the final /presse article is unpublished', async () => {
|
||||
const post = await payload.create({
|
||||
collection: 'posts',
|
||||
context: { disableRevalidate: true },
|
||||
data: {
|
||||
_status: 'published',
|
||||
content: lexicalDocument,
|
||||
slug: `${fixtureKey}-post-final`,
|
||||
title: `${fixtureKey} post final`,
|
||||
},
|
||||
draft: false,
|
||||
})
|
||||
cleanup.push(() =>
|
||||
payload.delete({
|
||||
collection: 'posts',
|
||||
context: { disableRevalidate: true },
|
||||
id: post.id,
|
||||
}),
|
||||
)
|
||||
|
||||
expect((await findFixtureDocs('posts', [post.id], false)).map((doc) => doc.id)).toEqual([
|
||||
post.id,
|
||||
])
|
||||
|
||||
await payload.update({
|
||||
collection: 'posts',
|
||||
context: { disableRevalidate: true },
|
||||
id: post.id,
|
||||
data: { _status: 'draft' },
|
||||
draft: false,
|
||||
})
|
||||
|
||||
expect(await findFixtureDocs('posts', [post.id], false)).toEqual([])
|
||||
expect((await findFixtureDocs('posts', [post.id], true)).map((doc) => doc.id)).toEqual([
|
||||
post.id,
|
||||
])
|
||||
})
|
||||
|
||||
it('omits an unpublished press article previously rendered on /presse', async () => {
|
||||
const published = await payload.create({
|
||||
collection: 'posts',
|
||||
|
||||
Reference in New Issue
Block a user