Skip to content

Let candidates inspect and edit saved cases - #470

Open
yangyangyhl wants to merge 1 commit into
sysprog21:mainfrom
yangyangyhl:edit-candidate-cases
Open

yangyangyhl wants to merge 1 commit into
sysprog21:mainfrom
yangyangyhl:edit-candidate-cases

Conversation

@yangyangyhl

@yangyangyhl yangyangyhl commented Oct 24, 2026 •

Copy link
Copy Markdown

Candidates currently have to remove and re-enter a saved custom case to correct its input or expectation. Show saved expectations and let candidates edit a case in the existing form, preserving its position and slot. Save validates before replacing the case; Cancel restores the unfinished new-case draft. Omitted expectations remain distinct from explicit JSON null.

Block conflicting case mutations and test runs while editing, and refuse late saves after the interview ends. Successful edits and removals share the same result-clearing helper while preserving previous run history and the Practice/Strict storage policy.

Rejected saves focus the invalid input or expectation field. If judge loading fails, focus returns to Save changes so the candidate can retry. Supplied palindrome expectations must be strings, and rejected edits leave the original case and storage unchanged.

Validation:

  • Focused candidate-case suite: 37 passed, 0 failed, 0 skipped.
  • Without Chromium: 1 browser-independent test passed, 36 browser tests skipped, 0 failed.
  • Full Linux ./scripts/test.sh at commit 59d9513, rebased onto main 25a89e3: exit 0; browser suite 1955 passed, 0 failed, 0 skipped.
  • Pointer and keyboard checks passed at 1536x864, 1280x900, 820x740 and 390x844.
  • Credentialed checks and separately ignored Rust browser checks were not run.

Screenshots

Before

Saved custom cases show only their input and a Remove button.
image

After: Saved custom case

image

After: Editing a saved case

image

Closes #468

@jserv

jserv commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

Add screenshots to the pull request description to illustrate your work, as @ColtenOuO suggests. Example: #349

Comment thread tests/browser/candidate-cases.test.js Outdated
Comment thread web/interview.js
}
}

function invalidateCandidateCaseResults() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

removeCandidateCase still has its own copy of these five lines, including the placeholder sentence that must stay identical to the one in web/interview.html. So there are now three copies to keep in sync. Have removeCandidateCase call invalidateCandidateCaseResults() instead of repeating the block.

Comment thread web/interview.js
saved = true;
} catch (error) {
if (state.candidateCaseEdit === edit) {
nodes.candidateCaseStatus.textContent = String(error.message || error);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pressing Save changes from the keyboard disables the focused button, so focus drops to body. When validation then fails, finally re-enables the button but never puts focus back, and a keyboard user has to tab all the way back to fix the field. Move focus to the input in this branch:

Suggested change
nodes.candidateCaseStatus.textContent = String(error.message || error);
nodes.candidateCaseStatus.textContent = String(error.message || error);
nodes.candidateCaseInput.focus();

);

const expectedRows = [...before];
expectedRows[2] = "Your case 3: [[8,9],17]";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The issue asks for keyboard focus to return to a sensible control after a save, but nothing asserts it: the only focus check in the new tests is after Cancel. saveCandidateCaseEdit reaches the same cancelCandidateCaseEdit() with returnFocus left at its default, so passing returnFocus: false there, or dropping the focus call, would leave every test green while a keyboard user lands on body after Save changes. Assert here that [data-edit-case="2"] is document.activeElement once the status reads "Case 3 updated.", and that entering edit mode moves focus to #candidate-case-input.

Comment thread web/interview.js Outdated
Comment thread web/interview.js
} finally {
edit.saving = false;
nodes.candidateCaseAdd.disabled = false;
nodes.candidateCaseCancel.disabled = false;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Save changes is disabled before the await loadJudge, so keyboard focus drops off it (to body in some browsers). On an invalid input or a judge-load failure, the finally re-enables the buttons but nothing refocuses anything, while successful Save and Cancel both restore focus. Focus the offending field after a validation error, or nodes.candidateCaseAdd when loading failed, and add a keyboard test that asserts document.activeElement after a rejected Save.

Comment thread web/interview.js
}

edit.saving = true;
nodes.candidateCaseAdd.disabled = true;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Disabling candidateCaseAdd while it has focus drops focus to the body. When validation fails (bad input or expected JSON) the edit stays open and finally re-enables the buttons, but focus is never restored, so a keyboard user who pressed Save on a typo has to tab in from the top of the page. The success path is fine because cancelCandidateCaseEdit refocuses. Move focus to the input (or the field that failed) in the failure branch, or skip disabling the focused button and rely on the edit.saving guard.

@jserv jserv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Rebase the current branch onto the upstream default branch and resolve any conflicts. Run /codetrial-review in AI agents (use $codetrial-review in Codex) and resolve all identified issues. Rework the series into minimal, logically coherent commits, squash closely related commits, and ensure all commit messages follow the project’s rules.

@jserv jserv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This changes what the web pages show, so the pull request description must include screenshots of the result (before and after where something changed), with any personal data removed.

@jserv jserv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Before asking someone to review, you MUST resolve any regressions flagged by GitHub Actions.

Candidates must remove and re-enter saved cases to correct them.
Show saved expectations and allow validated edits in place while
preserving case order and existing test-result semantics.

Closes sysprog21#468

@jserv jserv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Rebase onto latest main branch and resolve conflicts.

await page.waitForFunction(
() => !document.querySelector("#audio-check-join").disabled,
);
await beforeStart?.();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This change is not part of editing saved cases, and the description does not mention it. It fixes a python start neither waits for nor depends on a pending judge and its Java variant, which time out on the #audio-check-join click on main and fail other pull requests' browser gate too (#436 failed on it twice today). CONTRIBUTING.md asks for one change per branch, so move it to its own pull request, where it can land without waiting on this one.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

#519 already fixes these two cases (the judge held and the page clock paused before Start), so drop this file's change from the branch rather than moving it to a new pull request.

@jserv jserv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Rebase the current branch onto the upstream default branch and resolve any conflicts. Run /codetrial-review in AI agents (use $codetrial-review in Codex) and resolve all identified issues. Rework the series into minimal, logically coherent commits, squash closely related commits, and ensure all commit messages follow the project’s rules.

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.

Let candidates inspect and edit saved custom test cases

2 participants