From b7af2c91834f6322e6e3ef4b1bb43066133cb646 Mon Sep 17 00:00:00 2001 From: Mounir Dhahri Date: Wed, 25 Sep 2024 15:30:05 +0200 Subject: [PATCH] chore: remove persistence tests --- .../metaphysicsMiddleware.tests.ts | 83 ------------------- 1 file changed, 83 deletions(-) delete mode 100644 src/app/system/relay/middlewares/metaphysicsMiddleware.tests.ts diff --git a/src/app/system/relay/middlewares/metaphysicsMiddleware.tests.ts b/src/app/system/relay/middlewares/metaphysicsMiddleware.tests.ts deleted file mode 100644 index 69735894e5a..00000000000 --- a/src/app/system/relay/middlewares/metaphysicsMiddleware.tests.ts +++ /dev/null @@ -1,83 +0,0 @@ -import { persistedQueryMiddleware } from "./metaphysicsMiddleware" -import { GraphQLRequest } from "./types" - -jest.mock("../../../../../data/complete.queryMap.json", () => ({ - "query-id": "persisted-query-text", -})) - -describe("persisted queries", () => { - describe("with a 404 response from metaphysics", () => { - const request: GraphQLRequest = { - operation: { - id: "query-id", - query: "query-text", - } as any, - variables: {}, - cacheConfig: {}, - fetchOpts: {} as any, - getID() { - return "query-id" - }, - getVariables() { - return {} - }, - } as any - beforeAll(() => { - // @ts-ignore - __DEV__ = false - }) - afterAll(() => { - // @ts-ignore - __DEV__ = true - }) - it(`will be retried if the query id was not recognized by MP`, async () => { - let rejected = false - let retried = false - - const mockedErrorsNext = (req: any) => { - if (JSON.parse(req.fetchOpts.body).documentID) { - rejected = true - return Promise.reject(new Error("Unable to serve persisted query with ID")) - } else { - retried = true - return Promise.resolve({ - status: 200, - json: { data: { success: true }, errors: undefined }, - }) - } - } - // @ts-ignore - await expect(persistedQueryMiddleware()(mockedErrorsNext)(request)).resolves.toMatchObject({ - json: { data: { success: true } }, - }) - - expect(rejected).toBe(true) - expect(retried).toBe(true) - }) - - it(`will be not be retried if failure was something else`, async () => { - let rejected = false - let retried = false - - const mockedErrorsNext = (req: any) => { - if (JSON.parse(req.fetchOpts.body).documentID) { - rejected = true - return Promise.reject(new Error("something unrecognized went wrong")) - } else { - retried = true - return Promise.resolve({ - status: 200, - json: { data: { success: true }, errors: undefined }, - }) - } - } - - await expect(persistedQueryMiddleware()(mockedErrorsNext as any)(request)).rejects.toEqual( - new Error("something unrecognized went wrong") - ) - - expect(rejected).toBe(true) - expect(retried).toBe(false) - }) - }) -})