# Playwright Testing with On-the-Fly Response Modifications

This test demonstrates how to use [Playwright](https://playwright.dev) in combination with [ts-morph](https://ts-morph.com/)  to run a frontend application while dynamically modifying API responses and frontend code.

## What It Does

- **Feature Flag Override:**  
  The test intercepts the GraphQL endpoint used for feature flags (`.../graphql?op=Features`) and forces all features to be `"enabled"`. This ensures that the tests run with every feature turned on.

- **Frontend Code Hack (AST Transformation):**  
  The test intercepts the JavaScript bundle (`frontend-settings.main.9b04138bb48551819b1f.js`) that contains the `hasAccess` functions. Using ts-morph, it replaces every instance of the `hasAccess` property with a new function that always returns `true`. This bypasses any access restrictions in the UI during testing.

- **Login & Invite User Workflow:**  
  The test navigates to the application, logs in using credentials provided in a `.env` file, and simulates a user inviting another user.
## Prerequisites

Before running the tests, ensure you have the following installed:

- **Node.js** (v20)
- **npm**

Install the required packages by running:

```bash
npm i
npx playwright install
```

## Project Structure
* `test`: Runs the tests in headless mode.
* `test:headed`: Runs tests in headed mode (visible browser window).
* `test:ui`: Opens Playwright’s UI test runner.
