Skip to content

test: adapt UI e2e tests to prod environment#1271

Merged
rsoaresd merged 13 commits intocodeready-toolchain:masterfrom
rsoaresd:adapt_ui_e2e_tests_to_prod_needs
Apr 24, 2026
Merged

test: adapt UI e2e tests to prod environment#1271
rsoaresd merged 13 commits intocodeready-toolchain:masterfrom
rsoaresd:adapt_ui_e2e_tests_to_prod_needs

Conversation

@rsoaresd
Copy link
Copy Markdown
Contributor

@rsoaresd rsoaresd commented Mar 25, 2026

Description

Adapt UI E2E tests to run properly against production environment

Issue ticket number and link

SANDBOX-1630

Summary by CodeRabbit

  • New Features

    • Run E2E tests against production with new local and in-container targets; ENVIRONMENT and KUBECONFIG can be supplied externally.
  • Documentation

    • Added README section documenting production E2E runs and required credentials.
  • Tests

    • Improved production signup handling and cleanup, tightened timeouts, adjusted login flow and cookie handling, conditional artifact tracing, and improved failed-test video naming.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 25, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Adds production-capable E2E test support: externalizes environment/kubeconfig, adds prod make targets and README docs, adapts tests and login/setup for prod behavior, introduces ksctl-based user-signup management, and refactors test artifact/video handling.

Changes

Cohort / File(s) Summary
Configuration & Build
deploy/devsandbox-dashboard/ui-e2e-tests/.env, make/devsandbox-dashboard.mk, test/e2e/devsandbox-dashboard/README.md
.env now sources ENVIRONMENT and KUBECONFIG from external vars. Added make targets test-devsandbox-dashboard-e2e-prod and test-devsandbox-dashboard-in-container-prod, and documented prod test workflow and requirements in README.
E2E Test Flow & Setup
test/e2e/devsandbox-dashboard/fresh_signup_test.go, testsupport/devsandbox-dashboard/setup.go, testsupport/devsandbox-dashboard/login.go
Refactored signup cleanup to handle ProdEnv (ksctl) and reload page; added exported ProdEnv constant; changed cookie-consent handling to prod; treated Prod like Dev for login controls; added explicit page Goto timeout; tightened loading waits; conditional trace recording based on ARTIFACT_DIR.
Test Utilities & Signup Management
testsupport/devsandbox-dashboard/usersignup.go, testsupport/devsandbox-dashboard/trace.go
Added GetUserSignupThroughKsctl and DeleteUserSignupThroughKsctl (ksctl exec, YAML parsing, polling delete). Refactored popup video renaming into buildPopupVideoPath helper and simplified test logging.

Sequence Diagram

sequenceDiagram
    participant Test as E2E Test
    participant Ksctl as ksctl CLI
    participant Prod as Prod Environment
    participant Page as Browser Page

    rect rgba(76, 175, 80, 0.5)
    Note over Test,Page: Production flow (ProdEnv)
    Test->>Ksctl: ksctl get usersignup <username>
    Ksctl->>Prod: request UserSignup (yaml)
    Prod-->>Ksctl: UserSignup (yaml)
    Ksctl-->>Test: parsed UserSignup

    Test->>Page: Navigate to https://sandbox.redhat.com/
    Test->>Page: Fill creds & submit (Next / Log in)
    Test->>Page: Detect /oauth/authorize popup
    Page-->>Test: redirect to project page & welcome text

    Test->>Ksctl: ksctl gdpr-delete <username> (stdin "y")
    Ksctl->>Ksctl: poll get usersignup until NotFound
    Ksctl-->>Test: deletion confirmed
    end

    rect rgba(33, 150, 243, 0.5)
    Note over Test,Page: Non-production flow (Test/Dev)
    Test->>Page: host-based signup cleanup
    Test->>Page: wait for image/heading/list assertions
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 45.45% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'test: adapt UI e2e tests to prod environment' clearly and concisely summarizes the main change: adapting E2E tests to work with production environments.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
testsupport/devsandbox-dashboard/trace.go (1)

97-125: Make maskUsername() idempotent per browser context.

This helper installs a new init script every time it is called. LoginPage.Navigate() and ClickAndWaitForPopup() now both invoke it on the same context, so each popup open registers another copy of the script and another MutationObserver for future pages. Add a guard here so repeated calls become a no-op.

Possible minimal guard inside the injected script
 func maskUsername(t *testing.T, page playwright.Page) {
 	err := page.Context().AddInitScript(playwright.Script{
 		Content: playwright.String(`
+			if (window.__usernameMaskInitialized) {
+				return;
+			}
+			window.__usernameMaskInitialized = true;
+
 			const applyBlur = () => {
 				document.querySelectorAll('input[name="username"], span.co-username, span[data-test="username"], [data-test="username"]').forEach(el => {
 					el.style.filter = 'blur(5px)';
 					el.style.userSelect = 'none';
 				});
 			};
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@testsupport/devsandbox-dashboard/trace.go` around lines 97 - 125,
maskUsername registers the same init script each call causing multiple
MutationObservers; modify the injected script (the one passed to
page.Context().AddInitScript in maskUsername) to be idempotent by
checking/setting a per-context flag (e.g. window.__maskUsernameInstalled) at the
top: if the flag is already true, return immediately; otherwise set it true and
then run applyBlur + create the MutationObserver. Keep the rest of the
applyBlur/observer logic intact so repeated calls become no-ops for that browser
context.
testsupport/devsandbox-dashboard/usersignup.go (1)

66-99: Consider extracting repeated command arguments to constants.

SonarCloud flagged the "--config" literal being duplicated 3 times (lines 48, 70, 81). You could extract common ksctl command arguments to reduce duplication.

♻️ Proposed refactor
+const (
+	ksctlConfigFlag = "--config"
+	ksctlHostTarget = "-t"
+)
+
 func GetUserSignupThroughKsctl(t *testing.T, username string) *toolchainv1alpha1.UserSignup {
 	t.Logf("Getting UserSignup through ksctl")
 
 	// `#nosec` G204 -- username is from test config, not user input
-	cmd := exec.Command("ksctl", "get", "usersignup", username, "--config", viper.GetString("KUBECONFIG"), "-t", "host", "-o", "yaml")
+	cmd := exec.Command("ksctl", "get", "usersignup", username, ksctlConfigFlag, viper.GetString("KUBECONFIG"), ksctlHostTarget, "host", "-o", "yaml")

Apply similarly to lines 70 and 81.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@testsupport/devsandbox-dashboard/usersignup.go` around lines 66 - 99, The
function DeleteUserSignupThroughKsctl repeats the same ksctl arguments (the
"--config" flag and viper.GetString("KUBECONFIG")) in multiple exec.Command
calls; extract the common args into a single reusable variable or helper (e.g.,
ksctlConfigArg := []string{"--config", viper.GetString("KUBECONFIG")} or a
buildKsctlCmd helper) and use it when constructing exec.Command for the initial
"ksctl gdpr-delete" call and the subsequent "ksctl get usersignup" calls to
remove duplication and make intent clearer while preserving existing command
composition and stdin behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@testsupport/devsandbox-dashboard/setup.go`:
- Around line 67-71: The current gate using ARTIFACT_DIR prevents trace(t,
context, testName) from running in CI and removes Playwright traces; instead
remove the ARTIFACT_DIR check and always call trace(...) (so traces continue to
be routed by getTraceDirectory()), or if you need to disable tracing only for
production, gate on env == ProdEnv or a dedicated opt-out flag (e.g.
DISABLE_TRACING) rather than ARTIFACT_DIR; update
testsupport/devsandbox-dashboard/setup.go to call trace(t, context, testName)
unconditionally or replace the ARTIFACT_DIR condition with the appropriate
ProdEnv/opt-out check.

---

Nitpick comments:
In `@testsupport/devsandbox-dashboard/trace.go`:
- Around line 97-125: maskUsername registers the same init script each call
causing multiple MutationObservers; modify the injected script (the one passed
to page.Context().AddInitScript in maskUsername) to be idempotent by
checking/setting a per-context flag (e.g. window.__maskUsernameInstalled) at the
top: if the flag is already true, return immediately; otherwise set it true and
then run applyBlur + create the MutationObserver. Keep the rest of the
applyBlur/observer logic intact so repeated calls become no-ops for that browser
context.

In `@testsupport/devsandbox-dashboard/usersignup.go`:
- Around line 66-99: The function DeleteUserSignupThroughKsctl repeats the same
ksctl arguments (the "--config" flag and viper.GetString("KUBECONFIG")) in
multiple exec.Command calls; extract the common args into a single reusable
variable or helper (e.g., ksctlConfigArg := []string{"--config",
viper.GetString("KUBECONFIG")} or a buildKsctlCmd helper) and use it when
constructing exec.Command for the initial "ksctl gdpr-delete" call and the
subsequent "ksctl get usersignup" calls to remove duplication and make intent
clearer while preserving existing command composition and stdin behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 40b3f0e3-cf7f-4d4d-b833-c27d59928c58

📥 Commits

Reviewing files that changed from the base of the PR and between 629dc7b and 90600a0.

📒 Files selected for processing (9)
  • deploy/devsandbox-dashboard/ui-e2e-tests/.env
  • make/devsandbox-dashboard.mk
  • test/e2e/devsandbox-dashboard/README.md
  • test/e2e/devsandbox-dashboard/fresh_signup_test.go
  • testsupport/devsandbox-dashboard/login.go
  • testsupport/devsandbox-dashboard/popup.go
  • testsupport/devsandbox-dashboard/setup.go
  • testsupport/devsandbox-dashboard/trace.go
  • testsupport/devsandbox-dashboard/usersignup.go

Comment on lines +67 to +71
// save trace only if not running in CI
// we do not want to expose sensitive information in CI
if artifactDir := os.Getenv("ARTIFACT_DIR"); artifactDir == "" { // not CI environment
trace(t, context, testName)
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Don't disable tracing for every CI run.

ARTIFACT_DIR is already how getTraceDirectory() routes trace artifacts into CI storage. Gating trace() on that variable removes Playwright traces from all CI jobs, including the existing ui-e2e-tests path, so failures lose the most useful debugging artifact. If the concern is prod secrecy, gate on env == ProdEnv or a dedicated opt-out flag instead of CI detection.

🧰 Tools
🪛 GitHub Check: SonarCloud Code Analysis

[warning] 69-69: Remove this unnecessary variable declaration and use the expression directly in the condition.

See more on https://sonarcloud.io/project/issues?id=codeready-toolchain_toolchain-e2e&issues=AZ0mCgEWDAKfaaDBdd63&open=AZ0mCgEWDAKfaaDBdd63&pullRequest=1271

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@testsupport/devsandbox-dashboard/setup.go` around lines 67 - 71, The current
gate using ARTIFACT_DIR prevents trace(t, context, testName) from running in CI
and removes Playwright traces; instead remove the ARTIFACT_DIR check and always
call trace(...) (so traces continue to be routed by getTraceDirectory()), or if
you need to disable tracing only for production, gate on env == ProdEnv or a
dedicated opt-out flag (e.g. DISABLE_TRACING) rather than ARTIFACT_DIR; update
testsupport/devsandbox-dashboard/setup.go to call trace(t, context, testName)
unconditionally or replace the ARTIFACT_DIR condition with the appropriate
ProdEnv/opt-out check.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
testsupport/devsandbox-dashboard/setup.go (1)

67-71: ⚠️ Potential issue | 🟠 Major

Don't key tracing off ARTIFACT_DIR.

getTraceDirectory() already routes CI traces into ARTIFACT_DIR. This guard disables Playwright tracing in every CI job, so failed ui-e2e-tests runs lose the main debugging artifact. If only prod runs need different handling, gate on env == ProdEnv or a dedicated opt-out flag instead of CI detection.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@testsupport/devsandbox-dashboard/setup.go` around lines 67 - 71, The current
guard that skips trace(t, context, testName) based on os.Getenv("ARTIFACT_DIR")
prevents CI jobs from saving Playwright traces; instead remove that ARTIFACT_DIR
check and either always call trace(...) or gate it on the production-only
condition (compare the current environment to ProdEnv) or a dedicated opt-out
flag (e.g. DISABLE_TRACING) so CI traces still get written via
getTraceDirectory(); update the logic around trace(...) and any callers
accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@testsupport/devsandbox-dashboard/usersignup.go`:
- Around line 54-60: GetUserSignupThroughKsctl() and the delete-poll block
currently treat ksctl "not found" responses differently and swallow other
errors; update both places so they consistently detect NotFound
(case-insensitive match for "not found" and the exact "Error from server
(NotFound)") and treat that as the missing-resource success case, but for any
other non-NotFound error return the error immediately (fail fast) instead of
returning nil/false and continuing to poll; apply the same change to the other
occurrence referenced in the comment (the delete poll block around lines 87-100)
so both code paths behave the same.

---

Duplicate comments:
In `@testsupport/devsandbox-dashboard/setup.go`:
- Around line 67-71: The current guard that skips trace(t, context, testName)
based on os.Getenv("ARTIFACT_DIR") prevents CI jobs from saving Playwright
traces; instead remove that ARTIFACT_DIR check and either always call trace(...)
or gate it on the production-only condition (compare the current environment to
ProdEnv) or a dedicated opt-out flag (e.g. DISABLE_TRACING) so CI traces still
get written via getTraceDirectory(); update the logic around trace(...) and any
callers accordingly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a4b2b2ec-2c4c-4f02-9228-10653211e4ac

📥 Commits

Reviewing files that changed from the base of the PR and between 90600a0 and b7acc0f.

📒 Files selected for processing (3)
  • test/e2e/devsandbox-dashboard/fresh_signup_test.go
  • testsupport/devsandbox-dashboard/setup.go
  • testsupport/devsandbox-dashboard/usersignup.go

Comment thread testsupport/devsandbox-dashboard/usersignup.go Outdated
Copy link
Copy Markdown
Contributor

@mfrancisc mfrancisc left a comment

Choose a reason for hiding this comment

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

Great job 👏

I have only few minor comments/questions.

Comment thread test/e2e/devsandbox-dashboard/fresh_signup_test.go Outdated
Comment thread testsupport/devsandbox-dashboard/setup.go Outdated
return strings.Replace(targetPath, "popup", fmt.Sprintf("popup-%s", uuid), 1)
}

func maskUsername(t *testing.T, page playwright.Page) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think the extra caution of masking also the username doesn't harm. Hopefully this doesn't cause flakyness .
I'm thinking about the case where the SSO login page might change they CSS selectors.

Let's keep it as is, but if we see it breaks often I would be in favor of removing it since sandbox is free to use and anyone can signup easly for a new account.

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.

stupid question, what is this masking used for? What is its purpose?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I spoke with Matous in our 1on1. Let's drop the masking of username since it is not necessary. Sorry for complicating and for the noise

require.NoError(t, err)
}
case sandboxui.ProdEnv:
userSignup := sandboxui.GetUserSignupThroughKsctl(t, username)
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.

do we actually need this? creating UserSignup should be a deterministic process, so there should be always the same UserSignup for the given username.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I thought about calling GetUserSignupThroughKsctl here in order to just call the delete func if usersignup exists

userSignup := sandboxui.GetUserSignupThroughKsctl(t, username)
if userSignup != nil {
// delete user signup
sandboxui.DeleteUserSignupThroughKsctl(t, username)
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.

as we already discussed in our 1-1, it could be simplified by only deleting the UserSignup directly. but using ksctl is OK too 👍 feel free to keep it as it is

Comment thread testsupport/devsandbox-dashboard/usersignup.go Outdated
@rsoaresd
Copy link
Copy Markdown
Contributor Author

@MatousJobanek @mfrancisc thank you so much for your inputs!

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
test/e2e/devsandbox-dashboard/fresh_signup_test.go (1)

43-63: ⚠️ Potential issue | 🟠 Major

Handle DevEnv explicitly instead of silently skipping cleanup.

testsupport/devsandbox-dashboard/setup.go still exposes dev as a supported environment, but both switches fall through for it. In dev, this test now skips the pre-run delete and never registers teardown, so reruns can inherit stale UserSignup state. Either route dev to the correct strategy or fail fast on unsupported values.

Minimal guardrail
 switch env {
 case sandboxui.TestEnv:
 	...
 case sandboxui.ProdEnv:
 	...
+default:
+	require.Failf(t, "unsupported ENVIRONMENT", "unexpected ENVIRONMENT=%q", env)
 }

Apply the same guard to both switches until sandboxui.DevEnv is wired to the intended cleanup path.

Also applies to: 136-149

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/e2e/devsandbox-dashboard/fresh_signup_test.go` around lines 43 - 63, The
switch in ensureNoUserSignup does not handle sandboxui.DevEnv and silently skips
cleanup; update ensureNoUserSignup to explicitly handle sandboxui.DevEnv (either
route it to the same cleanup flow as sandboxui.TestEnv by using
testsupport.WaitForDeployments/hostAwait and
sandboxui.WaitForUserSignup/DeleteUserSignup, or return an explicit failure for
unsupported envs), and apply the same explicit handling to the other similar
switch later in the file (the second occurrence around the teardown logic) so
DevEnv does not fall through silently.
♻️ Duplicate comments (1)
testsupport/devsandbox-dashboard/usersignup.go (1)

54-60: ⚠️ Potential issue | 🟠 Major

Broaden ksctl NotFound matching before require.NoError.

DeleteUserSignupThroughKsctl() now depends on this helper in its poll loop. Matching only Error from server (NotFound) means a valid missing-resource response with different casing/wording turns a completed delete into a hard failure instead of the expected nil result. Please verify this against the ksctl version used in CI.

Possible fix
+func ksctlUserSignupNotFound(output []byte, err error) bool {
+	text := strings.ToLower(string(output))
+	errText := ""
+	if err != nil {
+		errText = strings.ToLower(err.Error())
+	}
+
+	return strings.Contains(text, "not found") ||
+		strings.Contains(text, "notfound") ||
+		strings.Contains(errText, "not found") ||
+		strings.Contains(errText, "notfound")
+}
+
 func GetUserSignupThroughKsctl(t *testing.T, username string) *toolchainv1alpha1.UserSignup {
 	t.Logf("Getting UserSignup through ksctl")
 
 	// `#nosec` G204 -- username is from test config, not user input
 	cmd := exec.Command("ksctl", "get", "usersignup", username, configFlag, viper.GetString("KUBECONFIG"), "-t", "host", "-o", "yaml")
 	output, err := cmd.CombinedOutput()
-	if err != nil {
-		// Check if it's a not found error
-		if strings.Contains(string(output), "Error from server (NotFound)") {
-			return nil
-		}
+	if err != nil && ksctlUserSignupNotFound(output, err) {
+		return nil
 	}
 	require.NoError(t, err)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@testsupport/devsandbox-dashboard/usersignup.go` around lines 54 - 60, The
current check only matches the exact substring "Error from server (NotFound)"
and should be made more resilient: in the block inside
DeleteUserSignupThroughKsctl()'s helper (the if err != nil { ... } section
referencing output), replace the strict match with a case-insensitive/looser
check (e.g., lowercase output and check for "notfound" or "not found", or a
case-insensitive regex like `(?i)not\s*found`) so variants of ksctl/ kubectl
missing-resource messages are treated as the expected nil return before the
subsequent require.NoError call; keep the early return nil for matches and
otherwise let require.NoError(t, err) run.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@testsupport/devsandbox-dashboard/usersignup.go`:
- Around line 70-78: DeleteUserSignupThroughKsctl should first check whether the
UserSignup exists and return early if it does not to avoid failing cleanup; call
the helper GetUserSignupThroughKsctl(t, username) (or run `ksctl get`
equivalent) and if it indicates the resource is absent, log and return instead
of executing `ksctl gdpr-delete`; only run the delete command and assert on its
success when the pre-check shows the UserSignup exists so that cleanup does not
mask earlier test failures.

---

Outside diff comments:
In `@test/e2e/devsandbox-dashboard/fresh_signup_test.go`:
- Around line 43-63: The switch in ensureNoUserSignup does not handle
sandboxui.DevEnv and silently skips cleanup; update ensureNoUserSignup to
explicitly handle sandboxui.DevEnv (either route it to the same cleanup flow as
sandboxui.TestEnv by using testsupport.WaitForDeployments/hostAwait and
sandboxui.WaitForUserSignup/DeleteUserSignup, or return an explicit failure for
unsupported envs), and apply the same explicit handling to the other similar
switch later in the file (the second occurrence around the teardown logic) so
DevEnv does not fall through silently.

---

Duplicate comments:
In `@testsupport/devsandbox-dashboard/usersignup.go`:
- Around line 54-60: The current check only matches the exact substring "Error
from server (NotFound)" and should be made more resilient: in the block inside
DeleteUserSignupThroughKsctl()'s helper (the if err != nil { ... } section
referencing output), replace the strict match with a case-insensitive/looser
check (e.g., lowercase output and check for "notfound" or "not found", or a
case-insensitive regex like `(?i)not\s*found`) so variants of ksctl/ kubectl
missing-resource messages are treated as the expected nil return before the
subsequent require.NoError call; keep the early return nil for matches and
otherwise let require.NoError(t, err) run.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 33710e6d-96b0-40cd-b4d7-b1e5c776a241

📥 Commits

Reviewing files that changed from the base of the PR and between b7acc0f and d38f13c.

📒 Files selected for processing (6)
  • test/e2e/devsandbox-dashboard/README.md
  • test/e2e/devsandbox-dashboard/fresh_signup_test.go
  • testsupport/devsandbox-dashboard/login.go
  • testsupport/devsandbox-dashboard/setup.go
  • testsupport/devsandbox-dashboard/trace.go
  • testsupport/devsandbox-dashboard/usersignup.go
✅ Files skipped from review due to trivial changes (1)
  • test/e2e/devsandbox-dashboard/README.md
🚧 Files skipped from review as they are similar to previous changes (3)
  • testsupport/devsandbox-dashboard/setup.go
  • testsupport/devsandbox-dashboard/login.go
  • testsupport/devsandbox-dashboard/trace.go

Comment thread testsupport/devsandbox-dashboard/usersignup.go Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
test/e2e/devsandbox-dashboard/fresh_signup_test.go (1)

44-67: Consider adding a default case for unexpected environments.

If ENVIRONMENT is misconfigured to something other than test or prod, this switch silently does nothing, potentially leaving stale UserSignup resources and causing non-deterministic test behavior.

Suggested improvement
 	case sandboxui.ProdEnv:
 		userSignup := sandboxui.GetUserSignupThroughKsctl(t, username)
 		if userSignup != nil {
 			// delete user signup
 			sandboxui.DeleteUserSignupThroughKsctl(t, username)
 			_, err := page.Reload()
 			require.NoError(t, err)
 		}
+	default:
+		t.Logf("Warning: unknown environment %q, skipping UserSignup cleanup", env)
 	}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/e2e/devsandbox-dashboard/fresh_signup_test.go` around lines 44 - 67, The
switch on env (switch env { case sandboxui.TestEnv: ... case sandboxui.ProdEnv:
... }) lacks a default branch so an unexpected ENVIRONMENT value will skip
cleanup; add a default case that fails the test or at minimum logs and calls
t.Fatalf/require.Failf with the unexpected env value to stop the test and
surface the misconfiguration; reference the existing functions
(sandboxui.WaitForUserSignup / sandboxui.GetUserSignupThroughKsctl and
sandboxui.DeleteUserSignup / sandboxui.DeleteUserSignupThroughKsctl) so the
default case occurs alongside those branches and prevents silent no-ops.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@test/e2e/devsandbox-dashboard/fresh_signup_test.go`:
- Around line 44-67: The switch on env (switch env { case sandboxui.TestEnv: ...
case sandboxui.ProdEnv: ... }) lacks a default branch so an unexpected
ENVIRONMENT value will skip cleanup; add a default case that fails the test or
at minimum logs and calls t.Fatalf/require.Failf with the unexpected env value
to stop the test and surface the misconfiguration; reference the existing
functions (sandboxui.WaitForUserSignup / sandboxui.GetUserSignupThroughKsctl and
sandboxui.DeleteUserSignup / sandboxui.DeleteUserSignupThroughKsctl) so the
default case occurs alongside those branches and prevents silent no-ops.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: c08ffe2a-40cd-4888-b9a8-b4834e245f3f

📥 Commits

Reviewing files that changed from the base of the PR and between d38f13c and d86580b.

📒 Files selected for processing (1)
  • test/e2e/devsandbox-dashboard/fresh_signup_test.go

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
test/e2e/devsandbox-dashboard/fresh_signup_test.go (1)

44-67: Fail fast on unsupported ENVIRONMENT values.

These branches now silently do nothing for unknown envs, which can skip cleanup/setup and later fail in the wrong assertion path. A default case with require.FailNow would make misconfiguration obvious.

Proposed fix
 	switch env {
 	case sandboxui.TestEnv:
 		...
 	case sandboxui.ProdEnv:
 		...
+	default:
+		require.FailNow(t, "unsupported ENVIRONMENT", "got %q", env)
 	}

Also applies to: 141-154

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/e2e/devsandbox-dashboard/fresh_signup_test.go` around lines 44 - 67, The
switch on env (comparing against sandboxui.TestEnv and sandboxui.ProdEnv)
currently ignores unknown values; update both switch statements that branch on
env to include a default case that calls require.FailNow(t, "unsupported
ENVIRONMENT: %s", env) (or equivalent require.FailNow usage) so misconfiguration
fails immediately; locate the switches that reference env, sandboxui.TestEnv,
and sandboxui.ProdEnv (including the similar switch further down) and add the
default require.FailNow handling to each.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@test/e2e/devsandbox-dashboard/fresh_signup_test.go`:
- Around line 214-217: The prod redirect branch currently calls
devSandboxPage.WaitForURL with a 30s timeout which can hard-fail; update the
call to use the same extended timeout as the subsequent assertion (e.g., 180000
ms / 3 minutes) by changing the playwright.PageWaitForURLOptions Timeout passed
to devSandboxPage.WaitForURL (the call that follows the
strings.Contains(devSandboxPage.URL(), "/oauth/authorize") check) so the
OAuth/console startup path waits long enough before failing.
- Around line 59-65: The cleanup path in ProdEnv currently calls
sandboxui.GetUserSignupThroughKsctl and sandboxui.DeleteUserSignupThroughKsctl
unconditionally; add a guard that inspects the returned UserSignup object's
labels/annotations (e.g., a test-only label like "test-suite=true" or an
annotation "tests.openshift.io/test-account=true") and only call
sandboxui.DeleteUserSignupThroughKsctl if that label/annotation is present,
otherwise log/return an error and skip deletion; apply the same validation
before the second delete call at the other occurrence so both code paths verify
the resource is a test account before deleting.

---

Nitpick comments:
In `@test/e2e/devsandbox-dashboard/fresh_signup_test.go`:
- Around line 44-67: The switch on env (comparing against sandboxui.TestEnv and
sandboxui.ProdEnv) currently ignores unknown values; update both switch
statements that branch on env to include a default case that calls
require.FailNow(t, "unsupported ENVIRONMENT: %s", env) (or equivalent
require.FailNow usage) so misconfiguration fails immediately; locate the
switches that reference env, sandboxui.TestEnv, and sandboxui.ProdEnv (including
the similar switch further down) and add the default require.FailNow handling to
each.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 708969ca-e8f9-4bed-8420-90acf4951622

📥 Commits

Reviewing files that changed from the base of the PR and between d86580b and 4b31e46.

📒 Files selected for processing (1)
  • test/e2e/devsandbox-dashboard/fresh_signup_test.go

Comment thread test/e2e/devsandbox-dashboard/fresh_signup_test.go Outdated
Comment thread test/e2e/devsandbox-dashboard/fresh_signup_test.go
Copy link
Copy Markdown
Contributor

@mfrancisc mfrancisc left a comment

Choose a reason for hiding this comment

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

Nice Job 👏

Sorry for the slow response!

@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented Apr 22, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alexeykazakov, MatousJobanek, mfrancisc, rsoaresd

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [MatousJobanek,alexeykazakov,mfrancisc,rsoaresd]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sonarqubecloud
Copy link
Copy Markdown

@rsoaresd rsoaresd merged commit f67a1a3 into codeready-toolchain:master Apr 24, 2026
8 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants