UI States & Dynamic Behavior
Run 35 test cases across 4 parallel agents covering loading states, empty/error states, overlays, and animations.
Setup
URL="${ARGUMENTS:-http://localhost:3000}"
TIMESTAMP=$(date +%Y%m%d-%H%M%S)
OUTDIR="test-results/test-states/$TIMESTAMP"
mkdir -p "$OUTDIR/screenshots" "$OUTDIR/snapshots" "$OUTDIR/traces"
Parallel Execution — 4 Subagents
Agent 1: Loading (-s=states-loading)
Tests loading, skeleton, and transition states.
playwright-cli -s=states-loading open "$URL"
playwright-cli -s=states-loading tracing-start
Test Cases:
| TC |
Test |
How to Check |
| TC-ST1 |
Loading spinner appears during async ops |
run-code to intercept network requests (delay responses), check for spinner/loading indicator |
| TC-ST2 |
Skeleton screens render before data loads |
run-code to intercept API calls (delay response), check for skeleton CSS (animated pulse/shimmer) |
| TC-ST3 |
No FOUC (Flash of Unstyled Content) |
run-code to observe page load, check if unstyled flash occurs (watch for style recalculation) |
| TC-ST4 |
No layout shift when content loads |
run-code to measure CLS during page load via PerformanceObserver |
| TC-ST5 |
Progressive loading — above-fold first |
run-code to check if above-fold images/content load before below-fold |
| TC-ST6 |
Optimistic UI — updates before server response |
run-code to intercept a mutation request (delay it), check if UI updates immediately |
| TC-ST7 |
Loading states on buttons (prevent double-click) |
Click a submit button, check if it shows loading state / becomes disabled |
playwright-cli -s=states-loading tracing-stop
playwright-cli -s=states-loading close
Agent 2: Empty/Error (-s=states-empty)
Tests empty states, error states, and edge cases.
playwright-cli -s=states-empty open "$URL"
playwright-cli -s=states-empty tracing-start
Test Cases:
| TC |
Test |
How to Check |
| TC-ST8 |
Empty state shown for empty lists/tables |
run-code to mock API returning empty array, check for empty state UI |
| TC-ST9 |
Empty state has helpful CTA |
When empty state shown, check for action button/link (e.g., "Add your first item") |
| TC-ST10 |
404 page exists and is helpful |
Navigate to $URL/nonexistent-page-xyz-404, verify custom 404 page with navigation back |
| TC-ST11 |
500 error page exists (no stack trace) |
run-code to mock API returning 500, check error page doesn't show stack trace |
| TC-ST12 |
Network error state (offline/timeout) |
run-code to set page offline mode, trigger action, check for error UI |
| TC-ST13 |
Permission denied state |
run-code to mock API returning 403, check for appropriate UI |
| TC-ST14 |
Session expired state + redirect |
run-code to mock API returning 401, check for redirect to login or session expired message |
| TC-ST15 |
Partial failure — some items load, some don't |
run-code to mock mixed success/failure responses, verify partial UI renders |
playwright-cli -s=states-empty tracing-stop
playwright-cli -s=states-empty close
Agent 3: Overlays (-s=states-overlay)
Tests modals, toasts, tooltips, and dropdowns.
playwright-cli -s=states-overlay open "$URL"
playwright-cli -s=states-overlay tracing-start
playwright-cli -s=states-overlay snapshot --filename="$OUTDIR/snapshots/overlay-initial.yaml"
Test Cases:
| TC |
Test |
How to Check |
| TC-ST16 |
Modal opens/closes correctly |
Find and click modal trigger, verify modal appears. Click close, verify dismissed |
| TC-ST17 |
Modal traps focus (Tab cycles within) |
Open modal, Tab repeatedly, verify focus stays within modal via run-code checking activeElement |
| TC-ST18 |
Modal closes on Escape |
Open modal, press Escape, verify modal dismissed |
| TC-ST19 |
Modal closes on backdrop click |
Open modal, click outside modal content area, verify dismissed |
| TC-ST20 |
Body scroll locked when modal open |
Open modal, run-code to check document.body.style.overflow is hidden |
| TC-ST21 |
Multiple modals stack correctly |
If multiple modals possible: open two, verify z-index stacking, top modal is interactive |
| TC-ST22 |
Toast/notification appears + auto-dismisses |
Trigger toast (e.g., form submit), verify it appears then disappears after timeout |
| TC-ST23 |
Multiple toasts stack (don't overlap) |
Trigger multiple toasts, verify they stack vertically without overlapping |
| TC-ST24 |
Tooltip shows on hover + keyboard focus |
hover over tooltip trigger, verify tooltip appears. Tab to it, verify also appears |
| TC-ST25 |
Dropdown closes on outside click |
Open dropdown, click outside it, verify it closes |
| TC-ST26 |
Dropdown closes on Escape |
Open dropdown, press Escape, verify it closes |
| TC-ST27 |
Context menu doesn't go off-screen |
run-code to find context menus/dropdowns near edges, verify they reposition to stay in viewport |
playwright-cli -s=states-overlay tracing-stop
playwright-cli -s=states-overlay close
Agent 4: Animation (-s=states-animation)
Tests animations, transitions, and motion.
playwright-cli -s=states-animation open "$URL"
playwright-cli -s=states-animation tracing-start
Test Cases:
| TC |
Test |
How to Check |
| TC-ST28 |
Animations are smooth (no jank) |
run-code with requestAnimationFrame to measure frame timing, flag >16ms gaps |
| TC-ST29 |
prefers-reduced-motion disables animations |
run-code: page.emulateMedia({reducedMotion:'reduce'}), verify animations disabled via computed transition/animation styles |
| TC-ST30 |
Transitions complete (not stuck mid-animation) |
run-code to observe transition elements, verify they reach final state |
| TC-ST31 |
Hover effects work |
hover over interactive elements, run-code to check style changes (color, background, transform) |
| TC-ST32 |
Active/pressed states visible on buttons |
run-code to simulate mousedown on buttons, check for active state styles |
| TC-ST33 |
Scroll-triggered animations fire |
run-code to scroll page, check if animation classes are added to elements entering viewport |
| TC-ST34 |
Page transitions in SPA (not abrupt) |
Navigate between pages, check for transition effects (fade, slide) rather than abrupt replacement |
| TC-ST35 |
Micro-interactions smooth |
Find toggle switches/checkboxes, interact, check for smooth animation via run-code |
playwright-cli -s=states-animation tracing-stop
playwright-cli -s=states-animation close
Report Generation
After all 4 agents complete, merge results into $OUTDIR/report.md following the standard report format.
Group results by agent category:
- Loading (TC-ST1 through TC-ST7)
- Empty/Error (TC-ST8 through TC-ST15)
- Overlays (TC-ST16 through TC-ST27)
- Animation (TC-ST28 through TC-ST35)
Cleanup
playwright-cli -s=states-loading close 2>/dev/null
playwright-cli -s=states-empty close 2>/dev/null
playwright-cli -s=states-overlay close 2>/dev/null
playwright-cli -s=states-animation close 2>/dev/null
1---2name: test-states-23description: Test UI states and dynamic behavior including loading, empty, error, overlay, and animation states. Use when user wants to test modals, toasts, loading spinners, empty states, error handling, or animations.4---56# UI States & Dynamic Behavior78Run 35 test cases across 4 parallel agents covering loading states, empty/error states, overlays, and animations.910## Setup1112```bash13URL="${ARGUMENTS:-http://localhost:3000}"14TIMESTAMP=$(date +%Y%m%d-%H%M%S)15OUTDIR="test-results/test-states/$TIMESTAMP"16mkdir -p "$OUTDIR/screenshots" "$OUTDIR/snapshots" "$OUTDIR/traces"17```1819## Parallel Execution — 4 Subagents2021### Agent 1: Loading (`-s=states-loading`)2223Tests loading, skeleton, and transition states.2425```bash26playwright-cli -s=states-loading open "$URL"27playwright-cli -s=states-loading tracing-start28```2930**Test Cases:**3132| TC | Test | How to Check |33|----|------|-------------|34| TC-ST1 | Loading spinner appears during async ops | `run-code` to intercept network requests (delay responses), check for spinner/loading indicator |35| TC-ST2 | Skeleton screens render before data loads | `run-code` to intercept API calls (delay response), check for skeleton CSS (animated pulse/shimmer) |36| TC-ST3 | No FOUC (Flash of Unstyled Content) | `run-code` to observe page load, check if unstyled flash occurs (watch for style recalculation) |37| TC-ST4 | No layout shift when content loads | `run-code` to measure CLS during page load via PerformanceObserver |38| TC-ST5 | Progressive loading — above-fold first | `run-code` to check if above-fold images/content load before below-fold |39| TC-ST6 | Optimistic UI — updates before server response | `run-code` to intercept a mutation request (delay it), check if UI updates immediately |40| TC-ST7 | Loading states on buttons (prevent double-click) | Click a submit button, check if it shows loading state / becomes disabled |4142```bash43playwright-cli -s=states-loading tracing-stop44playwright-cli -s=states-loading close45```4647### Agent 2: Empty/Error (`-s=states-empty`)4849Tests empty states, error states, and edge cases.5051```bash52playwright-cli -s=states-empty open "$URL"53playwright-cli -s=states-empty tracing-start54```5556**Test Cases:**5758| TC | Test | How to Check |59|----|------|-------------|60| TC-ST8 | Empty state shown for empty lists/tables | `run-code` to mock API returning empty array, check for empty state UI |61| TC-ST9 | Empty state has helpful CTA | When empty state shown, check for action button/link (e.g., "Add your first item") |62| TC-ST10 | 404 page exists and is helpful | Navigate to `$URL/nonexistent-page-xyz-404`, verify custom 404 page with navigation back |63| TC-ST11 | 500 error page exists (no stack trace) | `run-code` to mock API returning 500, check error page doesn't show stack trace |64| TC-ST12 | Network error state (offline/timeout) | `run-code` to set page offline mode, trigger action, check for error UI |65| TC-ST13 | Permission denied state | `run-code` to mock API returning 403, check for appropriate UI |66| TC-ST14 | Session expired state + redirect | `run-code` to mock API returning 401, check for redirect to login or session expired message |67| TC-ST15 | Partial failure — some items load, some don't | `run-code` to mock mixed success/failure responses, verify partial UI renders |6869```bash70playwright-cli -s=states-empty tracing-stop71playwright-cli -s=states-empty close72```7374### Agent 3: Overlays (`-s=states-overlay`)7576Tests modals, toasts, tooltips, and dropdowns.7778```bash79playwright-cli -s=states-overlay open "$URL"80playwright-cli -s=states-overlay tracing-start81playwright-cli -s=states-overlay snapshot --filename="$OUTDIR/snapshots/overlay-initial.yaml"82```8384**Test Cases:**8586| TC | Test | How to Check |87|----|------|-------------|88| TC-ST16 | Modal opens/closes correctly | Find and click modal trigger, verify modal appears. Click close, verify dismissed |89| TC-ST17 | Modal traps focus (Tab cycles within) | Open modal, Tab repeatedly, verify focus stays within modal via `run-code` checking activeElement |90| TC-ST18 | Modal closes on Escape | Open modal, `press Escape`, verify modal dismissed |91| TC-ST19 | Modal closes on backdrop click | Open modal, click outside modal content area, verify dismissed |92| TC-ST20 | Body scroll locked when modal open | Open modal, `run-code` to check `document.body.style.overflow` is `hidden` |93| TC-ST21 | Multiple modals stack correctly | If multiple modals possible: open two, verify z-index stacking, top modal is interactive |94| TC-ST22 | Toast/notification appears + auto-dismisses | Trigger toast (e.g., form submit), verify it appears then disappears after timeout |95| TC-ST23 | Multiple toasts stack (don't overlap) | Trigger multiple toasts, verify they stack vertically without overlapping |96| TC-ST24 | Tooltip shows on hover + keyboard focus | `hover` over tooltip trigger, verify tooltip appears. Tab to it, verify also appears |97| TC-ST25 | Dropdown closes on outside click | Open dropdown, click outside it, verify it closes |98| TC-ST26 | Dropdown closes on Escape | Open dropdown, `press Escape`, verify it closes |99| TC-ST27 | Context menu doesn't go off-screen | `run-code` to find context menus/dropdowns near edges, verify they reposition to stay in viewport |100101```bash102playwright-cli -s=states-overlay tracing-stop103playwright-cli -s=states-overlay close104```105106### Agent 4: Animation (`-s=states-animation`)107108Tests animations, transitions, and motion.109110```bash111playwright-cli -s=states-animation open "$URL"112playwright-cli -s=states-animation tracing-start113```114115**Test Cases:**116117| TC | Test | How to Check |118|----|------|-------------|119| TC-ST28 | Animations are smooth (no jank) | `run-code` with requestAnimationFrame to measure frame timing, flag >16ms gaps |120| TC-ST29 | `prefers-reduced-motion` disables animations | `run-code`: `page.emulateMedia({reducedMotion:'reduce'})`, verify animations disabled via computed transition/animation styles |121| TC-ST30 | Transitions complete (not stuck mid-animation) | `run-code` to observe transition elements, verify they reach final state |122| TC-ST31 | Hover effects work | `hover` over interactive elements, `run-code` to check style changes (color, background, transform) |123| TC-ST32 | Active/pressed states visible on buttons | `run-code` to simulate mousedown on buttons, check for active state styles |124| TC-ST33 | Scroll-triggered animations fire | `run-code` to scroll page, check if animation classes are added to elements entering viewport |125| TC-ST34 | Page transitions in SPA (not abrupt) | Navigate between pages, check for transition effects (fade, slide) rather than abrupt replacement |126| TC-ST35 | Micro-interactions smooth | Find toggle switches/checkboxes, interact, check for smooth animation via `run-code` |127128```bash129playwright-cli -s=states-animation tracing-stop130playwright-cli -s=states-animation close131```132133## Report Generation134135After all 4 agents complete, merge results into `$OUTDIR/report.md` following the standard report format.136137Group results by agent category:1381. Loading (TC-ST1 through TC-ST7)1392. Empty/Error (TC-ST8 through TC-ST15)1403. Overlays (TC-ST16 through TC-ST27)1414. Animation (TC-ST28 through TC-ST35)142143## Cleanup144145```bash146playwright-cli -s=states-loading close 2>/dev/null147playwright-cli -s=states-empty close 2>/dev/null148playwright-cli -s=states-overlay close 2>/dev/null149playwright-cli -s=states-animation close 2>/dev/null150```