fix(e2e): isolate error-tracker tests from admin page-load noise#102
Merged
Conversation
…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>
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.
Description
Closes #101
Two
error-tracker-cap.spec.tstests were failing intermittently in CI on PRs that changeclass-sybgo.php(#91,#92): known signature (expects count=1, gets 2) and dashboard widget (expects count=3, gets 4).Root cause: the two
beforeEachhooks ran in the wrong order —CLEAR_QUERYfired beforeloginAsAdmin. Navigating the WP admin during login runsSybgo::init()(viaplugins_loaded), which may emit a PHP notice captured byError_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
Detailed scenario
What was tested
beforeEachhook execution order against the Playwright docs (hooks fire in declaration order)Sybgo::init()→init_abilities()→ plugin code runs during admin page load →Error_Tracker::handle_error()→ row inserted withreport_id=0init_abilities()changes) passes E2E while Extract Ability_Manager as a WP7 ability registration utility #91/Extract Admin_Manager as a pure admin registration utility #92 (which addinit_abilities()) fail the same two testsHow to test
bin/dev-up.sh, thennpx playwright testintests/e2e/error-tracker-cap.spec.tsshould pass, including the two previously failingAffected Features & Quality Assurance Scope
tests/e2e/specs/error-tracker-cap.spec.ts— error tracker daily-limit tests onlyTechnical description
Documentation
No documentation update needed.
Fix 1 —
beforeEachorder: swap sologinAsAdminruns first, thenCLEAR_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. AddedCLEAR_QUERYinline aftergoto()(before triggering the 3 test errors), and apage.reload()to give the widget fresh DB data.New dependencies
None.
Risks
None. Test-only change; no production code modified.
Mandatory Checklist
Code validation
Code style
Unticked items justification
None.
Additional Checks