From 01f648c20c0c5d25b704d06cd869acee2e3f17ed Mon Sep 17 00:00:00 2001 From: kolaente Date: Wed, 5 Oct 2022 16:27:12 +0200 Subject: [PATCH] fix(task): setting a label would not show up on the kanban board after setting it --- cypress/e2e/task/task.spec.ts | 60 +++++++++++++++++++++++++++-------- src/stores/kanban.ts | 3 +- src/stores/tasks.ts | 2 +- 3 files changed, 48 insertions(+), 17 deletions(-) diff --git a/cypress/e2e/task/task.spec.ts b/cypress/e2e/task/task.spec.ts index 0c2794ab1..ca8d5bd78 100644 --- a/cypress/e2e/task/task.spec.ts +++ b/cypress/e2e/task/task.spec.ts @@ -13,14 +13,36 @@ import {BucketFactory} from '../../factories/bucket' import '../../support/authenticateUser' +function addLabelToTaskAndVerify(labelTitle: string) { + cy.get('.task-view .action-buttons .button') + .contains('Add Labels') + .click() + cy.get('.task-view .details.labels-list .multiselect input') + .type(labelTitle) + cy.get('.task-view .details.labels-list .multiselect .search-results') + .children() + .first() + .click() + + cy.get('.global-notification', { timeout: 4000 }) + .should('contain', 'Success') + cy.get('.task-view .details.labels-list .multiselect .input-wrapper span.tag') + .should('exist') + .should('contain', labelTitle) +} + describe('Task', () => { let namespaces let lists + let buckets beforeEach(() => { UserFactory.create(1) namespaces = NamespaceFactory.create(1) lists = ListFactory.create(1) + buckets = BucketFactory.create(1, { + list_id: lists[0].id, + }) TaskFactory.truncate() UserListFactory.truncate() }) @@ -345,21 +367,31 @@ describe('Task', () => { cy.visit(`/tasks/${tasks[0].id}`) - cy.get('.task-view .action-buttons .button') - .contains('Add Labels') + addLabelToTaskAndVerify(labels[0].title) + }) + + it('Can add a label to a task and it shows up on the kanban board afterwards', () => { + const tasks = TaskFactory.create(1, { + id: 1, + list_id: lists[0].id, + bucket_id: buckets[0].id, + }) + const labels = LabelFactory.create(1) + LabelTaskFactory.truncate() + + cy.visit(`/lists/${lists[0].id}/kanban`) + + cy.get('.bucket .task') + .contains(tasks[0].title) .click() - cy.get('.task-view .details.labels-list .multiselect input') - .type(labels[0].title) - cy.get('.task-view .details.labels-list .multiselect .search-results') - .children() - .first() + + addLabelToTaskAndVerify(labels[0].title) + + cy.get('.modal-content .close') .click() - - cy.get('.global-notification', { timeout: 4000 }) - .should('contain', 'Success') - cy.get('.task-view .details.labels-list .multiselect .input-wrapper span.tag') - .should('exist') - .should('contain', labels[0].title) + + cy.get('.bucket .task') + .should('contain.text', labels[0].title) }) it('Can remove a label from a task', () => { @@ -441,7 +473,7 @@ describe('Task', () => { .should('have.value', '4') }) - it.only('Can set the progress for a task', () => { + it('Can set the progress for a task', () => { const tasks = TaskFactory.create(1, { id: 1, }) diff --git a/src/stores/kanban.ts b/src/stores/kanban.ts index 5b93a1ab0..25583a0e4 100644 --- a/src/stores/kanban.ts +++ b/src/stores/kanban.ts @@ -75,12 +75,11 @@ export const useKanbanStore = defineStore('kanban', { getTaskById(state) { return (id: ITask['id']) => { const { bucketIndex, taskIndex } = getTaskIndicesById(state, id) - return { bucketIndex, taskIndex, - task: bucketIndex && taskIndex && state.buckets[bucketIndex]?.tasks?.[taskIndex] || null, + task: bucketIndex !== null && taskIndex !== null && state.buckets[bucketIndex]?.tasks?.[taskIndex] || null, } } }, diff --git a/src/stores/tasks.ts b/src/stores/tasks.ts index 632b1d13c..68ca7ff65 100644 --- a/src/stores/tasks.ts +++ b/src/stores/tasks.ts @@ -252,7 +252,7 @@ export const useTaskStore = defineStore('task', { // Don't try further adding a label if the task is not in kanban // Usually this means the kanban board hasn't been accessed until now. // Vuex seems to have its difficulties with that, so we just log the error and fail silently. - console.debug('Could not add label to task in kanban, task not found', t) + console.debug('Could not add label to task in kanban, task not found', {taskId, t}) return r }