Feature ETP-4959: Add component test runner to etendo-go-core - #138
Open
sebastianbarrozo wants to merge 2 commits into
Open
Feature ETP-4959: Add component test runner to etendo-go-core#138sebastianbarrozo wants to merge 2 commits into
sebastianbarrozo wants to merge 2 commits into
Conversation
LoginStep carried two independent copies of the post-authentication continuation, one per authentication branch. When the caller-owned onAuthenticated prop was introduced only the password copy was updated, so an SSO login on the invitation page persisted the session and then stopped: the caller never got its callback and the user was stranded on the login form with an unconsumed invitation token. Extract the continuation into a single exported helper that both branches call, so the two paths can no longer diverge. Add the missing onAuthenticated entry to the handleSsoProviderLogin dependency array, which otherwise captured a stale callback for any caller that memoizes config. Replace the previous source-text assert.match regression test with behavioural unit tests covering routing suppression, persistence-before- handover ordering, forwarded arguments, error propagation and the no-continuation default.
packages/etendo-go-core ran only node --test, which cannot parse .jsx. That is why the ETP-4958 regression test degraded into a source-text assert.match against LoginStep.jsx: a change detector that passes even when the code path is unreachable, and that asserts nothing about the wiring between the two authentication branches and the shared continuation helper. Add a Vitest + jsdom + Testing Library setup mirroring app-shell-core, and cover the ETP-4958 contract at component level by rendering the real LoginStep and driving each branch to a successful login: caller-owned continuation invoked with the authenticated session, no environment routing when the caller takes over, default routing preserved otherwise, and both branches producing an identical outcome. Wire the suite into .github/workflows/test.yml and make test. The workflow runs npm test per workspace, which is node --test only, so a Vitest suite without its own step would never execute. Only this package's suite is wired in; app-shell-core has the same gap but is red on the epic and is tracked separately under ETP-4961.
Contributor
Copilot PR ReviewOutcome: Comment only Warnings
|
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.

0 New Issues
0 Fixed Issues
0 Accepted Issues
No data about coverage
ETP-4959 — Component test runner for
etendo-go-core+ LoginStep auth-continuation coveragehttps://etendoproject.atlassian.net/browse/ETP-4959
Why
ETP-4958 fixed a user-visible dead end:
LoginStep's SSO branch silently skipped the caller-ownedonAuthenticatedcontinuation. Its unit tests cover the extractedcompleteAuthentication()helper, but nothing asserted that the two authentication branches actually route through it — you could re-inline the buggy logic into either branch and every test would still pass.The blocker was infrastructure.
packages/etendo-go-coreran onlynode --test, which cannot parse.jsx, so the original regression test degraded into a source-textassert.match()againstLoginStep.jsx. That is what let the bug ship.Changes
packages/etendo-go-core/vitest.config.jspackages/app-shell-core. Includessrc/**/*.vitest.{js,jsx}.packages/etendo-go-core/test/vitest-setup.jsjest-dommatchers + jsdom scroll stubs. Lives undertest/so it stays out of the published tarball (files: ["src", …]).packages/etendo-go-core/package.jsontest:vitestscript + Testing Library / jsdom / vitest devDependencies.…/src/onboarding/steps/__tests__/LoginStep.vitest.jsxLoginStep..github/workflows/test.ymlMakefilemake testnow also runs bothetendo-go-coresuites (it previously ran neither).CLAUDE.mdWhat the tests cover
The real component is rendered; only genuine external boundaries are stubbed — the SSO provider SDK (
sso.js) and the HTTP layer (api.js). The SSO mock captures theonCredentialcallback the component hands the provider, so a test can fire a successful credential without a real Google button.onAuthenticated→ callback invoked with(token, account),routeByEnvironmentsnot called.localStorage(token andsf_platform_auth_method: 'sso') before the caller is handed control.routeByEnvironments(token)preserved.onAuthenticated→ same continuation as SSO.ssoCaller.mock.callsequalspasswordCaller.mock.callsrather than testing each in isolation.Verification
npm run test:vitest --workspace=packages/etendo-go-core: 6 passed.npm test --workspace=packages/etendo-go-core: 188 passed (unchanged).handleAuthSuccess(data.token, data.account, { authMethod: 'sso' }), bypassing the helper) makes 3 of the 6 fail, including the divergence test. Restored → 6/6. This is the guarantee the old source-text test could not give.Note on scope —
app-shell-coreis deliberately not wired inWhile wiring CI I found that no automated gate in this repo has ever run Vitest:
test.ymlrunsnpm testper workspace (node --testonly), no workflow invokesmake test, and.githooks/pre-pushruns no unit tests at all.packages/app-shell-core's 687-test suite has consequently rotted and is red onepic/ETP-3504today — 3 orphaned files importing components that no longer exist, plus 2 realAddLineButtonfailures.Wiring it in here would block this PR on unrelated breakage, so only the new
etendo-go-coresuite is added to CI. Theapp-shell-corecleanup is ETP-4961.