Repository navigation
Conversation
| if (data.attachmentDest !== undefined) { | ||
| outlineItem.attachmentDest = data.attachmentDest; | ||
| } |
There was a problem hiding this comment.
Why handle this particular case specifically?
Simply adding attachmentDest: data.attachmentDest; just after the attachment-line above seems correct.
| return new Catalog({ docBaseUrl: null }, xref); | ||
| } | ||
|
|
||
| describe("documentOutline", function () { |
There was a problem hiding this comment.
This seems pretty redundant, given the unit-test using an actual PDF in api_spec.js above.
| for (const [description, dest, expected] of [ | ||
| ["explicit", [1, Name.get("Fit")], '[1,{"name":"Fit"}]'], | ||
| ["string", "second-page", "second-page"], | ||
| ["name", Name.get("second-page"), "second-page"], | ||
| ]) { | ||
| it(`preserves a GoToE ${description} destination`, function () { |
There was a problem hiding this comment.
For future reference: Generating test-cases within loops isn't a great pattern to use, despite what your AI might "think".
| import { EventBus } from "../../web/event_utils.js"; | ||
| import { PDFOutlineViewer } from "../../web/pdf_outline_viewer.js"; | ||
|
|
||
| describe("PDFOutlineViewer", function () { |
There was a problem hiding this comment.
It seems pointless to have a unit-test that stub-out significant parts of the viewer functionality.
If you want to test that code it should really be done using integration-tests instead.
There was a problem hiding this comment.
It seems pointless to have a unit-test that stub-out significant parts of the viewer functionality. If you want to test that code it should really be done using integration-tests instead.
Thanks for the review.(・ω・)ノ I’ll simplify the assignment, remove the redundant catalog tests, and keep the PDF-based API test. I’ll replace the mocked viewer tests with integration coverage.
Snuffleupagus
left a comment
There was a problem hiding this comment.
- See also https://github.com/mozilla/pdf.js/wiki/Squashing-Commits
- Please improve the commit message, since it's currently just a single line (but do so without adding lots of AI generated words).
| await attachmentPage.waitForFunction( | ||
| () => document.querySelector("#pageNumber")?.valueAsNumber === 2 | ||
| ); | ||
| const currentPage = await attachmentPage.$eval( | ||
| "#pageNumber", | ||
| el => el.valueAsNumber | ||
| ); | ||
| expect(currentPage).withContext(`In ${browserName}`).toBe(2); |
There was a problem hiding this comment.
Looking at other integration-tests, why make this so complicated?
| await attachmentPage.waitForFunction( | |
| () => document.querySelector("#pageNumber")?.valueAsNumber === 2 | |
| ); | |
| const currentPage = await attachmentPage.$eval( | |
| "#pageNumber", | |
| el => el.valueAsNumber | |
| ); | |
| expect(currentPage).withContext(`In ${browserName}`).toBe(2); | |
| await attachmentPage.waitForFunction( | |
| () => window.PDFViewerApplication.page === 2 | |
| ); |
There was a problem hiding this comment.
👌Thanks for the review.
a333547 to
5517f96
Compare
|
Squashed into a single commit and expanded the commit message, as requested. |
|
@xjtu-ctgg can you rebase ? |
5517f96 to
74c3f4d
Compare
|
Rebased onto current master, thanks. The only conflict was in |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #22001 +/- ##
==========================================
- Coverage 90.22% 90.21% -0.01%
==========================================
Files 275 275
Lines 67837 67837
==========================================
- Hits 61203 61200 -3
- Misses 6634 6637 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
74c3f4d to
b383602
Compare
|
@Snuffleupagus are you ok with this PR ? |
The implementation itself seems OK now, however I've not really checked the integration-test. |
| const text = await attachmentPage.$eval( | ||
| textLayer, | ||
| el => el.textContent | ||
| ); | ||
| expect(text) | ||
| .withContext(`In ${browserName}`) | ||
| .toContain("Attachment page TWO"); |
There was a problem hiding this comment.
I don't really understand why you test that stuff.
Even if we're on page 1, this assertion won't fail since page 2 is rendered, so the real test is the waitForFunction just above.
There was a problem hiding this comment.
Right, the waitForFunction is what checks it. Removed the text check.
| ); | ||
| }); | ||
|
|
||
| it("opens an attachment at a named destination", async () => { |
There was a problem hiding this comment.
nit: one it is enough I think.
There was a problem hiding this comment.
I tried that, but both bookmarks open the same chapter.pdf, and in Firefox the second click doesn't give a new popup while the first one is still open, so the test times out. I kept the two its, but I can close the first popup in between if you'd rather have a single one.
| "#outlinesView .treeItem a", | ||
| "page-fit", | ||
| null, | ||
| { sidebarViewOnLoad: 2 } |
There was a problem hiding this comment.
No, the PDF has /PageMode /UseOutlines, so the outline opens anyway. Removed.
Keep attachment destinations in outline data and pass them to the download manager when opening embedded PDFs. Add API and integration tests for explicit and named destinations.
b383602 to
d8fffe3
Compare
Viewer previewCommit d8fffe3 (build logs).
🔒 A user with write access must approve this commit with the |
GoToE outline entries lose
attachmentDestwhen the catalog builds the outline, and the outline viewer does not pass the destination to the download manager. A bookmark targeting a page inside an embedded PDF therefore ignores that destination, opening at the first page on an initial visit, while the equivalent page annotation works.Preserve the optional destination in outline data and forward it unchanged when opening the attachment. Add a self-contained PDF and regression coverage for explicit and named attachment destinations.
Validation:
attachmentDestfield.gulp generic lib-legacyandgulp lintpassed.