Skip to content

Adds an opt-in GitKraken sign-in for e2e workers, with signed-in MCP write-path e2e - #6030

Open
nikolay-1986 wants to merge 5 commits into
mainfrom
feature/#5682-e2e-signin-fixture
Open

nikolay-1986 wants to merge 5 commits into
mainfrom
feature/#5682-e2e-signin-fixture

Conversation

@nikolay-1986

@nikolay-1986 nikolay-1986 commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Parts 1 and 2 of #5682 (#6033 was merged into this branch): lets an e2e worker sign in to a GitKraken test account with no person involved, and uses it for the integration-backed happy paths of the MCP Start Work / Start Review tools (#5106). Opt-in only — without a session cookie the signed-in specs skip, and the existing suite is unaffected.

Why this way

The normal sign-in can't run under the test host: VS Code refuses the "open external website" dialog in tests (DialogService: refused to show dialog in tests). Instead the worker asks the GitKraken site for a sign-in code with the test account's session cookie (the code is in the first redirect of /login, no browser), and hands GitLens the login deep link through the harness evaluator. The account's cloud integrations come with the sign-in — no provider OAuth.

Changes

Sign-in fixture (#5682)

  • tests/e2e/fixtures/gkSignIn.ts — the unattended sign-in.
    • Backend: chosen by GK_E2E_ENV, which has no default. It must name staging or dev; production also needs GK_E2E_ALLOW_PRODUCTION=1. The setting picks each backend's session cookie name and GitLens' gitkraken.env.
    • Access: a Cloudflare Access credential is sent off production only — the staging and dev sites are gated, their APIs are not. It never follows a redirect to another host.
    • Retries: only the code request is retried. The exchange mints a token; the request doesn't.
    • Waiting: it waits with locator.waitFor, so a failed sign-in doesn't snapshot the Account page.
    • Diagnostics: fixed vocabularies only — no credentials, codes, state or account text are logged. The account's plan labels are logged.
  • tests/e2e/baseTest.ts:
    • adds vscodeOptions.signIn (true or { requiredIntegrations });
    • writes gitkraken.env into the signed-in worker's settings;
    • gives every signed-in worker its own XDG_DATA_HOME, so GitLens' follow-up gk auth login doesn't replace the machine-wide GK CLI login;
    • strips GK_E2E_* from the editor's launch environment, so VS Code, GitLens, git, the GK CLI and the MCP server never inherit the credentials;
    • exports canSignIn / requiredIntegrations.
  • tests/e2e/specs/signIn.test.ts — @signed-in: the account page shows the signed-in state, and the required integrations are connected.

Signed-in MCP write paths (#5106)

  • tests/e2e/specs/mcpGitlensWritePathSignedIn.test.ts — @signed-in. It runs gitlens_start_review and gitlens_start_work on a GitHub test repository under a simulated Pro plan, and checks what they report against git:
    • the review worktree is at the PR head as the host publishes it, tracking the PR's own branch on origin;
    • the issue branch and its worktree start from the default branch.
  • On failure it prints the GitLens log lines that explain the wizard's decision. Before printing:
    • entries naming the GK CLI sign-in are dropped whole;
    • sign-in codes, state, tokens and e-mail addresses are masked.
  • It skips without the cookie or the E2E_GITHUB_REPO_URL / _ISSUE_URL / _PR_URL variables, and fails instead under E2E_REQUIRE_SIGNIN.
  • tests/e2e/specs/mcpGitlensWritePath.test.ts — its header now points to the signed-in spec.

Docs

  • docs/testing.md — "Opt-in specs: signed-in workers": how to opt in, how to run locally, the variables (including the GitHub fixtures), and what a sign-in costs.
  • .claude/skills/add-test/SKILL.md — a pointer for signed-in specs.

How it was tested

  • pnpm run check clean.
  • In a private CI sandbox (GitHub-hosted ubuntu-latest, bundle:e2e, same harness):
    • the full VS Code suite stayed green with signed-in workers in it;
    • against the staging backend, signIn.test.ts ×2 and both Add E2E test coverage for GitLens MCP server #5106 cases pass (4/4, most recently after the review fixes);
    • the worker signs in in ~5–8 s and sees GitHub, GitLab, Bitbucket, Azure DevOps, Jira and Linear connected;
    • nothing secret appeared in logs or artifacts.
  • Without GK_E2E_ACCESS_TOKEN_COOKIE the signed-in specs skip, and no editor is launched for them.

Notes

  • CI wiring is Adds an opt-in CI job for signed-in e2e against staging #6039: a dedicated job with its own Environment restricted to main, staging only, and artifacts scanned for secret values before upload. It stays off until enabled, and waits on a Cloudflare Access credential for CI.
  • Every sign-in mints a GitLens token for the test account that the backend neither expires nor revokes. Hence:
    • the fixture is opt-in per spec;
    • signed-in specs don't retry;
    • production needs an explicit opt-in, and CI signs in to staging only.

🤖 Generated with Claude Code

Signed-in specs opt in with the `signIn` worker option and the @signed-in tag: the worker asks the GitKraken site for a sign-in code with the test account's session cookie and hands GitLens the login deep link through the evaluator, since the normal sign-in can't run under the test host. Picks the backend from GK_E2E_ENV (production/staging/dev), passes a Cloudflare Access credential off production, retries only the code request, and keeps credentials, codes and account text out of its diagnostics. Without a cookie the specs skip.
@nikolay-1986
nikolay-1986 requested a review from a team October 19, 2026 14:24
@nikolay-1986 nikolay-1986 self-assigned this Oct 19, 2026
@augmentcode

augmentcode Bot commented Oct 19, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

Summary:
Adds opt-in GitKraken sign-in so account-dependent E2E tests can run unattended.
Changes:

  • Adds a session-cookie fixture that obtains login codes without a browser.
  • Delivers authentication through the running editor's login deep link.
  • Selects production, staging, or dev with matching cookies and backend settings.
  • Supports Cloudflare Access credentials for non-production sites.
  • Retries code acquisition without retrying the token exchange.
  • Exposes worker sign-in options and required-integration checks.
  • Adds a credential-gated smoke spec with recordings/retries disabled, plus setup and token-cost documentation.

🤖 Was this summary useful? React with 👍 or 👎

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review completed. 3 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

Comment thread tests/e2e/baseTest.ts
}

if (vscodeOptions.signIn) {
await signInToGitKraken(

@augmentcode augmentcode Bot Oct 19, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Could we account for the CLI authentication side effect at tests/e2e/baseTest.ts:600? SubscriptionService.loginCore() invokes gitlens.ai.mcp.authCLI, and the AI-enabled harness inherits the real home/config environment, so a production sign-in can replace the developer's machine-wide CLI login with the test account and leave its non-expiring token behind after worker cleanup.

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

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.

Fixed in c5cda86: signed-in workers now get their own XDG_DATA_HOME (the GK CLI keeps its install and sessions there), so the gk auth login GitLens runs after sign-in lands in the worker's temp dir — deleted at teardown — instead of replacing the machine-wide CLI login. Verified on CI: the MCP specs that use a signed-in worker still pass with the isolated CLI data.

await evaluate(
// The host's own scheme (`vscode-insiders`, a fork's) — a `vscode://` link would reach another editor, or none
async (vscode, query: string) =>
vscode.env.openExternal(vscode.Uri.parse(`${vscode.env.uriScheme}://eamodio.gitlens/login?${query}`)),

@augmentcode augmentcode Bot Oct 19, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Could we account for the extension's own logging at tests/e2e/fixtures/gkSignIn.ts:134? SubscriptionService.onLoginUriReceived() uses @info() and the logger serializes Uri with its full query, so this path writes the sign-in code and state into the GitLens output log despite the fixture's no-secret-logging guarantee.

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

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.

Confirmed: GitLens' own @info() on the login handler logs the URI with its query. That's product code, outside this test-only PR, so it's noted for a separate fix (log the callback with code/state masked or hashed). For the harness: the code is single-use and exchanged right after, the log lives in the worker's temp profile (deleted at teardown), and the fixture's docs now say so instead of claiming nothing is logged (c5cda86).

});

test.skip(!canSignIn(), 'GK_E2E_ACCESS_TOKEN_COOKIE is not set');
test.use({ trace: 'off', video: 'off', screenshot: 'off' });

@augmentcode augmentcode Bot Oct 19, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Could we account for Playwright's error-context.md attachments at tests/e2e/specs/signIn.test.ts:17? These three options do not disable failed-assertion ARIA snapshots in Playwright 1.63, so a failure on the Account webview can still copy the account name/e-mail into test artifacts despite the recording opt-out.

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

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.

Confirmed: Playwright 1.63 writes error-context.md on any test error, and there is no option to turn it off. d0818be makes the fixture wait with locator.waitFor instead of expect matchers, so a failed sign-in no longer snapshots the Account page, and documents the limitation for assertions in specs. Artifacts from the CI job will be scanned and redacted before upload — that's part of the separate CI-wiring PR.

Copilot AI left a comment

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.

🟡 Changes recommended

Extension logs and failure diagnostics can expose authentication values or account information.

4 open issues
What changed in this PR

Adds opt-in, unattended GitKraken sign-in for E2E workers, enabling future tests that need connected cloud integrations.

Changes:

  • Adds backend-aware sign-in with guarded requests and retries.
  • Adds signed-in account and integration checks.
  • Documents setup, credentials, and token costs.
File Description
tests/​e2e/​specs/​signIn.test.ts Checks account sign-in and required integrations.
tests/​e2e/​fixtures/​gkSignIn.ts Implements unattended sign-in and diagnostics.
tests/​e2e/​baseTest.ts Adds worker sign-in options and setup.
docs/​testing.md Documents opt-in execution and safeguards.
.claude/​skills/​add-test/​SKILL.md Adds guidance for signed-in specs.

Review effort: Balanced

Comment thread tests/e2e/baseTest.ts
Comment thread tests/e2e/fixtures/gkSignIn.ts
Comment thread tests/e2e/specs/signIn.test.ts
Comment thread tests/e2e/fixtures/gkSignIn.ts Outdated
After signing in, GitLens logs the GK CLI in with the account's token. Signed-in workers now get their own XDG_DATA_HOME so that login lands in the worker's temp dir instead of replacing the machine-wide CLI login. Also documents that GitLens' own log records the single-use deep link code inside the temp profile, and that Playwright's error-context snapshots can still carry account text on a failure.
Waits with locator.waitFor instead of expect matchers in the sign-in fixture, so a failed sign-in doesn't put an ARIA snapshot of the Account page into Playwright's error-context, and reports a page answer to the code request in fixed trait labels only instead of the response's title and content type. Documents that error-context can't be turned off.

Copilot AI left a comment

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.

🔵 Needs a closer look

Real-account authentication mints non-expiring tokens, requiring human verification of credential isolation, teardown, and artifact handling.

No open issues 🎉

4 resolved since last review

Review effort: Balanced

…explicit opt-in

The harness strips GK_E2E_* from the environment it launches the editor with, so GitLens, git, the GK CLI and the MCP server never inherit the cookie or the Cloudflare credential; only the Playwright process reads them. GK_E2E_ENV no longer defaults to production: it must name staging or dev, and production also needs GK_E2E_ALLOW_PRODUCTION=1, since a production sign-in mints a token the backend never expires or revokes.
@nikolay-1986

Copy link
Copy Markdown
Contributor Author

Follow-up from a design review of the CI rollout (eda5e8f):

  • The harness now strips GK_E2E_* from the environment it launches the editor with, so VS Code, GitLens, git, the GK CLI and the MCP server never inherit the cookie or the Cloudflare credential; only the Playwright process reads them.
  • GK_E2E_ENV no longer defaults to production: it must name staging or dev, and production also needs GK_E2E_ALLOW_PRODUCTION=1 — a production sign-in mints a token the backend never expires or revokes.

Merged up into #6033 and #6039. Verified with the signed-in specs against staging in a sandbox fork (4 passed).

#6033)

* Adds signed-in e2e for the MCP Start Work and Start Review happy paths (#5106)

Runs gitlens_start_review and gitlens_start_work on a GitHub test repository from a signed-in worker under a simulated Pro plan, and checks what they report against git. On failure, prints the GitLens log lines that explain the wizard's decision, with the CLI sign-in entries dropped and sign-in codes, tokens and e-mail addresses masked. Skips without the cookie or the E2E_GITHUB_* variables.

* Checks Start Review tracks the PR's own branch, not just any origin branch
@nikolay-1986 nikolay-1986 changed the title Adds an opt-in GitKraken sign-in for e2e workers Adds an opt-in GitKraken sign-in for e2e workers, with signed-in MCP write-path e2e Oct 21, 2026
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