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')
|
|
|
|
|
2022-10-05 15:21:19 +02:00
|
|
|
cy.get('.g-gantt-rows-container')
|
2021-11-17 18:11:19 +01:00
|
|
|
.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')
|
|
|
|
|
2022-07-21 00:50:03 +02:00
|
|
|
cy.get('.g-timeunits-container')
|
2021-11-17 18:11:19 +01:00
|
|
|
.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')
|
|
|
|
|
2022-10-05 15:21:19 +02:00
|
|
|
cy.get('.g-gantt-rows-container')
|
2021-11-17 18:11:19 +01:00
|
|
|
.should('not.be.empty')
|
|
|
|
.should('contain', tasks[0].title)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Shows tasks with no dates after enabling them', () => {
|
2022-07-21 00:50:03 +02:00
|
|
|
const tasks = TaskFactory.create(1, {
|
2021-11-17 18:11:19 +01:00
|
|
|
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()
|
|
|
|
|
2022-10-05 15:21:19 +02:00
|
|
|
cy.get('.g-gantt-rows-container')
|
2021-11-17 18:11:19 +01:00
|
|
|
.should('not.be.empty')
|
2022-07-21 00:50:03 +02:00
|
|
|
.should('contain', tasks[0].title)
|
2021-11-17 18:11:19 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Drags a task around', () => {
|
2022-07-21 00:50:03 +02:00
|
|
|
cy.intercept('**/api/v1/tasks/*')
|
|
|
|
.as('taskUpdate')
|
|
|
|
|
2021-11-17 18:11:19 +01:00
|
|
|
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')
|
|
|
|
|
2022-10-05 15:21:19 +02:00
|
|
|
cy.get('.g-gantt-rows-container .g-gantt-row .g-gantt-row-bars-container div .g-gantt-bar')
|
2021-11-17 18:11:19 +01:00
|
|
|
.first()
|
|
|
|
.trigger('mousedown', {which: 1})
|
|
|
|
.trigger('mousemove', {clientX: 500, clientY: 0})
|
|
|
|
.trigger('mouseup', {force: true})
|
2022-07-21 00:50:03 +02:00
|
|
|
cy.wait('@taskUpdate')
|
2021-11-17 18:11:19 +01:00
|
|
|
})
|
|
|
|
})
|