Skip to content

Commit d545aeb

Browse files
Add Data Explorer Python Polars Smoke Test (#3917)
### Intent Add Smoke test for Data Explorer using Python Polars ### Approach * Added new section to existing data explorer test. The new section is broken up into several `it()` blocks to cover multiple TestRail test cases. * Added a console/runtime restart after the pandas test as the polars test uses the same variable names * Added timeout to expect block in `addFilter` as it defaults to no timeout and could get stuck in loop. ### QA Notes Passes in [Smoke CI](https://github.com/posit-dev/positron/actions/runs/9824943969)
1 parent 6363fe6 commit d545aeb

File tree

2 files changed

+109
-4
lines changed

2 files changed

+109
-4
lines changed

test/automation/src/positron/positronDataExplorer.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import { expect } from '@playwright/test';
88
import { Code } from '../code';
9+
import { PositronBaseElement } from './positronBaseElement';
910

1011
const COLUMN_HEADERS = '.data-explorer-panel .column-2 .data-grid-column-headers';
1112
const HEADER_TITLES = '.data-grid-column-header .title-description .title';
@@ -24,6 +25,7 @@ const FILTER_SELECTOR = '.positron-modal-overlay .row-filter-parameter-input .te
2425
const APPLY_FILTER = '.positron-modal-overlay .button-apply-row-filter';
2526
const STATUS_BAR = '.positron-data-explorer .status-bar';
2627
const OVERLAY_BUTTON = '.positron-modal-overlay .positron-button';
28+
const CLEAR_SORTING_BUTTON = '.codicon-positron-clear-sorting';
2729

2830
export interface CellData {
2931
[key: string]: string;
@@ -34,7 +36,11 @@ export interface CellData {
3436
*/
3537
export class PositronDataExplorer {
3638

37-
constructor(private code: Code) { }
39+
clearSortingButton: PositronBaseElement;
40+
41+
constructor(private code: Code) {
42+
this.clearSortingButton = new PositronBaseElement(CLEAR_SORTING_BUTTON, this.code);
43+
}
3844

3945
/*
4046
* Get the currently visible data explorer table data
@@ -101,7 +107,7 @@ export class PositronDataExplorer {
101107
await this.code.waitAndClick(COLUMN_SELECTOR_CELL);
102108
const checkValue = (await this.code.waitForElement(COLUMN_SELECTOR)).textContent;
103109
expect(checkValue).toBe(columnName);
104-
}).toPass();
110+
}).toPass({timeout: 10000});
105111

106112

107113
await this.code.waitAndClick(FUNCTION_SELECTOR);

test/smoke/src/areas/positron/dataexplorer/dataexplorer.test.ts

+101-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import { expect } from '@playwright/test';
88
import { Application, Logger, PositronPythonFixtures, PositronRFixtures } from '../../../../../automation';
99
import { installAllHandlers } from '../../../utils';
10+
import { join } from 'path';
1011

1112
/*
1213
* Data explorer tests with small data frames
@@ -17,7 +18,7 @@ export function setup(logger: Logger) {
1718
// Shared before/after handling
1819
installAllHandlers(logger);
1920

20-
describe('Python Data Explorer', () => {
21+
describe('Python Pandas Data Explorer', () => {
2122

2223
before(async function () {
2324

@@ -34,10 +35,13 @@ export function setup(logger: Logger) {
3435

3536
await app.workbench.positronDataExplorer.closeDataExplorer();
3637
await app.workbench.positronVariables.openVariables();
38+
await app.workbench.quickaccess.runCommand('workbench.action.closeAllEditors', { keepOpen: false });
39+
await app.workbench.positronConsole.barRestartButton.click();
40+
await app.workbench.positronConsole.waitForConsoleContents((contents) => contents.some((line) => line.includes('restarted')));
3741

3842
});
3943

40-
it('Python - Verifies basic data explorer functionality [C557556]', async function () {
44+
it('Python Pandas - Verifies basic data explorer functionality [C557556]', async function () {
4145
const app = this.app as Application;
4246

4347
// modified snippet from https://www.geeksforgeeks.org/python-pandas-dataframe/
@@ -67,6 +71,101 @@ df = pd.DataFrame(data)`;
6771
expect(tableData.length).toBe(4);
6872

6973
});
74+
75+
76+
});
77+
78+
describe('Python Polars Data Explorer', () => {
79+
before(async function () {
80+
81+
const app = this.app as Application;
82+
83+
const pythonFixtures = new PositronPythonFixtures(app);
84+
await pythonFixtures.startPythonInterpreter();
85+
86+
});
87+
88+
after(async function () {
89+
90+
const app = this.app as Application;
91+
92+
await app.workbench.positronDataExplorer.closeDataExplorer();
93+
await app.workbench.positronVariables.openVariables();
94+
await app.workbench.quickaccess.runCommand('workbench.action.closeAllEditors', { keepOpen: false });
95+
96+
});
97+
98+
it('Python Polars - Verifies basic data explorer functionality [C644538]', async function () {
99+
const app = this.app as Application;
100+
await app.workbench.quickaccess.openFile(join(app.workspacePathOrFolder, 'workspaces', 'polars-dataframe-py', 'polars_basic.py'));
101+
await app.workbench.quickaccess.runCommand('python.execInConsole');
102+
103+
logger.log('Opening data grid');
104+
await expect(async () => {
105+
await app.workbench.positronVariables.doubleClickVariableRow('df');
106+
await app.code.driver.getLocator('.label-name:has-text("Data: df")').innerText();
107+
}).toPass();
108+
109+
await app.workbench.positronSideBar.closeSecondarySideBar();
110+
111+
const tableData = await app.workbench.positronDataExplorer.getDataExplorerTableData();
112+
113+
expect(tableData[0]['foo']).toBe('1');
114+
expect(tableData[1]['foo']).toBe('2');
115+
expect(tableData[2]['foo']).toBe('3');
116+
expect(tableData[0]['bar']).toBe('6.00');
117+
expect(tableData[1]['bar']).toBe('7.00');
118+
expect(tableData[2]['bar']).toBe('8.00');
119+
expect(tableData[0]['ham']).toBe('2020-01-02');
120+
expect(tableData[1]['ham']).toBe('2021-03-04');
121+
expect(tableData[2]['ham']).toBe('2022-05-06');
122+
expect(tableData.length).toBe(3);
123+
124+
});
125+
126+
it('Python Polars - Add Simple Column filter [C557557]', async function () {
127+
const app = this.app as Application;
128+
const FILTER_PARAMS = ['foo', 'is not equal to', '1'];
129+
await app.workbench.positronDataExplorer.addFilter(...FILTER_PARAMS as [string, string, string]);
130+
131+
const tableData = await app.workbench.positronDataExplorer.getDataExplorerTableData();
132+
133+
expect(tableData[0]['foo']).toBe('2');
134+
expect(tableData[1]['foo']).toBe('3');
135+
expect(tableData[0]['bar']).toBe('7.00');
136+
expect(tableData[1]['bar']).toBe('8.00');
137+
expect(tableData[0]['ham']).toBe('2021-03-04');
138+
expect(tableData[1]['ham']).toBe('2022-05-06');
139+
expect(tableData.length).toBe(2);
140+
});
141+
142+
it('Python Polars - Add Simple Column Sort [C557561]', async function () {
143+
const app = this.app as Application;
144+
await app.workbench.positronDataExplorer.selectColumnMenuItem(1, 'Sort Descending');
145+
146+
let tableData = await app.workbench.positronDataExplorer.getDataExplorerTableData();
147+
148+
expect(tableData[0]['foo']).toBe('3');
149+
expect(tableData[1]['foo']).toBe('2');
150+
expect(tableData[0]['bar']).toBe('8.00');
151+
expect(tableData[1]['bar']).toBe('7.00');
152+
expect(tableData[0]['ham']).toBe('2022-05-06');
153+
expect(tableData[1]['ham']).toBe('2021-03-04');
154+
expect(tableData.length).toBe(2);
155+
156+
await app.workbench.positronDataExplorer.clearSortingButton.click();
157+
158+
tableData = await app.workbench.positronDataExplorer.getDataExplorerTableData();
159+
160+
expect(tableData[0]['foo']).toBe('2');
161+
expect(tableData[1]['foo']).toBe('3');
162+
expect(tableData[0]['bar']).toBe('7.00');
163+
expect(tableData[1]['bar']).toBe('8.00');
164+
expect(tableData[0]['ham']).toBe('2021-03-04');
165+
expect(tableData[1]['ham']).toBe('2022-05-06');
166+
expect(tableData.length).toBe(2);
167+
168+
});
70169
});
71170

72171
describe('R Data Explorer', () => {

0 commit comments

Comments
 (0)