Skip to content

Commit b80a192

Browse files
committed
Merge remote-tracking branch 'origin/develop' into feature/ci-pwa-kit-q3-perf
2 parents fb81711 + 3632d67 commit b80a192

File tree

122 files changed

+6780
-1195
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+6780
-1195
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
description: QA Tests for Template Retail React App Test Generation Rules
3+
globs: ["packages/template-retail-react-app/app/components/**/*-underTest.test.{js,jsx}"]
4+
alwaysApply: false
5+
---
6+
# 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

.github/CODEOWNERS

Lines changed: 60 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,64 @@
11
# https://help.github.com/en/enterprise/2.17/user/articles/about-code-owners
22

3-
# These owners will be the default owners for everything in
4-
# the repo. Unless a later match takes precedence,
5-
# @global-owner1 and @global-owner2 will be requested for
6-
# review when someone opens a pull request.
3+
# Global directories
4+
.cursor/ @SalesforceCommerceCloud/mobifyers
5+
.github/ @SalesforceCommerceCloud/mobifyers
6+
e2e/ @SalesforceCommerceCloud/mobifyers
7+
scripts/ @SalesforceCommerceCloud/mobifyers
8+
9+
# Package-specific ownership
10+
packages/commerce-sdk-react/ @SalesforceCommerceCloud/mobifyers
11+
packages/internal-lib-build/ @SalesforceCommerceCloud/mobifyers
12+
packages/pwa-kit-create-app/ @SalesforceCommerceCloud/mobifyers
13+
packages/pwa-kit-dev/ @SalesforceCommerceCloud/mobifyers
14+
packages/pwa-kit-mcp/ @SalesforceCommerceCloud/mobifyers
15+
packages/pwa-kit-react-sdk/ @SalesforceCommerceCloud/mobifyers
16+
packages/pwa-kit-runtime/ @SalesforceCommerceCloud/mobifyers
17+
packages/template-express-minimal/ @SalesforceCommerceCloud/mobifyers
18+
packages/template-mrt-reference-app/ @SalesforceCommerceCloud/mobifyers
19+
packages/template-retail-react-app/ @SalesforceCommerceCloud/mobifyers
20+
packages/template-typescript-minimal/ @SalesforceCommerceCloud/mobifyers
21+
packages/test-commerce-sdk-react/ @SalesforceCommerceCloud/mobifyers
22+
23+
# Root configuration and documentation files
24+
/README.md @SalesforceCommerceCloud/mobifyers
25+
/CODE_OF_CONDUCT.md @SalesforceCommerceCloud/mobifyers
26+
/CONTRIBUTING.md @SalesforceCommerceCloud/mobifyers
27+
/SECURITY.md @SalesforceCommerceCloud/mobifyers
28+
/STATEMENTS.md @SalesforceCommerceCloud/mobifyers
29+
/TERMS_OF_USE.md @SalesforceCommerceCloud/mobifyers
30+
/LICENSE @SalesforceCommerceCloud/mobifyers
31+
/.eslintrc.js @SalesforceCommerceCloud/mobifyers
32+
/.gitattributes @SalesforceCommerceCloud/mobifyers
33+
/.gitignore @SalesforceCommerceCloud/mobifyers
34+
/.prettierignore @SalesforceCommerceCloud/mobifyers
35+
/.prettierrc.yaml @SalesforceCommerceCloud/mobifyers
36+
/lerna.json @SalesforceCommerceCloud/mobifyers
37+
/package.json @SalesforceCommerceCloud/mobifyers
38+
/package-lock.json @SalesforceCommerceCloud/mobifyers
39+
/playwright.config.js @SalesforceCommerceCloud/mobifyers
40+
/.git2gus/ @SalesforceCommerceCloud/mobifyers
41+
42+
# Specific feature file ownership (overrides package-level rules above)
43+
44+
# BOPIS (Buy Online Pick up In Store) feature files - PR #2646
45+
packages/template-retail-react-app/app/components/store-display/ @SalesforceCommerceCloud/cc-spark
46+
packages/template-retail-react-app/app/hooks/use-selected-store.js @SalesforceCommerceCloud/cc-spark
47+
packages/template-retail-react-app/app/hooks/use-pickup-shipment.js @SalesforceCommerceCloud/cc-spark
48+
packages/template-retail-react-app/app/hooks/use-pickup-shipment.test.js @SalesforceCommerceCloud/cc-spark
49+
e2e/tests/desktop/bopis.spec.js @SalesforceCommerceCloud/cc-spark
50+
51+
# Bonus Products feature files - PR #2704
52+
packages/template-retail-react-app/app/components/product-item/bonus-product-quantity.jsx @SalesforceCommerceCloud/cc-sharks
53+
packages/template-retail-react-app/app/components/product-item/bonus-product-quantity.test.jsx @SalesforceCommerceCloud/cc-sharks
54+
packages/template-retail-react-app/app/components/product-item/product-quantity-picker.jsx @SalesforceCommerceCloud/cc-sharks
55+
packages/template-retail-react-app/app/components/product-item/product-quantity-picker.test.jsx @SalesforceCommerceCloud/cc-sharks
56+
packages/template-retail-react-app/app/pages/cart/partials/bonus-products-title.jsx @SalesforceCommerceCloud/cc-sharks
57+
packages/template-retail-react-app/app/pages/cart/partials/bonus-products-title.test.js @SalesforceCommerceCloud/cc-sharks
58+
59+
# Standard Products feature files - PR #2697
60+
packages/template-retail-react-app/app/mocks/standard-product.js @SalesforceCommerceCloud/cc-sharks
61+
packages/template-retail-react-app/app/utils/add-to-cart-utils.js @SalesforceCommerceCloud/cc-sharks
62+
763

8-
* @SalesforceCommerceCloud/mobifyers
964
#ECCN:Open Source

e2e/config.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module.exports = {
1313
GENERATED_PROJECTS_DIR: "../generated-projects",
1414
GENERATE_PROJECTS: ["retail-app-demo", "retail-app-ext", "retail-app-no-ext"],
1515
GENERATOR_CMD:
16-
"node packages/pwa-kit-create-app/scripts/create-mobify-app-dev.js --outputDir",
16+
"node packages/pwa-kit-create-app/scripts/create-mobify-app-dev.js --initGit --outputDir",
1717
CLI_RESPONSES: {
1818
"retail-app-demo": [
1919
{
@@ -112,6 +112,8 @@ module.exports = {
112112
},
113113
EXPECTED_GENERATED_ARTIFACTS: {
114114
"retail-app-demo": [
115+
".git",
116+
".gitignore",
115117
".cursor",
116118
".eslintignore",
117119
".eslintrc.js",
@@ -126,6 +128,8 @@ module.exports = {
126128
"worker",
127129
],
128130
"retail-app-ext": [
131+
".git",
132+
".gitignore",
129133
".cursor",
130134
".eslintignore",
131135
".eslintrc.js",

e2e/scripts/utils.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,11 @@ const getCreditCardExpiry = (yearsFromNow = 5) => {
4242
*/
4343
function simplifyViolations(violations) {
4444
return violations.map((violation) => ({
45-
id: violation.id, // Rule ID
46-
impact: violation.impact, // Impact (critical, serious, moderate, minor)
47-
description: violation.description, // Description of the rule
48-
help: violation.help, // Short description
45+
id: violation.id,
46+
// Severity of violation (critical, serious, moderate, minor)
47+
impact: violation.impact,
48+
description: violation.description,
49+
help: violation.help,
4950
helpUrl: violation.helpUrl,
5051
nodes: violation.nodes.map((node) => ({
5152
// Simplify the HTML to make it more stable for snapshots
@@ -54,7 +55,13 @@ function simplifyViolations(violations) {
5455
failureSummary: node.failureSummary,
5556
// Simplify target selectors for stability
5657
// #app-header[data-v-12345] > .navigation[data-testid="main-nav"] => #app-header > .navigation
57-
target: node.target.map((t) => t.split(/\[.*?\]/).join(''))
58+
// Also handle Chakra UI dynamic selectors like #popover-trigger-:r5l4v:
59+
target: node.target.map((t) =>
60+
t
61+
.split(/\[.*?\]/).join('') // Remove data attributes
62+
.replace(/#([^-\s]+(?:-[^:]*)?):([^"\s]*)/g, '#$1-...') // Remove Chakra UI dynamic IDs
63+
.replace(/\.css-[a-zA-Z0-9]+/g, '.css-...') // Simplify Chakra UI CSS classes
64+
)
5865
}))
5966
}))
6067
}
@@ -77,6 +84,10 @@ function sanitizeHtml(html) {
7784
.replace(/style="[^"]*"/g, '')
7885
// Remove content of script tags
7986
.replace(/<script\b[^>]*>([\s\S]*?)<\/script>/gi, '<script>...</script>')
87+
// Dynamic values - keep stable part:
88+
// Before: aria-controls="popover-content-:rn:"
89+
// After: aria-controls="popover-content-..."
90+
.replace(/(aria-(?:controls|describedby|labelledby|owns))="([^:]*?)(?::[^"]*)?"/g, '$1="$2..."')
8091
// Trim whitespace
8192
.trim()
8293
)

e2e/tests/a11y/desktop/__snapshots__/guest/cart-a11y-violations.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
"helpUrl": "https://dequeuniversity.com/rules/axe/4.10/aria-allowed-attr?application=playwright",
88
"nodes": [
99
{
10-
"html": "<form id=\"...\" aria-haspopup=\"dialog\" aria-expanded=\"false\" aria-controls=\"popover-content-:rh:\">",
10+
"html": "<form id=\"...\" aria-haspopup=\"dialog\" aria-expanded=\"false\" aria-controls=\"popover-content-...\">",
1111
"failureSummary": "Fix all of the following:\n ARIA attribute is not allowed: aria-expanded=\"false\"",
1212
"target": [
13-
"#popover-trigger-\\:rh\\:"
13+
"#popover-trigger-\\-..."
1414
]
1515
}
1616
]

e2e/tests/a11y/desktop/__snapshots__/guest/checkout-a11y-violations-step-0.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"html": "<a class=\"...\" aria-label=\"Back to cart, number of items: 2\" href=\"/cart\">",
2727
"failureSummary": "Fix any of the following:\n Some page content is not contained by landmarks",
2828
"target": [
29-
".css-1k2aozt"
29+
".css-..."
3030
]
3131
}
3232
]

e2e/tests/a11y/desktop/__snapshots__/guest/checkout-a11y-violations-step-1.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"html": "<a class=\"...\" aria-label=\"Back to cart, number of items: 2\" href=\"/cart\">",
2727
"failureSummary": "Fix any of the following:\n Some page content is not contained by landmarks",
2828
"target": [
29-
".css-1k2aozt"
29+
".css-..."
3030
]
3131
}
3232
]

e2e/tests/a11y/desktop/__snapshots__/guest/checkout-a11y-violations-step-2.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"html": "<a class=\"...\" aria-label=\"Back to cart, number of items: 2\" href=\"/cart\">",
2727
"failureSummary": "Fix any of the following:\n Some page content is not contained by landmarks",
2828
"target": [
29-
".css-1k2aozt"
29+
".css-..."
3030
]
3131
}
3232
]

e2e/tests/a11y/desktop/__snapshots__/guest/checkout-a11y-violations-step-3.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"html": "<a class=\"...\" aria-label=\"Back to cart, number of items: 2\" href=\"/cart\">",
2727
"failureSummary": "Fix any of the following:\n Some page content is not contained by landmarks",
2828
"target": [
29-
".css-1k2aozt"
29+
".css-..."
3030
]
3131
}
3232
]

e2e/tests/a11y/desktop/__snapshots__/guest/checkout-a11y-violations-step-4-order-confirmation.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"html": "<a class=\"...\" aria-label=\"Back to cart, number of items: 2\" href=\"/cart\">",
2727
"failureSummary": "Fix any of the following:\n Some page content is not contained by landmarks",
2828
"target": [
29-
".css-1k2aozt"
29+
".css-..."
3030
]
3131
}
3232
]

0 commit comments

Comments
 (0)