Skip to content

Commit 98e901f

Browse files
committed
test(web): read-only preview copy test covers each end of the selection
One partial selection stopped inside the rows at both ends, so dropping either boundary check still passed. Two selections now each stop inside the rows at one end only.
1 parent 923d347 commit 98e901f

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

‎apps/web/src/components/files/ReadOnlySourcePreview.browser.test.tsx‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,13 @@ describe("ReadOnlySourcePreview", () => {
5555
await userEvent.keyboard("{ControlOrMeta>}a{/ControlOrMeta}");
5656
expect(copiedText(rows()[0]!)).toBe(text);
5757

58-
// A selection that ends inside the mounted rows stays the browser's to copy.
58+
// A selection that stops inside the mounted rows at either end stays the browser's to copy.
59+
const pre = root.querySelector("pre")!;
5960
const firstText = rows()[0]!.querySelector("span")!.firstChild!;
6061
const lastText = rows()[rows().length - 1]!.querySelector("span")!.firstChild!;
61-
document.getSelection()!.setBaseAndExtent(firstText, 0, lastText, 4);
62+
document.getSelection()!.setBaseAndExtent(pre, 0, lastText, 4);
63+
expect(copiedText(rows()[0]!)).toBeNull();
64+
document.getSelection()!.setBaseAndExtent(firstText, 4, pre, pre.childNodes.length);
6265
expect(copiedText(rows()[0]!)).toBeNull();
6366
});
6467
});

0 commit comments

Comments
 (0)