fix: add tests to make sure tasks are sorted correctly on overview
This commit is contained in:
parent
72c123f3f9
commit
9d6822a75f
|
@ -21,6 +21,16 @@ describe('List View List', () => {
|
||||||
.contains('This list is currently empty.')
|
.contains('This list is currently empty.')
|
||||||
.should('exist')
|
.should('exist')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('Should create a new task', () => {
|
||||||
|
const newTaskTitle = 'New task'
|
||||||
|
|
||||||
|
cy.visit('/lists/1')
|
||||||
|
cy.get('.task-add textarea')
|
||||||
|
.type(newTaskTitle+'{enter}')
|
||||||
|
cy.get('.tasks')
|
||||||
|
.should('contain.text', newTaskTitle)
|
||||||
|
})
|
||||||
|
|
||||||
it('Should navigate to the task when the title is clicked', () => {
|
it('Should navigate to the task when the title is clicked', () => {
|
||||||
const tasks = TaskFactory.create(5, {
|
const tasks = TaskFactory.create(5, {
|
||||||
|
|
102
cypress/integration/task/overview.spec.js
Normal file
102
cypress/integration/task/overview.spec.js
Normal file
|
@ -0,0 +1,102 @@
|
||||||
|
import {ListFactory} from '../../factories/list'
|
||||||
|
import {seed} from '../../support/seed'
|
||||||
|
import {TaskFactory} from '../../factories/task'
|
||||||
|
import {formatISO} from 'date-fns'
|
||||||
|
import {UserFactory} from '../../factories/user'
|
||||||
|
import {NamespaceFactory} from '../../factories/namespace'
|
||||||
|
|
||||||
|
function seedTasks(numberOfTasks = 100) {
|
||||||
|
UserFactory.create(1)
|
||||||
|
NamespaceFactory.create(1)
|
||||||
|
const list = ListFactory.create()[0]
|
||||||
|
BucketFactory.create(1, {
|
||||||
|
list_id: list.id,
|
||||||
|
})
|
||||||
|
const tasks = []
|
||||||
|
let due_date = new Date()
|
||||||
|
for (let i = 0; i < numberOfTasks; i++) {
|
||||||
|
const now = new Date()
|
||||||
|
due_date = (new Date(due_date.valueOf())).setDate((new Date(due_date.valueOf())).getDate() + 2)
|
||||||
|
tasks.push({
|
||||||
|
id: i + 1,
|
||||||
|
list_id: list.id,
|
||||||
|
done: false,
|
||||||
|
created_by_id: 1,
|
||||||
|
title: 'Test Task ' + i,
|
||||||
|
index: i + 1,
|
||||||
|
due_date: formatISO(due_date),
|
||||||
|
created: formatISO(now),
|
||||||
|
updated: formatISO(now),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
seed(TaskFactory.table, tasks)
|
||||||
|
return tasks
|
||||||
|
}
|
||||||
|
|
||||||
|
import '../../support/authenticateUser'
|
||||||
|
import {BucketFactory} from '../../factories/bucket'
|
||||||
|
|
||||||
|
describe('Home Page Task Overview', () => {
|
||||||
|
it('Should show tasks with a near due date first on the home page overview', () => {
|
||||||
|
const tasks = seedTasks()
|
||||||
|
|
||||||
|
cy.visit('/')
|
||||||
|
cy.get('[data-cy="showTasks"] .card .task')
|
||||||
|
.each(([task], index) => {
|
||||||
|
expect(task.innerText).to.contain(tasks[index].title)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Should show a new task with a very soon due date at the top', () => {
|
||||||
|
const tasks = seedTasks()
|
||||||
|
const newTaskTitle = 'New Task'
|
||||||
|
|
||||||
|
cy.visit('/')
|
||||||
|
|
||||||
|
TaskFactory.create(1, {
|
||||||
|
id: 999,
|
||||||
|
title: newTaskTitle,
|
||||||
|
due_date: formatISO(new Date()),
|
||||||
|
}, false)
|
||||||
|
|
||||||
|
cy.visit(`/lists/${tasks[0].list_id}/list`)
|
||||||
|
cy.get('.tasks .task')
|
||||||
|
.first()
|
||||||
|
.should('contain.text', newTaskTitle)
|
||||||
|
cy.visit('/')
|
||||||
|
cy.get('[data-cy="showTasks"] .card .task')
|
||||||
|
.first()
|
||||||
|
.should('contain.text', newTaskTitle)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Should not show a new task without a date at the bottom when there are > 50 tasks', () => {
|
||||||
|
// We're not using the api here to create the task in order to verify the flow
|
||||||
|
const tasks = seedTasks()
|
||||||
|
const newTaskTitle = 'New Task'
|
||||||
|
|
||||||
|
cy.visit('/')
|
||||||
|
|
||||||
|
cy.visit(`/lists/${tasks[0].list_id}/list`)
|
||||||
|
cy.get('.task-add textarea')
|
||||||
|
.type(newTaskTitle+'{enter}')
|
||||||
|
cy.visit('/')
|
||||||
|
cy.get('[data-cy="showTasks"] .card .task')
|
||||||
|
.last()
|
||||||
|
.should('not.contain.text', newTaskTitle)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Should show a new task without a date at the bottom when there are < 50 tasks', () => {
|
||||||
|
seedTasks(40)
|
||||||
|
const newTaskTitle = 'New Task'
|
||||||
|
TaskFactory.create(1, {
|
||||||
|
id: 999,
|
||||||
|
title: newTaskTitle,
|
||||||
|
}, false)
|
||||||
|
|
||||||
|
cy.visit('/')
|
||||||
|
cy.get('[data-cy="showTasks"] .card .task')
|
||||||
|
.last()
|
||||||
|
.should('contain.text', newTaskTitle)
|
||||||
|
})
|
||||||
|
// Should do the same with adding tasks via quick add magic
|
||||||
|
})
|
|
@ -6,13 +6,13 @@ import {TaskCommentFactory} from '../../factories/task_comment'
|
||||||
import {UserFactory} from '../../factories/user'
|
import {UserFactory} from '../../factories/user'
|
||||||
import {NamespaceFactory} from '../../factories/namespace'
|
import {NamespaceFactory} from '../../factories/namespace'
|
||||||
import {UserListFactory} from '../../factories/users_list'
|
import {UserListFactory} from '../../factories/users_list'
|
||||||
|
|
||||||
import '../../support/authenticateUser'
|
|
||||||
import {TaskAssigneeFactory} from '../../factories/task_assignee'
|
import {TaskAssigneeFactory} from '../../factories/task_assignee'
|
||||||
import {LabelFactory} from '../../factories/labels'
|
import {LabelFactory} from '../../factories/labels'
|
||||||
import {LabelTaskFactory} from '../../factories/label_task'
|
import {LabelTaskFactory} from '../../factories/label_task'
|
||||||
import {BucketFactory} from '../../factories/bucket'
|
import {BucketFactory} from '../../factories/bucket'
|
||||||
|
|
||||||
|
import '../../support/authenticateUser'
|
||||||
|
|
||||||
describe('Task', () => {
|
describe('Task', () => {
|
||||||
let namespaces
|
let namespaces
|
||||||
let lists
|
let lists
|
||||||
|
|
Reference in New Issue
Block a user