test(e2e): shared brokering e2e helpers + real KMSI assertion (Foundation PR 1)#8721
Draft
lalimasharda wants to merge 1 commit into
Draft
test(e2e): shared brokering e2e helpers + real KMSI assertion (Foundation PR 1)#8721lalimasharda wants to merge 1 commit into
lalimasharda wants to merge 1 commit into
Conversation
Foundation PR 1 (Seq 01) of the JS-WAM platform-broker test-automation plan. Extracts the duplicated broker/brokered cache + frame helpers previously copy-pasted across the 1P BrokerTestApp-React specs into shared utilities in samples/e2eTestUtils, and adds a real Keep Me Signed In assertion that verifies the cached ID token signin_state claim contains 'kmsi' (the legacy flow only clicked the KMSI page and never verified persistence). - BrokerTestUtils.ts: verifyBrokerTokenStore (returns BrokerCacheSnapshot), verifyBrokeredTokenStore (token/account isolation, no refresh token in child), verifyEmptyCache, getBrokerFrame/getEmbeddedFrame/getAuthenticatedEmbeddedFrame, loginWidget. Ports/selectors parameterized for reuse across samples. - KmsiTestUtils.ts: decodeJwtPayload, getIdTokenClaimsFromCache, selectKmsiOption, assertKmsiSigninState, verifyKmsiFromCache. - index.ts: export the new helpers and puppeteer Frame. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 964fc129-b5c7-43d9-b02d-880d7e5677dc
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds reusable end-to-end (E2E) test utilities under samples/e2eTestUtils to support JS-WAM platform-broker brokering flows, including a cache-based “real” KMSI (Keep Me Signed In) assertion and shared broker/iframe helpers to reduce duplication across brokering specs.
Changes:
- Added
KmsiTestUtilshelpers to interact with the KMSI prompt and assert KMSI via the cached ID tokensignin_stateclaim. - Added
BrokerTestUtilshelpers for broker/brokered cache assertions and for locating/waiting on broker/embedded iframes and initiating brokered login actions. - Updated
samples/e2eTestUtilspublic exports to include the new helpers andpuppeteer’sFrametype.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| samples/e2eTestUtils/src/KmsiTestUtils.ts | Adds KMSI prompt helpers and cache-based ID token claim assertion utilities. |
| samples/e2eTestUtils/src/BrokerTestUtils.ts | Adds shared brokering helpers for token-store assertions and iframe discovery/auth readiness checks. |
| samples/e2eTestUtils/src/index.ts | Exports the new KMSI/broker utilities and re-exports Frame for consumers. |
Comment on lines
+56
to
+59
| // base64url -> base64 | ||
| const payload = parts[1].replace(/-/g, "+").replace(/_/g, "/"); | ||
| const json = Buffer.from(payload, "base64").toString("utf-8"); | ||
| return JSON.parse(json) as IdTokenClaims; |
Comment on lines
+95
to
+100
| if (broker) { | ||
| // Access token, ID token, and account must differ from the broker's. | ||
| expect(tokenStore.accessTokens[0]).not.toBe(broker.accessToken); | ||
| expect(tokenStore.idTokens[0]).not.toBe(broker.idToken); | ||
| expect(embeddedAccount).not.toBe(broker.account); | ||
| } |
Comment on lines
+166
to
+171
| const embeddedFrame = await page.waitForFrame( | ||
| async (frame) => frame.url().includes(embeddedPort.toString()), | ||
| { timeout } | ||
| ); | ||
| await embeddedFrame.waitForSelector(readySelector); | ||
|
|
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
Foundation PR 1 (Seq 01) of the JS-WAM platform-broker e2e test-automation plan. Adds shared brokering e2e helpers and a real Keep Me Signed In (KMSI) assertion to
samples/e2eTestUtils, so the brokering specs stop copy-pasting helpers and actually verify KMSI persistence.Changes
BrokerTestUtils.ts—verifyBrokerTokenStore(returns aBrokerCacheSnapshot),verifyBrokeredTokenStore(token/account isolation, no refresh token in the child),verifyEmptyCache,getBrokerFrame/getEmbeddedFrame/getAuthenticatedEmbeddedFrame,loginWidget. Ports/selectors parameterized for reuse.KmsiTestUtils.ts— decodes the cached ID token and asserts thesignin_stateclaim containskmsi(verifyKmsiFromCache), plusselectKmsiOption.index.ts— export the new helpers + puppeteerFrame.Cross-repo
Paired 1P PR on matching branch
js-wam/e2e-broker-harnessrefactorsBrokerTestApp-Reactspecs to consume these helpers. This 3P PR merges first, then the 1P submodule pointer is bumped.Testing
Prettier clean;
tsctypecheck clean. No runtime/library changes — test utilities only.Note
Draft — foundation gate for the remaining 13 PRs in the plan.