vikunja-frontend/cypress/e2e/list/list-view-gantt.spec.ts

80 lines
2 KiB
TypeScript
Raw Normal View History

2021-11-17 18:11:19 +01:00
import {formatISO, format} from 'date-fns'
import {TaskFactory} from '../../factories/task'
import {prepareLists} from './prepareLists'
2021-11-17 18:11:19 +01:00
import '../../support/authenticateUser'
describe('List View Gantt', () => {
prepareLists()
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('#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', () => {
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)
nextMonth.setMonth(9)
2021-11-17 18:11:19 +01:00
cy.visit('/lists/1/gantt')
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),
end_date: formatISO(now.setDate(now.getDate() + 4)),
2021-11-17 18:11:19 +01:00
})
cy.visit('/lists/1/gantt')
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', () => {
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()
cy.get('#g-gantt-rows-container')
2021-11-17 18:11:19 +01:00
.should('not.be.empty')
.should('contain', tasks[0].title)
2021-11-17 18:11:19 +01:00
})
it('Drags a task around', () => {
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),
end_date: formatISO(now.setDate(now.getDate() + 4)),
2021-11-17 18:11:19 +01:00
})
cy.visit('/lists/1/gantt')
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})
cy.wait('@taskUpdate')
2021-11-17 18:11:19 +01:00
})
})