spyglass/junit: add copy-to-clipboard widget for test names - #832
spyglass/junit: add copy-to-clipboard widget for test names#832petr-muller wants to merge 1 commit into
Conversation
Test names in the JUnit lens are rendered as "ClassName: Name", which is awkward to select by hand and yields a string that needs editing before it can be used as a test filter or a search term. Add a small copy icon next to every test name that puts the bare test name on the clipboard. The name is carried in a data attribute rather than scraped from the cell, since the cell also holds the expander arrow and, for skipped tests, the skip reason. The icon only appears on row hover. Click handling is delegated to a single listener on the container, since a run can have thousands of tests and thus thousands of copy icons. It runs in the capture phase: the row's own expand/collapse handler is bound directly to the row, which sits between the icon and the container, so a bubble-phase listener here would run after the row's handler already fired. Capturing lets us stop the click before it gets there.
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: petr-muller The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
✅ Deploy Preview for k8s-prow ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
@petr-muller: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
BenTheElder
left a comment
There was a problem hiding this comment.
Can you share an example screenshot?
My TS is rusty but this looks OK.
Test names in the JUnit lens are rendered as "ClassName: Name", which is awkward to select by hand and yields a string that needs editing before it can be used as a test filter or a search term.
Add a small copy icon next to every test name that puts the bare test name on the clipboard. The name is carried in a data attribute rather than scraped from the cell, since the cell also holds the expander arrow and, for skipped tests, the skip reason. The icon only appears on row hover.
Click handling is delegated to a single listener on the container, since a run can have thousands of tests and thus thousands of copy icons. It runs in the capture phase: the row's own expand/collapse handler is bound directly to the row, which sits between the icon and the container, so a bubble-phase listener here would run after the row's handler already fired. Capturing lets us stop the click before it gets there.
Assisted by Claude Code