Skip to content

Commit

Permalink
test for setting URL param
Browse files Browse the repository at this point in the history
  • Loading branch information
ashokaditya committed May 22, 2023
1 parent cbf0aa1 commit b6f3bbe
Showing 1 changed file with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -479,5 +479,33 @@ describe('Response actions history page', () => {

expect(history.location.search).toEqual('?endDate=now&startDate=now-15m');
});

it('should set actionIds using `withOutputs` to URL params ', async () => {
const allActionIds = mockUseGetEndpointActionList.data?.data.map((action) => action.id) ?? [];
const actionIdsWithDetails = allActionIds
.reduce<string[]>((acc, e, i) => {
if ([0, 1].includes(i)) {
acc.push(e);
}
return acc;
}, [])
.join()
.split(',')
.join('%2C');

render();
const { getAllByTestId } = renderResult;

const expandButtons = getAllByTestId(`${testPrefix}-expand-button`);
// expand some rows
expandButtons.forEach((button, i) => {
if ([0, 1].includes(i)) {
userEvent.click(button);
}
});

// verify 4 rows are expanded and are the ones from before
expect(history.location.search).toEqual(`?withOutputs=${actionIdsWithDetails}`);
});
});
});

0 comments on commit b6f3bbe

Please sign in to comment.