Repository navigation
Conversation
Candidates must select their submission manually to copy it from the report. Provide a copy action using the original text, with feedback when clipboard access fails and no action when saved code is unavailable. Closes sysprog21#318
The copy action already ignores duplicate activation, but its appearance does not reflect that state. Reuse the waiting style and describe the mocked interaction test according to the behavior it actually checks.
| const available = | ||
| typeof code === "string" && | ||
| code.trim() !== "" && | ||
| code !== "(final code was not saved)"; |
There was a problem hiding this comment.
The button's visibility depends on matching the literal "(final code was not saved)", which is also hard-coded in the Past attempts card (web/app.js, which calls reportMarkup with that string and never calls mountFinalCodeCopy) and in reportMarkdown. If any of those copies changes its wording, Past attempts shows a "Copy code" button with no handler, so clicking it does nothing. Export one constant from render.js and use it in all three places (or have app.js pass code: null and treat null as not saved here).
|
Add screenshots to the pull request description to illustrate your work, as @ColtenOuO suggests. Example: #349 |
| querySelector: (selector) => | ||
| selector === "[data-copy-code]" ? button : status, |
There was a problem hiding this comment.
This stub hands back status for any selector other than [data-copy-code], and every test mounts on the stub rather than on what reportMarkup emits, so nothing ties data-copy-code-status in the markup to the selector mountFinalCodeCopy queries. If the two drift, status is null, the click throws at status.textContent before the try, and the button stays aria-disabled for good while every test here still passes. Mount at least one test on the real reportMarkup output (for example parse it with the DOM the other browser tests use) and assert the status text changes there.
User currently have to select their submitted code manually to copy it from the final report. Add a Copy code button beside Your final code, preserve the original whitespace and line breaks, and show brief success or error feedback.
Hide the button when code is unavailable, including reports containing the unsaved-code placeholder. Code persistence remains unchanged.
Automated tests cover successful copying, clipboard errors, unavailable code, and repeated clicks while copying.
Closes #318
Summary by cubic
Adds a Copy code button next to "Your final code" in the report so candidates no longer have to select their submission manually. The button copies the original submission text, preserving whitespace and line breaks, and shows "Copied!" feedback or an error message when clipboard access fails.
Written for commit fc8b143. Summary will update on new commits.