Skip to content

Delete dead jest harness and move specs - #272

Open
Dumea Alexandru (alexdumea) wants to merge 5 commits into
mainfrom
197/delete-dead-jest-data
Open

Dumea Alexandru (alexdumea) wants to merge 5 commits into
mainfrom
197/delete-dead-jest-data

Conversation

@alexdumea

@alexdumea Dumea Alexandru (alexdumea) commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

1. Why is this change necessary?

The Administration Jest specs lived in two places that both broke Shopware's test-structure ADR (adr/2022-10-20-test-structure.md), which puts each spec next to the code it tests: src/Resources/app/administration/test/ and tests/jest/administration/. lint:admin doesn't cover administration/test/, so 14 of the 17 specs were never linted.

A second Jest setup under src/Resources/app/administration/ (jest.config.js, babel.config.js, package.json, package-lock.json) was unused as a test harness.

The release zip also shipped test scaffolding: the 14 specs in administration/test/, the dead Jest setup and the test-only PHP helpers in src/Ucp/Test. Those helpers are already kept out of production by services.php and routes.php, but they shouldn't ship at all.

2. What does this change do, exactly?

  • Removes the unused Jest setup. jest.config.js, babel.config.js and package-lock.json are deleted; nothing referenced them. The live config at tests/jest/administration/jest.config.js has its own @swc/jest transform, and the admin source imports no npm packages.

  • Replaces the admin package.json with a minimal one ({"private": true}), dropping the old Jest scripts and dependencies. The file has to stay: it is the nearest package.json above the admin source, and without it the plugin root's "type": "module" applies there. Webpack 5 (the 6.6 webpack build) then treats the admin .js files as strict ESM and fails on extensionless imports such as ./core-feature. A package.json without "type" keeps normal resolution, like core's admin package.json. Webpack 4 (6.5) and Vite (6.6 vite, trunk) don't apply this rule.

  • Moves all 17 specs next to the code they test, under src/Resources/app/administration/src/, named the way core names them:

    • <component>.spec.js for a component's main spec;
    • <component>-<aspect>.spec.js for extra specs on the same component, like core's sw-sales-channel-detail-tabs.spec.js;
    • <file>.spec.js next to plain modules.

    Only relative paths changed. The eslint-disable comments for rules that aren't configured (import/first, global-require) were removed.

  • Reduces Jest's testMatch to one glob, src/Resources/app/administration/src/**/*.spec.js. The specs now fall under the existing lint:admin scope, so eslint.config.mjs is unchanged and jest/no-disabled-tests stays at warn.

  • Keeps test scaffolding out of the zip (.shopware-extension.yml):

    • src/Ucp/Test is added to pack.excludes.paths.
    • The specs are removed by a pack.before_hooks step, because excludes.paths only takes literal paths, not globs. The hook runs in the temporary build copy ($EXTENSION_DIR) before the checksums and the zip are written, so production files next to the specs still ship.
  • Guards the test-only PHP helpers, so a non-prod shop installed from the zip still boots without src/Ucp/Test. Before, services.php, routes.php and TestAgentProfileFetcherCompilerPass loaded those classes whenever APP_ENV wasn't prod. They now also check class_exists() / is_dir().

  • Fails the build if test scaffolding comes back. bin/ci-assert-zip-no-vendor.sh, which package-zip.yml already runs, now fails when the zip contains any *.spec.js or anything under src/Ucp/Test/. The spec removal depends on a shopware-cli hook, so this catches a future CLI change that silently stops running it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant