diff --git a/frontend/cypress/e2e/project/prepareProjects.ts b/frontend/cypress/e2e/project/prepareProjects.ts index ea7a1b01d..27c8b20df 100644 --- a/frontend/cypress/e2e/project/prepareProjects.ts +++ b/frontend/cypress/e2e/project/prepareProjects.ts @@ -1,15 +1,50 @@ import {ProjectFactory} from '../../factories/project' import {TaskFactory} from '../../factories/task' +import {ProjectViewFactory} from "../../factories/project_view"; + +export function createDefaultViews(projectId) { + ProjectViewFactory.truncate() + const list = ProjectViewFactory.create(1, { + id: 1, + project_id: projectId, + view_kind: 0, + }, false) + const gantt = ProjectViewFactory.create(1, { + id: 2, + project_id: projectId, + view_kind: 1, + }, false) + const table = ProjectViewFactory.create(1, { + id: 3, + project_id: projectId, + view_kind: 2, + }, false) + const kanban = ProjectViewFactory.create(1, { + id: 4, + project_id: projectId, + view_kind: 3, + bucket_configuration_mode: 1, + }, false) + + return [ + list[0], + gantt[0], + table[0], + kanban[0], + ] +} export function createProjects() { const projects = ProjectFactory.create(1, { title: 'First Project' }) TaskFactory.truncate() + projects.views = createDefaultViews(projects[0].id) return projects } -export function prepareProjects(setProjects = (...args: any[]) => {}) { +export function prepareProjects(setProjects = (...args: any[]) => { +}) { beforeEach(() => { const projects = createProjects() setProjects(projects) diff --git a/frontend/cypress/e2e/project/project-view-gantt.spec.ts b/frontend/cypress/e2e/project/project-view-gantt.spec.ts index 5a67c7081..507588d29 100644 --- a/frontend/cypress/e2e/project/project-view-gantt.spec.ts +++ b/frontend/cypress/e2e/project/project-view-gantt.spec.ts @@ -11,7 +11,7 @@ describe('Project View Gantt', () => { it('Hides tasks with no dates', () => { const tasks = TaskFactory.create(1) - cy.visit('/projects/1/gantt') + cy.visit('/projects/1/2') cy.get('.g-gantt-rows-container') .should('not.contain', tasks[0].title) @@ -25,7 +25,7 @@ describe('Project View Gantt', () => { nextMonth.setDate(1) nextMonth.setMonth(9) - cy.visit('/projects/1/gantt') + cy.visit('/projects/1/2') cy.get('.g-timeunits-container') .should('contain', format(now, 'MMMM')) @@ -38,7 +38,7 @@ describe('Project View Gantt', () => { start_date: now.toISOString(), end_date: new Date(new Date(now).setDate(now.getDate() + 4)).toISOString(), }) - cy.visit('/projects/1/gantt') + cy.visit('/projects/1/2') cy.get('.g-gantt-rows-container') .should('not.be.empty') @@ -50,7 +50,7 @@ describe('Project View Gantt', () => { start_date: null, end_date: null, }) - cy.visit('/projects/1/gantt') + cy.visit('/projects/1/2') cy.get('.gantt-options .fancycheckbox') .contains('Show tasks which don\'t have dates set') @@ -69,7 +69,7 @@ describe('Project View Gantt', () => { start_date: now.toISOString(), end_date: new Date(new Date(now).setDate(now.getDate() + 4)).toISOString(), }) - cy.visit('/projects/1/gantt') + cy.visit('/projects/1/2') cy.get('.g-gantt-rows-container .g-gantt-row .g-gantt-row-bars-container div .g-gantt-bar') .first() @@ -83,7 +83,7 @@ describe('Project View Gantt', () => { const now = Date.UTC(2022, 10, 9) cy.clock(now, ['Date']) - cy.visit('/projects/1/gantt') + cy.visit('/projects/1/2') cy.get('.project-gantt .gantt-options .field .control input.input.form-control') .click() @@ -99,7 +99,7 @@ describe('Project View Gantt', () => { }) it('Should change the date range based on date query parameters', () => { - cy.visit('/projects/1/gantt?dateFrom=2022-09-25&dateTo=2022-11-05') + cy.visit('/projects/1/2?dateFrom=2022-09-25&dateTo=2022-11-05') cy.get('.g-timeunits-container') .should('contain', 'September 2022') @@ -115,7 +115,7 @@ describe('Project View Gantt', () => { start_date: formatISO(now), end_date: formatISO(now.setDate(now.getDate() + 4)), }) - cy.visit('/projects/1/gantt') + cy.visit('/projects/1/2') cy.get('.gantt-container .g-gantt-chart .g-gantt-row-bars-container .g-gantt-bar') .dblclick() diff --git a/frontend/cypress/e2e/project/project-view-kanban.spec.ts b/frontend/cypress/e2e/project/project-view-kanban.spec.ts index 2c74ba9a9..0bbe53a7f 100644 --- a/frontend/cypress/e2e/project/project-view-kanban.spec.ts +++ b/frontend/cypress/e2e/project/project-view-kanban.spec.ts @@ -4,18 +4,49 @@ import {BucketFactory} from '../../factories/bucket' import {ProjectFactory} from '../../factories/project' import {TaskFactory} from '../../factories/task' import {prepareProjects} from './prepareProjects' +import {ProjectViewFactory} from "../../factories/project_view"; +import {TaskBucketFactory} from "../../factories/task_buckets"; function createSingleTaskInBucket(count = 1, attrs = {}) { const projects = ProjectFactory.create(1) - const buckets = BucketFactory.create(2, { + const views = ProjectViewFactory.create(1, { + id: 1, project_id: projects[0].id, + view_kind: 3, + bucket_configuration_mode: 1, + }) + const buckets = BucketFactory.create(2, { + project_view_id: views[0].id, }) const tasks = TaskFactory.create(count, { project_id: projects[0].id, bucket_id: buckets[0].id, ...attrs, }) - return tasks[0] + TaskBucketFactory.create(1, { + task_id: tasks[0].id, + bucket_id: buckets[0].id, + project_view_id: views[0].id, + }) + return { + task: tasks[0], + view: views[0], + project: projects[0], + } +} + +function createTaskWithBuckets(count = 1) { + const data = TaskFactory.create(10, { + project_id: 1, + }) + TaskBucketFactory.truncate() + data.forEach(t => TaskBucketFactory.create(1, { + task_id: t.id, + bucket_id: buckets[0].id, + project_view_id: buckets[0].project_view_id, + }, false)) + + return data } describe('Project View Kanban', () => { @@ -24,15 +55,14 @@ describe('Project View Kanban', () => { let buckets beforeEach(() => { - buckets = BucketFactory.create(2) + buckets = BucketFactory.create(2, { + project_view_id: 4, + }) }) it('Shows all buckets with their tasks', () => { - const data = TaskFactory.create(10, { - project_id: 1, - bucket_id: 1, - }) - cy.visit('/projects/1/kanban') + const data = createTaskWithBuckets(10) + cy.visit('/projects/1/4') cy.get('.kanban .bucket .title') .contains(buckets[0].title) @@ -46,11 +76,8 @@ describe('Project View Kanban', () => { }) it('Can add a new task to a bucket', () => { - TaskFactory.create(2, { - project_id: 1, - bucket_id: 1, - }) - cy.visit('/projects/1/kanban') + createTaskWithBuckets(2) + cy.visit('/projects/1/4') cy.get('.kanban .bucket') .contains(buckets[0].title) @@ -68,7 +95,7 @@ describe('Project View Kanban', () => { }) it('Can create a new bucket', () => { - cy.visit('/projects/1/kanban') + cy.visit('/projects/1/4') cy.get('.kanban .bucket.new-bucket .button') .click() @@ -82,7 +109,7 @@ describe('Project View Kanban', () => { }) it('Can set a bucket limit', () => { - cy.visit('/projects/1/kanban') + cy.visit('/projects/1/4') cy.get('.kanban .bucket .bucket-header .dropdown.options .dropdown-trigger') .first() @@ -103,7 +130,7 @@ describe('Project View Kanban', () => { }) it('Can rename a bucket', () => { - cy.visit('/projects/1/kanban') + cy.visit('/projects/1/4') cy.get('.kanban .bucket .bucket-header .title') .first() @@ -114,7 +141,7 @@ describe('Project View Kanban', () => { }) it('Can delete a bucket', () => { - cy.visit('/projects/1/kanban') + cy.visit('/projects/1/4') cy.get('.kanban .bucket .bucket-header .dropdown.options .dropdown-trigger') .first() @@ -137,11 +164,8 @@ describe('Project View Kanban', () => { }) it('Can drag tasks around', () => { - const tasks = TaskFactory.create(2, { - project_id: 1, - bucket_id: 1, - }) - cy.visit('/projects/1/kanban') + createTaskWithBuckets(2) + cy.visit('/projects/1/4') cy.get('.kanban .bucket .tasks .task') .contains(tasks[0].title) @@ -155,12 +179,8 @@ describe('Project View Kanban', () => { }) it('Should navigate to the task when the task card is clicked', () => { - const tasks = TaskFactory.create(5, { - id: '{increment}', - project_id: 1, - bucket_id: 1, - }) - cy.visit('/projects/1/kanban') + createTaskWithBuckets(5) + cy.visit('/projects/1/4') cy.get('.kanban .bucket .tasks .task') .contains(tasks[0].title) @@ -173,16 +193,21 @@ describe('Project View Kanban', () => { it('Should remove a task from the kanban board when moving it to another project', () => { const projects = ProjectFactory.create(2) - BucketFactory.create(2, { + ProjectViewFactory.create(2, { project_id: '{increment}', + view_kind: 3, }) + BucketFactory.create(2) const tasks = TaskFactory.create(5, { id: '{increment}', project_id: 1, bucket_id: 1, }) + TaskBucketFactory.create(5, { + project_view_id: 1, + }) const task = tasks[0] - cy.visit('/projects/1/kanban') + cy.visit('/projects/1/4') cy.get('.kanban .bucket .tasks .task') .contains(task.title) @@ -209,19 +234,15 @@ describe('Project View Kanban', () => { }) it('Shows a button to filter the kanban board', () => { - const data = TaskFactory.create(10, { - project_id: 1, - bucket_id: 1, - }) - cy.visit('/projects/1/kanban') + cy.visit('/projects/1/4') cy.get('.project-kanban .filter-container .base-button') .should('exist') }) it('Should remove a task from the board when deleting it', () => { - const task = createSingleTaskInBucket(5) - cy.visit('/projects/1/kanban') + const {task , view} = createSingleTaskInBucket(5) + cy.visit(`/projects/1/${view.id}`) cy.get('.kanban .bucket .tasks .task') .contains(task.title) @@ -246,11 +267,11 @@ describe('Project View Kanban', () => { it('Should show a task description icon if the task has a description', () => { cy.intercept(Cypress.env('API_URL') + '/projects/1/buckets**').as('loadTasks') - const task = createSingleTaskInBucket(1, { + const {task, view} = createSingleTaskInBucket(1, { description: 'Lorem Ipsum', }) - cy.visit(`/projects/${task.project_id}/kanban`) + cy.visit(`/projects/${task.project_id}/${view.id}`) cy.wait('@loadTasks') cy.get('.bucket .tasks .task .footer .icon svg') @@ -259,11 +280,11 @@ describe('Project View Kanban', () => { it('Should not show a task description icon if the task has an empty description', () => { cy.intercept(Cypress.env('API_URL') + '/projects/1/buckets**').as('loadTasks') - const task = createSingleTaskInBucket(1, { + const {task, view} = createSingleTaskInBucket(1, { description: '', }) - cy.visit(`/projects/${task.project_id}/kanban`) + cy.visit(`/projects/${task.project_id}/${view.id}`) cy.wait('@loadTasks') cy.get('.bucket .tasks .task .footer .icon svg') @@ -272,14 +293,14 @@ describe('Project View Kanban', () => { it('Should not show a task description icon if the task has a description containing only an empty p tag', () => { cy.intercept(Cypress.env('API_URL') + '/projects/1/buckets**').as('loadTasks') - const task = createSingleTaskInBucket(1, { + const {task, view} = createSingleTaskInBucket(1, { description: '

', }) - cy.visit(`/projects/${task.project_id}/kanban`) + cy.visit(`/projects/${task.project_id}/${view.id}`) cy.wait('@loadTasks') cy.get('.bucket .tasks .task .footer .icon svg') .should('not.exist') }) -}) \ No newline at end of file +}) diff --git a/frontend/cypress/e2e/task/overview.spec.ts b/frontend/cypress/e2e/task/overview.spec.ts index 342134b23..22a047545 100644 --- a/frontend/cypress/e2e/task/overview.spec.ts +++ b/frontend/cypress/e2e/task/overview.spec.ts @@ -5,11 +5,13 @@ import {seed} from '../../support/seed' import {TaskFactory} from '../../factories/task' import {BucketFactory} from '../../factories/bucket' import {updateUserSettings} from '../../support/updateUserSettings' +import {createDefaultViews} from "../project/prepareProjects"; function seedTasks(numberOfTasks = 50, startDueDate = new Date()) { const project = ProjectFactory.create()[0] + const views = createDefaultViews(project.id) BucketFactory.create(1, { - project_id: project.id, + project_view_id: views[3].id, }) const tasks = [] let dueDate = startDueDate diff --git a/frontend/cypress/e2e/task/task.spec.ts b/frontend/cypress/e2e/task/task.spec.ts index aa1653e8b..d0cd39d96 100644 --- a/frontend/cypress/e2e/task/task.spec.ts +++ b/frontend/cypress/e2e/task/task.spec.ts @@ -12,6 +12,7 @@ import {BucketFactory} from '../../factories/bucket' import {TaskAttachmentFactory} from '../../factories/task_attachments' import {TaskReminderFactory} from '../../factories/task_reminders' +import {createDefaultViews} from "../project/prepareProjects"; function addLabelToTaskAndVerify(labelTitle: string) { cy.get('.task-view .action-buttons .button') @@ -53,8 +54,9 @@ describe('Task', () => { beforeEach(() => { // UserFactory.create(1) projects = ProjectFactory.create(1) + const views = createDefaultViews(projects[0].id) buckets = BucketFactory.create(1, { - project_id: projects[0].id, + project_view_id: views[3].id, }) TaskFactory.truncate() UserProjectFactory.truncate() @@ -314,8 +316,9 @@ describe('Task', () => { it('Can move a task to another project', () => { const projects = ProjectFactory.create(2) + const views = createDefaultViews(projects[0].id) BucketFactory.create(2, { - project_id: '{increment}', + project_view_id: views[3].id, }) const tasks = TaskFactory.create(1, { id: 1, diff --git a/frontend/cypress/factories/bucket.ts b/frontend/cypress/factories/bucket.ts index 2e0e91077..23b1cfe60 100644 --- a/frontend/cypress/factories/bucket.ts +++ b/frontend/cypress/factories/bucket.ts @@ -10,7 +10,7 @@ export class BucketFactory extends Factory { return { id: '{increment}', title: faker.lorem.words(3), - project_id: 1, + project_view_id: '{increment}', created_by_id: 1, created: now.toISOString(), updated: now.toISOString(), diff --git a/frontend/cypress/factories/task.ts b/frontend/cypress/factories/task.ts index bc97446a8..9c37ad0f7 100644 --- a/frontend/cypress/factories/task.ts +++ b/frontend/cypress/factories/task.ts @@ -14,7 +14,6 @@ export class TaskFactory extends Factory { project_id: 1, created_by_id: 1, index: '{increment}', - position: '{increment}', created: now.toISOString(), updated: now.toISOString() } diff --git a/frontend/cypress/factories/task_buckets.ts b/frontend/cypress/factories/task_buckets.ts new file mode 100644 index 000000000..a91141d9d --- /dev/null +++ b/frontend/cypress/factories/task_buckets.ts @@ -0,0 +1,13 @@ +import {Factory} from '../support/factory' + +export class TaskBucketFactory extends Factory { + static table = 'task_buckets' + + static factory() { + return { + task_id: '{increment}', + bucket_id: '{increment}', + project_view_id: '{increment}', + } + } +} \ No newline at end of file