|
| 1 | +--- |
| 2 | +name: playwright-validation |
| 3 | +description: Use when validating UI changes in a branch require Playwright E2E testing. Reviews branch changes, validates UI with Playwright MCP, and adds missing test cases. |
| 4 | +--- |
| 5 | + |
| 6 | +# Playwright Validation Skill |
| 7 | + |
| 8 | +This skill guides you through validating UI changes and ensuring comprehensive Playwright E2E test coverage. |
| 9 | + |
| 10 | +## When to Use |
| 11 | + |
| 12 | +- After completing UI feature development |
| 13 | +- Before creating a PR for UI changes |
| 14 | +- When reviewing UI-related branches |
| 15 | +- To verify existing Playwright tests cover all scenarios |
| 16 | + |
| 17 | +## Workflow |
| 18 | + |
| 19 | +### Phase 1: Review Branch Changes |
| 20 | + |
| 21 | +1. **Identify changed files vs main:** |
| 22 | + ```bash |
| 23 | + git diff main --stat |
| 24 | + git diff main --name-only | grep -E "\.(tsx?|less|css|scss)$" |
| 25 | + ``` |
| 26 | + |
| 27 | +2. **Focus on UI component changes:** |
| 28 | + ```bash |
| 29 | + git diff main -- "openmetadata-ui/src/main/resources/ui/src/components/**" --stat |
| 30 | + ``` |
| 31 | + |
| 32 | +3. **Check for existing Playwright tests:** |
| 33 | + ```bash |
| 34 | + git diff main --name-only | grep -E "playwright.*\.spec\.ts$" |
| 35 | + ``` |
| 36 | + |
| 37 | +4. **Read the changed component files** to understand the UI modifications |
| 38 | + |
| 39 | +### Phase 2: Review Existing Playwright Tests |
| 40 | + |
| 41 | +1. **Locate relevant test files:** |
| 42 | + - Check `playwright/e2e/Pages/` for page-level tests |
| 43 | + - Check `playwright/e2e/Features/` for feature-specific tests |
| 44 | + - Use Glob/Grep to find tests related to the feature |
| 45 | + |
| 46 | +2. **Analyze test coverage:** |
| 47 | + - Read the existing test file(s) |
| 48 | + - Identify the test scenarios already covered |
| 49 | + - Note any gaps in coverage based on the UI changes |
| 50 | + |
| 51 | +3. **Review test utilities:** |
| 52 | + - Check `playwright/utils/` for helper functions |
| 53 | + - Check `playwright/support/` for entity classes and fixtures |
| 54 | + |
| 55 | +### Phase 3: Validate with Playwright MCP |
| 56 | + |
| 57 | +1. **Start the browser and navigate:** |
| 58 | + ``` |
| 59 | + mcp__playwright__browser_navigate to http://localhost:8585 |
| 60 | + ``` |
| 61 | + |
| 62 | +2. **Authenticate if needed:** |
| 63 | + - Use `mcp__playwright__browser_fill_form` for login |
| 64 | + - Default admin: `admin@open-metadata.org` / `admin` |
| 65 | + |
| 66 | +3. **Navigate to the feature area:** |
| 67 | + - Use `mcp__playwright__browser_click` for navigation |
| 68 | + - Use `mcp__playwright__browser_snapshot` to inspect page state |
| 69 | + |
| 70 | +4. **Validate UI behavior:** |
| 71 | + - Test the main user flows |
| 72 | + - Verify visual elements (icons, badges, labels) |
| 73 | + - Check interactive elements (buttons, dropdowns, forms) |
| 74 | + - Verify state changes and API calls |
| 75 | + |
| 76 | +5. **Document findings:** |
| 77 | + - Note what works correctly |
| 78 | + - Identify any issues or missing functionality |
| 79 | + - List scenarios not covered by existing tests |
| 80 | + |
| 81 | +### Phase 4: Add Missing Test Cases |
| 82 | + |
| 83 | +1. **Create a TodoWrite checklist** of missing test scenarios |
| 84 | + |
| 85 | +2. **For each missing test case:** |
| 86 | + |
| 87 | + a. **Add necessary test fixtures** in `beforeAll`: |
| 88 | + - Create new entity instances (TableClass, DataProduct, etc.) |
| 89 | + - Set up required relationships (domains, assets) |
| 90 | + |
| 91 | + b. **Add cleanup** in `afterAll`: |
| 92 | + - Delete created entities in reverse order |
| 93 | + |
| 94 | + c. **Write the test** following the pattern: |
| 95 | + ```typescript |
| 96 | + test('Descriptive Test Name - What it validates', async ({ page }) => { |
| 97 | + test.setTimeout(300000); |
| 98 | + |
| 99 | + await test.step('Step description', async () => { |
| 100 | + // Test actions and assertions |
| 101 | + }); |
| 102 | + |
| 103 | + await test.step('Next step', async () => { |
| 104 | + // More actions and assertions |
| 105 | + }); |
| 106 | + }); |
| 107 | + ``` |
| 108 | + |
| 109 | +3. **Test patterns to cover:** |
| 110 | + - Happy path (expected behavior) |
| 111 | + - Edge cases (empty states, max values) |
| 112 | + - Error handling (invalid inputs, failed requests) |
| 113 | + - State transitions (before/after actions) |
| 114 | + - UI feedback (loading states, success/error messages) |
| 115 | + - Permissions (disabled buttons, restricted actions) |
| 116 | + |
| 117 | +4. **Run lint check:** |
| 118 | + ```bash |
| 119 | + yarn eslint playwright/e2e/Pages/YourTest.spec.ts |
| 120 | + ``` |
| 121 | + |
| 122 | +## Common Test Utilities |
| 123 | + |
| 124 | +### Navigation |
| 125 | +```typescript |
| 126 | +import { sidebarClick } from '../../utils/sidebar'; |
| 127 | +import { redirectToHomePage } from '../../utils/common'; |
| 128 | +import { selectDataProduct, selectDomain } from '../../utils/domain'; |
| 129 | +``` |
| 130 | + |
| 131 | +### Waiting |
| 132 | +```typescript |
| 133 | +import { waitForAllLoadersToDisappear } from '../../utils/entity'; |
| 134 | +await page.waitForLoadState('networkidle'); |
| 135 | +await page.waitForSelector('[data-testid="loader"]', { state: 'detached' }); |
| 136 | +``` |
| 137 | + |
| 138 | +### API Responses |
| 139 | +```typescript |
| 140 | +const response = page.waitForResponse('/api/v1/endpoint*'); |
| 141 | +await someAction(); |
| 142 | +await response; |
| 143 | +expect((await response).status()).toBe(200); |
| 144 | +``` |
| 145 | + |
| 146 | +### Assertions |
| 147 | +```typescript |
| 148 | +await expect(page.getByTestId('element')).toBeVisible(); |
| 149 | +await expect(page.getByTestId('element')).toContainText('text'); |
| 150 | +await expect(page.locator('.class')).not.toBeVisible(); |
| 151 | +``` |
| 152 | + |
| 153 | +## Checklist Before Completion |
| 154 | + |
| 155 | +- [ ] All UI changes have corresponding test coverage |
| 156 | +- [ ] Tests cover both positive and negative scenarios |
| 157 | +- [ ] Tests verify visual indicators (icons, badges, states) |
| 158 | +- [ ] Tests validate API interactions |
| 159 | +- [ ] Lint check passes with no errors |
| 160 | +- [ ] Test fixtures are properly created and cleaned up |
| 161 | +- [ ] Test timeouts are appropriate (300000ms for complex tests) |
| 162 | + |
| 163 | +## Example: Data Contract Inheritance Tests |
| 164 | + |
| 165 | +For reference, see the comprehensive test coverage in: |
| 166 | +`playwright/e2e/Pages/DataContractInheritance.spec.ts` |
| 167 | + |
| 168 | +This file demonstrates: |
| 169 | +- Multiple entity setup in beforeAll |
| 170 | +- Domain assignment patches |
| 171 | +- Contract creation and validation |
| 172 | +- Inheritance icon verification |
| 173 | +- Action button state verification (disabled/enabled) |
| 174 | +- API response validation (POST vs PATCH) |
| 175 | +- Fallback behavior testing |
0 commit comments