-
Notifications
You must be signed in to change notification settings - Fork 21.8k
test: init e2e #34193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
test: init e2e #34193
Changes from 6 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
4cc9e73
test: init e2e
hyoban d92f60d
try cucumber
hyoban 8b0a1db
clean
hyoban e025614
clean
hyoban 78e1c69
add E2E_SLOW_MO
hyoban 36083c5
tweaks
hyoban dedc6e7
tweaks
hyoban 7e1d153
update
hyoban ecbc8ed
update
hyoban c5bb95c
update
hyoban 21a8ded
fix
hyoban e93cb21
tweaks
hyoban f8a3d1c
clean
hyoban c57b070
Merge branch 'main' into 3-27-e2e
hyoban 4fa2fe6
tweaks
hyoban ae93bfe
Apply suggestions from code review
hyoban 38dda33
tweaks
hyoban File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| name: Web Full-Stack E2E | ||
|
|
||
| on: | ||
| workflow_call: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: web-e2e-${{ github.head_ref || github.run_id }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| test: | ||
| name: Web Full-Stack E2E | ||
| runs-on: ubuntu-latest | ||
| defaults: | ||
| run: | ||
| shell: bash | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: Setup web dependencies | ||
| uses: ./.github/actions/setup-web | ||
|
|
||
| - name: Install E2E package dependencies | ||
| working-directory: ./e2e | ||
| run: pnpm install --frozen-lockfile | ||
|
|
||
| - name: Setup UV and Python | ||
| uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0 | ||
| with: | ||
| enable-cache: true | ||
| python-version: "3.12" | ||
| cache-dependency-glob: api/uv.lock | ||
|
|
||
| - name: Install API dependencies | ||
| run: uv sync --project api --dev | ||
|
|
||
| - name: Prepare built web app env | ||
| run: | | ||
| cp web/.env.example web/.env.local | ||
| sed -i 's|http://localhost:5001|http://127.0.0.1:5001|g' web/.env.local | ||
|
|
||
| - name: Prepare middleware stack env | ||
| run: | | ||
| cp docker/middleware.env.example docker/middleware.env | ||
| cat <<'EOF' >> docker/middleware.env | ||
| COMPOSE_PROFILES=postgresql,weaviate | ||
| EOF | ||
|
|
||
| - name: Start middleware stack | ||
| working-directory: ./e2e | ||
| run: pnpm e2e:middleware:up | ||
|
|
||
| - name: Install Playwright browser | ||
| working-directory: ./e2e | ||
| run: pnpm e2e:install | ||
|
|
||
| - name: Run source-api and built-web E2E tests | ||
| working-directory: ./e2e | ||
| env: | ||
| E2E_ADMIN_EMAIL: e2e-admin@example.com | ||
| E2E_ADMIN_NAME: E2E Admin | ||
| E2E_ADMIN_PASSWORD: E2eAdmin12345 | ||
| E2E_FORCE_WEB_BUILD: "1" | ||
| E2E_INIT_PASSWORD: E2eInit12345 | ||
| run: pnpm e2e | ||
|
|
||
| - name: Upload Playwright report | ||
| if: ${{ !cancelled() }} | ||
| uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 | ||
| with: | ||
| name: playwright-report | ||
| path: e2e/playwright-report | ||
| retention-days: 7 | ||
|
|
||
| - name: Upload Playwright test results | ||
| if: ${{ !cancelled() }} | ||
| uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 | ||
| with: | ||
| name: playwright-test-results | ||
| path: e2e/test-results | ||
| retention-days: 7 | ||
|
|
||
| - name: Stop middleware stack | ||
| if: ${{ always() }} | ||
| working-directory: ./e2e | ||
| run: pnpm e2e:middleware:down |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| node_modules/ | ||
| .auth/ | ||
| playwright-report/ | ||
| test-results/ | ||
| cucumber-report/ | ||
| .logs/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,177 @@ | ||
| # E2E | ||
|
|
||
| This package contains the repository-level end-to-end tests for Dify. | ||
|
|
||
| This file is the canonical package guide for `e2e/`. Keep detailed workflow, architecture, debugging, and reporting documentation here. Keep `README.md` as a minimal pointer to this file so the two documents do not drift. | ||
|
|
||
| The suite uses Cucumber for scenario definitions and Playwright as the browser execution layer. | ||
|
|
||
| It tests: | ||
|
|
||
| - backend API started from source | ||
| - frontend served from the production artifact | ||
| - middleware services started from Docker | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - Node.js `^22.22.1` | ||
| - `pnpm` | ||
| - `uv` | ||
| - Docker | ||
|
|
||
| Install Playwright browsers once: | ||
|
|
||
| ```bash | ||
| cd e2e | ||
| pnpm install | ||
| pnpm e2e:install | ||
| pnpm check | ||
| ``` | ||
|
|
||
| Use `pnpm check` as the default local verification step after editing E2E TypeScript, Cucumber support code, or feature glue. It runs formatting, linting, and type checks for this package. | ||
|
|
||
| Common commands: | ||
|
|
||
| ```bash | ||
| # authenticated-only regression (default excludes @fresh) | ||
| pnpm e2e | ||
|
|
||
| # full reset + fresh install + authenticated scenarios | ||
| pnpm e2e:full | ||
|
|
||
| # run a tagged subset | ||
| pnpm e2e -- --tags @smoke | ||
|
|
||
| # headed browser | ||
| pnpm e2e:headed -- --tags @smoke | ||
|
|
||
| # slow down browser actions for local debugging | ||
| E2E_SLOW_MO=500 pnpm e2e:headed -- --tags @smoke | ||
| ``` | ||
|
|
||
| Frontend artifact behavior: | ||
|
|
||
| - if `web/.next/BUILD_ID` exists, E2E reuses the existing build by default | ||
| - if you set `E2E_FORCE_WEB_BUILD=1`, E2E rebuilds the frontend before starting it | ||
|
|
||
| ## Lifecycle | ||
|
|
||
| ```mermaid | ||
| flowchart TD | ||
| A["Start E2E run"] --> B["run-cucumber.sh orchestrates reset/middleware/API"] | ||
| B --> C["typed web-server manager starts or reuses frontend"] | ||
| C --> D["Cucumber loads config, steps, and support modules"] | ||
| D --> E["BeforeAll bootstraps shared auth state via /install"] | ||
| E --> F{"Which command is running?"} | ||
| F -->|`pnpm e2e`| G["Run config default tags: not @fresh and not @skip"] | ||
| F -->|`pnpm e2e:full*`| H["Override tags to not @skip"] | ||
| G --> I["Per-scenario BrowserContext from shared browser"] | ||
| H --> I | ||
| I --> J["Failure artifacts written to cucumber-report/artifacts"] | ||
| ``` | ||
|
|
||
| Ownership is split like this: | ||
|
|
||
| - shell scripts orchestrate reset, middleware, and backend startup | ||
| - `support/web-server.ts` manages frontend reuse, startup, readiness, and shutdown | ||
| - `features/support/hooks.ts` manages auth bootstrap, scenario lifecycle, and diagnostics | ||
| - `features/support/world.ts` owns per-scenario typed context | ||
| - `features/step-definitions/` holds domain-oriented glue so the official VS Code Cucumber plugin works with default conventions when `e2e/` is opened as the workspace root | ||
|
|
||
| Package layout: | ||
|
|
||
| - `features/`: Gherkin scenarios grouped by capability | ||
| - `features/step-definitions/`: domain-oriented step definitions | ||
| - `features/support/hooks.ts`: suite lifecycle, auth-state bootstrap, diagnostics | ||
| - `features/support/world.ts`: shared scenario context | ||
| - `support/web-server.ts`: typed frontend startup/reuse logic | ||
| - `scripts/*.sh`: middleware and backend orchestration | ||
|
|
||
| Behavior depends on instance state: | ||
|
|
||
| - uninitialized instance: completes install and stores authenticated state | ||
| - initialized instance: signs in and reuses authenticated state | ||
|
|
||
| Because of that, the `@fresh` install scenario only runs in the `pnpm e2e:full*` flows. The default `pnpm e2e*` flows exclude `@fresh` via Cucumber config tags so they can be re-run against an already initialized instance. | ||
|
|
||
| Reset all persisted E2E state: | ||
|
|
||
| ```bash | ||
| pnpm e2e:reset | ||
| ``` | ||
|
|
||
| This removes: | ||
|
|
||
| - `docker/volumes/db/data` | ||
| - `docker/volumes/redis/data` | ||
| - `docker/volumes/weaviate` | ||
| - `docker/volumes/plugin_daemon` | ||
| - `e2e/.auth` | ||
| - `e2e/.logs` | ||
| - `e2e/cucumber-report` | ||
|
|
||
| Start the full middleware stack: | ||
|
|
||
| ```bash | ||
| pnpm e2e:middleware:up | ||
| ``` | ||
|
|
||
| Stop the full middleware stack: | ||
|
|
||
| ```bash | ||
| pnpm e2e:middleware:down | ||
| ``` | ||
|
|
||
| The middleware stack includes: | ||
|
|
||
| - PostgreSQL | ||
| - Redis | ||
| - Weaviate | ||
| - Sandbox | ||
| - SSRF proxy | ||
| - Plugin daemon | ||
|
|
||
| Fresh install verification: | ||
|
|
||
| ```bash | ||
| pnpm e2e:full | ||
| ``` | ||
|
|
||
| Repeat authenticated regression without clearing data: | ||
|
|
||
| ```bash | ||
| pnpm e2e:middleware:up | ||
| pnpm e2e | ||
| pnpm e2e:middleware:down | ||
| ``` | ||
|
|
||
| Run the Cucumber suite against an already running middleware stack: | ||
|
|
||
| ```bash | ||
| pnpm e2e:middleware:up | ||
| pnpm e2e | ||
| pnpm e2e:middleware:down | ||
| ``` | ||
|
|
||
| Interactive local debugging: | ||
|
|
||
| ```bash | ||
| pnpm e2e:full:ui | ||
| ``` | ||
|
|
||
| Artifacts and diagnostics: | ||
|
|
||
| - `cucumber-report/report.html`: HTML report | ||
| - `cucumber-report/report.json`: JSON report | ||
| - `cucumber-report/artifacts/`: failure screenshots and HTML captures | ||
| - `.logs/cucumber-api.log`: backend startup log | ||
| - `.logs/cucumber-web.log`: frontend startup log | ||
| - `.logs/web-server-manager.log`: typed web-server manager log | ||
|
|
||
| Open the HTML report locally with: | ||
|
|
||
| ```bash | ||
| open cucumber-report/report.html | ||
| ``` | ||
|
|
||
| `pnpm e2e:ui` and `pnpm e2e:full:ui` currently run the suite in headed mode. Cucumber does not provide a Playwright-style UI mode. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # E2E | ||
|
|
||
| Canonical documentation for this package lives in [AGENTS.md](./AGENTS.md). |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.