Unified · Split
| @@ -11,6 +11,8 @@ · 10 unmodified lines | ||
| 11 | 11 | // --------------------------------------------------------------------------- |
| 12 | 12 | |
| 13 | 13 | import { afterAll, describe, expect, it } from "@effect/vitest"; |
| 14 | +import { vi } from "vitest"; | |
| 15 | +import { waitUntil } from "cloudflare:workers"; | |
| 14 | 16 | import { Effect, Layer } from "effect"; |
| 15 | 17 | import { HttpRouter, HttpServer } from "effect/unstable/http"; |
| 16 | 18 | import { HttpApiBuilder } from "effect/unstable/httpapi"; |
| @@ -21,6 +23,7 @@ import { CloudAuthPublicApi } from "./api"; · 4 unmodified lines | ||
| 21 | 23 | import { UserStoreService } from "./context"; |
| 22 | 24 | import { WorkOSClient, type WorkOSClientService } from "./workos"; |
| 23 | 25 | import { encodeLoginState } from "./login-state"; |
| 26 | +import { AutumnService } from "../extensions/billing/service"; | |
| 24 | 27 | |
| 25 | 28 | // The route under test serves under the `/api` prefix in the composed app; |
| 26 | 29 | // toWebHandler mounts the raw group, so paths here are relative to the group. |
| @@ -46,6 +49,9 @@ const stubWorkOS = Layer.succeed( · 19 unmodified lines | ||
| 46 | 49 | if (prop === "listUserMemberships") { |
| 47 | 50 | return () => Effect.succeed({ data: [] }); |
| 48 | 51 | } |
| 52 | + if (prop === "listOrgMembers") { | |
| 53 | + return () => Effect.succeed({ data: [{ status: "active" }] }); | |
| 54 | + } | |
| 49 | 55 | return () => Effect.die(`unexpected WorkOSClient.${String(prop)} call`); |
| 50 | 56 | }, |
| 51 | 57 | }), |
| @@ -88,11 +94,15 @@ const App = HttpApiBuilder.layer(PublicApi).pipe( · 36 unmodified lines | ||
| 88 | 94 | Layer.provide(CloudAuthPublicHandlers), |
| 89 | 95 | Layer.provide(stubWorkOS), |
| 90 | 96 | Layer.provide(stubUsers), |
| 97 | + Layer.provide(AutumnService.Default), | |
| 91 | 98 | Layer.provide(HttpServer.layerServices), |
| 92 | 99 | ); |
| 93 | 100 | |
| 94 | 101 | const app = HttpRouter.toWebHandler(App, { disableLogger: true }); |
| 95 | −afterAll(() => app.dispose()); | |
| 102 | +afterAll(async () => { | |
| 103 | + await Promise.all(vi.mocked(waitUntil).mock.calls.map(([work]) => work)); | |
| 104 | + await app.dispose(); | |
| 105 | +}); | |
| 96 | 106 | |
| 97 | 107 | const run = (request: Request) => { |
| 98 | 108 | // beta.59: the handler type expects a context argument; this layer stack |