diff --git a/cypress/e2e/task/task.spec.ts b/cypress/e2e/task/task.spec.ts index cbde5f270..5963a7597 100644 --- a/cypress/e2e/task/task.spec.ts +++ b/cypress/e2e/task/task.spec.ts @@ -11,6 +11,7 @@ import {LabelTaskFactory} from '../../factories/label_task' import {BucketFactory} from '../../factories/bucket' import {TaskAttachmentFactory} from '../../factories/task_attachments' +import {TaskReminderFactory} from '../../factories/task_reminders' function addLabelToTaskAndVerify(labelTitle: string) { cy.get('.task-view .action-buttons .button') @@ -461,6 +462,154 @@ describe('Task', () => { .should('contain', 'Success') }) + it('Can set a reminder', () => { + TaskReminderFactory.truncate() + const tasks = TaskFactory.create(1, { + id: 1, + done: false, + }) + cy.visit(`/tasks/${tasks[0].id}`) + + cy.get('.task-view .action-buttons .button') + .contains('Set Reminders') + .click() + cy.get('.task-view .columns.details .column button') + .contains('Add a new reminder') + .click() + cy.get('.datepicker__quick-select-date') + .contains('Tomorrow') + .click() + + cy.get('.reminder-options-popup') + .should('not.be.visible') + cy.get('.global-notification') + .should('contain', 'Success') + }) + + it('Allows to set a relative reminder when the task already has a due date', () => { + TaskReminderFactory.truncate() + const tasks = TaskFactory.create(1, { + id: 1, + done: false, + due_date: (new Date()).toISOString(), + }) + cy.visit(`/tasks/${tasks[0].id}`) + + cy.get('.task-view .action-buttons .button') + .contains('Set Reminders') + .click() + cy.get('.task-view .columns.details .column button') + .contains('Add a new reminder') + .click() + cy.get('.datepicker__quick-select-date') + .should('not.exist') + cy.get('.reminder-options-popup .card-content') + .should('contain', '1 day before Due Date') + cy.get('.reminder-options-popup .card-content') + .contains('1 day before Due Date') + .click() + + cy.get('.reminder-options-popup') + .should('not.be.visible') + cy.get('.global-notification') + .should('contain', 'Success') + }) + + it('Allows to set a relative reminder when the task already has a start date', () => { + TaskReminderFactory.truncate() + const tasks = TaskFactory.create(1, { + id: 1, + done: false, + start_date: (new Date()).toISOString(), + }) + cy.visit(`/tasks/${tasks[0].id}`) + + cy.get('.task-view .action-buttons .button') + .contains('Set Reminders') + .click() + cy.get('.task-view .columns.details .column button') + .contains('Add a new reminder') + .click() + cy.get('.datepicker__quick-select-date') + .should('not.exist') + cy.get('.reminder-options-popup .card-content') + .should('contain', '1 day before Start Date') + cy.get('.reminder-options-popup .card-content') + .contains('1 day before Start Date') + .click() + + cy.get('.reminder-options-popup') + .should('not.be.visible') + cy.get('.global-notification') + .should('contain', 'Success') + }) + + it('Allows to set a custom relative reminder when the task already has a due date', () => { + TaskReminderFactory.truncate() + const tasks = TaskFactory.create(1, { + id: 1, + done: false, + due_date: (new Date()).toISOString(), + }) + cy.visit(`/tasks/${tasks[0].id}`) + + cy.get('.task-view .action-buttons .button') + .contains('Set Reminders') + .click() + cy.get('.task-view .columns.details .column button') + .contains('Add a new reminder') + .click() + cy.get('.datepicker__quick-select-date') + .should('not.exist') + cy.get('.reminder-options-popup .card-content') + .contains('Custom') + .click() + cy.get('.reminder-options-popup .card-content .reminder-period input') + .first() + .type('10') + cy.get('.reminder-options-popup .card-content .reminder-period select') + .first() + .select('days') + cy.get('.reminder-options-popup .card-content button') + .contains('Confirm') + .click() + + cy.get('.reminder-options-popup') + .should('not.be.visible') + cy.get('.global-notification') + .should('contain', 'Success') + }) + + it('Allows to set a fixed reminder when the task already has a due date', () => { + TaskReminderFactory.truncate() + const tasks = TaskFactory.create(1, { + id: 1, + done: false, + due_date: (new Date()).toISOString(), + }) + cy.visit(`/tasks/${tasks[0].id}`) + + cy.get('.task-view .action-buttons .button') + .contains('Set Reminders') + .click() + cy.get('.task-view .columns.details .column button') + .contains('Add a new reminder') + .click() + cy.get('.datepicker__quick-select-date') + .should('not.exist') + cy.get('.reminder-options-popup .card-content') + .contains('Date and time') + .click() + cy.get('.datepicker__quick-select-date') + .contains('Tomorrow') + .click() + + cy.get('.reminder-options-popup') + .should('not.be.visible') + cy.get('.global-notification') + .should('contain', 'Success') + }) + it('Can set a priority for a task', () => { const tasks = TaskFactory.create(1, { id: 1, diff --git a/cypress/factories/task_reminders.ts b/cypress/factories/task_reminders.ts new file mode 100644 index 000000000..2b5a005d2 --- /dev/null +++ b/cypress/factories/task_reminders.ts @@ -0,0 +1,18 @@ +import {Factory} from '../support/factory' + +export class TaskReminderFactory extends Factory { + static table = 'task_reminders' + + static factory() { + const now = new Date() + + return { + id: '{increment}', + task_id: 1, + reminder: now.toISOString(), + created: now.toISOString(), + relative_to: '', + relative_period: 0, + } + } +} \ No newline at end of file diff --git a/cypress/support/factory.ts b/cypress/support/factory.ts index 934f2fae9..b93dc7d8c 100644 --- a/cypress/support/factory.ts +++ b/cypress/support/factory.ts @@ -4,7 +4,7 @@ import {seed} from './seed' * A factory makes it easy to seed the database with data. */ export class Factory { - static table = null + static table: string | null = null static factory() { return {} diff --git a/src/components/tasks/partials/reminder-detail.vue b/src/components/tasks/partials/reminder-detail.vue index 529bd10f9..72f15ced4 100644 --- a/src/components/tasks/partials/reminder-detail.vue +++ b/src/components/tasks/partials/reminder-detail.vue @@ -46,7 +46,7 @@