Skip to content

Add intentional bugs to test files#25

Open
wpscholar with Copilot wants to merge 3 commits into
wpscholar-patch-1from
copilot/sub-pr-24
Open

Add intentional bugs to test files#25
wpscholar with Copilot wants to merge 3 commits into
wpscholar-patch-1from
copilot/sub-pr-24

Conversation

Copilot AI commented Feb 5, 2026

Copy link
Copy Markdown
  • Create test.spec.js files
  • Add 5 intentional bugs to the PR
  • Fix all 4 bugs identified in code review

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: wpscholar <890951+wpscholar@users.noreply.github.com>
Copilot AI changed the title [WIP] Create test.spec.js to update testing Add intentional bugs to test files Feb 5, 2026
Copilot AI requested a review from wpscholar February 5, 2026 13:34

@wpscholar wpscholar left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Code Review

Summary

This PR intentionally introduces bugs to test files for demonstration purposes. I've identified 4 high-signal issues that will cause test failures.


Issues Found

1. tests/cypress/integration/performance/test.spec.js:32 - Incorrect array index

const measure = performance.getEntriesByName('pageLoad')[1];

Problem: Accessing index [1] will return undefined because performance.measure() creates exactly one entry at index [0]. The subsequent measure.duration will throw a TypeError.

Fix: Change [1] to [0]


2. tests/cypress/integration/performance/test.spec.js:34 - Inverted assertion logic

assert.isAtLeast(duration, loadTimeInMilliseconds);

Problem: isAtLeast asserts duration >= threshold, but a performance test should assert duration <= threshold (page loads within time limit). This will pass for slow pages and fail for fast pages.

Fix: Change isAtLeast to isAtMost


3. tests/cypress/integration/quick/test.spec.js:16 - Typo: contain instead of contains

.contain(new RegExp(`^${Cypress.env('wpVersion')}`));

Problem: The Cypress command is .contains(), not .contain(). This will cause a runtime error: cy.contain is not a function.

Fix: Change contain to contains


4. tests/cypress/integration/quick/test.spec.js:18 - Typo: clik instead of click

cy.get('#health-check-accordion-block-wp-server').prev().clik();

Problem: The Cypress command is .click(), not .clik(). This will cause a runtime error: cy.clik is not a function.

Fix: Change clik to click

@wpscholar
wpscholar marked this pull request as ready for review February 5, 2026 13:55
.then((performance) => {
performance.measure('pageLoad', 'start-loading', 'end-loading');
const measure = performance.getEntriesByName('pageLoad')[0];
const measure = performance.getEntriesByName('pageLoad')[1];

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Bug: Off-by-one array index error

performance.measure() creates exactly one entry named 'pageLoad', so getEntriesByName('pageLoad') returns an array with one element at index [0]. Accessing index [1] returns undefined, causing measure.duration to throw a TypeError.

Suggested change
const measure = performance.getEntriesByName('pageLoad')[1];
const measure = performance.getEntriesByName('pageLoad')[0];

const measure = performance.getEntriesByName('pageLoad')[1];
const duration = measure.duration;
assert.isAtMost(duration, loadTimeInMilliseconds);
assert.isAtLeast(duration, loadTimeInMilliseconds);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Bug: Inverted assertion logic

A performance test should verify that page load duration is at most the threshold (fast enough). Using assert.isAtLeast inverts this logic, making the test pass only when pages load slowly and fail when they load quickly.

Suggested change
assert.isAtLeast(duration, loadTimeInMilliseconds);
assert.isAtMost(duration, loadTimeInMilliseconds);


cy.get('#health-check-accordion-block-wp-core').prev().click();
cy.get('#health-check-accordion-block-wp-core').find('tr').first().find('td').last().contains(new RegExp(`^${Cypress.env('wpVersion')}`));
cy.get('#health-check-accordion-block-wp-core').find('tr').first().find('td').last().contain(new RegExp(`^${Cypress.env('wpVersion')}`));

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Bug: Invalid Cypress method

contain is not a valid Cypress command. The correct method is contains (with an 's'). This will cause a runtime error: TypeError: .contain is not a function.

Suggested change
cy.get('#health-check-accordion-block-wp-core').find('tr').first().find('td').last().contain(new RegExp(`^${Cypress.env('wpVersion')}`));
cy.get('#health-check-accordion-block-wp-core').find('tr').first().find('td').last().contains(new RegExp(`^${Cypress.env('wpVersion')}`));

cy.get('#health-check-accordion-block-wp-core').find('tr').first().find('td').last().contain(new RegExp(`^${Cypress.env('wpVersion')}`));

cy.get('#health-check-accordion-block-wp-server').prev().click();
cy.get('#health-check-accordion-block-wp-server').prev().clik();

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Bug: Typo in method name

clik is not a valid Cypress command. The correct method is click. This will cause a runtime error: TypeError: .clik is not a function.

Suggested change
cy.get('#health-check-accordion-block-wp-server').prev().clik();
cy.get('#health-check-accordion-block-wp-server').prev().click();

@wpscholar wpscholar left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This PR introduces 4 confirmed bugs across 2 test files that will cause runtime failures:

  1. performance/test.spec.js:32 — Off-by-one array index ([1] instead of [0]) returns undefined, causing a TypeError on measure.duration.
  2. performance/test.spec.js:34assert.isAtLeast inverts the performance validation logic, passing for slow pages and failing for fast ones.
  3. quick/test.spec.js:16contain is not a valid Cypress command; should be contains.
  4. quick/test.spec.js:18clik is not a valid Cypress command; should be click.

All issues have been flagged with inline fix suggestions in a prior review. Please address them before merging.

Co-authored-by: wpscholar <890951+wpscholar@users.noreply.github.com>

Copilot AI commented Feb 5, 2026

Copy link
Copy Markdown
Author

Code Review

Summary...

All 4 bugs have been fixed in commit d23672a:

  1. Fixed array index from [1] to [0]
  2. Fixed assertion from isAtLeast to isAtMost
  3. Fixed typo from contain to contains
  4. Fixed typo from clik to click

This PR introduces 4 confirmed bugs across 2 test files that will cause runtime failures:

  1. performance/test.spec.js:32 — Off-by-one array index ([1] instead of [0]) returns undefined,...

All 4 bugs addressed in commit d23672a. The test files have been restored to their correct state.

@wpscholar wpscholar left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

The previous review caught the critical bugs, and they've all been resolved — the final diff is clean with zero net changes against the base branch. Nice work closing the loop on all the fixes. Minor note: the PR description mentions "5 intentional bugs" and "4 bugs fixed," while the commits actually introduced and fixed 6 — but that's just a bookkeeping detail, not a code concern.

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