|
| 1 | +--- |
| 2 | +name: playwright-test |
| 3 | +description: Generate robust, zero-flakiness Playwright E2E tests following OpenMetadata patterns. Creates comprehensive test files with proper waits, API validation, multi-role permissions, and complete entity lifecycle management. |
| 4 | +user-invocable: true |
| 5 | +--- |
| 6 | + |
| 7 | +# Playwright Test Generator - OpenMetadata |
| 8 | + |
| 9 | +Generate production-ready, zero-flakiness Playwright tests following OpenMetadata conventions. |
| 10 | + |
| 11 | +## Usage |
| 12 | + |
| 13 | +``` |
| 14 | +/playwright-test |
| 15 | +Feature: <feature name> |
| 16 | +Category: <Features|Pages|Flow|VersionPages> |
| 17 | +Entity: <Table|Dashboard|Pipeline|Topic|Database|User|Team|Glossary|Other> |
| 18 | +Domain: <Governance|Discovery|Platform|Observability|Integration> |
| 19 | +Scenarios: |
| 20 | + - <scenario 1 description> |
| 21 | + - <scenario 2 description> |
| 22 | + - <scenario 3 description> |
| 23 | +Roles: <admin|dataConsumer|dataSteward|owner> (optional, defaults to admin) |
| 24 | +``` |
| 25 | + |
| 26 | +## Quick Example |
| 27 | + |
| 28 | +``` |
| 29 | +/playwright-test |
| 30 | +Feature: Data Quality Rules |
| 31 | +Category: Features |
| 32 | +Entity: Table |
| 33 | +Domain: Observability |
| 34 | +Scenarios: |
| 35 | + - Admin can create and configure data quality rules |
| 36 | + - Data consumer can view test results but not edit rules |
| 37 | + - Test results are persisted after page reload |
| 38 | +Roles: admin, dataConsumer |
| 39 | +``` |
| 40 | + |
| 41 | +--- |
| 42 | + |
| 43 | +## Instructions |
| 44 | + |
| 45 | +### Step 1: Read the Handbook FIRST |
| 46 | + |
| 47 | +**CRITICAL**: Before generating any tests, read and apply ALL patterns from: |
| 48 | + |
| 49 | +``` |
| 50 | +openmetadata-ui/src/main/resources/ui/playwright/PLAYWRIGHT_DEVELOPER_HANDBOOK.md |
| 51 | +``` |
| 52 | + |
| 53 | +The handbook contains: |
| 54 | +- Testing philosophy (user-centric, behavior-focused) |
| 55 | +- Anti-flakiness patterns (the :visible selector chain pattern, etc.) |
| 56 | +- Test timeout strategies (test.slow() vs test.setTimeout()) |
| 57 | +- Common test patterns (form submission, dropdowns, multi-role testing) |
| 58 | +- Locator priority guidelines |
| 59 | +- Support classes reference |
| 60 | +- Domain tags |
| 61 | +- Validation checklist |
| 62 | + |
| 63 | +**Apply ALL handbook principles before proceeding.** |
| 64 | + |
| 65 | +--- |
| 66 | + |
| 67 | +### Step 2: Generate Test Using Handbook Template |
| 68 | + |
| 69 | +Use the **Test File Structure Template** from the handbook. It includes: |
| 70 | +- Proper imports (performAdminLogin, entity classes, utilities) |
| 71 | +- test.describe with domain tags |
| 72 | +- beforeAll/afterAll for entity lifecycle via API |
| 73 | +- test.slow() for timeout handling |
| 74 | +- test.step() for clear organization |
| 75 | +- API response validation pattern |
| 76 | + |
| 77 | +--- |
| 78 | + |
| 79 | +### Step 3: Apply Common Test Patterns from Handbook |
| 80 | + |
| 81 | +Reference the **Common Test Patterns** section for: |
| 82 | +- Form submission with API validation |
| 83 | +- Dropdown selection (with :visible chain pattern) |
| 84 | +- Multi-role permission testing |
| 85 | +- Data persistence verification |
| 86 | +- Navigation patterns |
| 87 | +- Search and filter patterns |
| 88 | + |
| 89 | +--- |
| 90 | + |
| 91 | +### Step 4: Validate Against Handbook Checklist |
| 92 | + |
| 93 | +Before returning the generated test, verify ALL items from the handbook's **Validation Checklist**: |
| 94 | + |
| 95 | +- ✅ Structure & Organization (test.step, domain tags, imports, beforeAll/afterAll) |
| 96 | +- ✅ Anti-Flakiness (no waitForTimeout, no networkidle, no force: true, no positional selectors, no stored :visible locators) |
| 97 | +- ✅ API & Network (waitForResponse before actions, status code validation) |
| 98 | +- ✅ Waits & Assertions (waitForAllLoadersToDisappear, semantic locators, proper assertions) |
| 99 | +- ✅ Coverage & Roles (multi-role tests, data persistence, error handling) |
| 100 | + |
| 101 | +--- |
| 102 | + |
| 103 | +## Key Reminders |
| 104 | + |
| 105 | +**All patterns, rules, and best practices are in the handbook.** |
| 106 | + |
| 107 | +Read and apply the handbook sections in order: |
| 108 | +1. **Anti-Flakiness Patterns** (CRITICAL - #1 cause of flaky tests) |
| 109 | +2. **Test File Structure Template** (for proper test structure) |
| 110 | +3. **Common Test Patterns** (for specific scenarios) |
| 111 | +4. **Validation Checklist** (before returning generated test) |
| 112 | + |
| 113 | +--- |
| 114 | + |
| 115 | +## Final Notes |
| 116 | + |
| 117 | +- Generate **production-ready** tests that pass 10/10 times |
| 118 | +- Follow ALL patterns from the handbook exactly |
| 119 | +- No comments for obvious code (e.g., `// Create entity` before `entity.create()`) |
| 120 | +- Test independence - each test runs in any order |
| 121 | +- Reference examples: `playwright/e2e/Pages/DataContractInheritance.spec.ts`, `playwright/e2e/Features/Table.spec.ts` |
| 122 | + |
| 123 | +**Generate tests that are production-ready, maintainable, and zero-flakiness by following the handbook patterns exactly.** |
0 commit comments