Repository navigation
test(cli-e2e): cover the e2e harness with effect lint (CLI-2878) #7384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+429
−196
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,64 +1,60 @@ | ||
| import { Config, ConfigProvider, Effect, Option } from "effect"; | ||
| import { REPLAY_PROJECT_REF } from "../server/placeholder.ts"; | ||
|
|
||
| type CliE2eMode = "replay" | "record"; | ||
| /** Reads an environment variable through `Config`, keeping empty values as set. */ | ||
| const readEnv = (name: string): string | undefined => | ||
| Effect.runSync( | ||
| Config.option(Config.String(name)) | ||
| .parse(ConfigProvider.fromEnv({ preserveEmptyStrings: true })) | ||
| .pipe(Effect.map(Option.getOrUndefined)), | ||
| ); | ||
|
|
||
| // Runtime mode. `replay` (default) serves recorded fixtures; `record` proxies to | ||
| // staging and captures fixtures. | ||
| // Back-compat: RECORD=true still maps to `record`. | ||
| const MODE: CliE2eMode = | ||
| (process.env["CLI_E2E_MODE"] as CliE2eMode | undefined) ?? | ||
| (process.env["RECORD"] === "true" ? "record" : "replay"); | ||
| const MODE = readEnv("CLI_E2E_MODE") ?? (readEnv("RECORD") === "true" ? "record" : "replay"); | ||
|
|
||
| export const isRecording = MODE === "record"; | ||
|
|
||
| // The replay server + tests/setup.ts key recording off RECORD directly, so keep | ||
| // it in sync with MODE in both directions: an explicit CLI_E2E_MODE=replay must | ||
| // not record and wipe fixtures just because RECORD=true lingers in the shell. | ||
| if (isRecording) { | ||
| process.env["RECORD"] = "true"; | ||
| } else { | ||
| delete process.env["RECORD"]; | ||
| } | ||
|
|
||
| // startReplayServer + tests/setup.ts read SUPABASE_STAGING_URL directly as the | ||
| // record proxy target. Normalise it from CLI_E2E_API_URL so | ||
| // The record proxy target. Normalised from CLI_E2E_API_URL so | ||
| // `CLI_E2E_MODE=record CLI_E2E_API_URL=…` works without also setting the legacy var. | ||
| if (isRecording && !process.env["SUPABASE_STAGING_URL"] && process.env["CLI_E2E_API_URL"]) { | ||
| process.env["SUPABASE_STAGING_URL"] = process.env["CLI_E2E_API_URL"]; | ||
| } | ||
| const LEGACY_STAGING_URL = readEnv("SUPABASE_STAGING_URL"); | ||
| const API_URL = readEnv("CLI_E2E_API_URL"); | ||
| export const STAGING_URL = | ||
| isRecording && !LEGACY_STAGING_URL && API_URL ? API_URL : LEGACY_STAGING_URL; | ||
|
|
||
| // In replay mode the token never reaches a real API, but the CLI validates the | ||
| // format before making any request (must match sbp_[a-f0-9]{40}). In record mode | ||
| // it must be a valid token for the staging API. | ||
| export const ACCESS_TOKEN = | ||
| process.env["SUPABASE_ACCESS_TOKEN"] ?? "sbp_0000000000000000000000000000000000000000"; | ||
| readEnv("SUPABASE_ACCESS_TOKEN") ?? "sbp_0000000000000000000000000000000000000000"; | ||
|
|
||
| // Region for the fresh recording project. | ||
| export const REGION = process.env["CLI_E2E_REGION"] ?? "us-east-1"; | ||
| export const REGION = readEnv("CLI_E2E_REGION") ?? "us-east-1"; | ||
|
|
||
| // Recorded fixtures store every project ref and org slug as REPLAY_PROJECT_REF, so replay | ||
| // requests use it too. In record mode supply a real project ref via env. | ||
| export const PROJECT_REF = process.env["SUPABASE_TEST_PROJECT_REF"] ?? REPLAY_PROJECT_REF; | ||
| export const PROJECT_REF = readEnv("SUPABASE_TEST_PROJECT_REF") ?? REPLAY_PROJECT_REF; | ||
|
|
||
| // In record mode supply a real org slug via env, or let the resolver derive it. | ||
| export const ORG_ID = process.env["SUPABASE_TEST_ORG_ID"] ?? REPLAY_PROJECT_REF; | ||
| export const ORG_ID = readEnv("SUPABASE_TEST_ORG_ID") ?? REPLAY_PROJECT_REF; | ||
|
|
||
| // UUID of an existing SAML provider on the staging project. | ||
| // In replay mode any UUID normalises to __UUID__ in fixture paths. | ||
| // In record mode supply a real provider ID via env. | ||
| export const PROVIDER_ID = | ||
| process.env["SUPABASE_TEST_PROVIDER_ID"] ?? "00000000-0000-0000-0000-000000000000"; | ||
| readEnv("SUPABASE_TEST_PROVIDER_ID") ?? "00000000-0000-0000-0000-000000000000"; | ||
|
|
||
| // UUID of an existing SQL snippet on the staging project. | ||
| // In replay mode any UUID normalises to __UUID__ in fixture paths. | ||
| // In record mode supply a real snippet UUID via env. | ||
| export const SNIPPET_ID = | ||
| process.env["SUPABASE_TEST_SNIPPET_ID"] ?? "00000000-0000-4000-8000-000000000001"; | ||
| readEnv("SUPABASE_TEST_SNIPPET_ID") ?? "00000000-0000-4000-8000-000000000001"; | ||
|
|
||
| // Unix epoch seconds for a PITR restore timestamp within the staging project's backup window. | ||
| // In replay mode the replay server serves responses in order regardless of the request body value. | ||
| // In record mode supply a real timestamp (within the backup window) via env. | ||
| export const BACKUP_TIMESTAMP = parseInt( | ||
| process.env["SUPABASE_TEST_BACKUP_TIMESTAMP"] ?? "1707407047", | ||
| readEnv("SUPABASE_TEST_BACKUP_TIMESTAMP") ?? "1707407047", | ||
| 10, | ||
| ); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.