Skip to content

fix: re-authenticate per account for the local env, not just io - #210

Open
huandrey wants to merge 1 commit into
mainfrom
fix/local-env-multi-account-login
Open

fix: re-authenticate per account for the local env, not just io#210
huandrey wants to merge 1 commit into
mainfrom
fix/local-env-multi-account-login

Conversation

@huandrey

@huandrey huandrey commented Aug 7, 2026

Copy link
Copy Markdown

Summary

visitAndClearCookies only re-authenticates against the target account's own VTEX ID session (POST /api/vtexid/apptoken/login?an=<account>) when VTEX_ENV === 'io'. VTEX_ENV === 'local' (used by vcs.checkout-ui's e2e.yml to test a PR's own locally-built server) hit no branch at all, so every spec kept the cookie from whichever account logged in first.

In practice this means only specs targeting the default account (vtexgame1) pass under local; every spec targeting a sibling account (vtexgame1geo, vtexgame1invoice, vtexgame1nolean, vtexgame1clean, vtexgame1nogeo, ...) fails at cy.visit() with a 500, because the checkout server's own account-scoped API calls come back 401 Token issued for a different account.

Fix: treat local the same as io for this re-authentication step in both utils/index.js (the implementation actually imported by specs) and the equivalent, currently-unused Cypress.Commands.add('visitAndClearCookies', ...) in cypress/support/commands.ts, so the two don't drift.

Note: this alone isn't enough to turn CI green — vcs.checkout-ui's e2e.yml doesn't currently forward CYPRESS_APP_KEY/CYPRESS_APP_TOKEN to the Cypress step, so baseConfig.appKey/appToken are still undefined under local. A companion PR is being opened there.

Test scenarios

Not covered by a new test here — this fixes the shared login helper used by every existing multi-account spec (tests/**/*.test.js targeting a non-default account). Verified via eslint on both changed files (no new errors).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@huandrey
huandrey requested a review from a team as a code owner August 7, 2026 17:23
@vtex-pr-sentinel

Copy link
Copy Markdown

🛡️ SDD Check — action required

I couldn't detect an SDD in this PR. Please check one option below (requires write access to the repo):

  • SDD lives in another PR — paste the SDD PR URL here:
  • This PR doesn't need an SDD
  • SDD applies, but I'm not adopting it in this PR

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.

1 participant