Skip to content

Commit a693fe1

Browse files
committed
Add manual test runner for page-designer-decorator tool- Add automated test runner script (index.test.mjs) with 24 test cases- Support both temporary directory mode (default) and real Storefront Next project mode- Update test documentation with usage instructions for both modes- Update tool README with manual test runner sectionThe test runner covers component discovery, auto mode, interactive mode,error handling, edge cases, and environment variable scenarios.
1 parent 1340563 commit a693fe1

3 files changed

Lines changed: 692 additions & 2 deletions

File tree

packages/b2c-dx-mcp/src/tools/page-designer-decorator/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,13 +218,32 @@ The tool uses direct function execution with no file I/O or compilation overhead
218218

219219
## ✅ Testing
220220

221+
### Automated Tests
222+
221223
```bash
222224
pnpm build
223225
pnpm test
224226
```
225227

226228
Comprehensive test suite covers all workflow modes, component discovery, and error handling.
227229

230+
### Manual Test Runner
231+
232+
For quick manual verification, use the test runner script:
233+
234+
```bash
235+
cd packages/b2c-dx-mcp
236+
pnpm build
237+
node test/tools/page-designer-decorator/index.test.mjs all
238+
```
239+
240+
Run a specific test case:
241+
```bash
242+
node test/tools/page-designer-decorator/index.test.mjs TC-1.1
243+
```
244+
245+
See [`test/tools/page-designer-decorator/README.md`](../../../test/tools/page-designer-decorator/README.md) for detailed testing instructions.
246+
228247
## 🎓 Learning Resources
229248

230249
- [Template Literals (MDN)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals)

packages/b2c-dx-mcp/test/tools/page-designer-decorator/README.md

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,77 @@ npx mcp-inspector --cli node bin/dev.js --toolsets STOREFRONTNEXT --allow-non-ga
5050
--args '{"component": "MyComponent"}'
5151
```
5252

53-
### 4. Manual Testing with Real Components
53+
### 4. Automated Manual Test Runner
54+
55+
A test runner script is available to quickly verify the tool with various test scenarios:
56+
57+
```bash
58+
cd packages/b2c-dx-mcp
59+
pnpm build # Build the package first
60+
node test/tools/page-designer-decorator/index.test.mjs all
61+
```
62+
63+
Run a specific test case:
64+
```bash
65+
node test/tools/page-designer-decorator/index.test.mjs TC-1.1
66+
```
67+
68+
The script covers 24 automated test cases including:
69+
- Component discovery (name-based, path-based, nested, custom paths)
70+
- Auto mode (basic, type inference, complex props exclusion)
71+
- Interactive mode (mode selection, analyze step)
72+
- Error handling (invalid input, missing parameters)
73+
- Edge cases (no props, optional props, union types, collisions)
74+
- Environment variables (SFCC_WORKING_DIRECTORY)
75+
76+
See the script's JSDoc header for a complete list of available test cases.
77+
78+
#### Running Tests Against a Local Storefront Next Installation
79+
80+
The test runner script supports two modes:
81+
82+
**1. Temporary Directory Mode (Default)**
83+
Creates isolated test environments with temporary directories. Ideal for CI/CD and regression testing.
84+
85+
```bash
86+
cd packages/b2c-dx-mcp
87+
pnpm build
88+
node test/tools/page-designer-decorator/index.test.mjs all
89+
```
90+
91+
**2. Real Storefront Next Project Mode**
92+
Test against an existing Storefront Next installation by setting `SFCC_WORKING_DIRECTORY`:
93+
94+
```bash
95+
cd packages/b2c-dx-mcp
96+
pnpm build
97+
SFCC_WORKING_DIRECTORY=/path/to/storefront-next \
98+
node test/tools/page-designer-decorator/index.test.mjs all
99+
```
100+
101+
Or set it as an environment variable:
102+
```bash
103+
export SFCC_WORKING_DIRECTORY=/path/to/storefront-next
104+
cd packages/b2c-dx-mcp
105+
pnpm build
106+
node test/tools/page-designer-decorator/index.test.mjs TC-1.1
107+
```
108+
109+
**Important Notes for Real Project Mode**:
110+
- Component discovery searches in your real Storefront Next project (`SFCC_WORKING_DIRECTORY`)
111+
- Test components created by the script are placed in a temporary directory (not in your real project)
112+
- The script will **not** modify your real project files (read-only)
113+
- Tests will use existing components from your real project if they exist
114+
- If a test component doesn't exist in your real project, the test will show a "component not found" result (this is expected)
115+
- The real project directory is preserved after testing
116+
- To test with specific components, ensure they exist in your real project's `src/components/` directory
117+
118+
**Alternative Testing Methods**:
119+
- **MCP Inspector**: Interactive UI testing (see section 2 above)
120+
- **CLI Testing**: Command-line testing (see section 3 above)
121+
- **Manual Test Plan**: Full integration testing including Business Manager and Page Designer (see [manual test plan](../../../../../Documents/page-designer-decorator-manual-test-plan.md) for TC-7.x tests)
122+
123+
### 5. Manual Testing with Real Components
54124

55125
1. Set up a Storefront Next project (or use an existing one)
56126
2. Create a test component:
@@ -74,7 +144,7 @@ export SFCC_WORKING_DIRECTORY=/path/to/storefront-next
74144

75145
4. Use the tool via MCP Inspector or your IDE's MCP integration
76146

77-
### 5. Test Scenarios
147+
### 6. Test Scenarios
78148

79149
#### Mode Selection
80150
```json

0 commit comments

Comments
 (0)