Skip to content

Commit

Permalink
Merge branch 'main' into 1323-bulk-upload
Browse files Browse the repository at this point in the history
  • Loading branch information
peterMuriuki committed Jul 5, 2024
2 parents 2544961 + f878746 commit bd2b221
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export const ChildLocations = ({ fhirBaseUrl, locationId }: InventoryViewProps)
<RbacCheck permissions={['Location.update']}>
<>
<Link
data-testid="edit-child-location"
to={`${URL_LOCATION_UNIT_EDIT}/${record.id.toString()}?${backToParam}`}
className="m-0 p-1"
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-floating-promises */
/* eslint-disable @typescript-eslint/no-non-null-assertion */
import React from 'react';
import { store } from '@opensrp/store';
Expand Down Expand Up @@ -144,8 +145,18 @@ test('works correctly - jurisdiction location', async () => {
);
expect(tableData).toEqual(['Kiambu CountyBuildingactiveEdit']);

// edit url
const editLinks = screen.getAllByTestId('edit-child-location').map((element) => {
return element.getAttribute('href');
});
expect(editLinks).toEqual([
'/admin/location/unit/edit/46bb8a3f-cf50-4cc2-b421-fe4f77c3e75d?back_to=%2Fprofile%2Fd9d7aa7b-7488-48e7-bae8-d8ac5bd09334',
]);

// validate search works.
const childLocationSearch = childLocationTab.querySelector('[data-testid="search-form"]')!;
const childLocationSearch = childLocationTab.querySelector(
'[data-testid="search-form"]'
) as HTMLElement;
userEvent.paste(childLocationSearch, 'searchLocation');
expect(history.location.pathname).toEqual('/profile/d9d7aa7b-7488-48e7-bae8-d8ac5bd09334');
expect(history.location.search).toEqual('?search=searchLocation&page=1&pageSize=20');
Expand All @@ -155,7 +166,9 @@ test('works correctly - jurisdiction location', async () => {
});
childLocationTab = document.querySelector('[data-testid="child-location-tab"]')!;
tableData = [...childLocationTab.querySelectorAll('table tbody tr')].map((tr) => tr.textContent);
expect(tableData).toEqual(['No data']);
waitFor(() => {
expect(tableData).toEqual(['No data']);
});

userEvent.clear(childLocationSearch);
await waitFor(() => {
Expand Down Expand Up @@ -246,7 +259,9 @@ test('works correctly - physical location', async () => {

// check records shown in table
tableData = [...inventoryTab.querySelectorAll('table tbody tr')].map((tr) => tr.textContent);
expect(tableData).toEqual(['No data']);
waitFor(() => {
expect(tableData).toEqual(['No data']);
});

userEvent.clear(childLocationSearch);
expect(history.location.pathname).toEqual('/profile/d9d7aa7b-7488-48e7-bae8-d8ac5bd09334');
Expand Down

0 comments on commit bd2b221

Please sign in to comment.