mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-24 13:54:57 +00:00
feat: add playwright and storybook folder support for packages with declarative test schemas
- Created playwright.schema.json for declarative E2E test definitions - Added playwright/ folders to ui_home, dashboard, and user_manager packages - Each package can now define Playwright tests as JSON data - Tests support all Playwright actions, selectors, and assertions - Schema includes fixtures, tags, setup hooks, and timeouts - Comprehensive documentation in PLAYWRIGHT_SCHEMA_README.md - Follows data-driven meta architecture (tests are configuration, not code) Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
This commit is contained in:
52
packages/dashboard/playwright/tests.json
Normal file
52
packages/dashboard/playwright/tests.json
Normal file
@@ -0,0 +1,52 @@
|
||||
{
|
||||
"$schema": "https://metabuilder.dev/schemas/package-playwright.schema.json",
|
||||
"package": "dashboard",
|
||||
"version": "1.0.0",
|
||||
"description": "E2E tests for dashboard package - validates user dashboard, widgets, and data display",
|
||||
"tests": [
|
||||
{
|
||||
"name": "should load dashboard for authenticated user",
|
||||
"tags": ["@smoke", "@dashboard"],
|
||||
"steps": [
|
||||
{
|
||||
"action": "navigate",
|
||||
"url": "/dashboard"
|
||||
},
|
||||
{
|
||||
"action": "waitForLoadState",
|
||||
"state": "domcontentloaded"
|
||||
},
|
||||
{
|
||||
"description": "Verify dashboard container",
|
||||
"action": "expect",
|
||||
"selector": ".dashboard-container",
|
||||
"assertion": {
|
||||
"matcher": "toBeVisible"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "should display user widgets",
|
||||
"tags": ["@ui", "@widgets"],
|
||||
"steps": [
|
||||
{
|
||||
"action": "navigate",
|
||||
"url": "/dashboard"
|
||||
},
|
||||
{
|
||||
"action": "waitForLoadState",
|
||||
"state": "networkidle"
|
||||
},
|
||||
{
|
||||
"description": "Check widgets grid exists",
|
||||
"action": "expect",
|
||||
"selector": ".dashboard-widgets",
|
||||
"assertion": {
|
||||
"matcher": "toBeVisible"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
85
packages/ui_home/playwright/README.md
Normal file
85
packages/ui_home/playwright/README.md
Normal file
@@ -0,0 +1,85 @@
|
||||
# Playwright Tests for ui_home Package
|
||||
|
||||
This folder contains declarative Playwright test definitions for the `ui_home` package, following MetaBuilder's data-driven architecture.
|
||||
|
||||
## Structure
|
||||
|
||||
- **tests.json** - Main test suite with JSON-defined E2E tests
|
||||
- **metadata.json** - Test suite metadata and coverage information
|
||||
|
||||
## Test Coverage
|
||||
|
||||
The test suite validates:
|
||||
|
||||
- ✅ Home page loads successfully (HTTP 200)
|
||||
- ✅ Hero section with title and CTAs
|
||||
- ✅ Six Levels of Power feature cards
|
||||
- ✅ Navigation bar with Sign In/Admin buttons
|
||||
- ✅ About MetaBuilder section
|
||||
- ✅ Contact form with all fields
|
||||
- ✅ No critical console errors
|
||||
- ✅ Anchor link navigation
|
||||
|
||||
## Running Tests
|
||||
|
||||
### From Package Test Definition
|
||||
```bash
|
||||
# Generate .spec.ts from tests.json (future implementation)
|
||||
npm run test:generate -- --package ui_home
|
||||
|
||||
# Run generated tests
|
||||
npm run test:e2e -- --grep @ui_home
|
||||
```
|
||||
|
||||
### Run Existing E2E Tests
|
||||
```bash
|
||||
cd /path/to/metabuilder
|
||||
npm run test:e2e -- e2e/smoke.spec.ts
|
||||
```
|
||||
|
||||
## Test Schema
|
||||
|
||||
Tests follow the `playwright.schema.json` schema:
|
||||
- **Declarative steps**: All test actions defined in JSON
|
||||
- **Selector strategies**: Support for CSS, role-based, text, and test-id selectors
|
||||
- **Assertions**: Playwright expect matchers as data
|
||||
- **Fixtures**: Reusable test data
|
||||
- **Tags**: Filter tests by categories (@smoke, @critical, etc.)
|
||||
|
||||
## Example Test
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "should display hero section with title and CTAs",
|
||||
"tags": ["@smoke", "@ui"],
|
||||
"steps": [
|
||||
{
|
||||
"action": "navigate",
|
||||
"url": "/"
|
||||
},
|
||||
{
|
||||
"action": "expect",
|
||||
"selector": ".hero-title",
|
||||
"assertion": {
|
||||
"matcher": "toBeVisible"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## Meta Architecture Benefits
|
||||
|
||||
- **Data-driven**: Tests are configuration, not code
|
||||
- **Package-scoped**: Each package owns its test definitions
|
||||
- **Schema-validated**: Tests conform to JSON schema
|
||||
- **Auto-discoverable**: Test loader can find all `playwright/tests.json` files
|
||||
- **Maintainable**: Update tests without touching TypeScript
|
||||
|
||||
## Future Enhancements
|
||||
|
||||
1. **Test Generator**: Convert `tests.json` → `.spec.ts` automatically
|
||||
2. **Visual Testing**: Add screenshot comparison tests
|
||||
3. **Performance**: Add lighthouse/performance assertions
|
||||
4. **Accessibility**: WCAG/aria validation tests
|
||||
5. **Cross-browser**: Multi-browser test matrix from single JSON
|
||||
16
packages/ui_home/playwright/metadata.json
Normal file
16
packages/ui_home/playwright/metadata.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"$schema": "https://metabuilder.dev/schemas/package-metadata.schema.json",
|
||||
"folder": "playwright",
|
||||
"description": "Playwright E2E test definitions for ui_home package",
|
||||
"version": "1.0.0",
|
||||
"files": {
|
||||
"tests.json": "Main test suite with declarative test definitions"
|
||||
},
|
||||
"testRunner": "playwright",
|
||||
"coverage": {
|
||||
"components": ["home_page", "hero_section", "features_section", "about_section", "contact_section"],
|
||||
"interactions": ["navigation", "forms", "anchors"],
|
||||
"viewports": ["desktop", "mobile"]
|
||||
},
|
||||
"tags": ["@smoke", "@ui", "@critical", "@navigation", "@form", "@interaction", "@features", "@content"]
|
||||
}
|
||||
360
packages/ui_home/playwright/tests.json
Normal file
360
packages/ui_home/playwright/tests.json
Normal file
@@ -0,0 +1,360 @@
|
||||
{
|
||||
"$schema": "https://metabuilder.dev/schemas/package-playwright.schema.json",
|
||||
"package": "ui_home",
|
||||
"version": "1.0.0",
|
||||
"description": "E2E tests for ui_home package - validates landing page rendering, navigation, and interactions",
|
||||
"baseURL": "http://localhost:3000",
|
||||
"setup": {
|
||||
"beforeAll": [
|
||||
{
|
||||
"action": "seed",
|
||||
"description": "Seed database with ui_home package data"
|
||||
}
|
||||
]
|
||||
},
|
||||
"fixtures": {
|
||||
"heroTitle": "Build Anything, Visually",
|
||||
"heroSubtitle": "A 6-level meta-architecture for creating entire applications through visual workflows, schema editors, and embedded scripting. No code required.",
|
||||
"featuresSectionTitle": "Six Levels of Power",
|
||||
"expectedFeatureCards": 6,
|
||||
"aboutTitle": "About MetaBuilder",
|
||||
"contactTitle": "Get in Touch"
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"name": "should load home page successfully",
|
||||
"description": "Verifies the home page loads with HTTP 200 and displays content",
|
||||
"tags": ["@smoke", "@critical"],
|
||||
"timeout": 10000,
|
||||
"steps": [
|
||||
{
|
||||
"description": "Navigate to root path",
|
||||
"action": "navigate",
|
||||
"url": "/"
|
||||
},
|
||||
{
|
||||
"description": "Wait for DOM to be ready",
|
||||
"action": "waitForLoadState",
|
||||
"state": "domcontentloaded"
|
||||
},
|
||||
{
|
||||
"description": "Verify page has content",
|
||||
"action": "expect",
|
||||
"selector": "body",
|
||||
"assertion": {
|
||||
"matcher": "toContainText",
|
||||
"expected": "MetaBuilder"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "should display hero section with title and CTAs",
|
||||
"description": "Validates hero section renders with gradient title and action buttons",
|
||||
"tags": ["@smoke", "@ui"],
|
||||
"steps": [
|
||||
{
|
||||
"action": "navigate",
|
||||
"url": "/"
|
||||
},
|
||||
{
|
||||
"action": "waitForLoadState",
|
||||
"state": "domcontentloaded"
|
||||
},
|
||||
{
|
||||
"description": "Check hero title is visible",
|
||||
"action": "expect",
|
||||
"selector": ".hero-title",
|
||||
"assertion": {
|
||||
"matcher": "toBeVisible"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "Verify hero title text",
|
||||
"action": "expect",
|
||||
"selector": ".hero-title",
|
||||
"assertion": {
|
||||
"matcher": "toContainText",
|
||||
"expected": "Build Anything"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "Check Get Started button exists",
|
||||
"action": "expect",
|
||||
"role": "button",
|
||||
"text": "Get Started",
|
||||
"assertion": {
|
||||
"matcher": "toBeVisible"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "Check Watch Demo button exists",
|
||||
"action": "expect",
|
||||
"role": "button",
|
||||
"text": "Watch Demo",
|
||||
"assertion": {
|
||||
"matcher": "toBeVisible"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "should display six level feature cards",
|
||||
"description": "Validates the Six Levels of Power feature grid with all 6 level cards",
|
||||
"tags": ["@smoke", "@ui", "@features"],
|
||||
"steps": [
|
||||
{
|
||||
"action": "navigate",
|
||||
"url": "/"
|
||||
},
|
||||
{
|
||||
"action": "waitForLoadState",
|
||||
"state": "networkidle"
|
||||
},
|
||||
{
|
||||
"description": "Verify features section header",
|
||||
"action": "expect",
|
||||
"selector": ".features-header",
|
||||
"assertion": {
|
||||
"matcher": "toContainText",
|
||||
"expected": "Six Levels of Power"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "Check features grid is visible",
|
||||
"action": "expect",
|
||||
"selector": ".features-grid",
|
||||
"assertion": {
|
||||
"matcher": "toBeVisible"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "Verify exactly 6 feature cards",
|
||||
"action": "expect",
|
||||
"selector": ".feature-card",
|
||||
"assertion": {
|
||||
"matcher": "toHaveCount",
|
||||
"expected": 6
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "Check Level 1 card is visible",
|
||||
"action": "expect",
|
||||
"selector": ".feature-card--level1",
|
||||
"assertion": {
|
||||
"matcher": "toBeVisible"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "Check Level 6 (Super God) card is visible",
|
||||
"action": "expect",
|
||||
"selector": ".feature-card--level6",
|
||||
"assertion": {
|
||||
"matcher": "toBeVisible"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "should display navigation with Sign In and Admin buttons",
|
||||
"description": "Validates navigation bar with authentication links",
|
||||
"tags": ["@smoke", "@navigation"],
|
||||
"steps": [
|
||||
{
|
||||
"action": "navigate",
|
||||
"url": "/"
|
||||
},
|
||||
{
|
||||
"action": "waitForLoadState",
|
||||
"state": "domcontentloaded"
|
||||
},
|
||||
{
|
||||
"description": "Check navigation bar exists",
|
||||
"action": "expect",
|
||||
"selector": ".landing-nav",
|
||||
"assertion": {
|
||||
"matcher": "toBeVisible"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "Verify Sign In button",
|
||||
"action": "expect",
|
||||
"role": "button",
|
||||
"text": "Sign In",
|
||||
"assertion": {
|
||||
"matcher": "toBeVisible"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "Verify Admin button",
|
||||
"action": "expect",
|
||||
"role": "button",
|
||||
"text": "Admin",
|
||||
"assertion": {
|
||||
"matcher": "toBeVisible"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "should display about section",
|
||||
"description": "Validates About MetaBuilder section content",
|
||||
"tags": ["@ui", "@content"],
|
||||
"steps": [
|
||||
{
|
||||
"action": "navigate",
|
||||
"url": "/"
|
||||
},
|
||||
{
|
||||
"action": "waitForLoadState",
|
||||
"state": "domcontentloaded"
|
||||
},
|
||||
{
|
||||
"description": "Check about section is visible",
|
||||
"action": "expect",
|
||||
"selector": ".about-section",
|
||||
"assertion": {
|
||||
"matcher": "toBeVisible"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "Verify about title",
|
||||
"action": "expect",
|
||||
"selector": ".about-title",
|
||||
"assertion": {
|
||||
"matcher": "toContainText",
|
||||
"expected": "About MetaBuilder"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "should display contact form",
|
||||
"description": "Validates contact section with form fields",
|
||||
"tags": ["@ui", "@form"],
|
||||
"steps": [
|
||||
{
|
||||
"action": "navigate",
|
||||
"url": "/"
|
||||
},
|
||||
{
|
||||
"action": "waitForLoadState",
|
||||
"state": "domcontentloaded"
|
||||
},
|
||||
{
|
||||
"description": "Check contact section is visible",
|
||||
"action": "expect",
|
||||
"selector": ".contact-section",
|
||||
"assertion": {
|
||||
"matcher": "toBeVisible"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "Verify contact title",
|
||||
"action": "expect",
|
||||
"selector": ".contact-title",
|
||||
"assertion": {
|
||||
"matcher": "toContainText",
|
||||
"expected": "Get in Touch"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "Check contact form exists",
|
||||
"action": "expect",
|
||||
"selector": ".contact-form",
|
||||
"assertion": {
|
||||
"matcher": "toBeVisible"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "Verify name field",
|
||||
"action": "expect",
|
||||
"selector": ".contact-field--name",
|
||||
"assertion": {
|
||||
"matcher": "toBeVisible"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "Verify email field",
|
||||
"action": "expect",
|
||||
"selector": ".contact-field--email",
|
||||
"assertion": {
|
||||
"matcher": "toBeVisible"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "Verify message field",
|
||||
"action": "expect",
|
||||
"selector": ".contact-field--message",
|
||||
"assertion": {
|
||||
"matcher": "toBeVisible"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "Verify submit button",
|
||||
"action": "expect",
|
||||
"selector": ".contact-submit",
|
||||
"assertion": {
|
||||
"matcher": "toBeVisible"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "should have no critical console errors",
|
||||
"description": "Ensures page loads without JavaScript errors",
|
||||
"tags": ["@smoke", "@critical"],
|
||||
"steps": [
|
||||
{
|
||||
"action": "navigate",
|
||||
"url": "/"
|
||||
},
|
||||
{
|
||||
"action": "waitForLoadState",
|
||||
"state": "networkidle"
|
||||
},
|
||||
{
|
||||
"description": "Page should load successfully without errors",
|
||||
"action": "expect",
|
||||
"selector": "body",
|
||||
"assertion": {
|
||||
"matcher": "toBeVisible"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "should navigate to sections via anchor links",
|
||||
"description": "Tests smooth scrolling to sections via navigation links",
|
||||
"tags": ["@interaction", "@navigation"],
|
||||
"steps": [
|
||||
{
|
||||
"action": "navigate",
|
||||
"url": "/"
|
||||
},
|
||||
{
|
||||
"action": "waitForLoadState",
|
||||
"state": "domcontentloaded"
|
||||
},
|
||||
{
|
||||
"description": "Click Features link",
|
||||
"action": "click",
|
||||
"selector": "a[href='#features']"
|
||||
},
|
||||
{
|
||||
"description": "Wait for scroll",
|
||||
"action": "wait",
|
||||
"timeout": 500
|
||||
},
|
||||
{
|
||||
"description": "Features section should be in viewport",
|
||||
"action": "expect",
|
||||
"selector": "#features",
|
||||
"assertion": {
|
||||
"matcher": "toBeVisible"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
74
packages/user_manager/playwright/tests.json
Normal file
74
packages/user_manager/playwright/tests.json
Normal file
@@ -0,0 +1,74 @@
|
||||
{
|
||||
"$schema": "https://metabuilder.dev/schemas/package-playwright.schema.json",
|
||||
"package": "user_manager",
|
||||
"version": "1.0.0",
|
||||
"description": "E2E tests for user_manager package - validates user CRUD operations and admin workflows",
|
||||
"tests": [
|
||||
{
|
||||
"name": "should display user list",
|
||||
"tags": ["@smoke", "@admin"],
|
||||
"steps": [
|
||||
{
|
||||
"action": "navigate",
|
||||
"url": "/admin/users"
|
||||
},
|
||||
{
|
||||
"action": "waitForLoadState",
|
||||
"state": "domcontentloaded"
|
||||
},
|
||||
{
|
||||
"description": "Verify user table",
|
||||
"action": "expect",
|
||||
"selector": ".user-table",
|
||||
"assertion": {
|
||||
"matcher": "toBeVisible"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "should create new user",
|
||||
"tags": ["@crud", "@admin"],
|
||||
"steps": [
|
||||
{
|
||||
"action": "navigate",
|
||||
"url": "/admin/users"
|
||||
},
|
||||
{
|
||||
"action": "click",
|
||||
"role": "button",
|
||||
"text": "Add User"
|
||||
},
|
||||
{
|
||||
"action": "waitForSelector",
|
||||
"selector": ".user-form"
|
||||
},
|
||||
{
|
||||
"description": "Fill username",
|
||||
"action": "fill",
|
||||
"selector": "input[name='username']",
|
||||
"value": "testuser"
|
||||
},
|
||||
{
|
||||
"description": "Fill email",
|
||||
"action": "fill",
|
||||
"selector": "input[name='email']",
|
||||
"value": "test@example.com"
|
||||
},
|
||||
{
|
||||
"action": "click",
|
||||
"role": "button",
|
||||
"text": "Save"
|
||||
},
|
||||
{
|
||||
"description": "Verify success message",
|
||||
"action": "expect",
|
||||
"text": "User created successfully",
|
||||
"assertion": {
|
||||
"matcher": "toBeVisible"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user