Skip to content

Commit 2d3f4b0

Browse files
e2e test - Data Columns Names (#8105)
### QA Notes This PR creates `data-columns.test.ts` test suite in order to verify data column names can be consistently generated in Positron's Data Explorer. It covers most cases, including edge cases, and addresses #5915 . @:win @:web @:data-explorer --------- Co-authored-by: Chris Mead <[email protected]>
1 parent c77630d commit 2d3f4b0

File tree

3 files changed

+78
-0
lines changed

3 files changed

+78
-0
lines changed

test/e2e/pages/dataExplorer.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,4 +328,18 @@ export class DataExplorer {
328328
await expect(hoverTooltip).toContainText('Missing Values');
329329
});
330330
}
331+
332+
// Note that herein we're getting the column headers from the filter popup, hence why new function and const.
333+
async getColumnHeaders(): Promise<string[]> {
334+
const headersLocator = this.code.driver.page.locator('div.column-name');
335+
return await headersLocator.allInnerTexts();
336+
}
337+
338+
async verifyColumnHeaders(expectedHeaders: string[]) {
339+
await test.step('Verify column headers', async () => {
340+
const actualHeaders = await this.getColumnHeaders();
341+
const missing = expectedHeaders.filter(item => !actualHeaders.includes(item));
342+
expect(missing).toEqual([]); // Will throw if any are missing
343+
});
344+
}
331345
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (C) 2025 Posit Software, PBC. All rights reserved.
3+
* Licensed under the Elastic License 2.0. See LICENSE.txt for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
import { test, tags } from '../_test.setup';
7+
import { expectedColumnNames } from './helpers/expected_columns';
8+
9+
test.use({
10+
suiteId: __filename
11+
});
12+
13+
test.describe('Data Explorer: Column Names', { tag: [tags.WEB, tags.WIN, tags.DATA_EXPLORER] }, () => {
14+
15+
test('Verify data columns - Python', async function ({ app, python, openDataFile }) {
16+
await openDataFile('data-files/data_explorer/data_columns.csv');
17+
await app.workbench.dataExplorer.addFilterButton.click();
18+
await app.workbench.dataExplorer.selectColumnButton.click();
19+
await app.workbench.dataExplorer.verifyColumnHeaders(expectedColumnNames);
20+
});
21+
22+
});
23+
24+
/* Add this after test.describe if there is a need to escape from the filter and delete all sessions for clean-up.
25+
test.afterEach(async ({ app, page }) => {
26+
await page.getByRole('button', { name: 'Select Column' }).focus();
27+
await page.keyboard.press('Escape');
28+
await page.keyboard.press('Escape');
29+
await expect(page.locator('.positron-modal-popup')).toHaveCount(0);
30+
await app.workbench.console.clearButton.click();
31+
await app.workbench.sessions.deleteAll();
32+
});
33+
*/
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (C) 2025 Posit Software, PBC. All rights reserved.
3+
* Licensed under the Elastic License 2.0. See LICENSE.txt for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
// This helper contains expected column names and a Python script that generates a data frame with similar names.
7+
export const expectedColumnNames = [
8+
'normal_name',
9+
'leading_space',
10+
'trailing_space',
11+
'both',
12+
'column04',
13+
'123numeric_start',
14+
'!@#symbols',
15+
'中文字符',
16+
'naïve_column',
17+
'name,with,comma',
18+
'"quoted"',
19+
'multiline header',
20+
'supercalifragilisticexpialidocious_column_name_that_is_really_really_long_to_test_limits',
21+
'whitespace (tab)',
22+
'duplicate',
23+
'duplicate_1',
24+
'Nombre_Español',
25+
'ID_Único',
26+
'Nome_Português',
27+
'Número_do_Pedido',
28+
'اسم_عربي',
29+
'رمز_المنتج',
30+
];
31+

0 commit comments

Comments
 (0)