fix: re-authenticate per account for the local env, not just io - #210
Open
huandrey wants to merge 1 commit into
Open
fix: re-authenticate per account for the local env, not just io#210huandrey wants to merge 1 commit into
huandrey wants to merge 1 commit into
Conversation
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
🛡️ SDD Check — action requiredI couldn't detect an SDD in this PR. Please check one option below (requires write access to the repo):
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
visitAndClearCookiesonly re-authenticates against the target account's own VTEX ID session (POST /api/vtexid/apptoken/login?an=<account>) whenVTEX_ENV === 'io'.VTEX_ENV === 'local'(used byvcs.checkout-ui'se2e.ymlto 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 underlocal; every spec targeting a sibling account (vtexgame1geo,vtexgame1invoice,vtexgame1nolean,vtexgame1clean,vtexgame1nogeo, ...) fails atcy.visit()with a 500, because the checkout server's own account-scoped API calls come back401 Token issued for a different account.Fix: treat
localthe same asiofor this re-authentication step in bothutils/index.js(the implementation actually imported by specs) and the equivalent, currently-unusedCypress.Commands.add('visitAndClearCookies', ...)incypress/support/commands.ts, so the two don't drift.Note: this alone isn't enough to turn CI green —
vcs.checkout-ui'se2e.ymldoesn't currently forwardCYPRESS_APP_KEY/CYPRESS_APP_TOKENto the Cypress step, sobaseConfig.appKey/appTokenare stillundefinedunderlocal. 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.jstargeting a non-default account). Verified viaeslinton both changed files (no new errors).