Skip to content

exclude /renew and /upgrade URLs from broken link validation#344

Open
hanna-meda wants to merge 1 commit intodevelopfrom
fix/exclude-renew-and-upgrade-from-broken-link-checks
Open

exclude /renew and /upgrade URLs from broken link validation#344
hanna-meda wants to merge 1 commit intodevelopfrom
fix/exclude-renew-and-upgrade-from-broken-link-checks

Conversation

@hanna-meda
Copy link
Contributor

@hanna-meda hanna-meda commented Mar 2, 2026

Description

This PR skips /renew/ and /upgrade/ URLs in WP Rocket settings E2E broken link tests to prevent triggering unintended transactional actions.

Fixes #343

Type of change

  • New feature (non-breaking change which adds functionality).
  • Bug fix (non-breaking change which fixes an issue).
  • Enhancement (non-breaking change which improves an existing functionality).
  • Breaking change (fix or feature that would cause existing functionality to not work as before).
  • Sub-task of #(issue number)
  • Chore
  • Release

Detailed scenario

What was tested

Added a temporarily log of the URLs being validated and ran command npm run test:brokenlinks
Confirmed /renew/ and /upgrade/ are excluded.
Screenshot 2026-03-02 at 17 22 11

How to test

Run command npm run test:brokenlinks

Affected Features & Quality Assurance Scope

  • WP Rocket settings UI link validation test.
  • Confirm no transactional side effects occur (no pending orders are created on the production site).

Technical description

Documentation

The step definition now filters out URLs containing /renew/ or /upgrade/ before validating their HTTP status.

New dependencies

None.

Risks

Minimal risk: Only skips specific URLs, does not affect other test logic.

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 actionnable.

Unticked items justification

N/A

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.)

Copy link

@nicomollet nicomollet left a comment

Choose a reason for hiding this comment

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

✅ I believe we are good, the links list doesn't show URLs that would create orders on WPR website.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the WP Rocket settings broken-link E2E check to avoid validating /renew/ and /upgrade/ URLs, preventing the test suite from triggering transactional side effects on wp-rocket.me.

Changes:

  • Add skip-pattern support to the shared validateLinks() helper.
  • Exclude /renew/ and /upgrade/ links from the WP Rocket settings link collection/validation flow.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
utils/helpers.ts Extends validateLinks() with optional skipPatterns filtering.
src/support/steps/broken-links.ts Filters out /renew/ and /upgrade/ URLs before running the broken-link validation step.

Comment on lines 644 to +659
/**
* Validates HTTP/HTTPS URLs and collects broken links, handling client/server errors appropriately.
* Fails on internal 4xx errors, allows external 401/403 (gated content), warns on 5xx and network errors.
*
* @async
* @param {Page} page - The Playwright page object
* @param {Set<string>} urls - Set of URLs to validate
* @param {string} currentHost - Current host to distinguish internal from external URLs
* @return {Promise<string[]>} - Array of broken link strings in format "STATUS: url"
*/
export const validateLinks = async (page: Page, urls: Set<string>, currentHost: string): Promise<string[]> => {
export const validateLinks = async (
page: Page,
urls: Set<string>,
currentHost: string,
skipPatterns: RegExp[] = []
): Promise<string[]> => {
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

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

validateLinks now accepts skipPatterns but the JSDoc wasn’t updated to document this new parameter. Please add an @param entry for skipPatterns (and describe expected matching semantics) so callers know how to use it.

Copilot uses AI. Check for mistakes.
Comment on lines +60 to +66
let normalizedUrls = normalizeUrls(allHrefs, basePageUrl);

// Exclude URLs that may trigger transactional side effects
const skipPatterns = [/\/renew\//i, /\/upgrade\//i];
normalizedUrls = new Set(
Array.from(normalizedUrls).filter(url => !skipPatterns.some(pattern => pattern.test(url)))
);
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

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

The URL skipping logic is duplicated: you filter normalizedUrls with skipPatterns here, but validateLinks also has built-in skipPatterns support (currently not used because it’s called without the 4th arg). Consider keeping the skip logic in one place by either (a) removing this manual filtering and passing skipPatterns into validateLinks, or (b) dropping the skipPatterns parameter from validateLinks if you want the step to own filtering.

Copilot uses AI. Check for mistakes.
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.

Exclude renew and upgrade URLs from E2E broken link checks to prevent unintended order creation

3 participants