|
| 1 | +# Concept: Reusable E2E Infrastructure as a Composer Package |
| 2 | + |
| 3 | +## Goal |
| 4 | + |
| 5 | +Extract the E2E test infrastructure from this plugin into a standalone Composer package |
| 6 | +(`sandstorm/neos-e2e-testing`) that any Neos plugin can install to get a working |
| 7 | +end-to-end test scaffold with minimal effort. |
| 8 | + |
| 9 | +**Scope:** Infrastructure only — Docker/SUT setup, Playwright project scaffold (config, |
| 10 | +package.json, tsconfig, teardown), Makefile, and GitHub Actions workflow. Step definitions, |
| 11 | +helpers (system, pages, totp, etc.), and feature files are entirely the plugin developer's |
| 12 | +responsibility. |
| 13 | + |
| 14 | +--- |
| 15 | + |
| 16 | +## Package Structure |
| 17 | + |
| 18 | +### Type: `library` |
| 19 | + |
| 20 | +Not `neos-package` — this is a dev tool. It belongs in `vendor/`, not `Packages/`, and |
| 21 | +has no Flow/Neos runtime dependency. |
| 22 | + |
| 23 | +``` |
| 24 | +sandstorm/neos-e2e-testing/ |
| 25 | +├── composer.json |
| 26 | +├── bin/ |
| 27 | +│ └── neos-e2e-setup ← self-contained PHP CLI script |
| 28 | +└── templates/ |
| 29 | + ├── Tests/ |
| 30 | + │ ├── E2E/ |
| 31 | + │ │ ├── package.json |
| 32 | + │ │ ├── playwright.config.ts |
| 33 | + │ │ ├── tsconfig.json |
| 34 | + │ │ ├── global-teardown.ts |
| 35 | + │ │ └── .nvmrc |
| 36 | + │ └── system_under_test/ |
| 37 | + │ ├── neos8/ |
| 38 | + │ │ ├── Dockerfile |
| 39 | + │ │ ├── docker-compose.yaml |
| 40 | + │ │ └── sut-files/ |
| 41 | + │ │ ├── entrypoint.sh |
| 42 | + │ │ ├── etc/caretakerd.yaml |
| 43 | + │ │ ├── etc/frankenphp/Caddyfile |
| 44 | + │ │ └── usr/local/etc/php/conf.d/php-ini-overrides.ini |
| 45 | + │ └── neos9/ |
| 46 | + │ └── (same) |
| 47 | + ├── .dockerignore |
| 48 | + ├── Makefile |
| 49 | + └── .github/ |
| 50 | + └── workflows/ |
| 51 | + └── e2e.yml |
| 52 | +``` |
| 53 | + |
| 54 | +### `composer.json` |
| 55 | + |
| 56 | +```json |
| 57 | +{ |
| 58 | + "name": "sandstorm/neos-e2e-testing", |
| 59 | + "type": "library", |
| 60 | + "description": "Scaffolds E2E test infrastructure for Neos plugins", |
| 61 | + "require": { "php": "^8.1" }, |
| 62 | + "bin": ["bin/neos-e2e-setup"] |
| 63 | +} |
| 64 | +``` |
| 65 | + |
| 66 | +--- |
| 67 | + |
| 68 | +## Usage |
| 69 | + |
| 70 | +```sh |
| 71 | +composer require --dev sandstorm/neos-e2e-testing |
| 72 | +vendor/bin/neos-e2e-setup --plugin-package sandstorm/neostwofactorauthentication |
| 73 | +``` |
| 74 | + |
| 75 | +The script copies templates into the plugin root, substitutes tokens, and skips files that |
| 76 | +already exist (safe to re-run). |
| 77 | + |
| 78 | +--- |
| 79 | + |
| 80 | +## Template Tokens |
| 81 | + |
| 82 | +Only two things vary between plugins: |
| 83 | + |
| 84 | +| Token | Example | Used in | |
| 85 | +|---|---|---| |
| 86 | +| `{{PLUGIN_PACKAGE}}` | `sandstorm/neostwofactorauthentication` | Dockerfile, docker-compose project name, Makefile, GH Actions | |
| 87 | +| `{{PLUGIN_SLUG}}` | `sandstorm-2fa` | Docker container/volume names | |
| 88 | + |
| 89 | +The slug is derived automatically from the package name (everything after `/`, hyphens |
| 90 | +preserved), so the developer only needs to provide `--plugin-package`. |
| 91 | + |
| 92 | +--- |
| 93 | + |
| 94 | +## The Dockerfile Template |
| 95 | + |
| 96 | +The only plugin-specific lines in the Dockerfile are the `composer require` call. These |
| 97 | +are made generic via a build arg: |
| 98 | + |
| 99 | +```dockerfile |
| 100 | +ARG PLUGIN_PACKAGE={{PLUGIN_PACKAGE}} |
| 101 | + |
| 102 | +COPY . /tmp/plugin/ |
| 103 | +RUN --mount=type=cache,target=/root/.composer \ |
| 104 | + composer config repositories.plugin \ |
| 105 | + '{"type":"path","url":"/tmp/plugin","options":{"symlink":false}}' \ |
| 106 | + && composer require ${PLUGIN_PACKAGE}:@dev |
| 107 | +``` |
| 108 | + |
| 109 | +Everything else (PHP extensions, caretakerd, FrankenPHP, Neos base distribution, config |
| 110 | +copy) is already generic across plugins. |
| 111 | + |
| 112 | +--- |
| 113 | + |
| 114 | +## `.dockerignore` (generated at plugin root) |
| 115 | + |
| 116 | +Without this, `COPY . /tmp/plugin/` in the Dockerfile would include the test |
| 117 | +infrastructure itself inside the image: |
| 118 | + |
| 119 | +``` |
| 120 | +Tests/E2E/node_modules |
| 121 | +Tests/E2E/.playwright |
| 122 | +Tests/system_under_test |
| 123 | +``` |
| 124 | + |
| 125 | +--- |
| 126 | + |
| 127 | +## The `bin/neos-e2e-setup` Script |
| 128 | + |
| 129 | +A self-contained PHP script — no autoloading, no framework. It: |
| 130 | + |
| 131 | +1. Parses `--plugin-package` from `$argv` |
| 132 | +2. Derives `{{PLUGIN_SLUG}}` from the package name |
| 133 | +3. Iterates over `templates/` recursively |
| 134 | +4. For each template file: substitutes tokens, copies to the target path |
| 135 | +5. Skips files that already exist (idempotent) |
| 136 | + |
| 137 | +--- |
| 138 | + |
| 139 | +## What the Developer Adds After Scaffolding |
| 140 | + |
| 141 | +The scaffolded layout has intentional empty directories (with `.gitkeep`) for the |
| 142 | +plugin-specific content: |
| 143 | + |
| 144 | +``` |
| 145 | +Tests/E2E/features/ |
| 146 | + ← write .feature files here |
| 147 | +
|
| 148 | +Tests/E2E/steps/ |
| 149 | + ← write step definitions here |
| 150 | +
|
| 151 | +Tests/system_under_test/neos8/sut-files/app/Configuration/Production/E2E-SUT/ |
| 152 | +Tests/system_under_test/neos9/sut-files/app/Configuration/Production/E2E-SUT/ |
| 153 | + ← plugin-specific Settings.yaml, Policy.yaml, context subdirectories, etc. |
| 154 | +``` |
| 155 | + |
| 156 | +The scaffold writes the base `Configuration/Production/E2E-SUT/Settings.yaml` (DB + Redis |
| 157 | +connection) and `Caches.yaml`. The plugin only adds its own configuration on top. |
| 158 | + |
| 159 | +--- |
| 160 | + |
| 161 | +## Open Question: Container Name Convention |
| 162 | + |
| 163 | +The `SUT` environment variable (used in step definitions as `${SUT}-neos-1` to target |
| 164 | +`docker exec`) is a contract between the scaffolded `docker-compose.yaml` and the |
| 165 | +developer's step helpers. Since step helpers are entirely the plugin developer's business, |
| 166 | +this convention needs to be documented somewhere visible — either in a generated `README` |
| 167 | +in `Tests/E2E/`, or as a comment in the scaffolded `playwright.config.ts`. |
| 168 | + |
| 169 | +A decision is needed on where this contract lives before the package is built. |
0 commit comments