Skip to content

Commit

Permalink
Workflow history - fix flaky test (#807)
Browse files Browse the repository at this point in the history
* Fix unit test

* Fix query param value

* Fix test
  • Loading branch information
adhityamamallan authored Feb 5, 2025
1 parent d53ebe0 commit 0bc0179
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions src/views/workflow-history/__tests__/workflow-history.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,13 @@ describe('WorkflowHistory', () => {
it('should show loading while searching for initial selectedEventId', async () => {
const { getRequestResolver } = await setup({
resolveLoadMoreManually: true,
pageQueryParamsValues: { historySelectedEventId: '3' },
pageQueryParamsValues: {
historySelectedEventId: completedDecisionTaskEvents[1].eventId,
},
hasNextPage: true,
});

await act(() => {
await act(async () => {
const resolver = getRequestResolver();
resolver({
history: {
Expand All @@ -151,21 +153,22 @@ describe('WorkflowHistory', () => {
});
});

expect(await screen.findByText('keep loading events')).toBeInTheDocument();
const loadingIndicator = await screen.findByText('keep loading events');
expect(loadingIndicator).toBeInTheDocument();

const secondPageResolver = getRequestResolver();
secondPageResolver({
history: {
events: [completedDecisionTaskEvents[1]],
},
archived: false,
nextPageToken: 'mock-next-page-token',
rawHistory: [],
await act(async () => {
const secondPageResolver = getRequestResolver();
secondPageResolver({
history: {
events: [completedDecisionTaskEvents[1]],
},
archived: false,
nextPageToken: 'mock-next-page-token',
rawHistory: [],
});
});

expect(
await screen.findByText('keep loading events')
).not.toBeInTheDocument();
await waitForElementToBeRemoved(loadingIndicator);
});
});

Expand Down

0 comments on commit 0bc0179

Please sign in to comment.