Skip to content

Commit

Permalink
Feature/cls2 704 use status for active and complete (#6543)
Browse files Browse the repository at this point in the history
* Use status for active and complete

* Add API calls to a11y test exclusion list

* Fix tasks/details-spec.js
  • Loading branch information
marijnkampf committed Feb 22, 2024
1 parent 010b0c3 commit 99e698b
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 23 deletions.
2 changes: 2 additions & 0 deletions src/client/modules/Tasks/TaskDetails/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { getTaskBreadcrumbs } from '../TaskForm/state'
export const ID = 'taskDetails'

export const TASK_GET_TASK_DETAILS = 'TASK_GET_TASK_DETAILS'
export const TASK_SAVE_STATUS_COMPLETE = 'TASK_SAVE_STATUS_COMPLETE'
export const TASK_SAVE_STATUS_ACTIVE = 'TASK_SAVE_STATUS_ACTIVE'
export const TASK_ARCHIVE_TASK = 'TASK_ARCHIVE_TASK'

export const state2props = (state) => {
Expand Down
5 changes: 4 additions & 1 deletion src/client/modules/Tasks/TaskDetails/tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ export const getTaskDetail = (id) =>
apiProxyAxios.get(`v4/task/${id}`).then(({ data }) => data)

export const saveTaskStatusComplete = ({ taskId }) =>
apiProxyAxios.post(`/v4/task/${taskId}/status_complete`)
apiProxyAxios.post(`/v4/task/${taskId}/status-complete`)

export const saveTaskStatusActive = ({ taskId }) =>
apiProxyAxios.post(`/v4/task/${taskId}/status-active`)
3 changes: 3 additions & 0 deletions src/client/tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -419,10 +419,12 @@ import { TASK_CREATE_ORDER } from './modules/Omis/CreateOrder/state'
import { createOrder } from './modules/Omis/CreateOrder/tasks'

import {
saveTaskStatusActive,
saveTaskStatusComplete,
getTaskDetail,
} from './modules/Tasks/TaskDetails/tasks'
import {
TASK_SAVE_STATUS_ACTIVE,
TASK_SAVE_STATUS_COMPLETE,
TASK_GET_TASK_DETAILS,
} from './modules/Tasks/TaskDetails/state'
Expand Down Expand Up @@ -651,6 +653,7 @@ export const tasks = {
[TASK_GET_TASK_DETAILS]: getTaskDetail,
[TASK_GET_INVESTMENT_PROJECT]: investmentProjectTasks.getInvestmentProject,
[TASK_SAVE_STATUS_COMPLETE]: saveTaskStatusComplete,
[TASK_SAVE_STATUS_ACTIVE]: saveTaskStatusActive,
[TASK_RECONCILE_OMIS_PAYMENT]: savePayment,
[TASK_SAVE_TASK_DETAILS]: saveTaskDetail,
[TASK_EDIT_INVOICE_DETAILS]: updateOrder,
Expand Down
2 changes: 2 additions & 0 deletions src/lib/urls.js
Original file line number Diff line number Diff line change
Expand Up @@ -729,5 +729,7 @@ module.exports = {
createInteraction: url('/tasks/create?interactionId=', ':interactionId'),
createCopyTask: url('/tasks/create?copyTaskId=', ':copyTaskId'),
edit: url('/tasks', '/:taskId/edit'),
statusComplete: url('/tasks', '/:taskId/status-complete'),
statusActive: url('/tasks', '/:taskId/status-active'),
},
}
5 changes: 5 additions & 0 deletions test/a11y/cypress/config/urlTestExclusions.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ export const urlTestExclusions = [
{ url: '/investments/projects/:investmentId/propositions/:propositionId' },
{ url: '/companies/:companyId/hierarchies/ghq/:globalHqId/add' },
{ url: '/companies/:companyId/hierarchies/ghq/remove' },
// API calls with redirect
{ url: '/tasks/:taskId/status-complete' },
{ url: '/tasks/:taskId/status-active' },
{ url: '/tasks/:taskId/archive' },
{ url: '/tasks/:taskId/unarchive' },
// 501 errors
{ url: '/api-proxy/v4/company/:companyId/export-win' },
{ url: '/investments/projects/:projectId/edit-ukcompany/:companyId' },
Expand Down
33 changes: 11 additions & 22 deletions test/functional/cypress/specs/tasks/details-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import {
import {
assertSummaryTable,
assertBreadcrumbs,
assertPayload,
assertUrl,
} from '../../support/assertions'
import { clickButton } from '../../support/actions'
import interactionsListFaker from '../../fakers/interactions'
import { STATUS } from '../../../../../src/client/modules/Tasks/TaskForm/constants'

describe('View details for a generic task', () => {
const genericTaskCompleted = taskFaker({ archived: true })
const genericTaskNotCompleteTask = taskFaker({ archived: false })
const genericTaskCompleted = taskFaker({ status: STATUS.COMPLETED })
const genericTaskNotCompleteTask = taskFaker({ status: STATUS.ACTIVE })

context('When visiting a completed task details', () => {
beforeEach(() => {
Expand Down Expand Up @@ -71,17 +71,6 @@ describe('View details for a generic task', () => {

cy.get('[data-test="activity-kind-label"]').should('not.exist')
})

it('should redirect to the dashboard and show the Flash message after marking as complete', () => {
cy.intercept(
'POST',
`/api-proxy/v4/task/${genericTaskNotCompleteTask.id}/archive`,
{}
).as('postTaskArchiveApiRequest')
clickButton('Mark as complete')
assertPayload('@postTaskArchiveApiRequest', { reason: 'completed' })
assertUrl(dashboard.myTasks())
})
})
})

Expand All @@ -91,7 +80,7 @@ describe('View details for task that is assigned to an investment project', () =
})

context('When visiting a not complete task details', () => {
before(() => {
beforeEach(() => {
cy.intercept(
'GET',
`/api-proxy/v4/task/${investmentProjectTask.id}`,
Expand All @@ -104,11 +93,11 @@ describe('View details for task that is assigned to an investment project', () =
it('should redirect to the investment project and show the Flash message after marking as complete', () => {
cy.intercept(
'POST',
`/api-proxy/v4/task/${investmentProjectTask.id}/archive`,
`/api-proxy/v4/task/${investmentProjectTask.id}/status-complete`,
{}
).as('postTaskArchiveApiRequest')
).as('postTaskStatusCompleteApiRequest')
clickButton('Mark as complete')
assertPayload('@postTaskArchiveApiRequest', { reason: 'completed' })
cy.wait('@postTaskStatusCompleteApiRequest')
assertUrl(dashboard.myTasks())
})
})
Expand All @@ -118,7 +107,7 @@ describe('View details for task that is assigned to a company', () => {
const companyTask = taskWithCompanyFaker({ archived: false })

context('When visiting a not complete task details', () => {
before(() => {
beforeEach(() => {
cy.intercept(
'GET',
`/api-proxy/v4/task/${companyTask.id}`,
Expand All @@ -131,11 +120,11 @@ describe('View details for task that is assigned to a company', () => {
it('should redirect to the investment project and show the Flash message after marking as complete', () => {
cy.intercept(
'POST',
`/api-proxy/v4/task/${companyTask.id}/archive`,
`/api-proxy/v4/task/${companyTask.id}/status-complete`,
{}
).as('postTaskArchiveApiRequest')
).as('postTaskStatusCompleteApiRequest')
clickButton('Mark as complete')
assertPayload('@postTaskArchiveApiRequest', { reason: 'completed' })
cy.wait('@postTaskStatusCompleteApiRequest')
assertUrl(dashboard.myTasks())
})
})
Expand Down

0 comments on commit 99e698b

Please sign in to comment.