Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is "Skip" in the snapshot review app broken? #2025

Open
jennybc opened this issue Nov 11, 2024 · 2 comments
Open

Is "Skip" in the snapshot review app broken? #2025

jennybc opened this issue Nov 11, 2024 · 2 comments

Comments

@jennybc
Copy link
Member

jennybc commented Nov 11, 2024

I'm working on making links like testthat::snapshot_review() work in Positron's package development tasks, which run in a terminal. In the course of this effort, I've launched that Shiny app a lot and it sure feels like "Skip" just does nothing. Is it me? Or is it broken?

The toy package I made this recoding with is here: https://github.com/jennybc/clilinks

At the time of writing, it has exactly 1 snapshot test, which will always fail.

Screen.Recording.2024-11-11.at.3.26.45.PM.mov
@jennybc
Copy link
Member Author

jennybc commented Nov 11, 2024

The recording is made in RStudio, but I see the same in Positron and if I pop it out into a browser.

@jennybc
Copy link
Member Author

jennybc commented Nov 12, 2024

From a slack convo:

I think the problem might be that there’s only one failing test so there’s nothing to skip to

I've updated the package mentioned above to have more failing snapshot tests and it doesn't seem to change anything.

jennybc added a commit to posit-dev/positron that referenced this issue Nov 25, 2024
…ks (#5231)

Addresses #5218

This PR makes suggested code hints like `testthat::snapshot_accept()` or
`testthat::snapshot_review()` clickable and runnable from the integrated
terminal where positron-r sends package development tasks, such as
`devtools::test()`. "Runnable" in the sense that the code is run in the
user's R console. This gets routed into the same handlers as clickable
code entered directly in the console, so the existing safety guards are
in place.

<img width="544" alt="Screenshot 2024-11-18 at 1 04 51 PM"
src="https://github.com/user-attachments/assets/ddead5f3-ee5c-4f36-a50b-12f5ac7e6465">

(Note that this PR does _not_ change behaviour for file hyperlinks,
which I've crossed out in the screenshot above. Those hyperlinks
currently get delegated to the operating system, so for many R users, a
`.R` file will open in RStudio. Changing that is a separate problem
#5409.)

### QA Notes

To see the new behaviour, you need a development version of the cli R
package. I would install that via `pak::pak("r-lib/cli")`. (Context:
r-lib/cli#739.)

Then you need to run tests or `R CMD check` on a package with a failing
snapshot test, in order to get a clickable invitation to accept a new
snapshot or to review the proposed snapshot in a Shiny app. I have made
a toy package that could be obtained via
[`usethis::create_from_github("jennybc/clilinks")`](https://github.com/jennybc/clilinks).
It has a couple of snapshot tests that will always fail 😄 because they
attempt to snapshot a random number.

* Install dev cli: `pak::pak("r-lib/cli")`
* Identify a package that tickles this feature and open it in Positron,
perhaps via: `usethis::create_from_github("jennybc/clilinks")`
* Use our gesture for running package tests: Ctrl/Cmd + Shift + T or
select *R: Test R Package* from the command palette.
* Click on a "runnable code" hyperlink:
- Note this requires Ctrl/Cmd click! This is a VS Code convention, not
specific to us.
- Note that you might have to click twice. This is a bug (or 2 bugs?)
for which fixes are making their way through the system
(microsoft/vscode#230010). Again, not us.
- You will need to grant the extension permission to handle such URIs,
either as a one-off or more persistently. This is a VS Code feature.

<img width="544" alt="Screenshot 2024-11-18 at 1 04 51 PM"
src="https://github.com/user-attachments/assets/24a880e0-9ebe-4d88-8051-f859480b04fa">

<img width="285" alt="Screenshot 2024-11-18 at 12 55 37 PM"
src="https://github.com/user-attachments/assets/d1187098-6a76-44b5-b5a5-be8752c43e5f">

If you click `testthat::snapshot_review()`, you should see the code
execute in the R console and this Shiny app appears. Click on "Accept"
(the fact that "Skip" seems broken is
r-lib/testthat#2025 and unrelated to this PR).

<img width="780" alt="Screenshot 2024-11-18 at 12 55 47 PM"
src="https://github.com/user-attachments/assets/f7dff7ea-1bf4-4e52-8eb5-e92fd3481cda">
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

No branches or pull requests

1 participant