Skip to content

fix(e2e): isolate error-tracker tests from admin page-load noise#102

Merged
MathieuLamiot merged 1 commit into
developfrom
fix/e2e-error-tracker-cap-isolation
May 18, 2026
Merged

fix(e2e): isolate error-tracker tests from admin page-load noise#102
MathieuLamiot merged 1 commit into
developfrom
fix/e2e-error-tracker-cap-isolation

Conversation

@MathieuLamiot

Copy link
Copy Markdown
Owner

Description

Closes #101

Two error-tracker-cap.spec.ts tests were failing intermittently in CI on PRs that change class-sybgo.php (#91, #92): known signature (expects count=1, gets 2) and dashboard widget (expects count=3, gets 4).

Root cause: the two beforeEach hooks ran in the wrong order — CLEAR_QUERY fired before loginAsAdmin. Navigating the WP admin during login runs Sybgo::init() (via plugins_loaded), which may emit a PHP notice captured by Error_Tracker. That stray row landed in the DB after the clear, inflating exact-count assertions in tests that don't fill the cap (tests 1–3, 5–6 fill cap=5 so an extra row is absorbed; tests 4 and 7 assert counts of 1 and 3 so they break).

Type of change

  • Bug fix (non-breaking change which fixes an issue).

Detailed scenario

What was tested

How to test

  1. Check out this branch, run bin/dev-up.sh, then npx playwright test in tests/e2e/
  2. All tests in error-tracker-cap.spec.ts should pass, including the two previously failing
  3. Run 3 consecutive times to confirm stability

Affected Features & Quality Assurance Scope

  • tests/e2e/specs/error-tracker-cap.spec.ts — error tracker daily-limit tests only
  • No production code changed

Technical description

Documentation

No documentation update needed.

Fix 1beforeEach order: swap so loginAsAdmin runs first, then CLEAR_QUERY. This ensures init-time PHP notices from the admin page load are cleaned up before each test asserts.

Fix 2 — dashboard widget test: the test body itself calls widget.goto() which triggers another WP admin load. Added CLEAR_QUERY inline after goto() (before triggering the 3 test errors), and a page.reload() to give the widget fresh DB data.

New dependencies

None.

Risks

None. Test-only change; no production code modified.

Mandatory Checklist

Code validation

  • I validated all the Acceptance Criteria. If possible, provide screenshots or videos.
  • I triggered all changed lines of code at least once without new errors/warnings/notices.
  • I implemented built-in tests to cover the new/changed code.

Code style

  • I wrote a self-explanatory code about what it does.
  • I protected entry points against unexpected inputs.
  • I did not introduce unnecessary complexity.
  • Output messages (errors, notices, logs) are explicit enough for users to understand the issue and are actionable.

Unticked items justification

None.

Additional Checks

  • In the case of complex code, I wrote comments to explain it.
  • When possible, I prepared ways to observe the implemented system (logs, data, etc.).
  • I added error handling logic when using functions that could throw errors (HTTP/API request, filesystem, etc.)

…ution

The two beforeEach hooks ran in wrong order: CLEAR_QUERY fired before
loginAsAdmin. Navigating through WP admin during login runs Sybgo::init()
which may emit PHP notices captured by Error_Tracker — those stray rows
landed in the DB after the clean, causing tests with low exact counts
(< cap) to fail.

Fix 1: swap the hook order so CLEAR_QUERY runs after loginAsAdmin.
Fix 2: in the dashboard widget UI test, navigate first (flushing any
init-time notices), clear again, then trigger the 3 known errors, then
reload to get fresh widget HTML.

Closes #101

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@MathieuLamiot MathieuLamiot merged commit 1ab6423 into develop May 18, 2026
4 checks passed
@MathieuLamiot MathieuLamiot deleted the fix/e2e-error-tracker-cap-isolation branch May 18, 2026 16:45
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.

Fix flaky E2E tests in error-tracker-cap.spec.ts (daily-limit enforcement)

1 participant