Skip to content

Commit 7af6cbe

Browse files
author
s3-1395 lane
committed
test(diff-view): pin the new-files setting on the same unreadable footing
The row above can only catch a dropped forward for the settings whose values differ from their defaults on that footing, and autoCloseZooOpenedNewFiles shares the false default there. Flipping that one flag catches the third argument the same way, so the pair pins all three forwards on a rollback whose close outcome cannot read two of them. Spec only. Reported-by: CodeRabbit review thread PRRT_kwDOSK-bwM62i_1a (upstream #1932).
1 parent a249a29 commit 7af6cbe

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

‎src/integrations/editor/__tests__/DiffViewProvider.spec.ts‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3652,6 +3652,43 @@ describe("DiffViewProvider", () => {
36523652
expect(args[3]).toBe(true)
36533653
expect(args[4]).toBe(false)
36543654
})
3655+
it("lines 918 to 921: pins the new-files argument in its own slot on the same unreadable footing", async () => {
3656+
// The row above sets the two settings the decision cannot read to distinct values only for the
3657+
// after-user-edited slot; autoCloseZooOpenedNewFiles shares its value with the base setting
3658+
// there, so dropping its forward would pass. Flipping only that flag here makes the same
3659+
// assertion catch it, and the two rows together pin all three arguments against being
3660+
// replaced by their centralized defaults on a path where the outcome cannot tell them apart.
3661+
const document = makeRollbackDocument("streamed content", false, true)
3662+
const keepOrClose = vi.fn().mockResolvedValue(undefined)
3663+
Object.assign(diffViewProvider, {
3664+
relPath: settleRelPath,
3665+
activeDiffEditor: { document },
3666+
editType: "modify",
3667+
createdDirs: [],
3668+
originalContent: "original",
3669+
documentWasOpen: false,
3670+
userTouchedDocument: false,
3671+
userTouchedDiffEditor: false,
3672+
})
3673+
diffViewProvider["taskRef"] = {
3674+
deref: () =>
3675+
makeTaskDouble({
3676+
autoCloseZooOpenedFiles: false,
3677+
autoCloseZooOpenedFilesAfterUserEdited: false,
3678+
autoCloseZooOpenedNewFiles: true,
3679+
}),
3680+
} as unknown as WeakRef<Task>
3681+
vi.mocked(vscode.workspace.applyEdit).mockResolvedValue(true)
3682+
diffViewProvider["closeAllDiffViews"] = vi.fn().mockResolvedValue(undefined)
3683+
diffViewProvider["keepOrCloseEditedFile"] = keepOrClose
3684+
3685+
await diffViewProvider.revertChanges()
3686+
3687+
const args = keepOrClose.mock.calls[0]
3688+
expect(args[2]).toBe(false)
3689+
expect(args[3]).toBe(false)
3690+
expect(args[4]).toBe(true)
3691+
})
36553692

36563693
it("lines 902 and 904: keeps the tab on the rollback path when the user touched the document and the after-user-edited setting is off", async () => {
36573694
// The touched-document branch is the only one where autoCloseZooOpenedFilesAfterUserEdited decides

0 commit comments

Comments
 (0)