How slavapislyakov/demo_playwright works
Project type and purpose
• This is an end‑to‑end UI/API test automation framework built on Playwright.
• It uses a Page Object Model (page‑objects), service wrappers for API calls (servicies), structured test data (data), utilities (utils), and Allure for reporting.
Main architectural components
a. Test Runner & Configuration
• Playwright CLI (playwright.config.ts) invokes the test suite.
• NPM scripts in package.json (run:test, run:test:ui, allure:reporter).
b. Test Suite
• tests/*.spec.ts: orchestration layer where individual test scenarios live (e.g., enotes.spec.ts).
c. Page Object Layer
• page-objects/pages/*.ts: high‑level page abstractions (HomePage, BasketPage, LoginPage).
• page-objects/components/*.ts: reusable UI widgets (NavBar, BasketModal).
• page-objects/fixtures/pageFixtures.ts: fixture definitions to wire Page Objects into tests.
d. Services Layer
• servicies/*.ts: wrappers around backend API endpoints (BasketApi).
e. Data Layer
• data/*.ts: configuration and test data (endpoint_urls.ts, products.ts, modals, urls).
• data/credentials.ts: auth credentials.
f. Utilities
• utils/apiServiceUtil.ts: generic HTTP request helpers.
• utils/stringUtils.ts: text‑manipulation helpers.
g. Browser & Network Actors
• Browser instance managed by Playwright.
• External HTTP APIs called by service layer.
h. Reporting
• Allure reporter plugin collects and visualizes test results.
Relationships & data flow
1. The Test Runner reads playwright.config.ts and launches tests.
2. A spec file imports page fixtures and data, invokes high‑level flows:
• Calls Page Objects that use Playwright to manipulate the browser.
• Calls Service wrappers to perform direct HTTP calls.
3. Page Objects and Service wrappers leverage Utils and Data modules.
4. All interactions (UI and API) against the System Under Test (web application or backend).
5. Test outcomes (pass/fail, logs, screenshots) are fed to the Allure reporter.
Architectural patterns & design principles
• Page Object Model (POM) for UI abstraction.
• Single‑responsibility for each layer: tests orchestrate, page‑objects drive UI, services drive APIs, data centralizes test fixtures, utils factor out common code.
• Dependency injection via fixtures.
• Separation of concerns: clear layering prevents brittle tests.