Skip to content

Commit 6f059a7

Browse files
adhityamamallanAssem-Uber
authored andcommitted
Workflow history - fix flaky test (#807)
* Fix unit test * Fix query param value * Fix test
1 parent 4864607 commit 6f059a7

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

src/views/workflow-history/__tests__/workflow-history.test.tsx

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,13 @@ describe('WorkflowHistory', () => {
135135
it('should show loading while searching for initial selectedEventId', async () => {
136136
const { getRequestResolver } = await setup({
137137
resolveLoadMoreManually: true,
138-
pageQueryParamsValues: { historySelectedEventId: '3' },
138+
pageQueryParamsValues: {
139+
historySelectedEventId: completedDecisionTaskEvents[1].eventId,
140+
},
139141
hasNextPage: true,
140142
});
141143

142-
await act(() => {
144+
await act(async () => {
143145
const resolver = getRequestResolver();
144146
resolver({
145147
history: {
@@ -151,21 +153,22 @@ describe('WorkflowHistory', () => {
151153
});
152154
});
153155

154-
expect(await screen.findByText('keep loading events')).toBeInTheDocument();
156+
const loadingIndicator = await screen.findByText('keep loading events');
157+
expect(loadingIndicator).toBeInTheDocument();
155158

156-
const secondPageResolver = getRequestResolver();
157-
secondPageResolver({
158-
history: {
159-
events: [completedDecisionTaskEvents[1]],
160-
},
161-
archived: false,
162-
nextPageToken: 'mock-next-page-token',
163-
rawHistory: [],
159+
await act(async () => {
160+
const secondPageResolver = getRequestResolver();
161+
secondPageResolver({
162+
history: {
163+
events: [completedDecisionTaskEvents[1]],
164+
},
165+
archived: false,
166+
nextPageToken: 'mock-next-page-token',
167+
rawHistory: [],
168+
});
164169
});
165170

166-
expect(
167-
await screen.findByText('keep loading events')
168-
).not.toBeInTheDocument();
171+
await waitForElementToBeRemoved(loadingIndicator);
169172
});
170173
});
171174

0 commit comments

Comments
 (0)