Deleting a digest makes it sendable again
The dispatch timestamp survived the deletion, so removing a message in Slack left the digest permanently swallowed. Deleting now rewinds the window to the newest digest that still stands.
This commit is contained in:
@@ -3,6 +3,7 @@ import { db } from '~/data/db'
|
||||
import { appSettings } from '~/data/schema'
|
||||
import { listReportRuns, writeSetting } from '~/data/repositories/settings'
|
||||
import { readSlackConfig, reportScope, runWeeklyReport } from '~/lib/report-settings'
|
||||
import { performDeleteMessage } from '~/lib/admin-settings'
|
||||
import { makeBrand, makeProject } from '../support/admin'
|
||||
import { makePost } from '../support/entries'
|
||||
|
||||
@@ -129,10 +130,10 @@ describe('Doppelter Versand', () => {
|
||||
|
||||
await makePost(project.id, { number: 1, slug: 'eins', status: 'published', publishAt: new Date() })
|
||||
await writeSetting('slack.botToken', 'xoxb-1234')
|
||||
await writeSetting('slack.channel', 'C123')
|
||||
await writeSetting('slack.channel', 'C0123456')
|
||||
|
||||
vi.stubGlobal('fetch', vi.fn(async () => new Response(
|
||||
JSON.stringify({ ok: true, channel: 'C123', ts: '1785600000.000100' }),
|
||||
JSON.stringify({ ok: true, channel: 'C0123456', ts: '1785600000.000100' }),
|
||||
{ headers: { 'content-type': 'application/json' } },
|
||||
)))
|
||||
|
||||
@@ -143,3 +144,37 @@ describe('Doppelter Versand', () => {
|
||||
expect(second.reason).toBe('nothing_published')
|
||||
})
|
||||
})
|
||||
|
||||
describe('Löschen nimmt den Versand zurück', () => {
|
||||
it('macht den Bericht nach dem Löschen wieder sendbar', async () => {
|
||||
const brand = await makeBrand()
|
||||
const project = await makeProject(brand.id)
|
||||
|
||||
await makePost(project.id, { number: 1, slug: 'eins', status: 'published', publishAt: new Date() })
|
||||
await writeSetting('slack.botToken', 'xoxb-1234')
|
||||
await writeSetting('slack.channel', 'C0123456')
|
||||
|
||||
vi.stubGlobal('fetch', vi.fn(async () => new Response(
|
||||
JSON.stringify({ ok: true, channel: 'C0123456', ts: '1785600000.000100' }),
|
||||
{ headers: { 'content-type': 'application/json' } },
|
||||
)))
|
||||
|
||||
const first = await runWeeklyReport({ origin, trigger: 'test' })
|
||||
|
||||
expect(first.reason).toBe('sent')
|
||||
expect((await runWeeklyReport({ origin, trigger: 'test' })).reason).toBe('nothing_published')
|
||||
|
||||
const form = new FormData()
|
||||
|
||||
form.set('runId', first.run.id)
|
||||
|
||||
const deleted = await performDeleteMessage(
|
||||
{ id: 'u1', name: 'Admin', email: '[email protected]', isAdmin: true, assignments: [] },
|
||||
form,
|
||||
)
|
||||
|
||||
expect(deleted.message).toBe('messageDeleted')
|
||||
expect(deleted.status).toBe('ok')
|
||||
expect((await runWeeklyReport({ origin, trigger: 'test' })).reason).toBe('sent')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user