fix(admin): series Delete button actually deletes the series

The /admin/series Delete handler only PUT-unlinked each event and never
called the DELETE /api/admin/series/[id] endpoint, so the series document
persisted (a no-op for empty series). Replace the redundant per-event loop
with a single DELETE call — the endpoint already unlinks events server-side.
Unskip the e2e delete test.
This commit is contained in:
Jennie Robinson Faber 2026-05-24 22:17:19 +01:00
parent eb6449de43
commit a9312c423b
2 changed files with 31 additions and 14 deletions

View file

@ -604,15 +604,7 @@ const deleteSeries = (series) => {
confirmAction.execute = async () => { confirmAction.execute = async () => {
confirmAction.running = true confirmAction.running = true
try { try {
for (const event of series.events) { await $fetch(`/api/admin/series/${series.id}`, { method: 'DELETE' })
await $fetch(`/api/admin/events/${event.id}`, {
method: 'PUT',
body: {
...event,
series: { isSeriesEvent: false, id: '', title: '', description: '', type: 'workshop_series', position: 1, totalEvents: null },
},
})
}
confirmAction.show = false confirmAction.show = false
await refresh() await refresh()
} catch (error) { } catch (error) {

View file

@ -57,9 +57,34 @@ test.describe('Admin series CRUD', () => {
await expect(editedCard).toContainText(editedDescription, { timeout: 10000 }) await expect(editedCard).toContainText(editedDescription, { timeout: 10000 })
}) })
// Delete is skipped: the series-management page's "Delete" button only test('delete a series', async ({ adminPage }) => {
// unlinks events from the series via PUT /api/admin/events/:id; it does const suffix = Date.now().toString().slice(-6)
// not call DELETE /api/admin/series/:id, so the series record remains. const title = `e2e-series-del-${suffix}`
// No UI affordance currently exists to remove an empty series.
test.skip('delete a series', async () => {}) // --- Create the series to delete ---
await adminPage.goto('/admin/series/create')
await expect(adminPage.locator('h1')).toContainText('Create New Series')
await adminPage
.getByPlaceholder('e.g., Cooperative Game Development Fundamentals')
.fill(title)
await adminPage
.getByPlaceholder('Describe what the series covers and its goals')
.fill('e2e delete-me series')
await adminPage.getByRole('button', { name: 'Create Series' }).click()
await adminPage.waitForURL('**/admin/series', { timeout: 15000 })
const card = adminPage.locator('.series-card', { hasText: title })
await expect(card).toBeVisible({ timeout: 10000 })
// --- Delete (card button → confirm modal) ---
await card.getByRole('button', { name: 'Delete' }).click()
const confirmModal = adminPage.locator('.modal-overlay', { hasText: 'Delete Series' })
await expect(confirmModal).toBeVisible()
await confirmModal.getByRole('button', { name: 'Delete', exact: true }).click()
// --- Series is gone ---
await expect(adminPage.locator('.series-card', { hasText: title })).toHaveCount(0, {
timeout: 10000,
})
})
}) })