Repository navigation
Conversation
032f429 to
e313f61
Compare
Retrying a coding attempt currently resets its language to Python, which can hide the mismatch until starter code or tests appear. Preserve the saved language only when the problem offers it, retaining Python as the fallback.
e313f61 to
99a05a9
Compare
| button.addEventListener("click", () => { | ||
| languageChoiceCommitted = true; | ||
| setLanguage(button.dataset.language); | ||
| }); |
There was a problem hiding this comment.
Nothing covers this languageChoiceCommitted = true. If I drop L871, every test in candidate-cases, editor-pipeline and dom-contract still passes. The case it guards: the URL asks for language=c, the candidate clicks JavaScript while C is still disabled, and the judge arriving later switches them to C anyway. The editing test covers the other half of the earlier "changing tabs or editing" request, but not this one.
Could you add a held-judge test that clicks [data-language="javascript"] before releaseJudge() and asserts JavaScript is still selected after candidateCasesReady?
| test("a requested C tab is restored after its judge loads", async (t) => { | ||
| if (!browser) return t.skip("playwright chromium unavailable"); | ||
| const runtimeConfig = DEFAULT_RUNTIME_CONFIG.replace( | ||
| "ENABLED = false", | ||
| "ENABLED = true", | ||
| ).replace('BASE_URL = ""', 'BASE_URL = "https://godbolt.org"'); | ||
| const enabled = await startStaticServer({ runtimeConfig }); | ||
| const page = await browser.newPage(); | ||
| let releaseJudge = () => {}; | ||
| try { | ||
| releaseJudge = await holdJudge(page); | ||
| await page.goto( | ||
| `${enabled.base}/interview.html?problem=chargeback-pair-match&language=c`, | ||
| { waitUntil: "domcontentloaded" }, | ||
| ); | ||
| const c = page.locator('[data-language="c"]'); | ||
| await page.waitForFunction( | ||
| () => document.querySelector('[data-language="c"]').disabled, | ||
| ); |
There was a problem hiding this comment.
The four new tests repeat the same setup: the Compiler Explorer runtime config (also used at L647), the static server, holdJudge, the language=c URL, the wait for C to be disabled, and the same finally cleanup. A helper would leave each test with just the step that differs:
async function withHeldRequestedC(body) {
const enabled = await startStaticServer({ runtimeConfig: CE_RUNTIME_CONFIG });
const page = await browser.newPage();
let releaseJudge = () => {};
try {
releaseJudge = await holdJudge(page);
await page.goto(
`${enabled.base}/interview.html?problem=chargeback-pair-match&language=c`,
{ waitUntil: "domcontentloaded" },
);
await page.waitForFunction(
() => document.querySelector('[data-language="c"]').disabled,
);
await body(page, () => releaseJudge());
} finally {
releaseJudge();
await page.close();
await new Promise((closed) => enabled.server.close(closed));
}
}CE_RUNTIME_CONFIG would be the DEFAULT_RUNTIME_CONFIG.replace(...) result, hoisted to module scope. The tab-click test from the other comment would then be a few lines.
Retrying a past coding attempt currently restores its problem, duration, loop, and mode but starts the next interview with Python regardless of the saved language.
This change carries the saved language into the interview URL and restores it only when the problem offers it. Missing, unknown, or unavailable languages retain the existing Python fallback, and a delayed C selection does not replace a language the candidate has already chosen or edited.
Tests cover retrying a JavaScript attempt, restoring an offered language, retaining Python for an unavailable language, and restoring C only after a compatible judge loads.
Closes #310
Summary by cubic
Retrying a past coding attempt now restores its saved language instead of always starting the interview in Python.
The language is only restored when the problem offers it; missing, unknown, or unavailable languages keep the Python fallback, and a delayed C judge no longer overrides a language the candidate has already selected, edited with, or run tests with.
Closes #310.
Written for commit 99a05a9. Summary will update on new commits.