Skip to content

Commit c054660

Browse files
authored
Fix workflow history flaky test (#861)
* await for resolver * add verification checks * remove unused changes and fix docker typo
1 parent 49500e6 commit c054660

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ COPY . .
3434
# Learn more here: https://nextjs.org/telemetry
3535
# Uncomment the following line in case you want to disable telemetry during the build.
3636
ENV NEXT_TELEMETRY_DISABLED 1
37-
# optimize Build size by inclduding only required resources
37+
# optimize Build size by including only required resources
3838

3939
RUN npm run generate:idl
4040
RUN npm run build
@@ -68,4 +68,4 @@ COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
6868
USER nextjs
6969

7070

71-
CMD ["sh","-c", "CADENCE_WEB_PORT=${CADENCE_WEB_PORT:-8088} CADENCE_WEB_HOSTNAME=${CADENCE_WEB_HOSTNAME:-0.0.0.0} exec node server.js"]
71+
CMD ["sh","-c", "CADENCE_WEB_PORT=${CADENCE_WEB_PORT:-8088} CADENCE_WEB_HOSTNAME=${CADENCE_WEB_HOSTNAME:-0.0.0.0} exec node server.js"]

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

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,11 @@ describe('WorkflowHistory', () => {
142142
hasNextPage: true,
143143
});
144144

145+
await waitFor(() => {
146+
expect(screen.getByText('keep loading events')).toBeInTheDocument();
147+
});
148+
149+
// Load first page
145150
await act(async () => {
146151
const resolver = getRequestResolver();
147152
resolver({
@@ -154,9 +159,11 @@ describe('WorkflowHistory', () => {
154159
});
155160
});
156161

157-
const loadingIndicator = await screen.findByText('keep loading events');
158-
expect(loadingIndicator).toBeInTheDocument();
162+
await waitFor(() => {
163+
expect(screen.getByText('keep loading events')).toBeInTheDocument();
164+
});
159165

166+
// Load second page
160167
await act(async () => {
161168
const secondPageResolver = getRequestResolver();
162169
secondPageResolver({
@@ -205,6 +212,7 @@ async function setup({
205212
const getRequestResolver = () => requestResolver;
206213
const getRequestRejector = () => requestRejector;
207214
let requestIndex = -1;
215+
208216
const renderResult = render(
209217
<Suspense fallback={'Suspense placeholder'}>
210218
<WorkflowHistory
@@ -225,10 +233,12 @@ async function setup({
225233
mockOnce: false,
226234
httpResolver: async () => {
227235
requestIndex = requestIndex + 1;
236+
228237
if (requestIndex > 0 && resolveLoadMoreManually) {
229238
return await new Promise((resolve, reject) => {
230239
requestResolver = (result: GetWorkflowHistoryResponse) =>
231240
resolve(HttpResponse.json(result, { status: 200 }));
241+
232242
requestRejector = () =>
233243
reject(
234244
HttpResponse.json(
@@ -238,11 +248,12 @@ async function setup({
238248
);
239249
});
240250
} else {
241-
if (error)
251+
if (error) {
242252
return HttpResponse.json(
243253
{ message: 'Failed to fetch workflow history' },
244254
{ status: 500 }
245255
);
256+
}
246257

247258
return HttpResponse.json(
248259
{

0 commit comments

Comments
 (0)