Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions test/flash/bridge-sandbox-e2e/cutover-state.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)
})
Expand Down
26 changes: 13 additions & 13 deletions test/flash/bridge-sandbox-e2e/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ type WithdrawalResult = GraphQlErrorResponse & {

type HandlerResponse = {
status: number
body?: unknown
body: Record<string, unknown>
}

// ============ Schema Execution ============
Expand All @@ -80,11 +80,11 @@ function buildContext(accountId: string): GraphQLPublicContextAuth {
} as GraphQLPublicContextAuth
}

export async function execQuery(
export async function execQuery<T = Record<string, unknown>>(
source: string,
accountId: string,
variableValues?: Record<string, unknown>,
): Promise<Record<string, unknown> | GraphQlErrorResponse> {
): Promise<T | GraphQlErrorResponse> {
const result = await graphql({
schema: gqlMainSchema,
source: new Source(source),
Expand All @@ -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 ============
Expand Down Expand Up @@ -266,10 +266,10 @@ export async function injectKycWebhook(payload: {
}): Promise<HandlerResponse> {
const { req, res } = createReqRes({ body: payload })
await kycHandler(
req as Parameters<typeof kycHandler>[0],
res as Parameters<typeof kycHandler>[1],
req as unknown as Parameters<typeof kycHandler>[0],
res as unknown as Parameters<typeof kycHandler>[1],
)
return { status: res.statusCode, body: res._body }
return { status: res.statusCode, body: (res._body ?? {}) as Record<string, unknown> }
}

/**
Expand All @@ -288,10 +288,10 @@ export async function injectExternalAccountWebhook(payload: {
}): Promise<HandlerResponse> {
const { req, res } = createReqRes({ body: payload })
await externalAccountHandler(
req as Parameters<typeof externalAccountHandler>[0],
res as Parameters<typeof externalAccountHandler>[1],
req as unknown as Parameters<typeof externalAccountHandler>[0],
res as unknown as Parameters<typeof externalAccountHandler>[1],
)
return { status: res.statusCode, body: res._body }
return { status: res.statusCode, body: (res._body ?? {}) as Record<string, unknown> }
}

/**
Expand All @@ -317,10 +317,10 @@ export async function injectDepositWebhook(payload: {
}): Promise<HandlerResponse> {
const { req, res } = createReqRes({ body: payload })
await depositHandler(
req as Parameters<typeof depositHandler>[0],
res as Parameters<typeof depositHandler>[1],
req as unknown as Parameters<typeof depositHandler>[0],
res as unknown as Parameters<typeof depositHandler>[1],
)
return { status: res.statusCode, body: res._body }
return { status: res.statusCode, body: (res._body ?? {}) as Record<string, unknown> }
}

// ============ ERPNext Verification ============
Expand Down
Loading