From 995cc12880e3e23a018fb1f86f601b287f5955df Mon Sep 17 00:00:00 2001 From: kolaente Date: Sat, 12 Nov 2022 12:13:00 +0100 Subject: [PATCH] fix(tasks): remove a task from its bucket when it is in the first kanban bucket Resolves https://github.com/go-vikunja/frontend/issues/89 --- cypress/e2e/list/list-view-kanban.spec.ts | 33 +++++++++++++++++++++++ src/stores/kanban.ts | 4 +-- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/cypress/e2e/list/list-view-kanban.spec.ts b/cypress/e2e/list/list-view-kanban.spec.ts index 6949626acc..ffa4cca9a4 100644 --- a/cypress/e2e/list/list-view-kanban.spec.ts +++ b/cypress/e2e/list/list-view-kanban.spec.ts @@ -204,4 +204,37 @@ describe('List View Kanban', () => { cy.get('.list-kanban .filter-container .base-button') .should('exist') }) + + it('Should remove a task from the board when deleting it', () => { + const lists = ListFactory.create(1) + const buckets = BucketFactory.create(2, { + list_id: lists[0].id, + }) + const tasks = TaskFactory.create(5, { + list_id: 1, + bucket_id: buckets[0].id, + }) + const task = tasks[0] + cy.visit('/lists/1/kanban') + + cy.getSettled('.kanban .bucket .tasks .task') + .contains(task.title) + .should('be.visible') + .click() + cy.get('.task-view .action-buttons .button') + .should('be.visible') + .contains('Delete') + .click() + cy.get('.modal-mask .modal-container .modal-content .header') + .should('contain', 'Delete this task') + cy.get('.modal-mask .modal-container .modal-content .actions .button') + .contains('Do it!') + .click() + + cy.get('.global-notification') + .should('contain', 'Success') + + cy.getSettled('.kanban .bucket .tasks') + .should('not.contain', task.title) + }) }) \ No newline at end of file diff --git a/src/stores/kanban.ts b/src/stores/kanban.ts index 70201935d8..629c3a637c 100644 --- a/src/stores/kanban.ts +++ b/src/stores/kanban.ts @@ -200,9 +200,9 @@ export const useKanbanStore = defineStore('kanban', () => { const { bucketIndex, taskIndex } = getTaskIndicesById(buckets.value, task.id) if ( - !bucketIndex || + bucketIndex === null || buckets.value[bucketIndex]?.id !== task.bucketId || - !taskIndex || + taskIndex === null || (buckets.value[bucketIndex]?.tasks[taskIndex]?.id !== task.id) ) { return