Harden E2E seed loading for test_cases schema drift and add preflight seed integrity check - #312
Merged
Merged
Conversation
Agent-Logs-Url: https://github.com/bg-playground/BGSTM/sessions/8873bd6c-5149-43d9-a4ee-00e976f25394 Co-authored-by: bg-playground <259109604+bg-playground@users.noreply.github.com>
Agent-Logs-Url: https://github.com/bg-playground/BGSTM/sessions/8873bd6c-5149-43d9-a4ee-00e976f25394 Co-authored-by: bg-playground <259109604+bg-playground@users.noreply.github.com>
Agent-Logs-Url: https://github.com/bg-playground/BGSTM/sessions/8873bd6c-5149-43d9-a4ee-00e976f25394 Co-authored-by: bg-playground <259109604+bg-playground@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Diagnose and fix E2E test environment issues
Harden E2E seed loading for test_cases schema drift and add preflight seed integrity check
May 7, 2026
bg-playground
marked this pull request as ready for review
May 7, 2026 14:06
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.
E2E startup was seeding requirements but dropping seeded test cases/links when
test_cases.auto_registeredis present and non-nullable, causing deterministic Traceability Matrix failures (TC-004missing, zeroed coverage). This PR aligns seed behavior with live schema and fails fast when seed integrity is incomplete.Diagnostic findings
frontend/tests/e2e/fixtures/seed.sqlinsertedtest_caseswithoutauto_registered, triggering NOT NULL violations and cascading FK failures forrequirement_test_case_links/link_suggestions.backend/app/db/sample_data.py.TRUNCATE/DELETE FROM test_caseshooks in frontend/backend test setup.Seed compatibility + startup fail-fast
seed.sqlto:ON_ERROR_STOPexternal_idforTC-001..TC-005auto_registered=falsewhen the column exists.backend/entrypoint.sh) to runpsql -v ON_ERROR_STOP=1so partial seed failures stop container startup.E2E smoke check (pre-test guardrail)
globalSetup(frontend/tests/e2e/global-setup.ts) and wired it infrontend/playwright.config.ts.requirements >= 5test_cases >= 5links >= 3TC-001..TC-005present byexternal_idWarning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
127.0.0.11REDACTED, pid is -1(packet block)dl.google.com/usr/lib/apt/methods/https /usr/lib/apt/methods/https --process /tmp/runc-process3457108610 --detach --pid-file /run/containerd/io.containerd.runtime.v2.task/moby/08efd86bb6084c004dc18f20bcd8c26643dfdf24644c36ddda252b3e7c321a7e/8a4903d29032e6e0f7d9a7cbb56dbe15c4baa5d00ebc328013e361301a532f6e.pid 08efd86bb6084c004dc18f20bcd8c26643dfdf24644c36ddda252b3e7c321a7e sql/17/bin/psql /run/containerd/python 19e9ee20d3bb68af927c02fa91d4da420be/aabe5d2470e792854e99a86113d2f5b02d2a2cd9489b8677�� 732/log.json sql/17/bin/psql 732/�� y filter docker-buildx d73/config.json -i gko9qeip1ax docker-buildx(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
Diagnostic + fix task for BGSTM#311
The E2E test environment is starting up with only requirements seeded — the 5 seeded
test_cases(TC-001..TC-005) and their 3requirement_test_case_linksare missing from the database by the time the Traceability Matrix tests run. This causesfrontend/tests/e2e/traceability.spec.ts:37(seeded test case "TC-004" is visible in the matrix) to fail deterministically.Full context, evidence, and three hypotheses are in BGSTM#311. Read that issue first — it has the failing-run screenshot evidence, the comparison table of observed vs. expected matrix metrics, and the diagnostic steps for each hypothesis.
Your job — diagnose, then fix
Step 1: Diagnose (don't skip)
Work through the three hypotheses in order and document what you find:
Hypothesis 1 — Schema mismatch in
frontend/tests/e2e/fixtures/seed.sql.seed.sqlagainst a freshly migrated test DB locally (use the same Postgres image/version the CI compose file uses).INSERT INTO test_cases ... ERROR— column count mismatch, NOT NULL violation, missing column, type mismatch, FK violation, etc.INSERT INTO test_cases (...)statement against the actualtest_casestable schema (check the latest Alembic migration that defines/alters it).requirement_test_case_links.Hypothesis 2 —
backend/app/db/sample_data.pyruns afterseed.sqland overwrites/diverges.docker-compose.test.yml(or whatever the E2E compose file is) and the backend container's entrypoint/start command.sample_data.pyis invoked during E2E startup, and in what order relative toseed.sqlloading.seed.sql—ON CONFLICT (id) DO NOTHINGonly protects against re-inserting matching IDs.Hypothesis 3 — A spec or fixture truncates
test_cases.git grep -n -E "TRUNCATE|DELETE FROM test_cases|truncate.*test_cases" frontend/ backend/playwright.config.tsglobal setup, anybeforeAll/globalSetuphooks, and backend test fixtures.Document findings in the PR description as a "Diagnostic findings" section. State which hypothesis was confirmed (or describe the actual root cause if it turns out to be something else).
Step 2: Fix
Apply the minimal fix that addresses the confirmed root cause. Most likely candidates based on the evidence:
seed.sqlcolumn list / values to match the live schema. Addexternal_idand any other required columns. Keep the existing TC-001..TC-005 IDs and titles intact so existing tests still find them.sample_data.pyfor the E2E profile, or align its data withseed.sql's expected IDs.Step 3: Add a fail-fast smoke check
Per #311's acceptance criteria, add a smoke check to the E2E setup that fails fast with a clear error if seed loading is incomplete. Suggested approach: a tiny pre-test script (or a
globalSetupstep inplaywright.config.ts) that queries the API or DB after seed and asserts row counts:If any assertion fails, throw with a clear message naming which seed entity is missing. This prevents future regressions from masquerading as flaky UI tests for hours of debugging.
Step 4: Verify
traceability.spec.ts:37(TC-004) must pass on first attempt without retries.seed.sql).Constraints
fixme/skip. The point is to fix the underlying data-layer bug.seed.sql, possibly a startup script, plus the new smoke check.Files likely involved
frontend/tests/e2e/fixtures/seed.sql— primary suspectfrontend/tests/e2e/playwright.config.ts(or equivalent) — for the new s...This pull request was created from Copilot chat.