You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# QA Tests for Template Retail React App Test Patterns
7
+
8
+
## Purpose
9
+
This file contains test cases to verify that the `unit-tests-template-retail-react-app.mdc` rule effectively guides the creation of consistent and robust React component tests.
10
+
11
+
## Test Cases
12
+
13
+
### Test 1: DrawerMenu Component Test Generation
14
+
**Workflow:** Generate → Analyze → Cleanup (NO test execution)
15
+
16
+
**Steps:**
17
+
1. **Generate:** Create new test file `drawer-menu-underTest.test.js` (colocated with existing drawer-menu component at `packages/template-retail-react-app/app/components/drawer-menu/`)
18
+
2. **Apply Rules:** Use `@/testing` (located at `.cursor/rules/testing/unit-tests-generic.mdc` and `.cursor/rules/testing/unit-tests-template-retail-react-app.mdc`)
19
+
3. **Prompt:** "Write unit test for drawer-menu component"
20
+
4. **Analyze:** Perform static code analysis against verification patterns (see below)
21
+
5. **Cleanup:** Delete the generated test file after validation
22
+
23
+
**Important:** DO NOT run the test after creation - skip test execution entirely
24
+
25
+
**Verify that the newly generated test file follows these patterns:**
26
+
1. Test Setup
27
+
- Uses `renderWithProviders` from `@salesforce/retail-react-app/app/utils/test-utils`
28
+
- Gets user events from return value: `const {user} = renderWithProviders(...)`
29
+
- Includes `beforeEach(() => jest.clearAllMocks())`
30
+
31
+
2. Import Structure
32
+
- Does NOT import `userEvent` directly
33
+
- Uses existing mock data from `@salesforce/retail-react-app/app/mocks/`
34
+
- Imports `screen` from `@testing-library/react`
35
+
36
+
3. Test Organization
37
+
- Uses `describe` block with component name
38
+
- Individual `test` or `it` blocks for different scenarios
39
+
- Async/await patterns for user interactions
40
+
41
+
4. API Mocking
42
+
- Uses `prependHandlersToServer` or `msw` for API mocking when needed
43
+
44
+
**Failure Indicators:**
45
+
- Direct import of `userEvent` from `@testing-library/user-event`
46
+
- Using custom render function instead of `renderWithProviders`
47
+
- Creating new mock data instead of using existing mocks
48
+
- Missing Commerce SDK context providers
49
+
- Not using async/await for user interactions
50
+
51
+
**Expected Output:**
52
+
Provide a clear, structured report based on **static code analysis only** (no test execution):
53
+
- ✅ **PASS** or ❌ **FAIL** for each verification point
54
+
- Specific line numbers and code snippets for any failures
55
+
- Summary: `X/Y patterns followed correctly`
56
+
- Overall result: **RULES EFFECTIVE** or **RULES NEED IMPROVEMENT**
57
+
58
+
**Cleanup:**
59
+
- Delete the generated test file `drawer-menu-underTest.test.js` after QA validation is complete
0 commit comments