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