Repository navigation
Let candidates inspect and edit saved cases - #470
yangyangyhl wants to merge 1 commit into
Conversation
|
Add screenshots to the pull request description to illustrate your work, as @ColtenOuO suggests. Example: #349 |
| } | ||
| } | ||
|
|
||
| function invalidateCandidateCaseResults() { |
There was a problem hiding this comment.
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.
| saved = true; | ||
| } catch (error) { | ||
| if (state.candidateCaseEdit === edit) { | ||
| nodes.candidateCaseStatus.textContent = String(error.message || error); |
There was a problem hiding this comment.
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:
| 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]"; |
There was a problem hiding this comment.
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.
| } finally { | ||
| edit.saving = false; | ||
| nodes.candidateCaseAdd.disabled = false; | ||
| nodes.candidateCaseCancel.disabled = false; |
There was a problem hiding this comment.
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.
| } | ||
|
|
||
| edit.saving = true; | ||
| nodes.candidateCaseAdd.disabled = true; |
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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.
eb5b024 to
59d9513
Compare
jserv
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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
59d9513 to
8f28b76
Compare
jserv
left a comment
There was a problem hiding this comment.
Rebase onto latest main branch and resolve conflicts.
| await page.waitForFunction( | ||
| () => !document.querySelector("#audio-check-join").disabled, | ||
| ); | ||
| await beforeStart?.(); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
#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
left a comment
There was a problem hiding this comment.
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.
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:
./scripts/test.shat commit59d9513, rebased onto main25a89e3: exit 0; browser suite 1955 passed, 0 failed, 0 skipped.Screenshots
Before
Saved custom cases show only their input and a Remove button.

After: Saved custom case
After: Editing a saved case
Closes #468