Skip to content

test(e2e): shared brokering e2e helpers + real KMSI assertion (Foundation PR 1)#8721

Draft
lalimasharda wants to merge 1 commit into
devfrom
js-wam/e2e-broker-harness
Draft

test(e2e): shared brokering e2e helpers + real KMSI assertion (Foundation PR 1)#8721
lalimasharda wants to merge 1 commit into
devfrom
js-wam/e2e-broker-harness

Conversation

@lalimasharda

Copy link
Copy Markdown
Contributor

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.tsverifyBrokerTokenStore (returns a BrokerCacheSnapshot), 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 the signin_state claim contains kmsi (verifyKmsiFromCache), plus selectKmsiOption.
  • index.ts — export the new helpers + puppeteer Frame.

Cross-repo

Paired 1P PR on matching branch js-wam/e2e-broker-harness refactors BrokerTestApp-React specs to consume these helpers. This 3P PR merges first, then the 1P submodule pointer is bumped.

Testing

Prettier clean; tsc typecheck clean. No runtime/library changes — test utilities only.

Note

Draft — foundation gate for the remaining 13 PRs in the plan.

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

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.

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 KmsiTestUtils helpers to interact with the KMSI prompt and assert KMSI via the cached ID token signin_state claim.
  • Added BrokerTestUtils helpers for broker/brokered cache assertions and for locating/waiting on broker/embedded iframes and initiating brokered login actions.
  • Updated samples/e2eTestUtils public exports to include the new helpers and puppeteer’s Frame type.

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);

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