fix(e2e): mock gutendex.com to fix flaky E2E write tests#608
Merged
vincentchalamon merged 8 commits into4.3from Mar 18, 2026
Merged
fix(e2e): mock gutendex.com to fix flaky E2E write tests#608vincentchalamon merged 8 commits into4.3from
vincentchalamon merged 8 commits into4.3from
Conversation
The BookCreate and BookEdit E2E tests depend on the external gutendex.com API for both browser-side autocomplete and server-side book URL validation. When gutendex.com is slow or unreachable, the tests fail intermittently. This adds gutendex.com mocking following the same pattern already used for openlibrary.org: - Docker network alias in compose.e2e.yaml - HTTPS mock server routing for gutendex search/book endpoints - Playwright browser-level route mocks in AbstractPage - Mock JSON fixtures for Asimov search results - Parameterized TLS verify_peer for PHP scoped HTTP clients Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
MUI Autocomplete triggers onInputChange with the full selected label (e.g. "Let's Get Together - Asimov, Isaac") which fires a new search. Return the same Asimov results for any gutendex search query. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The %env(bool:...)% approach doesn't work because the Symfony DI container is compiled at Docker build time with verify_peer: true. Instead, mount the mock server's self-signed certificate into the PHP container and append it to the system CA bundle via SSL_CERT_FILE. This lets PHP's cURL trust the mock gutendex.com without changing any Symfony configuration. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The mock server generates the cert at startup. The PHP container needs to wait for it to exist before concatenating it to the CA bundle. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Instead of overriding the PHP entrypoint (which broke the container), generate the mock server certificate on the CI host before starting services, then run update-ca-certificates inside the PHP container after it's up. The mock server reuses the pre-generated cert. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
BookRemoveProcessor now deletes bookmarks and reviews referencing the book before removing it, preventing a ForeignKeyConstraintViolation on the bookmark table. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The Bookmark entity has onDelete: 'CASCADE' on the book relation but the migration never added ON DELETE CASCADE to the actual FK constraint. This caused a ForeignKeyConstraintViolationException when deleting a book that had bookmarks. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
BookCreateandBookEditE2E@writetests intermittently fail because they depend on the externalgutendex.comAPI (both browser-side for autocomplete and server-side for book URL validation viaBookUrlValidator→GutendexBookRepository)gutendex.comis slow or unreachable, the PHP backend returns a validation error → React Admin stays on the form → theexpect(page.getByLabel("Book Reference")).not.toBeAttached()assertion fails4.3push runs #605 and #606, as well as multiple scheduled runsChanges
Adds
gutendex.commocking following the same pattern already used foropenlibrary.org:compose.e2e.yaml: addgutendex.comas a Docker network alias to the mock server + disable TLS peer verification for the PHP container viaHTTP_CLIENT_VERIFY_PEER=0e2e/mock-server/server.js: addgutendex.comto the self-signed certificate SAN + add routing for gutendex search endpoint (/books?search=)e2e/tests/admin/pages/AbstractPage.ts: add Playwrightpage.route()browser-level mocks for gutendex search and individual book URLse2e/tests/mocks/gutendex.com/: mock JSON fixtures for Asimov search results and individual book dataapi/config/packages/framework.yaml+api/.env: parameterizeverify_peer/verify_hostonopen_library.clientandgutendex.clientviaHTTP_CLIENT_VERIFY_PEERenv var (defaults to1/ enabled)Test plan
@writetests pass in CI (no more dependency on externalgutendex.com)@readtests still pass🤖 Generated with Claude Code