Skip to content

Commit a7b9d88

Browse files
authored
e2e: expand data explorer clipboard to include copy column data via context menu (#9671)
### Summary Updating the `data-explorer-clipboard.test.ts` to include a test case that verifies the correct behavior of copying a column using the context menu. Refer to the related issue: #9315 ### QA Notes @:data-explorer @:web @:win
1 parent a9fd9ad commit a7b9d88

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

test/e2e/pages/dataExplorer.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,17 @@ export class DataGrid {
320320
});
321321
}
322322

323+
/**
324+
* Copy a column by its position
325+
* @param colPosition (position is 0-based)
326+
*/
327+
async copyColumn(colPosition: number) {
328+
await test.step(`Copy column at 0-based position: ${colPosition}`, async () => {
329+
await this.jumpToStart(); // make sure we are at the start so our index is accurate
330+
await this.selectColumnAction(colPosition + 1, 'Copy Column'); // selectColumnAction is 1-based
331+
});
332+
}
333+
323334
/**
324335
* Pin a row by its position
325336
* @param rowPosition (position is 0-based)
@@ -360,10 +371,11 @@ export class DataGrid {
360371
/**
361372
* Click a column header by its title
362373
* @param columnTitle The exact title of the column to click
374+
* @param options Optional parameters (e.g., right-click)
363375
*/
364-
async clickColumnHeader(columnTitle: string) {
376+
async clickColumnHeader(columnTitle: string, options?: { button: 'left' | 'right' }) {
365377
await test.step(`Click column header: ${columnTitle}`, async () => {
366-
await this.columnHeaders.getByText(columnTitle).click();
378+
await this.columnHeaders.getByText(columnTitle).click({ button: options?.button ?? 'left' });
367379
});
368380
}
369381

@@ -961,4 +973,4 @@ export interface ColumnProfile {
961973

962974
export type CellPosition = { row: number; col: number };
963975

964-
export type ColumnRightMenuOption = 'Copy' | 'Select Column' | 'Pin Column' | 'Unpin Column' | 'Sort Ascending' | 'Sort Descending' | 'Clear Sorting' | 'Add Filter';
976+
export type ColumnRightMenuOption = 'Copy Column' | 'Select Column' | 'Pin Column' | 'Unpin Column' | 'Sort Ascending' | 'Sort Descending' | 'Clear Sorting' | 'Add Filter';

test/e2e/tests/data-explorer/data-explorer-clipboard.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ for (const { env, data, rowIndexOffset: indexOffset, tags: testTags = [] } of te
6161
test(`${env} - Copy and paste works on cells, rows, columns, and ranges of unsorted data`, async function ({ app }) {
6262
const { dataExplorer, clipboard } = app.workbench;
6363

64-
// verify copy and paste on columns
64+
// verify copy and paste on column (via shortcut)
6565
await dataExplorer.grid.clickColumnHeader('column3');
6666
await clipboard.copy();
6767
await clipboard.expectClipboardTextToBe(expectedData['col3'], '\n');
@@ -80,6 +80,12 @@ for (const { env, data, rowIndexOffset: indexOffset, tags: testTags = [] } of te
8080
await dataExplorer.grid.selectRange({ start: { row: 0, col: 0 }, end: { row: 1, col: 1 } });
8181
await clipboard.copy();
8282
await clipboard.expectClipboardTextToBe(expectedData['col0_col1'], '\n');
83+
84+
// verify copy and paste on column (via context menu)
85+
await dataExplorer.grid.clickCell(0, 0);
86+
await dataExplorer.grid.copyColumn(3)
87+
await clipboard.copy();
88+
await clipboard.expectClipboardTextToBe(expectedData['col3'], '\n');
8389
});
8490

8591
test(`${env} - Copy and paste works on cells, rows, columns, and ranges of sorted data`, async function ({ app }) {

0 commit comments

Comments
 (0)