[backport] Fix preview browse URL for single-file documents#14301
Merged
[backport] Fix preview browse URL for single-file documents#14301
Conversation
PR #13804 made project always non-null via singleFileProjectContext(), causing the initialPath computation to always take the project branch. This produced URLs like http://localhost:PORT/hello.html instead of http://localhost:PORT/ for standalone files, breaking Posit Workbench proxy access. Guard with project.isSingleFile so single-file previews use root path. Extract computation into previewInitialPath() for testability. Fixes #14298 [backport] Fix preview browse URL for single-file documents (#14298)
Extend createMockProjectContext() with options object supporting isSingleFile and config parameters. Use it in preview-initial-path tests instead of a duplicate mock function.
0e5cfb1 to
b3582f0
Compare
The handler selection at line 251 had the same project-truthiness bug as the URL path computation: single-file projects used projectHtmlFileRequestHandler (defaultFile="index.html") instead of htmlFileRequestHandler (defaultFile=basename of output). This caused GET / to return 404 for single-file previews since v1.9. Add isSingleFile guard to handler selection. Also fix test cleanup by letting createMockProjectContext own temp dir creation.
T17: Verify GET / returns 200 for single-file preview T18: Verify GET /filename.html also works T19: Verify project preview paths still work with isSingleFile guard
The skill now supports three invocation modes: - By test ID: /quarto-preview-test T17 T18 - By topic: /quarto-preview-test root URL (fuzzy match + confirm) - No args: ad-hoc preview testing workflow Also add tests/docs/manual/README.md documenting all manual test suites.
Collaborator
|
Thanks! (We would really benefit from a broader effort to have the hosted teams bring us tests against their expected behavior..) |
Collaborator
Author
|
Yes for sure. I have now added a skill to have help from claude testing preview. So manual regression tests we can run when we are touching preview code base. This will help. This expected behavior is now registered. It seems they have automatic tests though as this is how they discovered. We should probably see if we can run those tests again all our pre-release ! |
Required by T9/T17/T18 in the manual preview test matrix. This fixture exists on main but was not part of the backport.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Important
Backport of #14300
quarto preview hello.qmdprintsBrowse at http://localhost:PORT/hello.htmlinstead ofhttp://localhost:PORT/, andGET /returns 404. This breaks Posit Workbench Proxied Servers pane.PR #13804 made
projectalways non-null viasingleFileProjectContext(). Two code paths branch onprojectbeing truthy: the URL path computation (prints filename) and the handler selection (uses wrong default file). Fix guards both withproject.isSingleFile.Verified locally: v1.8.27 serves root URL correctly, v1.9.36 returns 404, fix restores v1.8 behavior. Also ran T17/T18 manual preview tests directly on this branch — both pass (
GET /andGET /plain.htmlreturn 200). Added missingplain.qmdtest fixture that was not part of the original backport.Fixes #14298