Skip to content

Fix Playwright plugin-row locator strict-mode collisions in Playground e2e specs#30

Closed
Copilot wants to merge 2 commits into
mainfrom
copilot/update-e2e-tests-playwright
Closed

Fix Playwright plugin-row locator strict-mode collisions in Playground e2e specs#30
Copilot wants to merge 2 commits into
mainfrom
copilot/update-e2e-tests-playwright

Conversation

Copy link
Copy Markdown

Copilot AI commented May 10, 2026

CI playwright-playground was failing because ensurePluginActivated() used a broad locator that matched both the plugin row and WordPress’s plugin update notice row (tr.plugin-update-tr), triggering Playwright strict-mode errors in two specs.

  • Scope

    • Updated only:
      • tests/e2e/playground.spec.js
      • tests/e2e/numeric-reorder.spec.js
  • Locator precision fix

    • Replaced combined/fallback plugin-row logic with a single selector keyed by plugin path and explicitly excluding update rows.
    • This removes ambiguity from the Plugins table lookup.
  • Assertion hardening

    • Added a uniqueness assertion before visibility checks in ensurePluginActivated():
      • await expect(pluginRow).toHaveCount(1);
    • Keeps failures explicit when DOM structure changes unexpectedly.
function getPluginRow(page) {
	return page.locator(
		'tr[data-plugin="borges-bibliography-builder/bibliography-builder.php"]:not(.plugin-update-tr)'
	);
}

Warning

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:

  • api.wordpress.org
    • Triggering command: /opt/hostedtoolcache/node/24.14.1/x64/bin/node /opt/hostedtoolcache/node/24.14.1/x64/bin/node --experimental-wasm-jspi /home/REDACTED/.npm/_npx/3b7824ec561ce8ed/node_modules/.bin/wp-playground-cli server --auto-mount --login --port=9400 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Update the failing Playwright e2e tests in the repository dknauss/borges-bibliography-builder to fix the CI failure from job 75264109601 in workflow run 25642047183.

Context:

Observed failure:

  • Playwright strict mode violation when resolving the plugin row locator used by ensurePluginActivated().
  • The current helper getPluginRow(page) matches both the actual plugin row and a WordPress plugin update notice row (tr.plugin-update-tr), causing expect(locator).toBeVisible() to fail because the locator resolves to 2 elements.

Required fix:

  • Update the test helper(s) so the plugin row locator matches only the real plugin row and excludes the update row.
  • Replace the broad combined/fallback locator logic with a more precise selector using the plugin path and excluding .plugin-update-tr.
  • Apply the fix consistently in both files listed above.

Suggested implementation:

function getPluginRow(page) {
	return page.locator(
		'tr[data-plugin="borges-bibliography-builder/bibliography-builder.php"]:not(.plugin-update-tr)'
	);
}

Optional hardening if appropriate:

  • Add an assertion like await expect(pluginRow).toHaveCount(1); before toBeVisible() if it improves test clarity and stability without making the tests brittle.

Please create a pull request with the test fixes only.

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: Please find a solution for this failing job. Use the logs, job definition, and any referenced files where the failure occurred. Keep your response focused on the solution and include code suggestions when appropriate.

Assistant: The failure is in the shared Playwright helper that finds the plugin row on Plugins → Installed Plugins.

Root cause

Both failing specs use getPluginRow():

The current locator combines:

page
  .locator(
    'tr[data-slug="borges-bibliography-builder"], tr[data-plugin="borges-bibliography-builder/bibliography-builder.php"]'
  )
  .first()
  .or(
    page.locator('tr', {
      hasText: 'Bibliography',
    })
  );

In CI, WordPress renders two matching rows for the plugin:

  1. the actual plugin row
  2. the plugin update notice row (tr.plugin-update-tr ...)

The logs show the strict mode violation came from that combined locator resolving to both rows.

Fix

Make getPluginRow() target only the real plugin row and exclude the update row fallback.

Suggested patch

Apply this in both files:

function getPluginRow(page) {
	return page.locator(
		'tr[data-plugin="borges-bibliography-builder/bibliography-builder.php"]:not(.plugin-update-tr)'
	);
}

Why this works

  • data-plugin="borges-bibliography-builder/bibliography-builder.php" uniquely identifies the plugin.
  • :not(.plugin-update-tr) filters out the update notice row that is breaking strict mode.
  • It removes the broad text fallback (hasText: 'Bibliography'), which is too loose.

Concrete edits

tests/e2e/playground.spec.js

Replace lines 4–15 with:

function getPluginRow(page) {
	return page.locator(
		'tr[data-plugin="borges-bibliography-builder/bibliography-builder.php"]:not(.plugin-update-tr)'
	);
}

tests/e2e/numeric-reorder.spec.js

Replace lines 4–15 with:

function getPluginRow(page) {
	return page.locator(
		'tr[data-plugin="borges-bibliography-builder/bibliography-builder.php"]:not(.plugin-update-tr)'
	);
}

Optional hardening

If you want to be extra defensive, also assert a single match before using it:

const pluginRow = getPluginRow(page);
await expect(pluginRow).toHaveCount(1);
await expect(pluginRow).toBeVisible();

Relevant failure locations

Job definition reference

This failure occurred in the Playwright job defined in:

This pull request was created from Copilot chat.

Copilot AI changed the title [WIP] Fix failing Playwright e2e tests for CI job 75264109601 Fix Playwright plugin-row locator strict-mode collisions in Playground e2e specs May 10, 2026
Copilot AI requested a review from dknauss May 10, 2026 23:07
@dknauss
Copy link
Copy Markdown
Owner

dknauss commented May 10, 2026

Fix applied directly to main in 91ac37d. Thanks Copilot.

dknauss added a commit that referenced this pull request May 10, 2026
Version bump:
- bibliography-builder.php, block.json, package.json, readme.txt → 1.4.0
- CHANGELOG.md and readme.txt changelog updated for 1.4.0

i18n:
- msgmerge all 19 PO files against updated POT; +30 new fuzzy strings
  per locale (BAC checks, BibLaTeX export, reorder controls, PHP errors)

E2E:
- Fix getPluginRow() in playground.spec.js and numeric-reorder.spec.js:
  use data-plugin + :not(.plugin-update-tr) to avoid strict-mode
  violations when WordPress renders a plugin update notice row alongside
  the plugin row. Closes Copilot PR #30.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@dknauss dknauss closed this May 10, 2026
@dknauss dknauss deleted the copilot/update-e2e-tests-playwright branch May 10, 2026 23:25
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.

2 participants