# rajatt95/testautomationframework_yt_rajat_web_playwright_ts architecture

> Architecture diagram of the GitHub repository rajatt95/testautomationframework_yt_rajat_web_playwright_ts, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rajatt95/testautomationframework_yt_rajat_web_playwright_ts
- Repository: https://github.com/rajatt95/testautomationframework_yt_rajat_web_playwright_ts

## Overview

##### Project type and purpose
- This is a **Test Automation Framework** for web applications, built using **Playwright** and **TypeScript**.
- Its purpose is to define and run UI tests against a target web application (in this case, the “saucedemo” demo site), generate HTML reports, and integrate with CI pipelines.

##### High-level analysis of the file structure
- **.github/workflows/** – GitHub Actions pipelines (01_ui_tests_chrome.yml, 02_ui_tests_select_one.yml, 03_ui_tests_ALL.yml) that trigger Playwright test runs on various browsers.
- **playwright.config.ts** – Core Playwright configuration (baseURL, browsers, testDir, reporter settings).
- **pages/** – Page Object Model (POM) classes (BasePage, LoginPage, ProductsPage, CartPage, Components) encapsulating page locators and actions.
- **utils/** – Utility modules (WaitUtils, VerificationUtils) providing common wait/verification helpers.
- **test-data/** – External JSON files (login_credentials.json) containing test data.
- **tests-saucedemo/** – Test specification files (.spec.ts) that import POM classes, utils, and data to define test scenarios.
- **package.json / package-lock.json** – NPM scripts (e.g. tests:ui-mode, tests:CHROME), dependencies (playwright, typescript, playwright-html-reporter).

##### Key architectural patterns and design principles
- **Page Object Model (POM):** separates test logic (tests-saucedemo) from page interactions (pages/).
- **Modular test data:** decouples credentials and test inputs into external files.
- **Utility layer:** centralizes common operations (waiting, assertions) in utils/.
- **Config-driven execution:** playwright.config.ts plus NPM scripts control browsers, headless/headed modes, parallelism, and reporters.
- **CI integration:** GitHub Actions workflows invoke NPM scripts across different browser targets.

##### Main components
a. **Test Runner Layer**
- Node.js process / NPM CLI scripts
- Playwright Test Runner (reads playwright.config.ts)
b. **Configuration**
- playwright.config.ts
- NPM scripts in package.json
- .github/workflows YAML files
c. **Test Suite**
- tests-saucedemo/*.spec.ts (test definitions)
d. **POM Layer**
- pages/BasePage.ts, LoginPage.ts, ProductsPage.ts, CartPage.ts, Components.ts
e. **Utilities**
- utils/WaitUtils.ts, VerificationUtils.ts
f. **Test Data**
- test-data/login_credentials.json
g. **Browser Engines**
- Chromium, WebKit, Firefox, Chrome, Edge (via Playwright drivers)
h. **Reporting**
- playwright-html-reporter output (HTML, screenshots, traces, videos)
- playwright-report directory
i. **CI/CD**
- GitHub Actions workflows invoking NPM scripts

##### Relationships and data flows
- **Test Runner** loads **Configuration** → spawns **Browser Engines**
- **Test Runner** executes **Test Suite**
- Each test uses **POM Layer** + **Utilities** + **Test Data** → interacts with **Browser Engines** → drives the AUT (Application Under Test)
- **Browser Engines** send back DOM states, screenshots, traces → **Reporting**
- **Reporting** artifacts stored and published by both the local reporter and the CI pipeline

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% CI/CD Layer
    subgraph "CI/CD (GitHub Actions)" 
        direction TB
        CI1["01_ui_tests_chrome.yml"]:::ci
        CI2["02_ui_tests_select_one.yml"]:::ci
        CI3["03_ui_tests_ALL.yml"]:::ci
    end

    %% Test Runner Layer
    subgraph "Test Runner Layer" 
        direction TB
        Runner["Node.js / NPM CLI"]:::runner
        PlaywrightRunner["Playwright Test Runner"]:::runner
    end

    %% Configuration Layer
    subgraph "Configuration" 
        direction TB
        PackageJSON["package.json (scripts)"]:::config
        PlaywrightConfig["playwright.config.ts"]:::config
    end

    %% Test Suite Layer
    subgraph "Test Suite (tests-saucedemo)" 
        direction TB
        LoginSpec["login.spec.ts"]:::tests
        ComponentsSpec["components.spec.ts"]:::tests
    end

    %% POM Layer
    subgraph "POM Layer (pages)" 
        direction TB
        BasePage["BasePage.ts"]:::pom
        LoginPage["LoginPage.ts"]:::pom
        ProductsPage["ProductsPage.ts"]:::pom
        CartPage["CartPage.ts"]:::pom
        ComponentsPage["Components.ts"]:::pom
    end

    %% Utilities Layer
    subgraph "Utilities (utils)" 
        direction TB
        WaitUtils["WaitUtils.ts"]:::util
        VerificationUtils["VerificationUtils.ts"]:::util
    end

    %% Test Data Layer
    subgraph "Test Data (test-data)" 
        direction TB
        LoginData["login_credentials.json"]:::data
    end

    %% Browser Engines
    subgraph "Browser Engines" 
        direction TB
        Browsers["Chromium, Firefox, WebKit"]:::browser
    end

    %% Reporting Layer
    subgraph "Reporting" 
        direction TB
        HTMLReporter["playwright-html-reporter"]:::report
        ReportDir["playwright-report (HTML, screenshots)"]:::report
    end

    %% Relationships
    CI1 -->|triggers| Runner
    CI2 -->|triggers| Runner
    CI3 -->|triggers| Runner
    Runner -->|reads| PackageJSON
    Runner -->|reads| PlaywrightConfig
    Runner -->|spawns| PlaywrightRunner
    PlaywrightRunner -->|executes| LoginSpec
    PlaywrightRunner -->|executes| ComponentsSpec
    LoginSpec -->|uses| BasePage
    LoginSpec -->|uses| LoginPage
    LoginSpec -->|uses| ProductsPage
    LoginSpec -->|uses| CartPage
    LoginSpec -->|uses| ComponentsPage
    ComponentsSpec -->|uses| BasePage
    ComponentsSpec -->|uses| ComponentsPage
    LoginSpec -->|uses| WaitUtils
    LoginSpec -->|uses| VerificationUtils
    ComponentsSpec -->|uses| WaitUtils
    ComponentsSpec -->|uses| VerificationUtils
    LoginSpec -->|uses| LoginData
    ComponentsSpec -->|uses| LoginData
    PlaywrightRunner -->|launches| Browsers
    Browsers -->|drive tests on| AUT(("Application Under Test"))
    Browsers -->|captures| HTMLReporter
    HTMLReporter -->|writes| ReportDir
    ReportDir -->|published by| CI3

    %% Click Events
    click PackageJSON "https://github.com/rajatt95/testautomationframework_yt_rajat_web_playwright_ts/blob/main/package.json"
    click PlaywrightConfig "https://github.com/rajatt95/testautomationframework_yt_rajat_web_playwright_ts/blob/main/playwright.config.ts"
    click CI1 "https://github.com/rajatt95/testautomationframework_yt_rajat_web_playwright_ts/blob/main/.github/workflows/01_ui_tests_chrome.yml"
    click CI2 "https://github.com/rajatt95/testautomationframework_yt_rajat_web_playwright_ts/blob/main/.github/workflows/02_ui_tests_select_one.yml"
    click CI3 "https://github.com/rajatt95/testautomationframework_yt_rajat_web_playwright_ts/blob/main/.github/workflows/03_ui_tests_ALL.yml"
    click LoginSpec "https://github.com/rajatt95/testautomationframework_yt_rajat_web_playwright_ts/blob/main/tests-saucedemo/login.spec.ts"
    click ComponentsSpec "https://github.com/rajatt95/testautomationframework_yt_rajat_web_playwright_ts/blob/main/tests-saucedemo/components.spec.ts"
    click BasePage "https://github.com/rajatt95/testautomationframework_yt_rajat_web_playwright_ts/blob/main/pages/BasePage.ts"
    click LoginPage "https://github.com/rajatt95/testautomationframework_yt_rajat_web_playwright_ts/blob/main/pages/LoginPage.ts"
    click ProductsPage "https://github.com/rajatt95/testautomationframework_yt_rajat_web_playwright_ts/blob/main/pages/ProductsPage.ts"
    click CartPage "https://github.com/rajatt95/testautomationframework_yt_rajat_web_playwright_ts/blob/main/pages/CartPage.ts"
    click ComponentsPage "https://github.com/rajatt95/testautomationframework_yt_rajat_web_playwright_ts/blob/main/pages/Components.ts"
    click WaitUtils "https://github.com/rajatt95/testautomationframework_yt_rajat_web_playwright_ts/blob/main/utils/WaitUtils.ts"
    click VerificationUtils "https://github.com/rajatt95/testautomationframework_yt_rajat_web_playwright_ts/blob/main/utils/VerificationUtils.ts"
    click LoginData "https://github.com/rajatt95/testautomationframework_yt_rajat_web_playwright_ts/blob/main/test-data/login_credentials.json"

    %% Styles
    classDef ci fill:#cce5ff,stroke:#004085,color:#004085;
    classDef runner fill:#d1ecf1,stroke:#0c5460,color:#0c5460;
    classDef config fill:#e2e3e5,stroke:#6c757d,color:#383d41;
    classDef tests fill:#d4edda,stroke:#155724,color:#155724;
    classDef pom fill:#fff3cd,stroke:#856404,color:#856404;
    classDef util fill:#f8d7da,stroke:#721c24,color:#721c24;
    classDef data fill:#e2ffe2,stroke:#228B22,color:#228B22;
    classDef browser fill:#ffeeba,stroke:#856404,color:#856404;
    classDef report fill:#f0f0f0,stroke:#333333,color:#333333;
```
