1
1
2
2
import { expect , test } from '@playwright/test' ;
3
- import { checkOpenTaskpane , clickButtonAndAwaitResponse , clickTab , getMitoFrame , getMitoFrameWithTestCSV } from '../utils' ;
3
+ import { checkColumnCellsHaveExpectedValues , checkOpenTaskpane , clickButtonAndAwaitResponse , clickTab , getMitoFrame , getMitoFrameWithTestCSV } from '../utils' ;
4
4
5
+ const openImportTaskpaneAndSelectData = async ( mito : any , file : string ) => {
6
+ await mito . locator ( '.mito-toolbar-button' , { hasText : 'Import' } ) . click ( ) ;
7
+ await mito . locator ( '.mito-dropdown-item' , { hasText : 'Import Files' } ) . click ( ) ;
8
+ await mito . getByText ( file , { exact : true } ) . dblclick ( ) ;
9
+ }
5
10
6
11
test . describe ( 'File Import Taskpane' , ( ) => {
7
12
@@ -34,4 +39,124 @@ test.describe('File Import Taskpane', () => {
34
39
await mito . getByRole ( 'button' , { name : 'Change Imports' , exact : true } ) . click ( ) ;
35
40
await mito . getByText ( 'Successfully replayed analysis on new data' ) . click ( ) ;
36
41
} ) ;
42
+
43
+ test ( 'Import XLSX file with multiple sheets' , async ( { page } ) => {
44
+ const mito = await getMitoFrame ( page ) ;
45
+ await mito . locator ( '.mito-toolbar-button' , { hasText : 'Import' } ) . click ( ) ;
46
+ await mito . locator ( '.mito-dropdown-item' , { hasText : 'Import Files' } ) . click ( ) ;
47
+ await mito . getByText ( 'test.xlsx' ) . dblclick ( ) ;
48
+
49
+ await mito . getByText ( 'Import 2 Selected Sheets' ) . click ( ) ;
50
+
51
+ await expect ( mito . locator ( '.tab' , { hasText : 'Sheet1' } ) ) . toBeVisible ( ) ;
52
+ await expect ( mito . locator ( '.tab' , { hasText : 'Sheet2' } ) ) . toBeVisible ( ) ;
53
+ await expect ( mito . locator ( '.endo-column-header-text' , { hasText : 'Column4' } ) ) . toBeVisible ( ) ;
54
+ } ) ;
55
+
56
+ test ( 'Import XLSX file with single sheet' , async ( { page } ) => {
57
+ const mito = await getMitoFrame ( page ) ;
58
+ await openImportTaskpaneAndSelectData ( mito , 'test.xlsx' )
59
+ await mito . getByText ( 'Sheet1' ) . click ( ) ;
60
+
61
+ await mito . getByText ( 'Import 1 Selected Sheet' ) . click ( ) ;
62
+
63
+ await expect ( mito . locator ( '.tab' , { hasText : 'Sheet1' } ) ) . not . toBeVisible ( ) ;
64
+ await expect ( mito . locator ( '.tab' , { hasText : 'Sheet2' } ) ) . toBeVisible ( ) ;
65
+ await expect ( mito . locator ( '.endo-column-header-text' , { hasText : 'Column4' } ) ) . toBeVisible ( ) ;
66
+ } ) ;
67
+
68
+ test ( 'Import XLSX file with configurations' , async ( { page } ) => {
69
+ const mito = await getMitoFrame ( page ) ;
70
+ await openImportTaskpaneAndSelectData ( mito , 'test.xlsx' )
71
+
72
+ // Turn 'Has Header Row' off
73
+ await mito . locator ( '.spacing-row' , { hasText : 'Has Header Row' } ) . locator ( '.select-text' ) . click ( ) ;
74
+ await mito . locator ( '.mito-dropdown-item' , { hasText : 'No' } ) . click ( ) ;
75
+
76
+ await mito . locator ( '.spacing-row' , { hasText : 'Rows to Skip' } ) . locator ( 'input' ) . fill ( '2' ) ;
77
+ await mito . getByText ( 'Import 2 Selected Sheets' ) . click ( ) ;
78
+
79
+ // Check that the configurations are applied
80
+ await expect ( mito . locator ( '.tab' , { hasText : 'Sheet1' } ) ) . toBeVisible ( ) ;
81
+ await expect ( mito . locator ( '.tab' , { hasText : 'Sheet2' } ) ) . toBeVisible ( ) ;
82
+ await checkColumnCellsHaveExpectedValues ( mito , 0 , [ 'lmnop' , 'wxyz' ] )
83
+ await expect ( mito . locator ( '.endo-column-header-text' , { hasText : '0' } ) ) . toBeVisible ( ) ;
84
+
85
+ // Check that the configurations are applied to the other sheet
86
+ await mito . locator ( '.tab' , { hasText : 'Sheet1' } ) . click ( ) ;
87
+ await expect ( mito . locator ( '.endo-column-header-text' , { hasText : '0' } ) ) . toBeVisible ( ) ;
88
+ await checkColumnCellsHaveExpectedValues ( mito , 0 , [ '2' , '3' , '4' , '5' ] )
89
+ } ) ;
90
+
91
+ test ( 'Range Import with one sheet selected' , async ( { page } ) => {
92
+ const mito = await getMitoFrame ( page ) ;
93
+ await openImportTaskpaneAndSelectData ( mito , 'test.xlsx' ) ;
94
+ await mito . getByText ( 'Sheet1' ) . click ( ) ;
95
+
96
+ // Click on Range Import
97
+ await mito . getByText ( 'Click here to import multiple ranges.' ) . click ( ) ;
98
+
99
+ // Fill in the range and name
100
+ await mito . locator ( '.spacing-row' , { hasText : 'Name' } ) . locator ( 'input' ) . fill ( 'Range Test' )
101
+ await mito . locator ( '.spacing-row' , { hasText : 'Excel Range' } ) . locator ( 'input' ) . fill ( 'B2:C3' ) ;
102
+ await mito . getByText ( 'Import Ranges' ) . click ( ) ;
103
+
104
+ await expect ( mito . locator ( '.tab' , { hasText : 'Range_Test' } ) ) . toBeVisible ( ) ;
105
+ await checkColumnCellsHaveExpectedValues ( mito , 0 , [ 'qrs' ] )
106
+ await checkColumnCellsHaveExpectedValues ( mito , 1 , [ 'tuv' ] )
107
+ } ) ;
108
+
109
+ test ( 'Import multiple ranges' , async ( { page } ) => {
110
+ const mito = await getMitoFrame ( page ) ;
111
+ await openImportTaskpaneAndSelectData ( mito , 'test.xlsx' ) ;
112
+ await mito . getByText ( 'Sheet1' ) . click ( ) ;
113
+
114
+ // Click on Range Import
115
+ await mito . getByText ( 'Click here to import multiple ranges.' ) . click ( ) ;
116
+
117
+ // Fill in the range and name
118
+ await mito . locator ( '.spacing-row' , { hasText : 'Name' } ) . locator ( 'input' ) . fill ( 'Range Test' )
119
+ await mito . locator ( '.spacing-row' , { hasText : 'Excel Range' } ) . locator ( 'input' ) . fill ( 'B2:C3' ) ;
120
+
121
+ // Add the second range
122
+ await mito . getByText ( 'Add' ) . click ( ) ;
123
+ await mito . locator ( '.spacing-row' , { hasText : 'Name' } ) . locator ( 'input' ) . fill ( 'Other Range' )
124
+ await mito . locator ( '.spacing-row' , { hasText : 'Locate By' } ) . locator ( '.select-text' ) . click ( ) ;
125
+ await mito . getByText ( 'Dynamic' , { exact : true } ) . click ( ) ;
126
+ await mito . locator ( '.spacing-row' , { hasText : 'Value' } ) . locator ( 'input' ) . fill ( 'lmnop' ) ;
127
+
128
+ await mito . getByText ( 'Import Ranges' ) . click ( ) ;
129
+
130
+ // Check that the tabs appear
131
+ await expect ( mito . locator ( '.tab' , { hasText : 'Range_Test' } ) ) . toBeVisible ( ) ;
132
+ await expect ( mito . locator ( '.tab' , { hasText : 'Other_Range' } ) ) . toBeVisible ( ) ;
133
+
134
+ // Check the first range (the Other_Range will automatically open)
135
+ await checkColumnCellsHaveExpectedValues ( mito , 0 , [ 'wxyz' ] )
136
+ await checkColumnCellsHaveExpectedValues ( mito , 1 , [ '123' ] )
137
+ await checkColumnCellsHaveExpectedValues ( mito , 2 , [ '456' ] )
138
+
139
+ // Check the second range
140
+ await mito . getByText ( 'Range_Test' ) . click ( ) ;
141
+ await checkColumnCellsHaveExpectedValues ( mito , 0 , [ 'qrs' ] )
142
+ await checkColumnCellsHaveExpectedValues ( mito , 1 , [ 'tuv' ] )
143
+ } ) ;
144
+
145
+ test ( 'Configure CSV imports' , async ( { page } ) => {
146
+ const mito = await getMitoFrame ( page ) ;
147
+
148
+ // Open the configure taskpane for the csv with special delimiters
149
+ await mito . getByText ( 'Import Files' ) . click ( ) ;
150
+ await mito . getByText ( 'semicolon-delimiter.csv' ) . click ( ) ;
151
+ await mito . getByText ( 'Configure' ) . click ( ) ;
152
+
153
+ // Change the delimiter to a semicolon
154
+ await mito . locator ( '.spacing-row' , { hasText : 'Delimiter' } ) . locator ( 'input' ) . fill ( ';' ) ;
155
+ await mito . locator ( '.spacing-row' , { hasText : 'Decimal Separator' } ) . locator ( '.select-text' ) . click ( ) ;
156
+ await mito . getByText ( 'Comma' ) . click ( ) ;
157
+
158
+ // Click the import button and check that the data is correct
159
+ await mito . locator ( 'button' , { hasText : 'Import semicolon-delimiter.csv' } ) . click ( ) ;
160
+ await checkColumnCellsHaveExpectedValues ( mito , 0 , [ 1.00 , 4.12 , 7.46 , 10.30 ] )
161
+ } ) ;
37
162
} ) ;
0 commit comments