From 0b5bb192af8138259ec5a13e09915e4eb3ff8a36 Mon Sep 17 00:00:00 2001 From: Dread Date: Wed, 17 Jun 2026 11:57:07 -0700 Subject: [PATCH] fix(bridge): resolve type errors in bridge-sandbox-e2e suite The Bridge sandbox e2e suite never passed through tsc (CI was disabled), so type errors accumulated and now fail Check Code. All test-only: - helpers.ts: route mock req/res through 'unknown' before casting to the Express handler param types (TS2352). - execQuery: make generic (default Record, backward compatible) so callers can type the GraphQL payload (TS2339). - HandlerResponse.body: type as Record instead of unknown, fixing .body access in the deposit/external-account specs without per-site casts (TS18046). - cutover-state.spec: type the execQuery result and narrow the error union before asserting. No production code touched. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../bridge-sandbox-e2e/cutover-state.spec.ts | 10 +++++-- test/flash/bridge-sandbox-e2e/helpers.ts | 26 +++++++++---------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/test/flash/bridge-sandbox-e2e/cutover-state.spec.ts b/test/flash/bridge-sandbox-e2e/cutover-state.spec.ts index ab69d191d..4b695ebbb 100644 --- a/test/flash/bridge-sandbox-e2e/cutover-state.spec.ts +++ b/test/flash/bridge-sandbox-e2e/cutover-state.spec.ts @@ -53,7 +53,10 @@ const CUTOVER_TESTS = process.env.CUTOVER_TESTS === "true" } ` - const response = await execQuery(source, dummyAccountId) + const response = await execQuery<{ + cashWalletCutover: { state: string; cutoverVersion: number; updatedAt: string } + }>(source, dummyAccountId) + if ("errors" in response) throw new Error(JSON.stringify(response.errors)) expect(response.cashWalletCutover).toBeDefined() expect(typeof response.cashWalletCutover.state).toBe("string") @@ -94,7 +97,10 @@ const CUTOVER_TESTS = process.env.CUTOVER_TESTS === "true" } ` - const response = await execQuery(source, dummyAccountId) + const response = await execQuery<{ + cashWalletCutover: { state: string } + }>(source, dummyAccountId) + if ("errors" in response) throw new Error(JSON.stringify(response.errors)) expect(VALID_STATES.has(response.cashWalletCutover?.state)).toBe(true) }) diff --git a/test/flash/bridge-sandbox-e2e/helpers.ts b/test/flash/bridge-sandbox-e2e/helpers.ts index e2fb5b939..06ea0c544 100644 --- a/test/flash/bridge-sandbox-e2e/helpers.ts +++ b/test/flash/bridge-sandbox-e2e/helpers.ts @@ -68,7 +68,7 @@ type WithdrawalResult = GraphQlErrorResponse & { type HandlerResponse = { status: number - body?: unknown + body: Record } // ============ Schema Execution ============ @@ -80,11 +80,11 @@ function buildContext(accountId: string): GraphQLPublicContextAuth { } as GraphQLPublicContextAuth } -export async function execQuery( +export async function execQuery>( source: string, accountId: string, variableValues?: Record, -): Promise | GraphQlErrorResponse> { +): Promise { const result = await graphql({ schema: gqlMainSchema, source: new Source(source), @@ -94,7 +94,7 @@ export async function execQuery( if (result.errors) { return { errors: result.errors.map((error) => ({ message: error.message })) } } - return result.data ?? {} + return (result.data ?? {}) as T } // ============ User Creation ============ @@ -266,10 +266,10 @@ export async function injectKycWebhook(payload: { }): Promise { const { req, res } = createReqRes({ body: payload }) await kycHandler( - req as Parameters[0], - res as Parameters[1], + req as unknown as Parameters[0], + res as unknown as Parameters[1], ) - return { status: res.statusCode, body: res._body } + return { status: res.statusCode, body: (res._body ?? {}) as Record } } /** @@ -288,10 +288,10 @@ export async function injectExternalAccountWebhook(payload: { }): Promise { const { req, res } = createReqRes({ body: payload }) await externalAccountHandler( - req as Parameters[0], - res as Parameters[1], + req as unknown as Parameters[0], + res as unknown as Parameters[1], ) - return { status: res.statusCode, body: res._body } + return { status: res.statusCode, body: (res._body ?? {}) as Record } } /** @@ -317,10 +317,10 @@ export async function injectDepositWebhook(payload: { }): Promise { const { req, res } = createReqRes({ body: payload }) await depositHandler( - req as Parameters[0], - res as Parameters[1], + req as unknown as Parameters[0], + res as unknown as Parameters[1], ) - return { status: res.statusCode, body: res._body } + return { status: res.statusCode, body: (res._body ?? {}) as Record } } // ============ ERPNext Verification ============