Skip to content

Commit 8cc1bc9

Browse files
authored
test: add retry to flaky abortsignal unit test (#6841)
1 parent 66ae8cf commit 8cc1bc9

File tree

2 files changed

+57
-53
lines changed

2 files changed

+57
-53
lines changed

cypress/e2e/laboratory-preflight.cy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ describe('Execution', () => {
246246
// Run GraphiQL
247247
cy.intercept({ headers: preflightHeaders }).as('request');
248248
cy.get(selectors.graphiql.buttonExecute).click();
249-
cy.wait('@request');
249+
cy.wait('@request', { timeout: 10_000 });
250250
});
251251

252252
it('result.request.headers are NOT substituted with environment variables', () => {
@@ -282,7 +282,7 @@ describe('Execution', () => {
282282
},
283283
}).as('request');
284284
cy.get(selectors.graphiql.buttonExecute).click();
285-
cy.wait('@request');
285+
cy.wait('@request', { timeout: 10_000 });
286286
});
287287

288288
it('header placeholders are substituted with environment variables', () => {

packages/services/schema/__tests__/cache.spec.ts

Lines changed: 55 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -220,60 +220,64 @@ test('timeout', async ({ expect }) => {
220220
expect(spy).toHaveBeenCalledTimes(2);
221221
});
222222

223-
test('run action again when the action expires', async ({ expect }) => {
224-
const ttlMs = 10;
225-
const redis = new Redis();
226-
const prefix = randomString();
227-
const pollIntervalMs = 5;
228-
const timeoutMs = 50;
229-
const cacheForRequest1 = createCache({
230-
redis,
231-
logger: {
232-
debug: vi.fn() as any,
233-
warn: vi.fn() as any,
234-
},
235-
prefix,
236-
pollIntervalMs,
237-
timeoutMs,
238-
ttlMs: {
239-
success: ttlMs,
240-
failure: ttlMs,
241-
},
242-
});
243-
244-
const cacheForRequest2 = createCache({
245-
redis,
246-
logger: {
247-
debug: vi.fn() as any,
248-
warn: vi.fn() as any,
249-
},
250-
prefix,
251-
pollIntervalMs,
252-
timeoutMs,
253-
ttlMs: {
254-
success: ttlMs,
255-
failure: ttlMs,
256-
},
257-
});
258-
259-
const actionId = randomString();
260-
async function actionFn() {
261-
await waitFor(timeoutMs - 1);
262-
return 'foo';
263-
}
223+
test(
224+
'run action again when the action expires',
225+
async ({ expect }) => {
226+
const ttlMs = 10;
227+
const redis = new Redis();
228+
const prefix = randomString();
229+
const pollIntervalMs = 5;
230+
const timeoutMs = 50;
231+
const cacheForRequest1 = createCache({
232+
redis,
233+
logger: {
234+
debug: vi.fn() as any,
235+
warn: vi.fn() as any,
236+
},
237+
prefix,
238+
pollIntervalMs,
239+
timeoutMs,
240+
ttlMs: {
241+
success: ttlMs,
242+
failure: ttlMs,
243+
},
244+
});
245+
246+
const cacheForRequest2 = createCache({
247+
redis,
248+
logger: {
249+
debug: vi.fn() as any,
250+
warn: vi.fn() as any,
251+
},
252+
prefix,
253+
pollIntervalMs,
254+
timeoutMs,
255+
ttlMs: {
256+
success: ttlMs,
257+
failure: ttlMs,
258+
},
259+
});
260+
261+
const actionId = randomString();
262+
async function actionFn() {
263+
await waitFor(timeoutMs - 1);
264+
return 'foo';
265+
}
264266

265-
const exec1 = cacheForRequest1.reuse(actionId, actionFn);
266-
const exec2 = cacheForRequest2.reuse(actionId, actionFn);
267+
const exec1 = cacheForRequest1.reuse(actionId, actionFn);
268+
const exec2 = cacheForRequest2.reuse(actionId, actionFn);
267269

268-
const run1 = exec1({});
269-
const run2 = exec2({});
270-
// force the cache to expire
271-
await waitFor(ttlMs + 10);
272-
await redis.flushall();
270+
const run1 = exec1({});
271+
const run2 = exec2({});
272+
// force the cache to expire
273+
await waitFor(ttlMs + 10);
274+
await redis.flushall();
273275

274-
await expect(run1).resolves.toBe('foo');
275-
await expect(run2).resolves.toBe('foo');
276-
});
276+
await expect(run1).resolves.toBe('foo');
277+
await expect(run2).resolves.toBe('foo');
278+
},
279+
{ retry: 3 },
280+
);
277281

278282
test('decide on cache duration', async ({ expect }) => {
279283
const ttlMs = {

0 commit comments

Comments
 (0)