-
Notifications
You must be signed in to change notification settings - Fork 0
Stop reporting truncated diff and stream output as if it were complete #7
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
a25b8e8
fix: mark truncated diff/stream output so it never reads as complete
3ace c64d54e
fix: disclose multi-stream truncation on --raw; resolve page content …
3ace bfbb976
feat: add GetPageContentStream for full multi-stream page content
3ace 9f58e34
refactor: concatenate page streams in dump stream; drop floor marker
3ace 65205f9
test: assert pdfMu lock in the helper a delegating method calls
3ace 79768fa
chore: correct stale comments on failing-stream NodeID and truncation…
3ace 283d2b0
fix: report a malformed contents array element instead of skipping it
3ace a0bc0e0
chore: say where multi-stream page content is assembled
3ace 823d976
fix(14-3): auto-expand to depth-capped diff nodes so the marker is re…
3ace 08739ee
refactor(14-3): consistent /Contents null handling; honest reconcilia…
3ace f30ac38
chore(14-3): drop leftover builder/blank line; document --raw join + …
3ace File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| /** | ||
| * Story 14.3: DiffView depth-cap truncation display branch (AC5, 14.3-COMP-001). | ||
| * | ||
| * DiffView's `identical` const (DiffView.tsx) mirrors Go's diffIsIdentical, and | ||
| * that includes `summary.truncatedSubtrees === 0`. Given a result whose walk was | ||
| * bounded by the depth cap (truncatedSubtrees > 0) but whose visible node counts | ||
| * are all zero, the component must NOT compute identical === true and must NOT | ||
| * render the "No structural differences" banner without a truncation marker -- | ||
| * the quiet lie this story closes, mirrored on the GUI surface. | ||
| * | ||
| * Before the fix these cases were red: `identical` ignored truncatedSubtrees, so | ||
| * the banner appeared on a bounded walk. This is the thin display branch of a | ||
| * backend-verified field, kept at the component level (NOT E2E). | ||
| * | ||
| * Naming: 14.3-COMP-001 [P1]. | ||
| * Run: cd frontend && npx vitest run src/components/DiffView.truncation.test.tsx | ||
| */ | ||
| import { render, screen, waitFor } from '@testing-library/react'; | ||
| import { describe, test, expect, vi, beforeEach } from 'vitest'; | ||
| import { DiffView } from './DiffView'; | ||
|
|
||
| const mockDiffDocuments = vi.fn(); | ||
| vi.mock( | ||
| '../../bindings/unidoc-pdf-debugger/internal/pdfservice/pdfservice.js', | ||
| () => ({ | ||
| DiffDocuments: (...a: unknown[]) => mockDiffDocuments(...a), | ||
| }) | ||
| ); | ||
|
|
||
| /** | ||
| * A diff whose visible node counts are all zero but whose walk was bounded by | ||
| * the depth cap (truncatedSubtrees > 0). Under the bug this reports identical; | ||
| * post-fix it must NOT. The single cut node carries `truncated: true`. | ||
| */ | ||
| const depthCappedResult = { | ||
| summary: { | ||
| added: 0, | ||
| removed: 0, | ||
| changed: 0, | ||
| pageCountLeft: 1, | ||
| pageCountRight: 1, | ||
| versionChanged: false, | ||
| encryptionChanged: false, | ||
| infoChanged: false, | ||
| xmpChanged: false, | ||
| // Additive field surfaced by the Go DiffSummary (AC2); declared on | ||
| // DiffSummaryData in DiffView.tsx. | ||
| truncatedSubtrees: 1, | ||
| }, | ||
| root: { | ||
| path: '/Root', | ||
| status: 'unchanged', | ||
| kind: 'dict', | ||
| changedKeys: [] as string[], | ||
| leftSummary: '', | ||
| rightSummary: '', | ||
| children: [ | ||
| { | ||
| path: '/Root/Deep', | ||
| status: 'unchanged', | ||
| kind: 'ref', | ||
| changedKeys: [] as string[], | ||
| leftSummary: '<< /L <ref> >>', | ||
| rightSummary: '<< /L <ref> >>', | ||
| truncated: true, | ||
| children: [], | ||
| }, | ||
| ], | ||
| }, | ||
| }; | ||
|
|
||
| beforeEach(() => { | ||
| vi.clearAllMocks(); | ||
| mockDiffDocuments.mockResolvedValue(depthCappedResult); | ||
| }); | ||
|
|
||
| describe('DiffView depth-cap truncation (Story 14.3)', () => { | ||
| // 14.3-COMP-001 [P1] AC5: a result with truncatedSubtrees > 0 must NOT render | ||
| // the "No structural differences / identical" banner -- the walk was bounded, | ||
| // so identity cannot be claimed. | ||
| test('14.3-COMP-001 suppresses the identical banner when a subtree was depth-capped', async () => { | ||
| render(<DiffView leftTabId="left" rightTabId="right" active />); | ||
|
|
||
| const summary = await screen.findByTestId('diff-summary'); | ||
| const text = (summary.textContent ?? '').toLowerCase(); | ||
| expect(text).not.toMatch(/no structural differences|no differ|identical/); | ||
| }); | ||
|
|
||
| // 14.3-COMP-001 [P1] AC5: the per-node [truncated: depth cap] ROW renders, not | ||
| // just the summary note. The depth-capped node reports status "unchanged", so | ||
| // hasDelta must treat `truncated` as a delta for its ancestors to auto-expand; | ||
| // otherwise the marker sits under an unexpanded ancestor and is unreachable. | ||
| // Asserts the bracketed row text (distinct from the summary note's "truncated | ||
| // at the depth cap") AND the cut node's path, so it genuinely covers the | ||
| // DiffView.tsx per-node marker branch rather than passing on the summary note. | ||
| test('14.3-COMP-001 auto-expands to the depth-cap node and renders its row marker', async () => { | ||
| render(<DiffView leftTabId="left" rightTabId="right" active />); | ||
|
|
||
| await waitFor(() => expect(mockDiffDocuments).toHaveBeenCalled()); | ||
| await screen.findByTestId('diff-summary'); | ||
|
|
||
| // The cut node itself is rendered (its ancestors auto-expanded to reach it). | ||
| expect(screen.getAllByText('/Root/Deep').length).toBeGreaterThan(0); | ||
| // ...carrying the per-node marker: bracketed row text, which the summary | ||
| // note ("... truncated at the depth cap ...") does not contain. | ||
| expect(screen.getAllByText(/\[truncated: depth cap\]/).length).toBeGreaterThan(0); | ||
| }); | ||
| }); |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.