Skip to content

Conversation

tnorling
Copy link
Collaborator

@tnorling tnorling commented Aug 26, 2025

This pull request introduces a new end-to-end (E2E) test setup for the ExpressSample in the MSAL browser samples, along with several improvements to the sample app's authentication flow, version switching, and UI. The most significant changes are the addition of E2E test infrastructure, enhancements to how authentication and profile data are handled and displayed, and improvements to the version switching logic and UI.

E2E Test Infrastructure and Configuration:

  • Added E2E test configuration and helpers for ExpressSample, including a new .env.e2e file, a jest.config.cjs configuration, and a test-helpers.ts utility for Puppeteer-based tests. This enables automated browser testing of authentication scenarios. [1] [2] [3]
  • Updated the pipeline configuration to include ExpressSample in E2E test runs.
  • Added necessary devDependencies and scripts for E2E testing in package.json.

Authentication and Profile Data Handling:

  • Modified the authentication flow to return the full MSAL authentication response, not just the access token, and updated the MS Graph call logic to pass and display this data. [1] [2] [3] [4] [5]
  • Added UI logic to display both profile data and raw authentication data, with sensitive fields (like the access token) redacted for display.

Version Switching and UI Improvements:

  • Refactored version switching logic to use consistent keys (e.g., latest-v3 instead of 3.x) and improved the UI for version selection, including unique IDs for dropdown items and better feedback when switching versions. [1] [2] [3] [4] [5] [6]
  • Ensured UI elements (such as sign-in and version switcher buttons) are only displayed after event handlers are registered, preventing flicker or premature interaction. [1] [2]

UI and Styling Enhancements:

  • Updated CSS classes and selectors to use .json-content for displaying JSON data, improving clarity and maintainability. [1] [2]
  • Minor CSS and code style cleanups for readability and consistency. [1] [2]

Other Improvements:

  • Removed unnecessary dependencies (like morgan) from the server and cleaned up middleware usage. [1] [2]
  • Improved screenshot utility to always capture full-page screenshots during E2E tests.

These changes collectively improve the testability, usability, and maintainability of the ExpressSample app and its E2E testing setup.

@github-actions github-actions bot added the samples Related to the samples apps for the library. label Aug 26, 2025
@tnorling tnorling marked this pull request as ready for review August 27, 2025 16:59
@Copilot Copilot AI review requested due to automatic review settings August 27, 2025 16:59
@tnorling tnorling requested a review from a team as a code owner August 27, 2025 16:59
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request introduces comprehensive end-to-end (E2E) testing infrastructure for the ExpressSample with upgrade/downgrade testing capabilities, along with authentication flow improvements and UI enhancements.

  • Adds E2E test infrastructure with Puppeteer-based tests for version switching and authentication scenarios
  • Enhances authentication data handling to return full MSAL response and display raw authentication data alongside profile information
  • Improves version switching logic with consistent naming and better UI feedback

Reviewed Changes

Copilot reviewed 18 out of 19 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
test/upgrade-downgrade.spec.ts E2E tests for cache compatibility across MSAL versions
test/test-helpers.ts Helper functions for E2E testing including authentication and version switching
jest.config.cjs Jest configuration for E2E testing
.env.e2e Environment configuration for E2E tests
tsconfig.json TypeScript configuration for test files
server.js Version key updates and middleware cleanup
public/js/auth.js Modified to return full authentication response
public/js/graph.js Updated to handle and display authentication data
public/js/versionSwitcher.js Added unique IDs and improved UI initialization
public/js/app.js UI element visibility improvements
views/partials/profile-content.hbs Added raw authentication data display section
views/partials/home-content.hbs Added ID to profile button for E2E testing
views/layouts/main.hbs Hidden UI elements until handlers are registered
views/error.hbs Updated CSS class for consistency
public/css/styles.css Renamed CSS classes and minor formatting improvements
package.json Added E2E testing dependencies and scripts
samples/e2eTestUtils/src/TestUtils.ts Enhanced screenshot utility for full-page captures
.pipelines/3p-e2e.yml Added ExpressSample to E2E test pipeline

tnorling and others added 3 commits August 27, 2025 10:14
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@tnorling tnorling enabled auto-merge (squash) August 28, 2025 20:42
@tnorling tnorling merged commit 6d975bc into dev Aug 28, 2025
7 checks passed
@tnorling tnorling deleted the upgrade-rollback-e2e branch August 28, 2025 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
samples Related to the samples apps for the library.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants