mirror of
https://github.com/graphql-hive/console
synced 2026-04-21 14:37:17 +00:00
test: add retry to flaky abortsignal unit test (#6841)
This commit is contained in:
parent
66ae8cf545
commit
8cc1bc9498
2 changed files with 55 additions and 51 deletions
|
|
@ -246,7 +246,7 @@ describe('Execution', () => {
|
|||
// Run GraphiQL
|
||||
cy.intercept({ headers: preflightHeaders }).as('request');
|
||||
cy.get(selectors.graphiql.buttonExecute).click();
|
||||
cy.wait('@request');
|
||||
cy.wait('@request', { timeout: 10_000 });
|
||||
});
|
||||
|
||||
it('result.request.headers are NOT substituted with environment variables', () => {
|
||||
|
|
@ -282,7 +282,7 @@ describe('Execution', () => {
|
|||
},
|
||||
}).as('request');
|
||||
cy.get(selectors.graphiql.buttonExecute).click();
|
||||
cy.wait('@request');
|
||||
cy.wait('@request', { timeout: 10_000 });
|
||||
});
|
||||
|
||||
it('header placeholders are substituted with environment variables', () => {
|
||||
|
|
|
|||
|
|
@ -220,60 +220,64 @@ test('timeout', async ({ expect }) => {
|
|||
expect(spy).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
test('run action again when the action expires', async ({ expect }) => {
|
||||
const ttlMs = 10;
|
||||
const redis = new Redis();
|
||||
const prefix = randomString();
|
||||
const pollIntervalMs = 5;
|
||||
const timeoutMs = 50;
|
||||
const cacheForRequest1 = createCache({
|
||||
redis,
|
||||
logger: {
|
||||
debug: vi.fn() as any,
|
||||
warn: vi.fn() as any,
|
||||
},
|
||||
prefix,
|
||||
pollIntervalMs,
|
||||
timeoutMs,
|
||||
ttlMs: {
|
||||
success: ttlMs,
|
||||
failure: ttlMs,
|
||||
},
|
||||
});
|
||||
test(
|
||||
'run action again when the action expires',
|
||||
async ({ expect }) => {
|
||||
const ttlMs = 10;
|
||||
const redis = new Redis();
|
||||
const prefix = randomString();
|
||||
const pollIntervalMs = 5;
|
||||
const timeoutMs = 50;
|
||||
const cacheForRequest1 = createCache({
|
||||
redis,
|
||||
logger: {
|
||||
debug: vi.fn() as any,
|
||||
warn: vi.fn() as any,
|
||||
},
|
||||
prefix,
|
||||
pollIntervalMs,
|
||||
timeoutMs,
|
||||
ttlMs: {
|
||||
success: ttlMs,
|
||||
failure: ttlMs,
|
||||
},
|
||||
});
|
||||
|
||||
const cacheForRequest2 = createCache({
|
||||
redis,
|
||||
logger: {
|
||||
debug: vi.fn() as any,
|
||||
warn: vi.fn() as any,
|
||||
},
|
||||
prefix,
|
||||
pollIntervalMs,
|
||||
timeoutMs,
|
||||
ttlMs: {
|
||||
success: ttlMs,
|
||||
failure: ttlMs,
|
||||
},
|
||||
});
|
||||
const cacheForRequest2 = createCache({
|
||||
redis,
|
||||
logger: {
|
||||
debug: vi.fn() as any,
|
||||
warn: vi.fn() as any,
|
||||
},
|
||||
prefix,
|
||||
pollIntervalMs,
|
||||
timeoutMs,
|
||||
ttlMs: {
|
||||
success: ttlMs,
|
||||
failure: ttlMs,
|
||||
},
|
||||
});
|
||||
|
||||
const actionId = randomString();
|
||||
async function actionFn() {
|
||||
await waitFor(timeoutMs - 1);
|
||||
return 'foo';
|
||||
}
|
||||
const actionId = randomString();
|
||||
async function actionFn() {
|
||||
await waitFor(timeoutMs - 1);
|
||||
return 'foo';
|
||||
}
|
||||
|
||||
const exec1 = cacheForRequest1.reuse(actionId, actionFn);
|
||||
const exec2 = cacheForRequest2.reuse(actionId, actionFn);
|
||||
const exec1 = cacheForRequest1.reuse(actionId, actionFn);
|
||||
const exec2 = cacheForRequest2.reuse(actionId, actionFn);
|
||||
|
||||
const run1 = exec1({});
|
||||
const run2 = exec2({});
|
||||
// force the cache to expire
|
||||
await waitFor(ttlMs + 10);
|
||||
await redis.flushall();
|
||||
const run1 = exec1({});
|
||||
const run2 = exec2({});
|
||||
// force the cache to expire
|
||||
await waitFor(ttlMs + 10);
|
||||
await redis.flushall();
|
||||
|
||||
await expect(run1).resolves.toBe('foo');
|
||||
await expect(run2).resolves.toBe('foo');
|
||||
});
|
||||
await expect(run1).resolves.toBe('foo');
|
||||
await expect(run2).resolves.toBe('foo');
|
||||
},
|
||||
{ retry: 3 },
|
||||
);
|
||||
|
||||
test('decide on cache duration', async ({ expect }) => {
|
||||
const ttlMs = {
|
||||
|
|
|
|||
Loading…
Reference in a new issue