Skip to content

Commit c1d67bd

Browse files
JulianMaurinclaude
andcommitted
test: re-record browser-extension fixtures on the current GitHub DOM, by era
GitHub A/B-tests its PR page markup, so the extension carries selectors for more than one DOM era. Split the fixture corpus into date-stamped era directories so both are exercised: github_dom_2025_02/ (the existing captures, moved and now sanitized — they were leaking the original capturers' identities into this public repo) and github_dom_2026_07/ (freshly recorded from synthetic PRs on the mergify-sandbox org: opened, merged, no_mergify, no_timeline_actions, batch_closed). The fixture loader takes an era; the flat searchConfig* and mergify_timestamp fragment fixtures are unaffected. Existing tests pin the legacy era explicitly; a new suite asserts the era-agnostic detection (data-status pill, merged-by-Mergify timeline, Mergify app-avatar marker) against the current DOM. Recorded via the record-github-fixtures + extract-browser-cookies skills (Mergifyio/skills#32, #33). MRGFY-8087 Test plan: - npx jest (284 passing) — legacy suite green through the era loader; new current-DOM parity suite green. - npx biome check — clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KJbLFjMX9mb8o5T3JXTAXL Change-Id: I966a2d36a92c50664bdea6918b1987293014b822
1 parent 09b2ada commit c1d67bd

13 files changed

Lines changed: 19540 additions & 166 deletions
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
const { injectFixtureInDOM, LEGACY_ERA, CURRENT_ERA } = require("./utils");
2+
const {
3+
isPullRequestOpen,
4+
isPullRequestDraft,
5+
wasMergedByMergify,
6+
} = require("../queue.js");
7+
8+
const APP_AVATAR = 'img[src^="https://avatars.githubusercontent.com/in/10562"]';
9+
const isMergifyAppShown = () => document.querySelector(APP_AVATAR) !== null;
10+
11+
// GitHub A/B-tests its PR page markup, so the extension's detection spans DOM
12+
// eras (legacy span.State / .gh-header-meta beside current data-status / React
13+
// header). The same checks run against every recorded era so a regression on
14+
// either path fails here. The two eras were captured from different PRs, so a
15+
// fixture's exact state can differ across eras — hence per-era expected values.
16+
// isPullRequestOpen / isPullRequestDraft are the dual-selector functions this
17+
// most directly exercises.
18+
const EXPECTED = {
19+
[LEGACY_ERA]: {
20+
github_pr_opened: {
21+
open: true,
22+
draft: true,
23+
merged: false,
24+
mergify: true,
25+
},
26+
github_pr_merged: {
27+
open: false,
28+
draft: false,
29+
merged: false,
30+
mergify: false,
31+
},
32+
github_pr_no_timeline_actions: {
33+
open: true,
34+
draft: true,
35+
merged: false,
36+
mergify: true,
37+
},
38+
github_pr_no_mergify: {
39+
open: true,
40+
draft: false,
41+
merged: false,
42+
mergify: false,
43+
},
44+
},
45+
[CURRENT_ERA]: {
46+
github_pr_opened: {
47+
open: true,
48+
draft: false,
49+
merged: false,
50+
mergify: true,
51+
},
52+
github_pr_merged: {
53+
open: false,
54+
draft: false,
55+
merged: true,
56+
mergify: true,
57+
},
58+
github_pr_no_timeline_actions: {
59+
open: false,
60+
draft: false,
61+
merged: false,
62+
mergify: false,
63+
},
64+
github_pr_no_mergify: {
65+
open: true,
66+
draft: false,
67+
merged: false,
68+
mergify: false,
69+
},
70+
},
71+
};
72+
73+
describe.each([
74+
LEGACY_ERA,
75+
CURRENT_ERA,
76+
])("fixture DOM detection — %s", (era) => {
77+
afterEach(() => {
78+
document.body.innerHTML = "";
79+
});
80+
81+
test.each(Object.keys(EXPECTED[era]))("%s", (name) => {
82+
injectFixtureInDOM(name, era);
83+
const exp = EXPECTED[era][name];
84+
expect(isPullRequestOpen()).toBe(exp.open);
85+
expect(isPullRequestDraft()).toBe(exp.draft);
86+
expect(wasMergedByMergify()).toBe(exp.merged);
87+
expect(isMergifyAppShown()).toBe(exp.mergify);
88+
});
89+
});

src/__tests__/fixtures/github_pr_merged.html renamed to src/__tests__/fixtures/github_dom_2025_02/github_pr_merged.html

Lines changed: 18 additions & 18 deletions
Large diffs are not rendered by default.

src/__tests__/fixtures/github_pr_no_mergify.html renamed to src/__tests__/fixtures/github_dom_2025_02/github_pr_no_mergify.html

Lines changed: 42 additions & 42 deletions
Large diffs are not rendered by default.

src/__tests__/fixtures/github_pr_no_timeline_actions.html renamed to src/__tests__/fixtures/github_dom_2025_02/github_pr_no_timeline_actions.html

Lines changed: 40 additions & 40 deletions
Large diffs are not rendered by default.

src/__tests__/fixtures/github_pr_opened.html renamed to src/__tests__/fixtures/github_dom_2025_02/github_pr_opened.html

Lines changed: 46 additions & 46 deletions
Large diffs are not rendered by default.

src/__tests__/fixtures/github_dom_2026_07/github_pr_batch_closed.html

Lines changed: 4093 additions & 0 deletions
Large diffs are not rendered by default.

src/__tests__/fixtures/github_dom_2026_07/github_pr_merged.html

Lines changed: 4932 additions & 0 deletions
Large diffs are not rendered by default.

src/__tests__/fixtures/github_dom_2026_07/github_pr_no_mergify.html

Lines changed: 2982 additions & 0 deletions
Large diffs are not rendered by default.

src/__tests__/fixtures/github_dom_2026_07/github_pr_no_timeline_actions.html

Lines changed: 2968 additions & 0 deletions
Large diffs are not rendered by default.

src/__tests__/fixtures/github_dom_2026_07/github_pr_opened.html

Lines changed: 4299 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)