Skip to content

Conversation

tnorling
Copy link
Collaborator

@tnorling tnorling commented Sep 2, 2025

This pull request introduces several improvements and new features to the ExpressSample in the msal-browser-samples, focusing on enhanced version switching, improved authentication and profile data display, and better testability. The most significant changes include a refactor of the MSAL version switching logic to support more granular version selection, expanded end-to-end (E2E) testing support, and UI/UX improvements for displaying authentication data.

Key changes:

Version switching and server logic improvements

  • Refactored the MSAL version switching logic in server.js to support explicit selection of the latest v4.x and v3.x versions, in addition to the general "latest" version. This includes improved caching and dynamic fetching of version numbers from NPM, and clearer naming/descriptions for each version option. [1] [2] [3]
  • Updated the version dropdown UI to assign unique IDs to version items and the custom version entry, improving accessibility and enabling more precise UI interactions. [1] [2]

E2E testing and configuration enhancements

  • Added E2E test configuration and scripts for the ExpressSample, including a dedicated .env.e2e file, a jest.config.cjs configuration, and new test dependencies/scripts in package.json. This enables automated, environment-specific testing for the sample app. [1] [2] [3] [4]

Authentication and profile data display improvements

  • Refactored the authentication and profile data fetching logic in auth.js and graph.js to return and display both the authentication response and profile data. A new displayAuthData function sanitizes and shows authentication details in the UI, with sensitive fields redacted. [1] [2] [3] [4] [5]
  • Updated the UI to ensure relevant buttons (such as sign-in and version switcher) are shown only after event handlers are registered, improving perceived responsiveness and reducing flicker. [1] [2]

UI and styling refinements

  • Renamed the .profile-json CSS class to .json-content and updated associated selectors for clarity and consistency. [1] [2]
  • Minor CSS and code formatting improvements for readability and maintainability. [1] [2]

These changes collectively make the ExpressSample more robust, testable, and user-friendly, especially for scenarios involving MSAL version switching and debugging authentication flows.

@github-actions github-actions bot added the samples Related to the samples apps for the library. label Sep 2, 2025
@tnorling tnorling marked this pull request as ready for review September 3, 2025 16:49
@Copilot Copilot AI review requested due to automatic review settings September 3, 2025 16:49
@tnorling tnorling requested a review from a team as a code owner September 3, 2025 16:49
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 PR introduces comprehensive enhancements to the ExpressSample in msal-browser-samples, focusing on MSAL version switching capabilities, end-to-end testing infrastructure, and improved authentication data display. The changes enable robust testing of upgrade/downgrade scenarios between different MSAL versions while providing better visibility into authentication flows.

Key changes include:

  • Enhanced version switching logic with support for granular version selection (latest, latest-v4, latest-v3, custom versions)
  • Complete E2E testing infrastructure with dedicated test files, configuration, and CI pipeline integration
  • Improved authentication data display showing both profile information and raw MSAL authentication responses

Reviewed Changes

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

Show a summary per file
File Description
server.js Refactored version switching logic to support v3, v4, and latest versions with improved NPM version fetching
test/upgrade-downgrade.spec.ts New comprehensive E2E test suite for version upgrade/downgrade scenarios
test/test-helpers.ts Helper functions for E2E tests including sign-in, version switching, and cache verification
public/js/graph.js Updated to return and display both profile data and authentication response data
public/js/auth.js Modified to return full authentication response instead of just access token
views/partials/profile-content.hbs Added new section to display raw authentication data alongside profile information
public/js/versionSwitcher.js Added unique IDs to version dropdown items and improved UI state management
public/js/app.js Enhanced UI initialization to show buttons only after event handlers are registered
Configuration files Added Jest config, TypeScript config, environment file, and updated package.json for E2E testing

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@tnorling tnorling enabled auto-merge (squash) September 3, 2025 20:58
@tnorling tnorling merged commit fc194a3 into msal-v5 Sep 4, 2025
7 checks passed
@tnorling tnorling deleted the v5-upgrade-e2e-tests branch September 4, 2025 16:45
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