Skip to content

Implement Mock Authentication Service for E2E Tests #312

@halsk

Description

@halsk

Overview

Implement a mock authentication service to resolve authentication timeout issues occurring during E2E test execution.

Background and Purpose

Currently, E2E tests experience timeout issues in auth-helper.ts because they depend on the actual authentication service (Supabase). To create a stable authentication flow in the test environment, we need to implement a mock authentication service.

Implementation Details

  1. Create a Mock Authentication Service

    • Create an integration-tests/mocks/auth-api directory
    • Implement a mock server using Express.js
    • Provide basic authentication endpoints for login, signup, and token verification
  2. Update Docker Compose Configuration

    • Add the mock authentication service to docker-compose.test.yml
    • Configure appropriate port settings and health checks
    • Follow the same configuration pattern as existing mock services (Slack API, OpenRouter API)
  3. Update Test Environment Settings

    • Update environment variables to use the mock authentication service
    • Implement a mechanism to auto-generate the frontend's .env.local file
  4. Modify auth-helper.ts

    • Update the authentication helper to work with the mock service
    • Add more robust error handling and debugging information
    • Strengthen authentication state verification
  5. Improve Test Fixtures

    • Enhance the authenticatedPage fixture to improve authentication state stability
    • Strengthen error handling and cleanup procedures

Related Documentation

Related Issues

Completion Criteria

  • Mock authentication service is implemented and working in the Docker Compose environment
  • E2E tests run successfully without authentication timeouts
  • Test execution is stable in CI environments
  • Test coverage is improved

Additional Notes

By using the same design pattern as existing mock services (Slack API, OpenRouter API), we can build a consistent test environment. The mock service should integrate with the TestDataHelper class to provide consistent authentication flows for testing.

Run E2E test locally for confirming fixes

Metadata

Metadata

Assignees

No one assigned

    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