# dannyjho/e2e-testing-playwright architecture

> Architecture diagram of the GitHub repository dannyjho/e2e-testing-playwright, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dannyjho/e2e-testing-playwright
- Repository: https://github.com/dannyjho/e2e-testing-playwright

## Overview

##### Project type and purpose
- This is an end-to-end (E2E) testing framework built with Playwright and TypeScript.
- Its goal is to validate user flows (login via various methods, adding items to cart) against a target web application, generate Allure test reports, and deploy those reports to GitHub Pages via GitHub Actions.

##### File structure
Top-level:
- .github/workflows/playwright.yml – CI/CD definition
- package.json / package-lock.json – npm dependencies & scripts
- playwright.config.ts / tsconfig.json – Playwright and TS config
- tests/ – all test code
– helpers/ – reusable flow abstractions (loginFlow, setLocaleToTaiwan)
– login/ – group of login-related specs
Patterns:
- Modular test helpers factor out common sequences
- Spec files under domain folders (login, cart) follow Playwright’s test runner conventions
- CI pipeline installs dependencies, runs tests, publishes reports

##### Extract insights from the README
- Tech stack: Playwright + TS, Allure for reporting, GitHub Actions for CI, GitHub Pages for hosting reports
- Workflow: on push to main → install deps → npx playwright install → run tests with Allure reporter → build & deploy report to gh-pages

##### Main components
a. Local Development Environment
- Developer machine with Node.js & Playwright CLI
- Tests folder (helpers + specs)
b. CI/CD Pipeline (GitHub Actions)
- Checkout repo
- npm install
- npx playwright install
- npx playwright test --reporter=line,allure-playwright
- allure generate & allure publish to gh-pages
c. Playwright Test Runner
- Browser drivers (Chromium/Firefox/WebKit)
- Test scripts invoke browser contexts, pages, selectors
d. Allure Reporter
- Collects test results, artifacts (screenshots, videos, logs)
- Generates static HTML report
e. GitHub Pages (gh-pages branch)
- Hosts the generated Allure report

##### Relationships and interactions
- Developer commits code → pushes to GitHub
- GitHub triggers Actions workflow → spins up runner → installs Node & Playwright browsers
- Workflow executes Playwright Test Runner against target web application URL(s)
- Tests leverage helpers to drive login / cart flows in browser instances
- Allure Reporter hooks capture results & artifacts → output report files
- Workflow pushes report to gh-pages branch → published on GitHub Pages
- Optionally: Developer can run same steps locally and serve report via Allure CLI

##### Architectural patterns & design principles
- Modularization: helpers vs specs
- Single source of truth for CI/CD in YAML
- Separation of concerns: test orchestration (CI) vs test implementation (Playwright code) vs reporting (Allure) vs hosting (Pages)
- Infrastructure as code: workflow configuration versioned alongside tests

##### What to capture in detail
- The sequence of CI steps and which config file drives each step (playwright.config.ts, tsconfig.json, yarn/npm scripts)
- How helpers are invoked by spec files
- Where test artifacts (screenshots, traces) are stored and how Allure picks them up
- How the workflow publishes to gh-pages

## Diagram (Mermaid)

```mermaid
flowchart TB
  %% Local Development Environment
  subgraph "Local Development Environment"
    L_PKG["package.json"]:::code
    L_TS["tsconfig.json"]:::code
    L_PWCONFIG["playwright.config.ts"]:::code
    L_README["README.md"]:::code
    L_LOCK["package-lock.json"]:::code
    DEV["Developer Machine\n(Node.js & Playwright CLI)"]:::external
  end

  %% CI/CD Pipeline
  subgraph "CI/CD Pipeline (GitHub Actions)"
    GH_A["GitHub Actions Runner"]:::ci
    WFLYML[".github/workflows/playwright.yml"]:::ci
    STEP1["Checkout Repo"]:::ci
    STEP2["npm install"]:::ci
    STEP3["npx playwright install"]:::ci
    STEP4["npx playwright test\n--reporter=line,allure-playwright"]:::ci
    STEP5["allure generate & publish"]:::ci
  end

  %% Playwright Test Runner
  subgraph "Playwright Test Runner"
    BROWSERS["Browser Drivers\n(Chromium/Firefox/WebKit)"]:::external
    HELPER_LF["loginFlow.ts"]:::code
    HELPER_SL["setLocaleToTaiwan.ts"]:::code
    SPEC_FB["login-facebook-oauth.spec.ts"]:::code
    SPEC_PW["login-with-password.spec.ts"]:::code
    CONFIG["playwright.config.ts"]:::code
    TS_CONF["tsconfig.json"]:::code
  end

  %% Reporting & Hosting
  subgraph "Reporting & Hosting"
    ALLURE["Allure Reporter"]:::report
    ARTIFACTS["Report Artifacts\n(screenshots, videos, logs)"]:::report
    GH_PAGES["GitHub Pages\n(gh-pages branch)"]:::storage
  end

  %% Relationships
  DEV -->|edits & runs| L_PKG
  DEV --> L_TS
  DEV --> L_PWCONFIG
  DEV --> L_README
  DEV --> L_LOCK

  DEV -->|"push code"| GH_A
  GH_A --> WFLYML
  WFLYML --> STEP1
  STEP1 --> STEP2
  STEP2 --> STEP3
  STEP3 --> STEP4
  STEP4 --> BROWSERS
  STEP4 --> HELPER_LF
  STEP4 --> HELPER_SL
  STEP4 --> SPEC_FB
  STEP4 --> SPEC_PW
  STEP4 --> CONFIG
  STEP4 --> TS_CONF
  STEP4 --> ALLURE
  ALLURE --> ARTIFACTS
  STEP5 --> GH_PAGES

  %% Click Events
  click L_PKG "https://github.com/dannyjho/e2e-testing-playwright/blob/main/package.json"
  click L_TS "https://github.com/dannyjho/e2e-testing-playwright/blob/main/tsconfig.json"
  click L_PWCONFIG "https://github.com/dannyjho/e2e-testing-playwright/blob/main/playwright.config.ts"
  click L_README "https://github.com/dannyjho/e2e-testing-playwright/blob/main/README.md"
  click L_LOCK "https://github.com/dannyjho/e2e-testing-playwright/blob/main/package-lock.json"
  click WFLYML "https://github.com/dannyjho/e2e-testing-playwright/blob/main/.github/workflows/playwright.yml"
  click HELPER_LF "https://github.com/dannyjho/e2e-testing-playwright/blob/main/tests/helpers/loginFlow.ts"
  click HELPER_SL "https://github.com/dannyjho/e2e-testing-playwright/blob/main/tests/helpers/setLocaleToTaiwan.ts"
  click SPEC_FB "https://github.com/dannyjho/e2e-testing-playwright/blob/main/tests/login/login-facebook-oauth.spec.ts"
  click SPEC_PW "https://github.com/dannyjho/e2e-testing-playwright/blob/main/tests/login/login-with-password.spec.ts"

  %% Styles
  classDef code fill:#e0f7e9,stroke:#2f8f4e,color:#2f8f4e
  classDef ci fill:#e0e9f7,stroke:#3f6fbf,color:#3f6fbf
  classDef report fill:#fff4e0,stroke:#d17f00,color:#d17f00
  classDef storage fill:#f0f0f0,stroke:#888888,color:#888888
  classDef external fill:#f5f5f5,stroke:#aaaaaa,color:#666666
```
