@@ -176,6 +176,90 @@ jobs:
176176 echo "Test Inspector status command:"
177177 bin/magento mageforge:theme:inspector status
178178
179+ - name : Test npm Sync Validation
180+ working-directory : magento2
181+ run : |
182+ echo "Setting up Node.js for npm testing..."
183+ export NVM_DIR="$HOME/.nvm"
184+ [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
185+
186+ # Install Node.js if not available
187+ if ! command -v node &> /dev/null; then
188+ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
189+ export NVM_DIR="$HOME/.nvm"
190+ [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
191+ nvm install 20
192+ nvm use 20
193+ fi
194+
195+ echo "Node version: $(node --version)"
196+ echo "npm version: $(npm --version)"
197+
198+ echo "Test npm sync validation with Magento/blank theme..."
199+ THEME_PATH="app/design/frontend/Magento/blank"
200+
201+ # Create a simple package.json for testing
202+ cat > ${THEME_PATH}/package.json << 'EOF'
203+ {
204+ "name": "magento-blank-theme",
205+ "version": "1.0.0",
206+ "description": "Test theme for npm sync validation",
207+ "dependencies": {
208+ "jquery": "^3.7.1"
209+ }
210+ }
211+ EOF
212+
213+ echo "Initial npm install to create package-lock.json and node_modules..."
214+ cd ${THEME_PATH}
215+ npm install
216+
217+ echo "Verifying initial sync status (should be in sync)..."
218+ if npm ls --depth=0 > /dev/null 2>&1; then
219+ echo "✓ Initial state: node_modules in sync"
220+ else
221+ echo "✗ Initial state should be in sync"
222+ exit 1
223+ fi
224+
225+ echo "Simulating out-of-sync state by adding new dependency..."
226+ # Add a new dependency to package.json that's not in node_modules
227+ cat > package.json << 'EOF'
228+ {
229+ "name": "magento-blank-theme",
230+ "version": "1.0.0",
231+ "description": "Test theme for npm sync validation",
232+ "dependencies": {
233+ "jquery": "^3.7.1",
234+ "lodash": "^4.17.21"
235+ }
236+ }
237+ EOF
238+
239+ # Update lock file without installing (simulates a git pull with updated lock file)
240+ npm install --package-lock-only
241+
242+ echo "Verifying out-of-sync state (should fail)..."
243+ if npm ls --depth=0 > /dev/null 2>&1; then
244+ echo "✗ Should detect out-of-sync state"
245+ exit 1
246+ else
247+ echo "✓ Correctly detected out-of-sync state (exit code: $?)"
248+ fi
249+
250+ echo "Testing that npm ci fixes the sync issue..."
251+ npm ci
252+
253+ if npm ls --depth=0 > /dev/null 2>&1; then
254+ echo "✓ npm ci successfully synchronized node_modules"
255+ else
256+ echo "✗ npm ci failed to synchronize"
257+ exit 1
258+ fi
259+
260+ echo "✓ npm sync validation tests passed"
261+ cd ../../../../../../
262+
179263 - name : Test Summary
180264 run : |
181265 echo "MageForge module compatibility test with Magento ${{ matrix.magento-version }} completed"
@@ -336,6 +420,90 @@ jobs:
336420 echo "Test Inspector status command:"
337421 bin/magento mageforge:theme:inspector status
338422
423+ - name : Test npm Sync Validation
424+ working-directory : magento2
425+ run : |
426+ echo "Setting up Node.js for npm testing..."
427+ export NVM_DIR="$HOME/.nvm"
428+ [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
429+
430+ # Install Node.js if not available
431+ if ! command -v node &> /dev/null; then
432+ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
433+ export NVM_DIR="$HOME/.nvm"
434+ [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
435+ nvm install 20
436+ nvm use 20
437+ fi
438+
439+ echo "Node version: $(node --version)"
440+ echo "npm version: $(npm --version)"
441+
442+ echo "Test npm sync validation with Magento/blank theme..."
443+ THEME_PATH="app/design/frontend/Magento/blank"
444+
445+ # Create a simple package.json for testing
446+ cat > ${THEME_PATH}/package.json << 'EOF'
447+ {
448+ "name": "magento-blank-theme",
449+ "version": "1.0.0",
450+ "description": "Test theme for npm sync validation",
451+ "dependencies": {
452+ "jquery": "^3.7.1"
453+ }
454+ }
455+ EOF
456+
457+ echo "Initial npm install to create package-lock.json and node_modules..."
458+ cd ${THEME_PATH}
459+ npm install
460+
461+ echo "Verifying initial sync status (should be in sync)..."
462+ if npm ls --depth=0 > /dev/null 2>&1; then
463+ echo "✓ Initial state: node_modules in sync"
464+ else
465+ echo "✗ Initial state should be in sync"
466+ exit 1
467+ fi
468+
469+ echo "Simulating out-of-sync state by adding new dependency..."
470+ # Add a new dependency to package.json that's not in node_modules
471+ cat > package.json << 'EOF'
472+ {
473+ "name": "magento-blank-theme",
474+ "version": "1.0.0",
475+ "description": "Test theme for npm sync validation",
476+ "dependencies": {
477+ "jquery": "^3.7.1",
478+ "lodash": "^4.17.21"
479+ }
480+ }
481+ EOF
482+
483+ # Update lock file without installing (simulates a git pull with updated lock file)
484+ npm install --package-lock-only
485+
486+ echo "Verifying out-of-sync state (should fail)..."
487+ if npm ls --depth=0 > /dev/null 2>&1; then
488+ echo "✗ Should detect out-of-sync state"
489+ exit 1
490+ else
491+ echo "✓ Correctly detected out-of-sync state (exit code: $?)"
492+ fi
493+
494+ echo "Testing that npm ci fixes the sync issue..."
495+ npm ci
496+
497+ if npm ls --depth=0 > /dev/null 2>&1; then
498+ echo "✓ npm ci successfully synchronized node_modules"
499+ else
500+ echo "✗ npm ci failed to synchronize"
501+ exit 1
502+ fi
503+
504+ echo "✓ npm sync validation tests passed"
505+ cd ../../../../../../
506+
339507 - name : Test Summary
340508 run : |
341509 echo "MageForge module compatibility test with Magento 2.4.8 completed"
0 commit comments