Skip to content

Commit

Permalink
Fix test regressions
Browse files Browse the repository at this point in the history
  • Loading branch information
peterMuriuki committed Dec 20, 2024
1 parent 4ebe41f commit 5ef9cd9
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/src/App/tests/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe('App - unauthenticated', () => {
</ContextProvider>
);
// before resolving get oauth state request, the user is logged out
expect(wrapper.text()).toMatchInlineSnapshot(`"AdministrationLogin"`);
expect(wrapper.text()).toMatchInlineSnapshot(`"AdministrationData ImportsLogin"`);

await act(async () => {
await flushPromises();
Expand Down Expand Up @@ -175,7 +175,7 @@ describe('App - authenticated', () => {
);
// before resolving get oauth state request, the user is logged out
expect(wrapper.text()).toMatchInlineSnapshot(
`"AdministrationdemoWelcome to OpenSRPUser ManagementQuestionnaire Management"`
`"AdministrationData ImportsdemoWelcome to OpenSRPUser ManagementQuestionnaire ManagementData Imports"`
);

await act(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@ Array [
</Link>
</MenuItem>
</SubMenu>,
<MenuItem
icon={<UploadIcon />}
>
<Link
className="admin-link"
to="/import"
>
Data Imports
</Link>
</MenuItem>,
]
`;

Expand Down Expand Up @@ -169,6 +179,16 @@ Array [
</Link>
</MenuItem>
</SubMenu>,
<MenuItem
icon={<UploadIcon />}
>
<Link
className="admin-link"
to="/import"
>
Data Imports
</Link>
</MenuItem>,
]
`;

Expand Down Expand Up @@ -300,6 +320,16 @@ Object {
</Link>
</MenuItem>
</SubMenu>
<MenuItem
icon={<UploadIcon />}
>
<Link
className="admin-link"
to="/import"
>
Data Imports
</Link>
</MenuItem>
</Menu>
</div>,
null,
Expand Down Expand Up @@ -389,5 +419,15 @@ Array [
</Link>
</MenuItem>
</SubMenu>,
<MenuItem
icon={<UploadIcon />}
>
<Link
className="admin-link"
to="/import"
>
Data Imports
</Link>
</MenuItem>,
]
`;
1 change: 1 addition & 0 deletions app/src/containers/pages/Home/tests/Home.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ describe('containers/pages/Home', () => {
'Location Management',
'Organization Management',
'Questionnaire Management',
'Data Imports',
]);
links.forEach((link) => {
expect(link).toMatchSnapshot(link.textContent ?? undefined);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`containers/pages/Home renders Home correctly & changes Title of page 2: Data Imports 1`] = `
<button
class="ant-btn css-dev-only-do-not-override-k7429z ant-btn-link admin-link btn-links"
type="button"
>
<span>
Data Imports
</span>
</button>
`;

exports[`containers/pages/Home renders Home correctly & changes Title of page 2: Location Management 1`] = `
<button
class="ant-btn css-dev-only-do-not-override-k7429z ant-btn-link admin-link btn-links"
Expand Down
51 changes: 48 additions & 3 deletions app/src/routes/tests/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import React from 'react';
import { store } from '@opensrp/store';
import { authenticateUser } from '@onaio/session-reducer';
import { filterFalsyRoutes, getRoutes } from '..';
import { DashboardOutlined } from '@ant-design/icons';
import React from 'react';
import { superUserRole } from '@opensrp/react-utils';
import UploadIcon from '@2fd/ant-design-icons/lib/Upload';

jest.mock('../../configs/env');
jest.mock('../../configs/settings');
Expand Down Expand Up @@ -124,67 +125,111 @@ describe('routes', () => {
{
key: 'users',
title: 'Users',
permissions: ['iam_user.read'],

url: '/admin/users',
},
{
key: 'user-groups',
permissions: ['iam_group.read'],

title: 'User Groups',
url: '/admin/users/groups',
},
{
key: 'user-roles',
permissions: ['iam_role.read'],
title: 'User Roles',
url: '/admin/users/roles',
},
],
enabled: true,
isHomePageLink: true,
key: 'user-management',
permissions: ['iam_user.read'],
title: 'User Management',
url: '/admin/users',
},
{
children: [
{
key: 'location-unit',
permissions: ['Location.read'],

title: 'Hierarchy',
url: '/admin/location/unit',
},
{
key: 'all-locations',
permissions: ['Location.read'],

title: 'All Locations',
url: '/admin/location/all',
},
],
enabled: true,
isHomePageLink: true,
key: 'location-management',
permissions: ['Location.read'],

title: 'Location Management',
url: '/admin/location/unit',
},
{
children: [
{
key: 'ORGS',
permissions: ['Organization.read'],

title: 'Organizations',
url: '/admin/teams',
},
{
enabled: true,
key: 'org-assignment',
permissions: ['OrganizationAffiliation.read', 'Location.read'],

title: 'Organization Assignment',
url: '/admin/teams/team-assignment',
},
],
enabled: true,
isHomePageLink: true,
key: 'org-management',
permissions: ['Organization.read'],

title: 'Organization Management',
url: '/admin/teams',
},
{
enabled: true,
isHomePageLink: true,
key: 'fhir-quest',
permissions: ['Questionnaire.read'],

title: 'Questionnaire Management',
url: '/quest',
},
{ enabled: true, key: 'fhir-quest', title: 'Questionnaire Management', url: '/quest' },
],
enabled: true,
key: 'admin',
otherProps: {
icon: <DashboardOutlined />,
},
permissions: [],
title: 'Administration',
},
{
enabled: true,
isHomePageLink: true,
key: 'data-import',
otherProps: {
icon: <UploadIcon />,
},
permissions: ['DataImport.read'],
title: 'Data Imports',
url: '/import',
},
]);
});

Expand All @@ -201,7 +246,7 @@ describe('routes', () => {
(t: string) => t,
superUserRole
);
const parentKeys = routes.flatMap((x) => x.children).map((x) => x.key);
const parentKeys = routes.flatMap((x) => x.children).map((x) => (x ? x.key ?? '' : ''));
expect(parentKeys).toContain('org-management');
expect(parentKeys).toContain('user-management');
expect(parentKeys).toContain('location-management');
Expand Down

0 comments on commit 5ef9cd9

Please sign in to comment.