Skip to content

[Issue #11704] set playwright base url and api url explicitly per env - #11800

Merged
doug-s-nava merged 3 commits into
mainfrom
dschrashun/11704-only-mgmt-env-changes
Aug 4, 2026
Merged

[Issue #11704] set playwright base url and api url explicitly per env#11800
doug-s-nava merged 3 commits into
mainfrom
dschrashun/11704-only-mgmt-env-changes

Conversation

@doug-s-nava

@doug-s-nava doug-s-nava commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

Work for #11704

Changes proposed

Introduces PLAYWRIGHT_API_URL and PLAYWRIGHT_BASE_URL environment variables into the playwright system and CI to allow for directly setting these values without any hard coding. This change is needed to support running tests from the mgmt repo after splitting code.

This piece of the work does not address the parts of the ticket oriented towards supporting grantee / grantor test environments. Those pieces are in #11804

Context for reviewers

There should be no change to functionality in this PR.

Validation steps

  1. VERIFY: e2e tests pass in CI

@doug-s-nava
doug-s-nava force-pushed the dschrashun/11704-only-mgmt-env-changes branch from c0e5ead to 2506e6a Compare August 3, 2026 14:49

const apiUrl = API_URLS[targetEnv];
const SUPPORTED_ENVS = ["local", "staging"] as const;
export type SupportedEnvs = (typeof SUPPORTED_ENVS)[number];

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is necessary for this change, but will be for the next part of the change. I can remove if that's preferred.

@doug-s-nava
doug-s-nava marked this pull request as ready for review August 3, 2026 15:05
Comment thread frontend/tests/e2e/playwright-env.ts Outdated
Comment on lines +40 to +41
baseUrl: process.env.PLAYWRIGHT_BASE_URL || "http://127.0.0.1:3000",
apiUrl: process.env.PLAYWRIGHT_API_URL || "http://127.0.0.1:8080",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These defaults apply no matter what targetEnv is, right? If someone sets PLAYWRIGHT_TARGET_ENV=staging and doesn't also set PLAYWRIGHT_BASE_URL/PLAYWRIGHT_API_URL, we don't start a web server and we point at localhost while using the staging org label and staging manager key, which could give confusing failures. Would it make sense to have something along these lines?:

const isLocal = targetEnv === "local";
const baseUrl = process.env.PLAYWRIGHT_BASE_URL || (isLocal ? "http://127.0.0.1:3000" : "");
const apiUrl = process.env.PLAYWRIGHT_API_URL || (isLocal ? "http://127.0.0.1:8080" : "");
if (!baseUrl || !apiUrl) {
  throw new Error(`PLAYWRIGHT_BASE_URL and PLAYWRIGHT_API_URL must be set when PLAYWRIGHT_TARGET_ENV=${targetEnv}`);
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I was thinking that in local environments we'd always want to use the default, so we'd want to button this up to make sure that all 3 env vars were either set or unset. However, there is a valid use case where you could have targetEnv unset and default to local, but you want to set different port numbers or something, so you'd manually set the url variables. I'm good with this change!

Comment thread frontend/.env.local.example Outdated
Comment on lines 137 to 141

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove these now?

Comment thread frontend/.env.local.example Outdated

# Target environment for playwright tests (local or staging)
PLAYWRIGHT_TARGET_ENV=local
# Target environment inro for playwright tests

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Target environment inro for playwright tests
# Target environment info for playwright tests

@kkrug

kkrug commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Testing.md could use some updating with these changes as well

@kkrug
kkrug self-requested a review August 3, 2026 19:09
@doug-s-nava
doug-s-nava merged commit 9e2bbde into main Aug 4, 2026
14 checks passed
@doug-s-nava
doug-s-nava deleted the dschrashun/11704-only-mgmt-env-changes branch August 4, 2026 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants