Skip to content

Feature/stricter excluded link enforcement#342

Merged
gin0115 merged 5 commits into
trunkfrom
feature/stricter-excluded-link-enforcement
May 28, 2026
Merged

Feature/stricter excluded link enforcement#342
gin0115 merged 5 commits into
trunkfrom
feature/stricter-excluded-link-enforcement

Conversation

@gin0115

@gin0115 gin0115 commented May 28, 2026

Copy link
Copy Markdown
Collaborator

Changes proposed in this Pull Request

This pull request introduces a comprehensive end-to-end (E2E) test harness for the plugin, adds Playwright-based E2E testing infrastructure, and implements a regression test for the per-link "Exclude this link" feature. It also refines exclusion logic so that only system-set (not manual) exclusions are automatically lifted when a link is fixed, and ensures that the front-end JS correctly ignores manually excluded links. Additionally, several developer experience and dependency updates are included.

E2E Test Infrastructure and Regression Coverage:

  • Added a full Playwright-based E2E test harness under the e2e/ directory, including configuration, environment setup, and a regression test for per-link exclusion. This includes .wp-env.json for local WordPress environments, Playwright config, and supporting fixtures. (.wp-env.json, e2e/global-setup.js, e2e/playwright.config.js, e2e/fixtures/seed-exclusion-bug.php, e2e/specs/link-exclusion.spec.js, [1] [2] [3] [4] [5]
  • Added E2E test workflow to GitHub Actions for CI, with artifact uploads on failure. (.github/workflows/e2e-tests.yml, .github/workflows/e2e-tests.ymlR1-R60)
  • Updated .distignore to exclude E2E-only files from deploys. (.distignore, .distignoreR27-R32)
  • Updated package.json with E2E test scripts and new dev dependencies. (package.json, [1] [2]
  • Added E2E test status badge to README.md. (README.md, README.mdL12-R15)

Exclusion Logic Improvements:

  • Refined logic so that only system-set exclusions (e.g., due to "no-access" errors) are automatically lifted when a link is fixed; manual exclusions (user-requested) are now preserved. This affects link rescanning and snapshot/validator status event handling. (src/Action/Link_Latest_Snapshot_Action.php, [1]; src/Event/Check_Snapshot_Status_Event.php, [2]; src/Event/Check_Validator_Status.php, [3]
  • Added is_manual_exclusion() method to the Link model to distinguish manual from system exclusions. (src/Link/Link.php, src/Link/Link.phpR217-R227)

Link Filtering and Front-End Behavior:

  • Updated Link_Repository::get_links_for_post() to ensure per-link exclusions are always honored, so excluded links are not sent to the front-end JS for rewriting. (src/Link/Link_Repository.php, src/Link/Link_Repository.phpL367-R376)

Dependency and Maintenance Updates:


These changes significantly improve test coverage for exclusion logic, prevent regressions, and enhance the reliability of both the code and the development workflow.

Testing instructions

Mentions #

Summary by CodeRabbit

  • New Features

    • Link exclusion now distinguishes manual vs system-set exclusions, preserving user-made exclusions.
  • Bug Fixes

    • System-set exclusions are lifted and stale error messages cleared when archives become available.
    • Manual exclusions remain intact during snapshot recovery.
  • Tests

    • Added Playwright end-to-end tests and expanded unit tests covering exclusion and snapshot behaviors.
  • Chores

    • CI workflow, local test environment config, ignore rules, and README badges updated.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 28, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8a6e8406-6e03-4b85-b47f-35d822fa1a84

📥 Commits

Reviewing files that changed from the base of the PR and between b67808d and 4fc1aa7.

⛔ Files ignored due to path filters (1)
  • composer.lock is excluded by !**/*.lock
📒 Files selected for processing (2)
  • .phpcs.xml
  • composer.json
✅ Files skipped from review due to trivial changes (1)
  • .phpcs.xml
🚧 Files skipped from review as they are similar to previous changes (1)
  • composer.json

Walkthrough

This pull request adds comprehensive support for distinguishing between manual and system-set link exclusions, then conditionally lifts only system exclusions when links are successfully repaired. A new is_manual_exclusion() method identifies manually excluded links by checking for a user-set message prefix. Three event handlers are updated to preserve manual exclusions while lifting system exclusions on success. The changes are covered by PHPUnit tests and verified end-to-end with Playwright and wp-env, including a new E2E regression test that seeds deterministic test data and verifies per-link exclusion behavior in the browser.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately summarizes the main change: stricter enforcement of per-link exclusions, distinguishing manual from system-set exclusions. The title is concise and specific.
Docstring Coverage ✅ Passed Docstring coverage is 96.30% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (3)
.github/workflows/e2e-tests.yml (2)

30-31: ⚡ Quick win

Consider removing --force flag from npm ci.

The --force flag can mask dependency conflicts and version mismatches that should be resolved. In CI environments, it's better to fail fast on dependency issues rather than force installation.

♻️ Proposed change
       - name: Install npm dependencies
-        run: npm ci --force
+        run: npm ci
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/e2e-tests.yml around lines 30 - 31, Remove the --force
flag from the npm install step so CI fails on real dependency issues: update the
workflow step named "Install npm dependencies" to run "npm ci" (remove the
"--force" from the command "npm ci --force") to allow the job to surface
dependency conflicts and version mismatches instead of masking them.

13-60: ⚖️ Poor tradeoff

Consider pinning GitHub Actions to commit SHAs for improved security.

Static analysis flagged that actions are referenced by tag (@v4, @v2) rather than commit SHA. While tag-based versions are more maintainable, SHA pinning provides stronger supply-chain security by preventing tag movements. This is a project policy decision.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/e2e-tests.yml around lines 13 - 60, Replace tag-based
action refs with pinned commit SHAs: change uses: actions/checkout@v4,
shivammathur/setup-php@v2, actions/setup-node@v4, and actions/upload-artifact@v4
to their corresponding repository commit SHAs (e.g., uses:
actions/checkout@<commit-sha>) so the workflow is immutably pinned; update each
"uses:" line in the workflow to the exact SHA for that action, and add a short
comment beside each pinned ref noting the original tag (for maintainability) and
a link or note on how to update the SHA in future.
composer.json (1)

41-41: ⚡ Quick win

Consider a more specific version constraint.

Using "*" allows any version of vlucas/phpdotenv, including future major releases with breaking changes. While this is a dev dependency, a breaking change can still disrupt development and CI workflows.

📦 Recommended version constraint
-        "vlucas/phpdotenv": "*",
+        "vlucas/phpdotenv": "^5.5",

Alternatively, if you need v6.x features, use "^6.0".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@composer.json` at line 41, The composer.json dependency "vlucas/phpdotenv"
currently uses a wildcard "*" which permits any version; update the version
constraint to a safer, more specific range (for example "^6.0" or another
targeted major like "^5.5") to avoid pulling breaking changes—edit the
composer.json entry for "vlucas/phpdotenv" to replace "*" with the chosen semver
constraint and run composer update/install to verify compatibility.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/Link/Link.php`:
- Around line 217-226: The is_manual_exclusion() method relies on the
user-facing string 'User Requested To Exclude' in $this->message which is
fragile; change the implementation to use a stable machine-readable marker or
dedicated flag instead: add a constant (e.g. MANUAL_EXCLUSION_MARKER) or a
boolean property (e.g. $this->manual_excluded) and set that marker in
Report_Page::handle_link_details_form() when a user manually excludes a link;
update is_manual_exclusion() to check $this->is_excluded && (marker presence or
$this->manual_excluded) and keep display text separate (use the
'internet-archive-wayback-machine-link-fixer' text domain for any translatable
UI string).

---

Nitpick comments:
In @.github/workflows/e2e-tests.yml:
- Around line 30-31: Remove the --force flag from the npm install step so CI
fails on real dependency issues: update the workflow step named "Install npm
dependencies" to run "npm ci" (remove the "--force" from the command "npm ci
--force") to allow the job to surface dependency conflicts and version
mismatches instead of masking them.
- Around line 13-60: Replace tag-based action refs with pinned commit SHAs:
change uses: actions/checkout@v4, shivammathur/setup-php@v2,
actions/setup-node@v4, and actions/upload-artifact@v4 to their corresponding
repository commit SHAs (e.g., uses: actions/checkout@<commit-sha>) so the
workflow is immutably pinned; update each "uses:" line in the workflow to the
exact SHA for that action, and add a short comment beside each pinned ref noting
the original tag (for maintainability) and a link or note on how to update the
SHA in future.

In `@composer.json`:
- Line 41: The composer.json dependency "vlucas/phpdotenv" currently uses a
wildcard "*" which permits any version; update the version constraint to a
safer, more specific range (for example "^6.0" or another targeted major like
"^5.5") to avoid pulling breaking changes—edit the composer.json entry for
"vlucas/phpdotenv" to replace "*" with the chosen semver constraint and run
composer update/install to verify compatibility.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 452d6a4f-3772-4cbc-9cf4-b615126297f0

📥 Commits

Reviewing files that changed from the base of the PR and between 805eaf3 and e27974b.

⛔ Files ignored due to path filters (2)
  • composer.lock is excluded by !**/*.lock
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (22)
  • .distignore
  • .github/workflows/e2e-tests.yml
  • .gitignore
  • .wp-env.json
  • README.md
  • composer.json
  • e2e/.env.example
  • e2e/fixtures/seed-exclusion-bug.php
  • e2e/global-setup.js
  • e2e/playwright.config.js
  • e2e/specs/link-exclusion.spec.js
  • package.json
  • src/Action/Link_Latest_Snapshot_Action.php
  • src/Event/Check_Snapshot_Status_Event.php
  • src/Event/Check_Validator_Status.php
  • src/Link/Link.php
  • src/Link/Link_Repository.php
  • tests/Action/Test_Link_Latest_Snapshot_Action.php
  • tests/Event/Test_Check_Snapshot_Status_Event.php
  • tests/Event/Test_Check_Validator_Status.php
  • tests/Link/Test_Link.php
  • tests/Link/Test_Link_Repository.php

Comment thread src/Link/Link.php
@coderabbitai

coderabbitai Bot commented May 28, 2026

Copy link
Copy Markdown

Actionable comments posted: 0

@coderabbitai

coderabbitai Bot commented May 28, 2026

Copy link
Copy Markdown

Actionable comments posted: 0

@gin0115 gin0115 merged commit 9bb9857 into trunk May 28, 2026
12 checks passed
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.

1 participant