Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugin-tests/dev-tooling/codex_manifest.bats
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ _assert_listing_matches_tools_json() {
# bats test_tags=directives
@test "the Claude directives send a ludtwig vendor/ refusal to php-tooling instead of the server that refused" {
# shellcheck disable=SC2016 # literal backticks in the prompt text
run grep -F 'a ludtwig refusal on a missing vendor/ names `php-tooling`' "${DIRECTIVES}"
run grep -F 'A ludtwig refusal on the `js-storefront-tooling` MCP server over a missing vendor/ names `php-tooling`.' "${DIRECTIVES}"
assert_success
run grep -F 'MCP server that refused' "${DIRECTIVES}"
assert_failure
Expand Down
84 changes: 58 additions & 26 deletions plugin-tests/dev-tooling/js_admin_tools.bats
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,21 @@ bats_test_function --description "blocks npx eslint → suggests eslint_check" \
bats_test_function --description "blocks npx jest → suggests jest_run" \
-- js_admin_hook_blocks "npx jest --watch" "jest_run"

# The target-less base scripts. No MCP tool calls them. Shopware's
# Administration package.json defines lint:debugging only, and the redirects
# stay for a project that defines the others.
# bats test_tags=blocking,base-scripts
bats_test_function --description "blocks npm run lint:debugging → suggests eslint_check" \
-- js_admin_hook_blocks "npm run lint:debugging" "eslint_check"
bats_test_function --description "blocks npm run stylelint:base → suggests stylelint_check" \
-- js_admin_hook_blocks "npm run stylelint:base" "stylelint_check"
bats_test_function --description "blocks npm run prettier:base → suggests prettier_check" \
-- js_admin_hook_blocks "npm run prettier:base" "prettier_check"
bats_test_function --description "blocks npm run jest:base → suggests jest_run" \
-- js_admin_hook_blocks "npm run jest:base" "jest_run"

# The Administration package defines `lint-fix` beside `lint:fix`.
# bats test_tags=blocking
bats_test_function --description "blocks npm run lint-fix → suggests eslint_fix" \
-- js_admin_hook_blocks "npm run lint-fix" "eslint_fix"

# jest_run's parameter is testPathPatterns; testPathPattern is not one.
# bats test_tags=blocking
bats_test_function --description "the npm run unit block names the testPathPatterns parameter" \
-- js_admin_hook_blocks "npm run unit" "testPathPatterns"
bats_test_function --description "the jest binary block names the testPathPatterns parameter" \
-- js_admin_hook_blocks "npx jest src" "testPathPatterns"

# A linter binary run through `npx`, `npm exec` or its node_modules/.bin path.
# The MCP servers run the binaries themselves through `npm exec --no --`, so an
Expand Down Expand Up @@ -141,23 +144,54 @@ bats_test_function --description "allows reading a linter binary" \
bats_test_function --description "allows a linter name inside quoted text after a semicolon" \
-- admin_hook_allows 'git commit -m "tidy; eslint config"'

# bats test_tags=context,allow
@test "allows npm run stylelint:app, a Storefront script name" {
run_hook "check-js-admin-tools.sh" "npm run stylelint:app"
assert_success
}

# bats test_tags=context,allow
@test "allows npm run eslint:app, a Storefront script name" {
run_hook "check-js-admin-tools.sh" "npm run eslint:app"
assert_success
# An env assignment ahead of npm, npm flags around `run`, the `run-script`
# alias, and a `;` glued to the script name still run it.
# bats test_tags=blocking
bats_test_function --description "blocks npm run lint behind an env assignment → suggests eslint_check" \
-- js_admin_hook_blocks "CI=true npm run lint" "eslint_check"
bats_test_function --description "blocks npm run with a flag before the script name → suggests eslint_check" \
-- js_admin_hook_blocks "npm run --silent lint" "eslint_check"
bats_test_function --description "blocks npm --prefix <dir> run before the script name → suggests tsc_check" \
-- js_admin_hook_blocks "npm --prefix src/Administration/Resources/app/administration run lint:types" "tsc_check"
bats_test_function --description "blocks npm run-script build → suggests vite_build" \
-- js_admin_hook_blocks "npm run-script build" "vite_build"
bats_test_function --description "blocks npm run lint glued to ; → suggests eslint_check" \
-- js_admin_hook_blocks "npm run lint;echo done" "eslint_check"

# Each npm-script row matches its own script name only.
# bats test_tags=blocking
@test "npm run lint:fix glued to ; is routed to eslint_fix, not eslint_check" {
run_hook "check-js-admin-tools.sh" "npm run lint:fix;echo done"
assert_failure 2
assert_output --partial "eslint_fix"
refute_output --partial "eslint_check"
}

# bats test_tags=context,allow
@test "allows npm run jest:base when the command names the Storefront tree" {
run_hook "check-js-admin-tools.sh" "cd src/Storefront/Resources/app/storefront && npm run jest:base"
assert_success
}
# bats test_tags=allow
bats_test_function --description "allows npm run lint--x, a longer script name" \
-- admin_hook_allows "npm run lint--x"
bats_test_function --description "allows npm run lintx, a longer script name" \
-- admin_hook_allows "npm run lintx"
bats_test_function --description "allows npm run build--watch, a longer script name" \
-- admin_hook_allows "npm run build--watch"
bats_test_function --description "allows an env-prefixed npm run named inside a quoted commit message" \
-- admin_hook_allows 'git commit -m "use CI=true npm run lint"'

# A binary run with `;` glued to its name, behind an env assignment, or through
# node and its node_modules/.bin path.
# bats test_tags=blocking,binaries
bats_test_function --description "blocks npx eslint glued to ; → suggests eslint_check" \
-- js_admin_hook_blocks "npx eslint;" "eslint_check"
bats_test_function --description "blocks npx eslint behind an env assignment → suggests eslint_check" \
-- js_admin_hook_blocks "CI=true npx eslint ." "eslint_check"
bats_test_function --description "blocks node node_modules/.bin/eslint → suggests eslint_check" \
-- js_admin_hook_blocks "node node_modules/.bin/eslint src" "eslint_check"

# The anchor has no `(`, so a binary inside parentheses in a quoted commit
# message is not a run.
# bats test_tags=binaries,allow
bats_test_function --description "allows npx eslint inside parentheses in a quoted commit message" \
-- admin_hook_allows 'git commit -m "fix (npx eslint)"'

# bats test_tags=allow
@test "allows unrelated commands" {
Expand All @@ -182,8 +216,6 @@ for spec in "eslint eslint_check" "stylelint stylelint_check" "prettier prettier
bats_test_function --description "blocks npm exec -c running ${bin} after cd" \
-- js_admin_hook_blocks "npm exec --no -c \"cd ../.. && ${bin} src\"" "$tool"
done
bats_test_function --description "blocks the npm exec -c form the MCP tools run for the components tree" \
-- js_admin_hook_blocks 'npm exec --no -c "cd ../.. && eslint views/components"' "eslint_check"
bats_test_function --description "blocks npx -c with a single-quoted string running stylelint" \
-- js_admin_hook_blocks "npx -c 'stylelint src'" "stylelint_check"
bats_test_function --description "blocks npm exec --call running jest" \
Expand Down
103 changes: 65 additions & 38 deletions plugin-tests/dev-tooling/js_storefront_tools.bats
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,12 @@ bats_test_function --description "blocks a bare npm run lint:js:fix → suggests
-- js_storefront_hook_blocks "npm run lint:js:fix" "eslint_fix"
bats_test_function --description "blocks a bare npm run lint:js → suggests eslint_check" \
-- js_storefront_hook_blocks "npm run lint:js" "eslint_check"
bats_test_function --description "blocks npm run lint:js:app → suggests eslint_check" \
-- js_storefront_hook_blocks "npm run lint:js:app" "eslint_check"
# lint:js and lint:js:fix chain the per-tree scripts, but both components
# scripts are reachable on their own; the :fix suffix must route to the fixer.
bats_test_function --description "blocks npm run lint:js:components → suggests eslint_check" \
-- js_storefront_hook_blocks "npm run lint:js:components" "eslint_check"
bats_test_function --description "blocks npm run lint:js:components:fix → suggests eslint_fix" \
-- js_storefront_hook_blocks "npm run lint:js:components:fix" "eslint_fix"
# The Storefront `lint` script runs ESLint and then Stylelint; `lint-fix` runs
# both fixers.
bats_test_function --description "the npm run lint block names Stylelint beside ESLint" \
-- js_storefront_hook_blocks "cd src/Storefront && npm run lint" "stylelint_check"
bats_test_function --description "blocks npm run lint-fix in Storefront context → suggests eslint_fix and stylelint_fix" \
-- js_storefront_hook_blocks "cd src/Storefront && npm run lint-fix" "\`eslint_fix\` or \`stylelint_fix\`"
bats_test_function --description "blocks npm run development in Storefront context → suggests webpack_build" \
-- js_storefront_hook_blocks "cd /app/storefront && npm run development" "webpack_build"
bats_test_function --description "blocks npx jest in Storefront context → suggests jest_run" \
Expand All @@ -79,10 +77,14 @@ bats_test_function --description "blocks npm run unit:components:coverage → su
-- js_storefront_hook_blocks "npm run unit:components:coverage" "vitest_run"
bats_test_function --description "blocks npx vitest in Storefront context → suggests vitest_run" \
-- js_storefront_hook_blocks "cd src/Storefront && npx vitest" "vitest_run"
bats_test_function --description "blocks the npm exec -c form the MCP tools run for the components tree → suggests eslint_check" \
-- js_storefront_hook_blocks 'npm exec --no -c "cd ../.. && eslint views/components"' "eslint_check"
bats_test_function --description "blocks composer storefront:components:unit → suggests vitest_run" \
-- js_storefront_hook_blocks "composer storefront:components:unit" "vitest_run"
bats_test_function --description "blocks composer ludtwig:storefront → suggests ludtwig_check" \
-- js_storefront_hook_blocks "composer ludtwig:storefront" "ludtwig_check"
bats_test_function --description "blocks composer -d <dir> ludtwig:storefront → suggests ludtwig_check" \
-- js_storefront_hook_blocks "composer -d /app ludtwig:storefront" "ludtwig_check"
bats_test_function --description "blocks composer ludtwig:storefront:fix → suggests ludtwig_fix" \
-- js_storefront_hook_blocks "composer ludtwig:storefront:fix" "ludtwig_fix"
bats_test_function --description "blocks a bare ludtwig invocation → suggests ludtwig_check" \
Expand All @@ -105,20 +107,57 @@ bats_test_function --description "blocks a runner passing a flag and -- before l
bats_test_function --description "blocks npm x running ludtwig" \
-- js_storefront_hook_blocks "npm x ludtwig src/Storefront/Resources/views" "ludtwig_check"

# The target-less base scripts. Shopware's Storefront package.json defines none
# of them and no MCP tool calls them; the redirects stay for a project that
# defines them. eslint:app, eslint:components and
# stylelint:app are Storefront names, so they are also Storefront context
# signals in their own right.
# bats test_tags=blocking,base-scripts
bats_test_function --description "blocks npm run eslint:app → suggests eslint_check" \
-- js_storefront_hook_blocks "npm run eslint:app" "eslint_check"
bats_test_function --description "blocks npm run eslint:components → suggests eslint_check" \
-- js_storefront_hook_blocks "npm run eslint:components" "eslint_check"
bats_test_function --description "blocks npm run stylelint:app → suggests stylelint_check" \
-- js_storefront_hook_blocks "npm run stylelint:app" "stylelint_check"
bats_test_function --description "blocks npm run jest:base in Storefront context → suggests jest_run" \
-- js_storefront_hook_blocks "cd src/Storefront && npm run jest:base" "jest_run"
# An env assignment ahead of npm, npm flags around `run`, and a `;` or `&&`
# glued to the script name still run it. The bare forms carry no
# tree marker, so the context detector has to recognize them as well.
# bats test_tags=blocking
bats_test_function --description "blocks npm run lint:js behind an env assignment in the Storefront tree → suggests eslint_check" \
-- js_storefront_hook_blocks "cd storefront && CI=true npm run lint:js" "eslint_check"
bats_test_function --description "blocks npm run with a flag before unit in the Storefront tree → suggests jest_run" \
-- js_storefront_hook_blocks "cd src/Storefront && npm run --silent unit" "jest_run"
bats_test_function --description "blocks a bare npm run lint:js glued to ; → suggests eslint_check" \
-- js_storefront_hook_blocks "npm run lint:js;echo done" "eslint_check"
bats_test_function --description "blocks a bare npm run unit:components:coverage glued to && → suggests vitest_run" \
-- js_storefront_hook_blocks "npm run unit:components:coverage&&echo done" "vitest_run"
bats_test_function --description "blocks composer run storefront:components:unit → suggests vitest_run" \
-- js_storefront_hook_blocks "composer run storefront:components:unit" "vitest_run"
bats_test_function --description "blocks composer run ludtwig:storefront → suggests ludtwig_check" \
-- js_storefront_hook_blocks "composer run ludtwig:storefront" "ludtwig_check"
bats_test_function --description "blocks composer run-script ludtwig:storefront:fix → suggests ludtwig_fix" \
-- js_storefront_hook_blocks "composer run-script ludtwig:storefront:fix" "ludtwig_fix"
bats_test_function --description "blocks ludtwig behind an env assignment in the Storefront tree → suggests ludtwig_check" \
-- js_storefront_hook_blocks "cd src/Storefront && CI=1 ludtwig ." "ludtwig_check"

# A composer script or ludtwig glued to `;` still runs it.
# bats test_tags=blocking
bats_test_function --description "blocks composer run storefront:components:unit glued to ; → suggests vitest_run" \
-- js_storefront_hook_blocks "composer run storefront:components:unit;echo done" "vitest_run"
bats_test_function --description "blocks a bare ludtwig glued to ; → suggests ludtwig_check" \
-- js_storefront_hook_blocks "ludtwig;" "ludtwig_check"

# bats test_tags=blocking
@test "composer ludtwig:storefront:fix glued to && is routed to ludtwig_fix, not ludtwig_check" {
run_hook "check-js-storefront-tools.sh" "composer ludtwig:storefront:fix&&true"
assert_failure 2
assert_output --partial "ludtwig_fix"
refute_output --partial "ludtwig_check"
}

# bats test_tags=blocking
@test "a bare npm run lint:js:fix glued to ; is routed to eslint_fix, not eslint_check" {
run_hook "check-js-storefront-tools.sh" "npm run lint:js:fix;echo done"
assert_failure 2
assert_output --partial "eslint_fix"
refute_output --partial "eslint_check"
}

# bats test_tags=allow
bats_test_function --description "allows npm run lint:js--x, a longer script name, in the Storefront tree" \
-- storefront_hook_allows "cd src/Storefront && npm run lint:js--x"
bats_test_function --description "allows npm run unit:components:watchx, a longer script name, in the Storefront tree" \
-- storefront_hook_allows "cd src/Storefront && npm run unit:components:watchx"
bats_test_function --description "allows composer run ludtwig:storefront-x, a longer script name" \
-- storefront_hook_allows "composer run ludtwig:storefront-x"

# A linter binary run through `npx`, `npm exec` or its node_modules/.bin path.
# The MCP servers run the binaries themselves through `npm exec --no --`, so an
Expand Down Expand Up @@ -151,6 +190,10 @@ bats_test_function --description "allows npm exec tsc in the Storefront tree, wh
-- storefront_hook_allows "cd src/Storefront/Resources/app/storefront && npm exec --no -- tsc src"
bats_test_function --description "allows npm exec vitest in the Administration tree" \
-- storefront_hook_allows "cd src/Administration/Resources/app/administration && npm exec --no -- vitest src"
# A Shopware plugin brings its own Vitest suite, which vitest_run refuses under
# a plugin scope, so a run naming no Storefront marker must stay unclaimed.
bats_test_function --description "allows npx vitest without a Storefront marker, which a plugin's own suite runs" \
-- storefront_hook_allows "npx vitest run"
bats_test_function --description "allows npm exec prettier in the Storefront tree, which has no prettier tool" \
-- storefront_hook_allows "cd src/Storefront/Resources/app/storefront && npm exec --no -- prettier --check src"
bats_test_function --description "allows npm exec running another tool in the Storefront tree" \
Expand All @@ -162,29 +205,13 @@ bats_test_function --description "allows a linter name after another tool in an
bats_test_function --description "allows a linter name inside quoted text after a semicolon in the Storefront tree" \
-- storefront_hook_allows 'cd src/Storefront && git commit -m "tidy; eslint config"'

# jest:base carries no side-specific marker. The Admin hook's unknown-context
# fallback owns the bare form, so this hook must decline it or the command
# would be blocked twice with two different tool names.
# bats test_tags=context,allow
@test "allows a bare npm run jest:base, which the Admin hook owns" {
run_hook "check-js-storefront-tools.sh" "npm run jest:base"
assert_success
}

# bats test_tags=blocking
@test "npm run lint:js:fix is routed to eslint_fix, not eslint_check" {
run_hook "check-js-storefront-tools.sh" "npm run lint:js:fix"
assert_failure 2
refute_output --partial "eslint_check"
}

# bats test_tags=blocking
@test "npm run lint:js:app:fix is routed to eslint_fix, not eslint_check" {
run_hook "check-js-storefront-tools.sh" "npm run lint:js:app:fix"
assert_failure 2
refute_output --partial "eslint_check"
}

# bats test_tags=blocking
@test "npm run unit:components is routed to vitest_run, not jest_run" {
run_hook "check-js-storefront-tools.sh" "npm run unit:components"
Expand Down
Loading
Loading