feat(task): add more tests
This commit is contained in:
parent
fc6b707405
commit
9fdb6a8d24
@ -5,6 +5,19 @@ import {ProjectFactory} from '../../factories/project'
|
|||||||
import {TaskFactory} from '../../factories/task'
|
import {TaskFactory} from '../../factories/task'
|
||||||
import {prepareProjects} from './prepareProjects'
|
import {prepareProjects} from './prepareProjects'
|
||||||
|
|
||||||
|
function createSingleTaskInBucket(count = 1, attrs = {}) {
|
||||||
|
const projects = ProjectFactory.create(1)
|
||||||
|
const buckets = BucketFactory.create(2, {
|
||||||
|
project_id: projects[0].id,
|
||||||
|
})
|
||||||
|
const tasks = TaskFactory.create(count, {
|
||||||
|
project_id: projects[0].id,
|
||||||
|
bucket_id: buckets[0].id,
|
||||||
|
...attrs,
|
||||||
|
})
|
||||||
|
return tasks[0]
|
||||||
|
}
|
||||||
|
|
||||||
describe('Project View Kanban', () => {
|
describe('Project View Kanban', () => {
|
||||||
createFakeUserAndLogin()
|
createFakeUserAndLogin()
|
||||||
prepareProjects()
|
prepareProjects()
|
||||||
@ -207,15 +220,7 @@ describe('Project View Kanban', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('Should remove a task from the board when deleting it', () => {
|
it('Should remove a task from the board when deleting it', () => {
|
||||||
const projects = ProjectFactory.create(1)
|
const task = createSingleTaskInBucket(5)
|
||||||
const buckets = BucketFactory.create(2, {
|
|
||||||
project_id: projects[0].id,
|
|
||||||
})
|
|
||||||
const tasks = TaskFactory.create(5, {
|
|
||||||
project_id: 1,
|
|
||||||
bucket_id: buckets[0].id,
|
|
||||||
})
|
|
||||||
const task = tasks[0]
|
|
||||||
cy.visit('/projects/1/kanban')
|
cy.visit('/projects/1/kanban')
|
||||||
|
|
||||||
cy.get('.kanban .bucket .tasks .task')
|
cy.get('.kanban .bucket .tasks .task')
|
||||||
@ -238,4 +243,43 @@ describe('Project View Kanban', () => {
|
|||||||
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', () => {
|
||||||
|
cy.intercept(Cypress.env('API_URL') + '/projects/1/buckets**').as('loadTasks')
|
||||||
|
const task = createSingleTaskInBucket(1, {
|
||||||
|
description: 'Lorem Ipsum',
|
||||||
|
})
|
||||||
|
|
||||||
|
cy.visit(`/projects/${task.project_id}/kanban`)
|
||||||
|
cy.wait('@loadTasks')
|
||||||
|
|
||||||
|
cy.get('.bucket .tasks .task .footer .icon svg')
|
||||||
|
.should('exist')
|
||||||
|
})
|
||||||
|
|
||||||
|
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, {
|
||||||
|
description: '',
|
||||||
|
})
|
||||||
|
|
||||||
|
cy.visit(`/projects/${task.project_id}/kanban`)
|
||||||
|
cy.wait('@loadTasks')
|
||||||
|
|
||||||
|
cy.get('.bucket .tasks .task .footer .icon svg')
|
||||||
|
.should('not.exist')
|
||||||
|
})
|
||||||
|
|
||||||
|
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, {
|
||||||
|
description: '<p></p>',
|
||||||
|
})
|
||||||
|
|
||||||
|
cy.visit(`/projects/${task.project_id}/kanban`)
|
||||||
|
cy.wait('@loadTasks')
|
||||||
|
|
||||||
|
cy.get('.bucket .tasks .task .footer .icon svg')
|
||||||
|
.should('not.exist')
|
||||||
|
})
|
||||||
})
|
})
|
@ -112,10 +112,50 @@ describe('Task', () => {
|
|||||||
.should('contain', 'Favorites')
|
.should('contain', 'Favorites')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('Should show a task description icon if the task has a description', () => {
|
||||||
|
cy.intercept(Cypress.env('API_URL') + '/projects/1/tasks**').as('loadTasks')
|
||||||
|
TaskFactory.create(1, {
|
||||||
|
description: 'Lorem Ipsum',
|
||||||
|
})
|
||||||
|
|
||||||
|
cy.visit('/projects/1/list')
|
||||||
|
cy.wait('@loadTasks')
|
||||||
|
|
||||||
|
cy.get('.tasks .task .project-task-icon')
|
||||||
|
.should('exist')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Should not show a task description icon if the task has an empty description', () => {
|
||||||
|
cy.intercept(Cypress.env('API_URL') + '/projects/1/tasks**').as('loadTasks')
|
||||||
|
TaskFactory.create(1, {
|
||||||
|
description: '',
|
||||||
|
})
|
||||||
|
|
||||||
|
cy.visit('/projects/1/list')
|
||||||
|
cy.wait('@loadTasks')
|
||||||
|
|
||||||
|
cy.get('.tasks .task .project-task-icon')
|
||||||
|
.should('not.exist')
|
||||||
|
})
|
||||||
|
|
||||||
|
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/tasks**').as('loadTasks')
|
||||||
|
TaskFactory.create(1, {
|
||||||
|
description: '<p></p>',
|
||||||
|
})
|
||||||
|
|
||||||
|
cy.visit('/projects/1/list')
|
||||||
|
cy.wait('@loadTasks')
|
||||||
|
|
||||||
|
cy.get('.tasks .task .project-task-icon')
|
||||||
|
.should('not.exist')
|
||||||
|
})
|
||||||
|
|
||||||
describe('Task Detail View', () => {
|
describe('Task Detail View', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TaskCommentFactory.truncate()
|
TaskCommentFactory.truncate()
|
||||||
LabelTaskFactory.truncate()
|
LabelTaskFactory.truncate()
|
||||||
|
TaskAttachmentFactory.truncate()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Shows all task details', () => {
|
it('Shows all task details', () => {
|
||||||
@ -213,6 +253,45 @@ describe('Task', () => {
|
|||||||
.should('exist')
|
.should('exist')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('Shows an empty editor when the description of a task is empty', () => {
|
||||||
|
const tasks = TaskFactory.create(1, {
|
||||||
|
id: 1,
|
||||||
|
description: '',
|
||||||
|
})
|
||||||
|
cy.visit(`/tasks/${tasks[0].id}`)
|
||||||
|
|
||||||
|
cy.get('.task-view .details.content.description .tiptap.ProseMirror p')
|
||||||
|
.should('have.attr', 'data-placeholder')
|
||||||
|
cy.get('.task-view .details.content.description .tiptap button.done-edit')
|
||||||
|
.should('not.exist')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Shows a preview editor when the description of a task is not empty', () => {
|
||||||
|
const tasks = TaskFactory.create(1, {
|
||||||
|
id: 1,
|
||||||
|
description: 'Lorem Ipsum dolor sit amet',
|
||||||
|
})
|
||||||
|
cy.visit(`/tasks/${tasks[0].id}`)
|
||||||
|
|
||||||
|
cy.get('.task-view .details.content.description .tiptap.ProseMirror p')
|
||||||
|
.should('not.have.attr', 'data-placeholder')
|
||||||
|
cy.get('.task-view .details.content.description .tiptap button.done-edit')
|
||||||
|
.should('exist')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Shows a preview editor when the description of a task contains html', () => {
|
||||||
|
const tasks = TaskFactory.create(1, {
|
||||||
|
id: 1,
|
||||||
|
description: '<p>Lorem Ipsum dolor sit amet</p>',
|
||||||
|
})
|
||||||
|
cy.visit(`/tasks/${tasks[0].id}`)
|
||||||
|
|
||||||
|
cy.get('.task-view .details.content.description .tiptap.ProseMirror p')
|
||||||
|
.should('not.have.attr', 'data-placeholder')
|
||||||
|
cy.get('.task-view .details.content.description .tiptap button.done-edit')
|
||||||
|
.should('exist')
|
||||||
|
})
|
||||||
|
|
||||||
it('Can add a new comment', () => {
|
it('Can add a new comment', () => {
|
||||||
const tasks = TaskFactory.create(1, {
|
const tasks = TaskFactory.create(1, {
|
||||||
id: 1,
|
id: 1,
|
||||||
@ -761,7 +840,7 @@ describe('Task', () => {
|
|||||||
.should('exist')
|
.should('exist')
|
||||||
})
|
})
|
||||||
|
|
||||||
it.only('Should render an image from attachment', async () => {
|
it('Should render an image from attachment', async () => {
|
||||||
|
|
||||||
TaskAttachmentFactory.truncate()
|
TaskAttachmentFactory.truncate()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user