Skip to content

Commit

Permalink
Merge pull request #3701 from bcgov/NDT-596-Filter-Package-by-null
Browse files Browse the repository at this point in the history
chore: filter package by null
  • Loading branch information
ccbc-service-account authored Dec 4, 2024
2 parents ddf4ba5 + b7ad4f0 commit 8950e15
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
## [1.214.3](https://github.com/bcgov/CONN-CCBC-portal/compare/v1.214.2...v1.214.3) (2024-12-04)

## [1.214.2](https://github.com/bcgov/CONN-CCBC-portal/compare/v1.214.1...v1.214.2) (2024-12-04)

### Bug Fixes
Expand Down
7 changes: 5 additions & 2 deletions app/components/AnalystDashboard/AllDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ const ApplicantStatusCell = ({ cell }) => {

const filterOutNullishs = (val) => val !== undefined && val !== null;

const toLabelValuePair = (value) =>
value ? { label: value, value } : { label: 'Unassigned', value: ' ' };

const accessorFunctionGeneratorInjectsEmptyString = (accessorKey) => {
return (row) => row[accessorKey] ?? '';
};
Expand Down Expand Up @@ -609,8 +612,8 @@ const AllDashboardTable: React.FC<Props> = ({ query }) => {
allApplications.edges.map((edge) => edge.node.package?.toString())
),
]
.filter(filterOutNullishs)
.sort((a, b) => Number(a) - Number(b));
.map(toLabelValuePair)
.toSorted((a, b) => Number(a.value) - Number(b.value));

return [
{
Expand Down
40 changes: 40 additions & 0 deletions app/tests/pages/analyst/dashboard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const mockQueryPayload = {
zones: [1, 2],
program: 'CCBC',
status: 'received',
package: '1',
applicationFormTemplate9DataByApplicationId: {
nodes: [
{
Expand Down Expand Up @@ -64,6 +65,7 @@ const mockQueryPayload = {
zones: [],
program: 'CCBC',
status: 'approved',
package: null,
applicationFormTemplate9DataByApplicationId: {
nodes: [
{
Expand Down Expand Up @@ -931,6 +933,44 @@ describe('The index page', () => {
expect(screen.getAllByText('Reporting complete')).toHaveLength(6);
});

it('should correctly filter by package filter', async () => {
jest
.spyOn(moduleApi, 'useFeature')
.mockReturnValue(mockShowCbcProjects(true));

pageTestingHelper.loadQuery();
pageTestingHelper.renderPage();

expect(screen.getByText('CCBC-010001')).toBeVisible();
expect(screen.getByText('CCBC-010002')).toBeVisible();

const columnActions = document.querySelectorAll(
'[aria-label="Show/Hide filters"]'
)[0];

await act(async () => {
fireEvent.click(columnActions);
});

const packageFilter = screen.getAllByText('Filter by Package')[0];

expect(packageFilter).toBeInTheDocument();

await act(async () => {
fireEvent.keyDown(packageFilter, { key: 'Enter', code: 'Enter' });
});

const option = screen.getByRole('option', { name: 'Unassigned' });
await act(async () => {
fireEvent.click(option);
});

await waitFor(() => {
expect(screen.getByText('CCBC-010002')).toBeInTheDocument();
expect(screen.queryByText('CCBC-010001')).not.toBeInTheDocument();
});
});

it('should correctly filter the cbc projects by analyst status filter', async () => {
jest
.spyOn(moduleApi, 'useFeature')
Expand Down
1 change: 1 addition & 0 deletions db/sqitch.plan
Original file line number Diff line number Diff line change
Expand Up @@ -755,3 +755,4 @@ mutations/create_assessment_form [mutations/[email protected]] 2024
@1.214.0 2024-12-04T01:18:22Z CCBC Service Account <[email protected]> # release v1.214.0
@1.214.1 2024-12-04T03:24:26Z CCBC Service Account <[email protected]> # release v1.214.1
@1.214.2 2024-12-04T18:39:28Z CCBC Service Account <[email protected]> # release v1.214.2
@1.214.3 2024-12-04T21:21:10Z CCBC Service Account <[email protected]> # release v1.214.3
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "CONN-CCBC-portal",
"version": "1.214.2",
"version": "1.214.3",
"main": "index.js",
"repository": "https://github.com/bcgov/CONN-CCBC-portal.git",
"author": "Romer, Meherzad CITZ:EX <[email protected]>",
Expand Down

0 comments on commit 8950e15

Please sign in to comment.