Skip to content

Commit b994876

Browse files
6pac-aiclaude
andcommitted
test: move the non-contiguous range copy test onto the Clipboard API transport
The multi-range gap test arrived with the `hidden` column work on next-v6 and stubbed `window.clipboardData` - the legacy IE transport this branch removes - then asserted synchronously. Against the async Clipboard API it captured nothing and the copied text read back as empty. It now stubs `navigator.clipboard` the same way the other tests in this spec do, and retries the assertion because the copy handler awaits the write. The expectation is unchanged, so it still covers what it was written for: gaps preserved between two non-contiguous ranges. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent 2062d27 commit b994876

1 file changed

Lines changed: 14 additions & 13 deletions

File tree

cypress/e2e/example-excel-compatible-spreadsheet.cy.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -90,28 +90,29 @@ describe('Example - Excel-compatible spreadsheet and Cell Selection', { retries:
9090
});
9191

9292
it('should preserve gaps when copying multiple non-contiguous ranges', () => {
93+
const store = { text: '' };
94+
9395
cy.window().then((win: any) => {
94-
const previousClipboardData = win.clipboardData;
95-
let copiedText = '';
96-
Object.defineProperty(win, 'clipboardData', {
96+
Object.defineProperty(win.navigator, 'clipboard', {
9797
configurable: true,
9898
value: {
99-
setData: (_format: string, text: string) => { copiedText = text; }
100-
}
99+
writeText: (t: string) => { store.text = t; return Promise.resolve(); },
100+
readText: () => Promise.resolve(store.text),
101+
},
101102
});
102103

103-
const selectionModel = win.grid.getSelectionModel();
104-
selectionModel.setSelectedRanges([
105-
new win.Slick.Range(1, 1, 1, 2),
106-
new win.Slick.Range(2, 3, 2, 3)
107-
]);
104+
const selectionModel = win.grid.getSelectionModel();
105+
selectionModel.setSelectedRanges([
106+
new win.Slick.Range(1, 1, 1, 2),
107+
new win.Slick.Range(2, 3, 2, 3)
108+
]);
108109
const copyEvent = new win.KeyboardEvent('keydown', { key: 'c', code: 'KeyC', ctrlKey: true, bubbles: true });
109110
Object.defineProperty(copyEvent, 'which', { value: 67 });
110111
win.grid.getCanvasNode().dispatchEvent(copyEvent);
111-
112-
expect(copiedText).to.eq('1\t2\t\r\n\t\t4\r\n');
113-
Object.defineProperty(win, 'clipboardData', { configurable: true, value: previousClipboardData });
114112
});
113+
114+
// the copy handler awaits the clipboard write, so retry until the stub has the text
115+
cy.wrap(store).its('text').should('eq', '1\t2\t\r\n\t\t4\r\n');
115116
});
116117
});
117118
});

0 commit comments

Comments
 (0)