Work on many entries at once
Rows carry a checkbox, the bar above publishes, withdraws, resets to draft, sets the audience or deletes drafts for the whole selection and reports what went through.
This commit is contained in:
@@ -2,6 +2,7 @@ import { beforeEach, describe, expect, it } from 'vitest'
|
||||
import { findEntry, listEntryBlocks } from '~/data/repositories/entries'
|
||||
import {
|
||||
performArchiveEntry,
|
||||
performBulkEntries,
|
||||
performPublishEntry,
|
||||
performResumeEntry,
|
||||
performSaveEntry,
|
||||
@@ -376,3 +377,40 @@ describe('performSaveEntry wechselt das Projekt', () => {
|
||||
expect(result.ok).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
describe('performBulkEntries', () => {
|
||||
it('veröffentlicht mehrere Entwürfe auf einmal', async () => {
|
||||
const first = await ready()
|
||||
const second = await performSaveEntry(adminViewer(), entryInput(first.project.id, { title: 'Zweiter Beitrag' }))
|
||||
|
||||
if (!second.ok) {
|
||||
throw new Error('Anlegen fehlgeschlagen')
|
||||
}
|
||||
|
||||
const outcome = await performBulkEntries(adminViewer(), [first.entry.id, second.entry.id], 'publish')
|
||||
|
||||
expect(outcome).toMatchObject({ done: 2, failed: 0, blocked: 0 })
|
||||
expect((await findEntry(first.entry.id))?.status).toBe('published')
|
||||
expect((await findEntry(second.entry.id))?.status).toBe('published')
|
||||
})
|
||||
|
||||
it('setzt die Zielgruppe für eine Auswahl', async () => {
|
||||
const { entry } = await ready()
|
||||
|
||||
const outcome = await performBulkEntries(adminViewer(), [entry.id], 'audience', 'public')
|
||||
|
||||
expect(outcome).toMatchObject({ done: 1 })
|
||||
expect((await findEntry(entry.id))?.audience).toBe('public')
|
||||
})
|
||||
|
||||
it('löscht nur Entwürfe', async () => {
|
||||
const { entry } = await ready()
|
||||
|
||||
await performPublishEntry(adminViewer(), { id: entry.id })
|
||||
|
||||
const outcome = await performBulkEntries(adminViewer(), [entry.id], 'delete')
|
||||
|
||||
expect(outcome).toMatchObject({ done: 0, failed: 1 })
|
||||
expect(await findEntry(entry.id)).toBeDefined()
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user