fix: show 404 on task detail page when the task does not exist (#1014)

This commit is contained in:
kolaente 2025-06-24 23:32:22 +02:00 committed by GitHub
parent f9b31ab4bf
commit 0f3da11bc4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 0 deletions

View File

@ -189,7 +189,13 @@ describe('Task', () => {
LabelTaskFactory.truncate()
TaskAttachmentFactory.truncate()
})
it('Shows a 404 page for nonexisting tasks', () => {
cy.visit('/tasks/9999')
cy.contains('Not found')
.should('be.visible')
})
it('Shows all task details', () => {
const tasks = TaskFactory.create(1, {
id: 1,

View File

@ -743,6 +743,13 @@ watch(
attachmentStore.set(task.value.attachments)
taskColor.value = task.value.hexColor
setActiveFields()
} catch (e) {
if (e?.response?.status === 404) {
router.replace({name: 'not-found'})
return
}
throw e
} finally {
await nextTick()
scrollToHeading()