fix(views): make kanban cypress tests work again

This commit is contained in:
kolaente 2024-03-19 14:21:32 +01:00
parent 165d291cd5
commit 53e57d524a
Signed by untrusted user: konrad
GPG Key ID: F40E70337AB24C9B

View File

@ -35,24 +35,24 @@ function createSingleTaskInBucket(count = 1, attrs = {}) {
} }
} }
function createTaskWithBuckets(count = 1) { function createTaskWithBuckets(buckets, count = 1) {
const data = TaskFactory.create(10, { const data = TaskFactory.create(10, {
project_id: 1, project_id: 1,
}) })
TaskBucketFactory.truncate() TaskBucketFactory.truncate()
data.forEach(t => TaskBucketFactory.create(1, { data.forEach(t => TaskBucketFactory.create(count, {
task_id: t.id, task_id: t.id,
bucket_id: buckets[0].id, bucket_id: buckets[0].id,
project_view_id: buckets[0].project_view_id, project_view_id: buckets[0].project_view_id,
}, false)) }, false))
return data return data
} }
describe('Project View Kanban', () => { describe('Project View Kanban', () => {
createFakeUserAndLogin() createFakeUserAndLogin()
prepareProjects() prepareProjects()
let buckets let buckets
beforeEach(() => { beforeEach(() => {
buckets = BucketFactory.create(2, { buckets = BucketFactory.create(2, {
@ -61,7 +61,7 @@ describe('Project View Kanban', () => {
}) })
it('Shows all buckets with their tasks', () => { it('Shows all buckets with their tasks', () => {
const data = createTaskWithBuckets(10) const data = createTaskWithBuckets(buckets, 10)
cy.visit('/projects/1/4') cy.visit('/projects/1/4')
cy.get('.kanban .bucket .title') cy.get('.kanban .bucket .title')
@ -76,7 +76,7 @@ describe('Project View Kanban', () => {
}) })
it('Can add a new task to a bucket', () => { it('Can add a new task to a bucket', () => {
createTaskWithBuckets(2) createTaskWithBuckets(buckets, 2)
cy.visit('/projects/1/4') cy.visit('/projects/1/4')
cy.get('.kanban .bucket') cy.get('.kanban .bucket')
@ -164,14 +164,14 @@ describe('Project View Kanban', () => {
}) })
it('Can drag tasks around', () => { it('Can drag tasks around', () => {
createTaskWithBuckets(2) const tasks = createTaskWithBuckets(buckets, 2)
cy.visit('/projects/1/4') cy.visit('/projects/1/4')
cy.get('.kanban .bucket .tasks .task') cy.get('.kanban .bucket .tasks .task')
.contains(tasks[0].title) .contains(tasks[0].title)
.first() .first()
.drag('.kanban .bucket:nth-child(2) .tasks') .drag('.kanban .bucket:nth-child(2) .tasks')
cy.get('.kanban .bucket:nth-child(2) .tasks') cy.get('.kanban .bucket:nth-child(2) .tasks')
.should('contain', tasks[0].title) .should('contain', tasks[0].title)
cy.get('.kanban .bucket:nth-child(1) .tasks') cy.get('.kanban .bucket:nth-child(1) .tasks')
@ -179,7 +179,7 @@ describe('Project View Kanban', () => {
}) })
it('Should navigate to the task when the task card is clicked', () => { it('Should navigate to the task when the task card is clicked', () => {
createTaskWithBuckets(5) const tasks = createTaskWithBuckets(buckets, 5)
cy.visit('/projects/1/4') cy.visit('/projects/1/4')
cy.get('.kanban .bucket .tasks .task') cy.get('.kanban .bucket .tasks .task')
@ -188,33 +188,33 @@ describe('Project View Kanban', () => {
.click() .click()
cy.url() cy.url()
.should('contain', `/tasks/${tasks[0].id}`, { timeout: 1000 }) .should('contain', `/tasks/${tasks[0].id}`, {timeout: 1000})
}) })
it('Should remove a task from the kanban board when moving it to another project', () => { it('Should remove a task from the kanban board when moving it to another project', () => {
const projects = ProjectFactory.create(2) const projects = ProjectFactory.create(2)
ProjectViewFactory.create(2, { const views = ProjectViewFactory.create(2, {
project_id: '{increment}', project_id: '{increment}',
view_kind: 3, view_kind: 3,
bucket_configuration_mode: 1,
}) })
BucketFactory.create(2) BucketFactory.create(2)
const tasks = TaskFactory.create(5, { const tasks = TaskFactory.create(5, {
id: '{increment}', id: '{increment}',
project_id: 1, project_id: 1,
bucket_id: 1,
}) })
TaskBucketFactory.create(5, { TaskBucketFactory.create(5, {
project_view_id: 1, project_view_id: 1,
}) })
const task = tasks[0] const task = tasks[0]
cy.visit('/projects/1/4') cy.visit('/projects/1/'+views[0].id)
cy.get('.kanban .bucket .tasks .task') cy.get('.kanban .bucket .tasks .task')
.contains(task.title) .contains(task.title)
.should('be.visible') .should('be.visible')
.click() .click()
cy.get('.task-view .action-buttons .button', { timeout: 3000 }) cy.get('.task-view .action-buttons .button', {timeout: 3000})
.contains('Move') .contains('Move')
.click() .click()
cy.get('.task-view .content.details .field .multiselect.control .input-wrapper input') cy.get('.task-view .content.details .field .multiselect.control .input-wrapper input')
@ -226,22 +226,22 @@ describe('Project View Kanban', () => {
.first() .first()
.click() .click()
cy.get('.global-notification', { timeout: 1000 }) cy.get('.global-notification', {timeout: 1000})
.should('contain', 'Success') .should('contain', 'Success')
cy.go('back') cy.go('back')
cy.get('.kanban .bucket') cy.get('.kanban .bucket')
.should('not.contain', task.title) .should('not.contain', task.title)
}) })
it('Shows a button to filter the kanban board', () => { it('Shows a button to filter the kanban board', () => {
cy.visit('/projects/1/4') cy.visit('/projects/1/4')
cy.get('.project-kanban .filter-container .base-button') cy.get('.project-kanban .filter-container .base-button')
.should('exist') .should('exist')
}) })
it('Should remove a task from the board when deleting it', () => { it('Should remove a task from the board when deleting it', () => {
const {task , view} = createSingleTaskInBucket(5) const {task, view} = createSingleTaskInBucket(5)
cy.visit(`/projects/1/${view.id}`) cy.visit(`/projects/1/${view.id}`)
cy.get('.kanban .bucket .tasks .task') cy.get('.kanban .bucket .tasks .task')
@ -260,13 +260,13 @@ describe('Project View Kanban', () => {
cy.get('.global-notification') cy.get('.global-notification')
.should('contain', 'Success') .should('contain', 'Success')
cy.get('.kanban .bucket .tasks') cy.get('.kanban .bucket .tasks')
.should('not.contain', task.title) .should('not.contain', task.title)
}) })
it('Should show a task description icon if the task has a description', () => { it('Should show a task description icon if the task has a description', () => {
cy.intercept(Cypress.env('API_URL') + '/projects/1/buckets**').as('loadTasks') cy.intercept(Cypress.env('API_URL') + '/projects/1/views/*/tasks**').as('loadTasks')
const {task, view} = createSingleTaskInBucket(1, { const {task, view} = createSingleTaskInBucket(1, {
description: 'Lorem Ipsum', description: 'Lorem Ipsum',
}) })
@ -279,7 +279,7 @@ describe('Project View Kanban', () => {
}) })
it('Should not show a task description icon if the task has an empty description', () => { 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') cy.intercept(Cypress.env('API_URL') + '/projects/1/views/*/tasks**').as('loadTasks')
const {task, view} = createSingleTaskInBucket(1, { const {task, view} = createSingleTaskInBucket(1, {
description: '', description: '',
}) })
@ -292,7 +292,7 @@ describe('Project View Kanban', () => {
}) })
it('Should not show a task description icon if the task has a description containing only an empty p tag', () => { 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') cy.intercept(Cypress.env('API_URL') + '/projects/1/views/*/tasks**').as('loadTasks')
const {task, view} = createSingleTaskInBucket(1, { const {task, view} = createSingleTaskInBucket(1, {
description: '<p></p>', description: '<p></p>',
}) })