
fix: project table view fix: e2e tests fix: typo in readme fix: list view route fix: don't wait until background is loaded for list to show fix: rename component imports fix: lint fix: parse task text fix: use list card grid fix: use correct class names fix: i18n keys fix: load project fix: task overview fix: list view spacing fix: find project fix: setLoading when updating a project fix: loading saved filter fix: project store loading fix: color picker import fix: cypress tests feat: migrate old list settings chore: add const for project settings fix: wrong projecten rename from lists chore: rename unused variable fix: editor list fix: shortcut list class name fix: pagination list class name fix: notifications list class name fix: list view variable name chore: clarify comment fix: i18n keys fix: router imports fix: comment chore: remove debugging leftover fix: remove duplicate variables fix: change comment fix: list view variable name fix: list view css class name fix: list item property name fix: name update tasks function correctly fix: update comment fix: project create route fix: list view class names fix: list view component name fix: result list class name fix: animation class list name fix: change debug log fix: revert a few navigation changes fix: use @ for imports of all views fix: rename link share list class fix: remove unused css class fix: dynamically import project components again
154 lines
4.3 KiB
TypeScript
154 lines
4.3 KiB
TypeScript
import {createFakeUserAndLogin} from '../../support/authenticateUser'
|
|
|
|
import {ProjectFactory} from '../../factories/project'
|
|
import {seed} from '../../support/seed'
|
|
import {TaskFactory} from '../../factories/task'
|
|
import {NamespaceFactory} from '../../factories/namespace'
|
|
import {BucketFactory} from '../../factories/bucket'
|
|
import {updateUserSettings} from '../../support/updateUserSettings'
|
|
|
|
function seedTasks(numberOfTasks = 50, startDueDate = new Date()) {
|
|
NamespaceFactory.create(1)
|
|
const project = ProjectFactory.create()[0]
|
|
BucketFactory.create(1, {
|
|
project_id: project.id,
|
|
})
|
|
const tasks = []
|
|
let dueDate = startDueDate
|
|
for (let i = 0; i < numberOfTasks; i++) {
|
|
const now = new Date()
|
|
dueDate = new Date(new Date(dueDate).setDate(dueDate.getDate() + 2))
|
|
tasks.push({
|
|
id: i + 1,
|
|
project_id: project.id,
|
|
done: false,
|
|
created_by_id: 1,
|
|
title: 'Test Task ' + i,
|
|
index: i + 1,
|
|
due_date: dueDate.toISOString(),
|
|
created: now.toISOString(),
|
|
updated: now.toISOString(),
|
|
})
|
|
}
|
|
seed(TaskFactory.table, tasks)
|
|
return {tasks, project}
|
|
}
|
|
|
|
describe('Home Page Task Overview', () => {
|
|
createFakeUserAndLogin()
|
|
|
|
it('Should show tasks with a near due date first on the home page overview', () => {
|
|
const taskCount = 50
|
|
const {tasks} = seedTasks(taskCount)
|
|
|
|
cy.visit('/')
|
|
cy.get('[data-cy="showTasks"] .card .task')
|
|
.each(([task], index) => {
|
|
expect(task.innerText).to.contain(tasks[index].title)
|
|
})
|
|
})
|
|
|
|
it('Should show overdue tasks first, then show other tasks', () => {
|
|
const now = new Date()
|
|
const oldDate = new Date(new Date(now).setDate(now.getDate() - 14))
|
|
const taskCount = 50
|
|
const {tasks} = seedTasks(taskCount, oldDate)
|
|
|
|
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: new Date().toISOString(),
|
|
}, false)
|
|
|
|
cy.visit(`/projects/${tasks[0].project_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(100)
|
|
const newTaskTitle = 'New Task'
|
|
|
|
cy.visit('/')
|
|
|
|
cy.visit(`/projects/${tasks[0].project_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)
|
|
})
|
|
|
|
it('Should show a task without a due date added via default project at the bottom', () => {
|
|
const {project} = seedTasks(40)
|
|
updateUserSettings({
|
|
default_project_id: project.id,
|
|
overdue_tasks_reminders_time: '9:00',
|
|
})
|
|
|
|
const newTaskTitle = 'New Task'
|
|
cy.visit('/')
|
|
|
|
cy.get('.add-task-textarea')
|
|
.type(`${newTaskTitle}{enter}`)
|
|
|
|
cy.get('[data-cy="showTasks"] .card .task')
|
|
.last()
|
|
.should('contain.text', newTaskTitle)
|
|
})
|
|
|
|
it('Should show the cta buttons for new project when there are no tasks', () => {
|
|
TaskFactory.truncate()
|
|
|
|
cy.visit('/')
|
|
|
|
cy.get('.home.app-content .content')
|
|
.should('contain.text', 'You can create a new project for your new tasks:')
|
|
.should('contain.text', 'Or import your projects and tasks from other services into Vikunja:')
|
|
})
|
|
|
|
it('Should not show the cta buttons for new project when there are tasks', () => {
|
|
seedTasks()
|
|
|
|
cy.visit('/')
|
|
|
|
cy.get('.home.app-content .content')
|
|
.should('not.contain.text', 'You can create a new project for your new tasks:')
|
|
.should('not.contain.text', 'Or import your projects and tasks from other services into Vikunja:')
|
|
})
|
|
})
|