Skip to content

Add Playwright e2e tests for React SDK (redirect + embedded sign-in) #363

@DonOmalVindula

Description

@DonOmalVindula

Summary

Add end-to-end tests for the @asgardeo/react SDK covering both redirect-based OAuth and embedded <SignIn /> component sign-in flows, running against two identity providers.

What's Included

Identity Providers

  • WSO2 Identity Server (wso2/wso2is:7.2.0) — full OIDC provider with DCR, SCIM2, and logout consent
  • Asgardeo Thunder - AsgardeoV2` platform

Test Coverage

Test IS Thunder
Redirect to IDP login page Yes Yes
Sign in with valid credentials (redirect) Yes Yes
Redirect unauthenticated users to IDP Yes Yes
Sign out and redirect to landing page Yes
Block protected routes after sign out Yes
Render embedded <SignIn /> component Yes Yes
Sign in via embedded component Yes Yes
Display user profile Yes Yes
Navigate back from profile Yes Yes

Infrastructure

  • Docker Compose setup for both IDPs with health checks
  • Automated IDP setup: app registration (DCR/management API), test user provisioning (SCIM2)
  • Unified test runner script (pnpm e2e -- --idp is|thunder|all --mode redirect|embedded|all --headed)
  • Separate Playwright configs for redirect and embedded modes (Vite bakes env vars at build time)

SDK Fixes

  • Fix AsgardeoProvider V2 race condition: loading poll could set isLoadingSync=false before token exchange completes, causing ProtectedRoute to redirect prematurely. Added auth-params guard to prevent this.

Sample App Improvements

  • Remove VITE_ASGARDEO_SIGN_IN_MODE custom env var — SignInPage now uses signInUrl from SDK context to determine redirect vs embedded mode (consistent with SignInButton behavior)
  • Remove CallbackPage workaround (no longer needed after SDK fix)
  • Remove test-only EmbeddedSignInPage

Test Structure

e2e/
├── tests/{is,thunder}/redirect/   # Redirect-based OAuth tests
├── tests/{is,thunder}/embedded/   # Embedded <SignIn /> component tests
├── setup/{is,thunder}/            # IDP-specific setup (app registration, user provisioning)
├── helpers/{is,thunder}/          # IDP-specific selectors and auth helpers
├── playwright.redirect.config.ts  # Playwright config for redirect tests
├── playwright.embedded.config.ts  # Playwright config for embedded tests
└── scripts/run-e2e.sh             # Unified test runner

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions