|
5 | 5 | The page-designer-decorator tool has comprehensive unit tests covering: |
6 | 6 | - ✅ Tool metadata (name, description, toolsets, isGA) |
7 | 7 | - ✅ Mode selection flow |
8 | | -- ✅ Error handling |
| 8 | +- ✅ Auto mode (basic, type inference, complex/UI props exclusion, edge cases) |
| 9 | +- ✅ Interactive mode (all steps: analyze, select_props, configure_attrs, configure_regions, confirm_generation) |
| 10 | +- ✅ Component resolution (name-based, kebab-case, nested, path-based, custom searchPaths, name collisions) |
| 11 | +- ✅ Error handling (invalid input, invalid step name, missing parameters) |
9 | 12 | - ✅ Input validation |
| 13 | +- ✅ Edge cases (no props, only complex props, optional props, union types, already decorated components) |
| 14 | +- ✅ Environment variables (SFCC_WORKING_DIRECTORY) |
10 | 15 |
|
11 | | -Some integration tests may require actual component files in a real workspace to fully validate component resolution. |
| 16 | +All tests use the standard Mocha test framework and run with `pnpm test`. |
12 | 17 |
|
13 | 18 | ## Testing Approaches |
14 | 19 |
|
@@ -50,68 +55,28 @@ npx mcp-inspector --cli node bin/dev.js --toolsets STOREFRONTNEXT --allow-non-ga |
50 | 55 | --args '{"component": "MyComponent"}' |
51 | 56 | ``` |
52 | 57 |
|
53 | | -### 4. Automated Manual Test Runner |
| 58 | +### 4. Running Tests Against a Local Storefront Next Installation |
54 | 59 |
|
55 | | -A test runner script is available to quickly verify the tool with various test scenarios: |
| 60 | +The Mocha test suite supports testing against a real Storefront Next installation by setting `SFCC_WORKING_DIRECTORY`: |
56 | 61 |
|
57 | 62 | ```bash |
58 | 63 | 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 | 64 | SFCC_WORKING_DIRECTORY=/path/to/storefront-next \ |
98 | | - node test/tools/page-designer-decorator/index.test.mjs all |
| 65 | + pnpm run test:agent -- test/tools/page-designer-decorator/index.test.ts |
99 | 66 | ``` |
100 | 67 |
|
101 | 68 | Or set it as an environment variable: |
102 | 69 | ```bash |
103 | 70 | export SFCC_WORKING_DIRECTORY=/path/to/storefront-next |
104 | 71 | cd packages/b2c-dx-mcp |
105 | | -pnpm build |
106 | | -node test/tools/page-designer-decorator/index.test.mjs TC-1.1 |
| 72 | +pnpm run test:agent -- test/tools/page-designer-decorator/index.test.ts |
107 | 73 | ``` |
108 | 74 |
|
109 | 75 | **Important Notes for Real Project Mode**: |
110 | 76 | - 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) |
| 77 | +- Tests create temporary directories for test components (not in your real project) |
| 78 | +- Tests will **not** modify your real project files (read-only) |
113 | 79 | - 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 | 80 | - The real project directory is preserved after testing |
116 | 81 | - To test with specific components, ensure they exist in your real project's `src/components/` directory |
117 | 82 |
|
|
0 commit comments