Skip to content

Commit

Permalink
Merge pull request #6461 from uktrade/CLS2-692/tasks-dashboard-update…
Browse files Browse the repository at this point in the history
…-filters

Enable status active/complete filter
  • Loading branch information
santoshdasa12345 authored Jan 30, 2024
2 parents 6b8c4d7 + ab6fdbf commit 3522bca
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/client/components/Dashboard/my-tasks/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ const sortbyMapping = {
company_ascending: 'company.name:asc',
project_ascending: 'investment_project.name:asc',
}

const statusMapping = {
active: { archived: false },
completed: { archived: true },
active: { status: 'active' },
completed: { status: 'complete' },
}

export const state2props = ({ router, ...state }) => {
Expand All @@ -50,6 +51,7 @@ export const state2props = ({ router, ...state }) => {
sortby: 'due_date:asc',
company: undefined,
project: undefined,
status: undefined,
}

const assignedToMapping = {
Expand Down
2 changes: 2 additions & 0 deletions src/client/components/Dashboard/my-tasks/tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const getMyTasks = ({
sortby = 'due_date:asc',
company,
project,
status,
}) =>
apiProxyAxios
.post('/v4/search/task', {
Expand All @@ -24,5 +25,6 @@ export const getMyTasks = ({
sortby,
company,
investment_project: project,
status,
})
.then(({ data }) => data)
1 change: 1 addition & 0 deletions test/functional/cypress/fakers/task.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const taskFaker = (overrides = {}) => ({
modifiedBy: basicAdviserFaker(),
modifiedOn: faker.date.past().toISOString(),
createdOn: faker.date.past().toISOString(),
status: 'active',

...overrides,
})
Expand Down
13 changes: 9 additions & 4 deletions test/functional/cypress/specs/dashboard/filter-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,24 +300,29 @@ describe('Task filters', () => {
})

it('should filter active status from the url', () => {
testFilterFromUrl(element, 'status=active', { archived: false }, 'Active')
testFilterFromUrl(
element,
'status=active',
{ status: 'active' },
'Active'
)
})

it('should filter completed status from the url', () => {
testFilterFromUrl(
element,
'status=completed',
{ archived: true },
{ status: 'complete' },
'Completed'
)
})

it('should filter active status from user input', () => {
testFilterFromUserInput(element, { archived: false }, 'Active')
testFilterFromUserInput(element, { status: 'active' }, 'Active')
})

it('should filter completed status from user input', () => {
testFilterFromUserInput(element, { archived: true }, 'Completed')
testFilterFromUserInput(element, { status: 'complete' }, 'Completed')
})
})

Expand Down

0 comments on commit 3522bca

Please sign in to comment.