Skip to content

Latest commit

 

History

History
78 lines (64 loc) · 3.78 KB

architecture.md

File metadata and controls

78 lines (64 loc) · 3.78 KB

Architecture

The framework separates what a test checks (specs), how the application is driven (page objects), how tests get their fixtures and data, and where the environment is configured.

Layers

flowchart TD
    SPEC["tests/**/*.spec.js: what is checked"] --> FIX["src/fixtures: env, credentials, page fixtures, prod guard"]
    FIX --> PAGE["src/pages: BasePage and page objects: how the app is driven"]
    FIX --> DATA["src/data: routes and expected values"]
    FIX --> CFG["src/config: TEST_ENV loader, tags, paths"]
    CFG --> ENVF["config/environments/*.json: base URL and read-only flag"]
    PAGE --> PW["Playwright"]
    PW --> APP["Application under test"]
Loading

Text alternative: specs use fixtures. Fixtures provide page objects, data, and the environment. Page objects drive Playwright, which drives the application. The environment comes from src/config and the environment JSON files.

Layer Location Owns Must not
Specs tests/ the scenarios, assertions, and tags contain raw selectors or fixed waits
Fixtures src/fixtures/index.js shared setup, the production guard hold test-specific logic
Page objects src/pages/ locators and user actions contain assertions
Data src/data/ routes and expected text read the environment or credentials
Config src/config/, config/environments/ which environment to run and its settings store secrets

Page Object rules

  • One class per page or major component, extending BasePage.
  • Locators are created in the constructor. Actions are methods.
  • Methods do something a user does: login, openModule, searchByUsername.
  • Assertions live in specs, so a failure points at the test, not the page object.
  • Use role, label, and placeholder locators first. Use a class-based locator only when the app gives no accessible name, and comment why.

How a run is wired

sequenceDiagram
    participant U as Developer or CI
    participant C as playwright.config.js
    participant E as src/config/environment.js
    participant S as setup project (auth.setup.js)
    participant P as public project (login.spec.js)
    participant A as authenticated project
    participant R as reports/
    U->>C: bun run test (TEST_ENV)
    C->>E: loadEnvironment()
    E-->>C: baseUrl, readOnly
    C->>S: run setup first
    S->>S: log in, save playwright/.auth/user.json
    par public tests
        C->>P: run with no session
    and authenticated tests
        C->>A: run with saved session
    end
    P->>R: results
    A->>R: results
Loading

Text alternative: the developer runs the suite. The config loads the environment, then the setup project logs in and saves the session. The public tests run logged out, and the authenticated tests run with the saved session. Both write results to reports/.

Projects

Project Tests Session
setup tests/auth/auth.setup.js creates the session
public tests/auth/login.spec.js none (starts logged out)
authenticated everything else loaded from playwright/.auth/user.json

Decisions

The reasoning behind the main choices is in adr/.