Skip to content

Commit

Permalink
Change trigger on dropdown to click and update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
peterMuriuki committed Jun 14, 2023
1 parent 2b04f36 commit 29fe732
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
1 change: 0 additions & 1 deletion packages/team-management/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
"@opensrp/react-utils": "^0.0.12",
"@opensrp/reducer-factory": "^0.0.13",
"@opensrp/server-service": "^0.0.16",
"@testing-library/react": "^14.0.0",
"antd": "^5.6.1",
"uuid": "^8.3.1"
},
Expand Down
5 changes: 3 additions & 2 deletions packages/team-management/src/components/TeamsView/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const Table: React.FC<Props> = (props: Props) => {
label: (
<Button
type='link'
data-testId='view-details'
data-testid='view-details'
onClick={() => {
if (onViewDetails) {
onViewDetails(
Expand Down Expand Up @@ -108,8 +108,9 @@ const Table: React.FC<Props> = (props: Props) => {
<Dropdown
menu={{items: getItems(record)}}
placement="bottomRight"
trigger={['click']}
>
<MoreOutlined className="more-options" rev={undefined} />
<MoreOutlined className="more-options" />
</Dropdown>
</span>
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,22 +245,25 @@ describe('components/TeamsView', () => {
wrapper.update();
});

const tree = document.querySelector('.content');
expect(tree).toMatchSnapshot();
console.log(wrapper.debug())
// find view details button
const dropdown = wrapper.find('[data-testid="view-details"]')
const firstRow = wrapper.find('table tbody tr').first()
expect(firstRow.text()).toEqual("The LuangEdit")
expect(wrapper.find('[data-testid="view-details"]')).toHaveLength(0)

// collapse menu items
console.log(toJson(firstRow.find('.more-options')))
firstRow.find('.more-options').last().simulate('click');
wrapper.update()

expect(wrapper.find('button[data-testid="view-details"]')).toHaveLength(1)

const dropdown = wrapper.find('button[data-testid="view-details"]')
dropdown.simulate('click');
wrapper.update();

fetch.mockResponseOnce(JSON.stringify(practitioners));
fetch.mockResponseOnce(JSON.stringify([assignments]));

// wrapper.find('.viewdetails').at(0).simulate('click');
// wrapper.update();

// click view details

await act(async () => {
await flushPromises();
wrapper.update();
Expand Down

0 comments on commit 29fe732

Please sign in to comment.