7
7
import { expect } from '@playwright/test' ;
8
8
import { Application , Logger , PositronPythonFixtures , PositronRFixtures } from '../../../../../automation' ;
9
9
import { installAllHandlers } from '../../../utils' ;
10
+ import { join } from 'path' ;
10
11
11
12
/*
12
13
* Data explorer tests with small data frames
@@ -17,7 +18,7 @@ export function setup(logger: Logger) {
17
18
// Shared before/after handling
18
19
installAllHandlers ( logger ) ;
19
20
20
- describe ( 'Python Data Explorer' , ( ) => {
21
+ describe ( 'Python Pandas Data Explorer' , ( ) => {
21
22
22
23
before ( async function ( ) {
23
24
@@ -34,10 +35,13 @@ export function setup(logger: Logger) {
34
35
35
36
await app . workbench . positronDataExplorer . closeDataExplorer ( ) ;
36
37
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' ) ) ) ;
37
41
38
42
} ) ;
39
43
40
- it ( 'Python - Verifies basic data explorer functionality [C557556]' , async function ( ) {
44
+ it ( 'Python Pandas - Verifies basic data explorer functionality [C557556]' , async function ( ) {
41
45
const app = this . app as Application ;
42
46
43
47
// modified snippet from https://www.geeksforgeeks.org/python-pandas-dataframe/
@@ -67,6 +71,101 @@ df = pd.DataFrame(data)`;
67
71
expect ( tableData . length ) . toBe ( 4 ) ;
68
72
69
73
} ) ;
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
+ } ) ;
70
169
} ) ;
71
170
72
171
describe ( 'R Data Explorer' , ( ) => {
0 commit comments