2021-11-17 18:11:19 +01:00
|
|
|
import {formatISO, format} from 'date-fns'
|
|
|
|
import {TaskFactory} from '../../factories/task'
|
2022-01-30 22:47:59 +01:00
|
|
|
import {prepareLists} from './prepareLists'
|
2021-11-17 18:11:19 +01:00
|
|
|
|
|
|
|
import '../../support/authenticateUser'
|
|
|
|
|
|
|
|
describe('List View Gantt', () => {
|
2022-01-30 22:47:59 +01:00
|
|
|
prepareLists()
|
2022-10-01 10:13:23 +02:00
|
|
|
|
2021-11-17 18:11:19 +01:00
|
|
|
it('Hides tasks with no dates', () => {
|
|
|
|
const tasks = TaskFactory.create(1)
|
|
|
|
cy.visit('/lists/1/gantt')
|
|
|
|
|
|
|
|
cy.get('.gantt-chart .tasks')
|
|
|
|
.should('not.contain', tasks[0].title)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Shows tasks from the current and next month', () => {
|
2022-10-01 10:13:23 +02:00
|
|
|
const now = Date.UTC(2022, 8, 25)
|
|
|
|
cy.clock(now, ['Date'])
|
|
|
|
|
|
|
|
const nextMonth = new Date(now)
|
2021-11-17 18:11:19 +01:00
|
|
|
nextMonth.setDate(1)
|
2022-10-01 10:13:23 +02:00
|
|
|
nextMonth.setMonth(9)
|
2021-11-17 18:11:19 +01:00
|
|
|
|
|
|
|
cy.visit('/lists/1/gantt')
|
|
|
|
|
|
|
|
cy.get('.gantt-chart .months')
|
|
|
|
.should('contain', format(now, 'MMMM'))
|
|
|
|
.should('contain', format(nextMonth, 'MMMM'))
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Shows tasks with dates', () => {
|
|
|
|
const now = new Date()
|
|
|
|
const tasks = TaskFactory.create(1, {
|
|
|
|
start_date: formatISO(now),
|
2022-10-01 10:13:23 +02:00
|
|
|
end_date: formatISO(now.setDate(now.getDate() + 4)),
|
2021-11-17 18:11:19 +01:00
|
|
|
})
|
|
|
|
cy.visit('/lists/1/gantt')
|
|
|
|
|
|
|
|
cy.get('.gantt-chart .tasks')
|
|
|
|
.should('not.be.empty')
|
|
|
|
cy.get('.gantt-chart .tasks')
|
|
|
|
.should('contain', tasks[0].title)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Shows tasks with no dates after enabling them', () => {
|
|
|
|
TaskFactory.create(1, {
|
|
|
|
start_date: null,
|
|
|
|
end_date: null,
|
|
|
|
})
|
|
|
|
cy.visit('/lists/1/gantt')
|
|
|
|
|
|
|
|
cy.get('.gantt-options .fancycheckbox')
|
|
|
|
.contains('Show tasks which don\'t have dates set')
|
|
|
|
.click()
|
|
|
|
|
|
|
|
cy.get('.gantt-chart .tasks')
|
|
|
|
.should('not.be.empty')
|
|
|
|
cy.get('.gantt-chart .tasks .task.nodate')
|
|
|
|
.should('exist')
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Drags a task around', () => {
|
|
|
|
const now = new Date()
|
|
|
|
TaskFactory.create(1, {
|
|
|
|
start_date: formatISO(now),
|
2022-10-01 10:13:23 +02:00
|
|
|
end_date: formatISO(now.setDate(now.getDate() + 4)),
|
2021-11-17 18:11:19 +01:00
|
|
|
})
|
|
|
|
cy.visit('/lists/1/gantt')
|
|
|
|
|
|
|
|
cy.get('.gantt-chart .tasks .task')
|
|
|
|
.first()
|
|
|
|
.trigger('mousedown', {which: 1})
|
|
|
|
.trigger('mousemove', {clientX: 500, clientY: 0})
|
|
|
|
.trigger('mouseup', {force: true})
|
|
|
|
})
|
|
|
|
})
|