From ca8304e3c9286ac99a4bb6eed29072b8de5e5c50 Mon Sep 17 00:00:00 2001 From: Jonas Probst Date: Sun, 15 Nov 2026 16:17:33 +0100 Subject: [PATCH] fix: include start-date-only cards in Gantt view Use the start date when filtering a card with no due date. Previously, the missing due date could be interpreted as 1970, filtering the card out before it reached the Gantt task builder. Add a regression test for start-only and undated cards. Signed-off-by: Jonas Probst Assisted-by: pi:gpt-6-luna --- src/components/board/GanttView.spec.js | 47 ++++++++++++++++++++++++++ src/components/board/GanttView.vue | 10 +++--- 2 files changed, 52 insertions(+), 5 deletions(-) create mode 100644 src/components/board/GanttView.spec.js diff --git a/src/components/board/GanttView.spec.js b/src/components/board/GanttView.spec.js new file mode 100644 index 000000000..eb89fd55c --- /dev/null +++ b/src/components/board/GanttView.spec.js @@ -0,0 +1,47 @@ +/** + * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +import { describe, expect, it, jest } from '@jest/globals' +import GanttView from './GanttView.vue' + +jest.mock('@nextcloud/vue', () => ({}), { virtual: true }) +jest.mock('frappe-gantt', () => ({})) +jest.mock('frappe-gantt/dist/frappe-gantt.css', () => ({}), { virtual: true }) +jest.mock('pinia', () => ({ mapActions: () => ({}), mapState: () => ({}) })) +jest.mock('vue-material-design-icons/ChartGantt.vue', () => ({})) +jest.mock('vue-material-design-icons/ChevronDown.vue', () => ({})) +jest.mock('vue-material-design-icons/ChevronRight.vue', () => ({})) +jest.mock('../../stores/board.js', () => ({})) +jest.mock('../../stores/card.js', () => ({})) + +describe('GanttView card partitioning', () => { + it('includes a start-only card in Gantt tasks and leaves undated cards in the undated list', () => { + const startOnlyCard = { + id: 1, + title: 'Start only', + startdate: new Date().toISOString(), + duedate: null, + } + const undatedCard = { + id: 2, + title: 'No dates', + startdate: null, + duedate: null, + } + const cardToGanttTask = jest.fn((card) => ({ id: String(card.id) })) + const context = { + stacks: [{ id: 10 }], + cardsByStack: () => [startOnlyCard, undatedCard], + currentViewMode: 'Day', + cardToGanttTask, + } + + const result = GanttView.computed.partitionedCards.call(context) + + expect(result.ganttTasks).toEqual([{ id: '1' }]) + expect(result.undatedCards).toEqual([undatedCard]) + expect(cardToGanttTask).toHaveBeenCalledWith(startOnlyCard, 0) + }) +}) diff --git a/src/components/board/GanttView.vue b/src/components/board/GanttView.vue index eb2fe038d..d761034cc 100644 --- a/src/components/board/GanttView.vue +++ b/src/components/board/GanttView.vue @@ -229,25 +229,25 @@ export default { } else { // gantt renders everything at once so large date ranges cause performance issues on render // therefore we limit the timeframe of visible tasks - const duedate = new Date(card.duedate) + const filterDate = new Date(card.duedate || card.startdate) switch (this.currentViewMode) { case 'Hour': - if (duedate < new Date() - 2 * 24 * 3600 * 1000) { + if (filterDate < new Date() - 2 * 24 * 3600 * 1000) { return } break case 'Day': - if (duedate < new Date() - 30 * 24 * 3600 * 1000) { + if (filterDate < new Date() - 30 * 24 * 3600 * 1000) { return } break case 'Week': - if (duedate < new Date() - 90 * 24 * 3600 * 1000) { + if (filterDate < new Date() - 90 * 24 * 3600 * 1000) { return } break case 'Month': - if (duedate < new Date() - 365 * 24 * 3600 * 1000) { + if (filterDate < new Date() - 365 * 24 * 3600 * 1000) { return } break