How cuongnguyenphu2005/test_codeceptjs_ai_testing works
Project Type and Purpose
• This is an automated testing framework (not a full-stack web app) that uses CodeceptJS to execute UI tests against a RiderVolt login page.
• It integrates with Azure OpenAI (via a custom service client) to augment or generate test logic.
• Key use-cases: successful/failed login, email-format validation, AI-powered tests, and Allure reporting.
File Structure
• Top-level files:
– codecept.conf.js: CodeceptJS configuration (test runner, helpers, output paths).
– package.json/package-lock.json: dependencies (CodeceptJS, Playwright, Azure SDK, Allure plugin).
• Directories:
– pages/ (Page Objects): encapsulate selectors and UI interactions.
– services/ (Model Client): wraps Azure OpenAI API calls.
– test_data/ (Fixtures): static JSON test inputs.
– tests/ (Test Scenarios): login_test.js, filless_login_test.js, ai_test.js.
– output/ (not in repo but generated): Allure results and HTML reports.
README for Insights
• The README confirms:
– Use of CodeceptJS with Playwright under the hood.
– Azure OpenAI for “AI” scenarios.
– Allure plugin for test-report generation.
– Environment variables (.env) for Azure credentials.
Main Components
a. Test Runner (CodeceptJS orchestrator)
b. Test Scenario Modules (tests/*.js)
c. Page Object Layer (pages/LoginPage.js)
d. Service Layer (services/modelClient.js)
e. Test Data Layer (test_data/loginData.json)
f. Reporting Engine (Allure plugin → output/)
g. External Service (Azure OpenAI REST API)
h. Browser Automation Engine (Playwright/WebDriver)
Relationships & Interactions
• The Test Runner loads Test Scenario Modules.
• Each Scenario:
– Imports Page Object(s) to perform UI actions in the browser.
– Reads test data from test_data.
– Optionally calls the modelClient service to query Azure OpenAI.
• modelClient → sends HTTPS requests to Azure OpenAI endpoint (using API key).
• Test Runner pipes execution logs & results into the Allure plugin → writes to output/.
• At the end, the “npx allure serve output” command renders HTML artifacts.
Architectural Patterns & Design Principles
• Layered architecture:
– Presentation layer: Page Objects abstract UI selectors.
– Business/test logic layer: Test Scenario files drive workflows.
– Integration layer: modelClient service for external API calls.
– Data layer: static test fixtures.
• Separation of concerns: UI actions vs. test definitions vs. external calls vs. reporting.
• Extensibility: Add new Page Objects under pages/, new scenarios under tests/, new data under test_data/, and new services under services/.