Skip to content

Commit 0eafe33

Browse files
author
GitHub Workshop Bot
committed
fix(learning-room): consolidate Challenge 7 conflict-verification tests
The new verification polling in ensureMergeConflictPractice silently broke the pre-existing regression suite at .github/scripts/__tests__/challenge-progression-conflict-practice.test.js (from commit c8754b4) - its fake request had no handler for polling the practice PR, so every test now took the fallback path instead of the success path, passing only by loose-regex coincidence and adding several seconds of real setTimeout delay per run. Add the missing handler, pass delayMs=0 in every test call, and add explicit fallback- path coverage here instead of in a disconnected new test file that was never wired into any CI-run glob.
1 parent 6b55cbd commit 0eafe33

2 files changed

Lines changed: 26 additions & 71 deletions

File tree

‎.github/scripts/__tests__/challenge-progression-conflict-practice.test.js‎

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ function fakeRequest(overrides = {}) {
4848
if (method === 'POST' && route === '/repos/org/room/pulls') {
4949
return { number: 99, html_url: 'https://example.test/pull/99' };
5050
}
51+
if (method === 'GET' && route === '/repos/org/room/pulls/99') {
52+
return { mergeable_state: 'dirty' };
53+
}
5154
return null;
5255
};
5356
return { calls, request };
@@ -56,7 +59,7 @@ function fakeRequest(overrides = {}) {
5659
test('opens a branch, two conflicting edits, a PR, and comments the issue', async () => {
5760
const { calls, request } = fakeRequest();
5861

59-
await ensureMergeConflictPractice(11, request);
62+
await ensureMergeConflictPractice(11, request, 0);
6063

6164
const refPosts = calls.filter((c) => c.method === 'POST' && c.route === '/repos/org/room/git/refs');
6265
assert.equal(refPosts.length, 1);
@@ -89,7 +92,7 @@ test('is idempotent: does nothing when a practice PR already exists in any state
8992
'GET /repos/org/room/pulls?': () => [{ number: 5, state: 'closed' }]
9093
});
9194

92-
await ensureMergeConflictPractice(11, request);
95+
await ensureMergeConflictPractice(11, request, 0);
9396

9497
const writes = calls.filter((c) => c.method === 'POST' || c.method === 'PUT');
9598
assert.deepEqual(writes, [
@@ -105,7 +108,7 @@ test('is idempotent: skips when the conflict anchor is already on main', async (
105108
})
106109
});
107110

108-
await ensureMergeConflictPractice(11, request);
111+
await ensureMergeConflictPractice(11, request, 0);
109112

110113
const writes = calls.filter((c) => c.method === 'POST' || c.method === 'PUT');
111114
assert.deepEqual(writes, []);
@@ -118,7 +121,7 @@ test('falls back to looking up the issue when no issue number is passed', async
118121
]
119122
});
120123

121-
await ensureMergeConflictPractice(null, request);
124+
await ensureMergeConflictPractice(null, request, 0);
122125

123126
const issueComments = calls.filter((c) => c.method === 'POST' && c.route === '/repos/org/room/issues/21/comments');
124127
assert.equal(issueComments.length, 1);
@@ -131,3 +134,22 @@ test('never throws: progression survives a seeding failure', async () => {
131134

132135
await assert.doesNotReject(ensureMergeConflictPractice(11, request));
133136
});
137+
138+
test('falls back to manual instructions when the practice PR never registers as conflicting', async () => {
139+
const { calls, request } = fakeRequest({
140+
'GET /repos/org/room/pulls/99': () => ({ mergeable_state: 'clean' })
141+
});
142+
143+
await ensureMergeConflictPractice(11, request, 0);
144+
145+
const successComments = calls.filter(
146+
(c) => c.method === 'POST' && c.route === '/repos/org/room/issues/11/comments' && /practice PR is ready/.test(c.body.body)
147+
);
148+
const fallbackComments = calls.filter(
149+
(c) => c.method === 'POST' && c.route === '/repos/org/room/issues/11/comments' && /did not register a conflict/.test(c.body.body)
150+
);
151+
assert.equal(successComments.length, 0);
152+
assert.equal(fallbackComments.length, 1);
153+
assert.match(fallbackComments[0].body.body, /#99/);
154+
assert.match(fallbackComments[0].body.body, /main/);
155+
});

‎learning-room/.github/scripts/__tests__/challenge-progression.test.js‎

Lines changed: 0 additions & 67 deletions
This file was deleted.

0 commit comments

Comments
 (0)