| @@ -6,7 +6,7 @@ · 5 unmodified lines |
| 6 | // --------------------------------------------------------------------------- | 6 | // --------------------------------------------------------------------------- |
| 7 | | 7 | |
| 8 | import { describe, expect, it } from "@effect/vitest"; | 8 | import { describe, expect, it } from "@effect/vitest"; |
| 9 | import { Effect } from "effect"; | 9 | import { Data, Effect, Schema } from "effect"; |
| 10 | | 10 | |
| 11 | import { | 11 | import { |
| 12 | OAUTH_POPUP_MESSAGE_TYPE, | 12 | OAUTH_POPUP_MESSAGE_TYPE, |
| @@ -169,16 +169,21 @@ describe("runOAuthCallback", () => { · 156 unmodified lines |
| 169 | }); | 169 | }); |
| 170 | | 170 | |
| 171 | it("renders a failure popup when completeOAuth fails and uses toErrorMessage", async () => { | 171 | it("renders a failure popup when completeOAuth fails and uses toErrorMessage", async () => { |
| 172 | class DomainError { | 172 | class DomainError extends Data.TaggedError("DomainError")<{ |
| 173 | readonly _tag = "DomainError"; | 173 | readonly message: string; |
| 174 | constructor(readonly message: string) {} | 174 | }> {} |
| 175 | } | 175 | const isDomainError = Schema.is(Schema.Struct({ |
| | 176 | _tag: Schema.Literal("DomainError"), |
| | 177 | message: Schema.String, |
| | 178 | })); |
| 176 | const html = await Effect.runPromise( | 179 | const html = await Effect.runPromise( |
| 177 | runOAuthCallback<GoogleAuth, DomainError, never>({ | 180 | runOAuthCallback<GoogleAuth, DomainError, never>({ |
| 178 | complete: () => Effect.fail(new DomainError("Code expired")), | 181 | complete: () => Effect.fail(new DomainError({ message: "Code expired" })), |
| 179 | urlParams: { state: "s1" }, | 182 | urlParams: { state: "s1" }, |
| 180 | toErrorMessage: (error) => | 183 | toErrorMessage: (error) => { |
| 181 | error instanceof DomainError ? error.message : "unknown", | 184 | // oxlint-disable-next-line executor/no-unknown-error-message -- boundary: schema guard narrows the unknown popup callback error to the public test message |
| | 185 | return isDomainError(error) ? error.message : "unknown"; |
| | 186 | }, |
| 182 | channelName: "c", | 187 | channelName: "c", |
| 183 | }), | 188 | }), |
| 184 | ); | 189 | ); |