1
1
import { FrameLocator , Page , expect , test } from '@playwright/test' ;
2
- import { awaitResponse , clickButtonAndAwaitResponse , closeTaskpane , getColumnHeaderContainer , getMitoFrame , getMitoFrameWithTestCSV , hasExpectedNumberOfRows , importCSV } from '../utils' ;
2
+ import { awaitResponse , checkColumnCount , checkColumnExists , clickButtonAndAwaitResponse , closeTaskpane , getColumnHeaderContainer , getMitoFrame , getMitoFrameWithTestCSV , hasExpectedNumberOfRows , importCSV } from '../utils' ;
3
3
4
4
5
5
const changeMergeType = async ( mito : FrameLocator , page : Page , mergeType : string ) => {
@@ -37,9 +37,7 @@ test.describe('Merge', () => {
37
37
38
38
await expect ( mito . getByText ( 'Merge Dataframes' ) ) . toBeVisible ( ) ;
39
39
40
- // Check that Column1 exists
41
- const ch1 = await getColumnHeaderContainer ( mito , 'Column1' ) ;
42
- await expect ( ch1 ) . toBeVisible ( ) ;
40
+ await checkColumnExists ( mito , 'Column1' ) ;
43
41
44
42
// Close the taskpane
45
43
await closeTaskpane ( mito ) ;
@@ -51,12 +49,7 @@ test.describe('Merge', () => {
51
49
// Add a merge key
52
50
await mito . getByRole ( 'button' , { name : '+ Add Merge Keys' } ) . click ( ) ;
53
51
54
- const newCh1 = await getColumnHeaderContainer ( mito , 'Column1' ) ;
55
- await expect ( newCh1 ) . toBeVisible ( ) ;
56
- const newCh2 = await getColumnHeaderContainer ( mito , 'Column2' ) ;
57
- await expect ( newCh2 ) . toBeVisible ( ) ;
58
- const Column3_test_1 = await getColumnHeaderContainer ( mito , 'Column3_test_1' ) ;
59
- await expect ( Column3_test_1 ) . toBeVisible ( ) ;
52
+ await checkColumnExists ( mito , [ 'Column1' , 'Column2' , 'Column3_test_1' ] ) ;
60
53
} ) ;
61
54
62
55
@@ -73,17 +66,15 @@ test.describe('Merge', () => {
73
66
// Wait for the merge to be finished before continuing so adding a column works!
74
67
await expect ( mito . getByText ( 'df_merge' ) ) . toBeVisible ( ) ;
75
68
76
- // Check that Column1 exists
77
- const ch1 = await getColumnHeaderContainer ( mito , 'Column1' ) ;
78
- await expect ( ch1 ) . toBeVisible ( ) ;
69
+ await checkColumnExists ( mito , 'Column1' ) ;
79
70
80
71
// Add a column
81
72
await mito . locator ( '[id="mito-toolbar-button-add\\ column\\ to\\ the\\ right"]' ) . getByRole ( 'button' , { name : 'Insert' } ) . click ( ) ;
82
73
await awaitResponse ( page ) ;
83
74
84
75
// Check that the merge table has been updated -- there should be
85
76
// 5 columns from merge + 1 added
86
- await expect ( mito . locator ( '.endo-column-header-container' ) ) . toHaveCount ( 6 ) ;
77
+ await checkColumnCount ( mito , 6 ) ;
87
78
88
79
// Reopen the edit merge
89
80
await mito . getByText ( 'df_merge' ) . click ( { button : 'right' } ) ;
@@ -92,15 +83,9 @@ test.describe('Merge', () => {
92
83
// Add a merge key
93
84
await mito . getByRole ( 'button' , { name : '+ Add Merge Keys' } ) . click ( ) ;
94
85
95
- const newCh1 = await getColumnHeaderContainer ( mito , 'Column1' ) ;
96
- await expect ( newCh1 ) . toBeVisible ( ) ;
97
- const newCh2 = await getColumnHeaderContainer ( mito , 'Column2' ) ;
98
- await expect ( newCh2 ) . toBeVisible ( ) ;
99
- const Column3_test_1 = await getColumnHeaderContainer ( mito , 'Column3_test_1' ) ;
100
- await expect ( Column3_test_1 ) . toBeVisible ( ) ;
101
-
102
- // Check that there are 5 columns still
103
- await expect ( mito . locator ( '.endo-column-header-container' ) ) . toHaveCount ( 5 ) ;
86
+ // Check the new columns
87
+ await checkColumnExists ( mito , [ 'Column1' , 'Column2' , 'Column3_test_1' ] ) ;
88
+ await checkColumnCount ( mito , 5 ) ;
104
89
} ) ;
105
90
106
91
test ( 'Change Merge Type' , async ( { page } ) => {
0 commit comments