Skip to content

test: add tests for isPullRequestOpen data-status detection#178

Closed
sileht wants to merge 1 commit intomainfrom
devs/sileht/dependabot-fix/I01b941cc836bdaa401ec5798b1c5b8a023c7fadb
Closed

test: add tests for isPullRequestOpen data-status detection#178
sileht wants to merge 1 commit intomainfrom
devs/sileht/dependabot-fix/I01b941cc836bdaa401ec5798b1c5b8a023c7fadb

Conversation

@sileht
Copy link
Member

@sileht sileht commented Feb 5, 2026

Cover the new data-status attribute selectors (pullOpened, draft),
priority over legacy span.State, fallback behavior, and edge cases.

Co-Authored-By: Claude Opus 4.5 noreply@anthropic.com

Copilot AI review requested due to automatic review settings February 5, 2026 17:51
@mergify mergify bot had a problem deploying to Mergify Merge Protections February 5, 2026 17:51 Failure
@mergify
Copy link
Contributor

mergify bot commented Feb 5, 2026

Merge Protections

Your pull request matches the following merge protections and will not be merged until they are valid.

🔴 Required Reviews

This rule is failing.
  • any of:
    • #approved-reviews-by >= 2
    • author = dependabot[bot]

🔴 🔎 Reviews

This rule is failing.
  • #review-threads-unresolved = 0
  • #changes-requested-reviews-by = 0
  • #review-requested = 0

🟢 Enforce conventional commit

Wonderful, this rule succeeded.

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert)(?:\(.+\))?:

🟢 📕 PR description

Wonderful, this rule succeeded.
  • body ~= (?ms:.{48,})

Copy link

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 adds comprehensive test coverage for the isPullRequestOpen function's data-status attribute detection logic. The tests verify the new data-status attribute selectors (pullOpened, draft) work correctly, that they take priority over the legacy span.State selector, and that fallback behavior works as expected.

Changes:

  • Renamed existing test descriptions to clarify they test legacy span.State behavior
  • Added tests for data-status="pullOpened" and data-status="draft" attribute detection
  • Added test to verify data-status takes priority over legacy span.State
  • Added edge case tests for missing status elements and unparseable titles

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +125 to +173
it("should detect open PR via data-status=pullOpened attribute", () => {
document.body.innerHTML =
'<span data-status="pullOpened">Open</span>';

expect(isPullRequestOpen()).toBe(true);
});

it("should detect draft PR via data-status=draft attribute", () => {
document.body.innerHTML = '<span data-status="draft">Draft</span>';

expect(isPullRequestOpen()).toBe(true);
});

it("should prefer data-status over legacy span.State", () => {
document.body.innerHTML =
'<span data-status="pullOpened">Open</span>' +
'<span class="State" title="Status: Closed">Closed</span>';

expect(isPullRequestOpen()).toBe(true);
});

it("should detect closed PR via legacy span.State when no data-status", () => {
document.body.innerHTML =
'<span class="State" title="Status: Closed">Closed</span>';

expect(isPullRequestOpen()).toBe(false);
});

it("should assume open when no status element is found", () => {
document.body.innerHTML = "<div>No status here</div>";

expect(isPullRequestOpen()).toBe(true);
});

it("should assume open when legacy span.State has no parseable title", () => {
const consoleSpy = jest
.spyOn(console, "warn")
.mockImplementation(() => {});

document.body.innerHTML =
'<span class="State" title="Malformed">Badge</span>';

expect(isPullRequestOpen()).toBe(true);
expect(consoleSpy).toHaveBeenCalledWith(
"Can't find pull request status",
);

consoleSpy.mockRestore();
});
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

Missing test coverage for closed/merged PRs using the new data-status attribute format. The implementation currently only checks for data-status="pullOpened" and data-status="draft", but if GitHub uses data-status="merged" or data-status="closed", the function would fall through to checking span.State. If span.State doesn't exist in the new format, it would incorrectly return true. Add test cases for data-status="merged" and data-status="closed" to ensure these scenarios are covered and work as expected.

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

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

@copilot open a new pull request to apply changes based on this feedback

Cover the new data-status attribute selectors (pullOpened, draft),
priority over legacy span.State, fallback behavior, and edge cases.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Change-Id: I01b941cc836bdaa401ec5798b1c5b8a023c7fadb
@sileht sileht force-pushed the devs/sileht/dependabot-fix/I01b941cc836bdaa401ec5798b1c5b8a023c7fadb branch from 9f627b1 to 2c30215 Compare February 5, 2026 18:46
@sileht sileht closed this Feb 5, 2026
@sileht sileht deleted the devs/sileht/dependabot-fix/I01b941cc836bdaa401ec5798b1c5b8a023c7fadb branch February 5, 2026 18:46
@mergify
Copy link
Contributor

mergify bot commented Feb 5, 2026

🧪 CI Insights

Here's what we observed from your CI run for 2c30215.

🟢 All jobs passed!

But CI Insights is watching 👀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants