1
+ import { expect , test } from '@playwright/test' ;
2
+ import { clickButtonAndAwaitResponse , getMitoFrameWithTestCSV } from '../utils' ;
3
+
4
+ test . describe ( 'Top of Toolbar' , ( ) => {
5
+ test ( 'Undo' , async ( { page } ) => {
6
+ const mito = await getMitoFrameWithTestCSV ( page ) ;
7
+ await expect ( mito . getByText ( 'Import Files' ) ) . not . toBeVisible ( ) ;
8
+
9
+ await mito . getByTitle ( / U n d o t h e m o s t r e c e n t e d i t ./ ) . click ( ) ;
10
+ await expect ( mito . getByText ( 'Import Files' ) ) . toBeVisible ( ) ;
11
+ } ) ;
12
+
13
+ test ( 'Redo' , async ( { page } ) => {
14
+ const mito = await getMitoFrameWithTestCSV ( page ) ;
15
+ await expect ( mito . getByText ( 'Import Files' ) ) . not . toBeVisible ( ) ;
16
+
17
+ await mito . getByTitle ( / U n d o t h e m o s t r e c e n t e d i t ./ ) . click ( ) ;
18
+ await expect ( mito . getByText ( 'Import Files' ) ) . toBeVisible ( ) ;
19
+
20
+ await mito . getByTitle ( / R e a p p l i e s t h e l a s t s t e p t h a t y o u u n d i d , a s l o n g a s y o u h a v e n ' t m a d e a n y e d i t s s i n c e t h e u n d o ./ ) . click ( ) ;
21
+ await expect ( mito . getByText ( 'Import Files' ) ) . not . toBeVisible ( ) ;
22
+ } ) ;
23
+
24
+ test ( 'Clear' , async ( { page } ) => {
25
+ const mito = await getMitoFrameWithTestCSV ( page ) ;
26
+
27
+ // Insert a new column
28
+ await mito . locator ( '.mito-toolbar-button' , { hasText : 'Insert' } ) . click ( ) ;
29
+ await expect ( mito . locator ( '.endo-column-header-final-text' , { hasText : / n e w - c o l u m n / } ) ) . toBeVisible ( ) ;
30
+
31
+ // Clear the analysis
32
+ await mito . getByTitle ( 'Removes all of the transformations you\'ve made to imported dataframes.' ) . click ( ) ;
33
+ await expect ( mito . getByText ( 'Clear your current analysis?' ) ) . toBeVisible ( ) ;
34
+ await mito . getByText ( 'Clear' , { exact : true } ) . click ( ) ;
35
+
36
+ // Expect that the column does not exist
37
+ await expect ( mito . locator ( '.endo-column-header-final-text' , { hasText : / n e w - c o l u m n / } ) ) . not . toBeVisible ( ) ;
38
+ } ) ;
39
+
40
+ test ( 'Steps' , async ( { page } ) => {
41
+ const mito = await getMitoFrameWithTestCSV ( page ) ;
42
+
43
+ await mito . locator ( '.mito-toolbar-button' , { hasText : 'Insert' } ) . click ( ) ;
44
+ await expect ( mito . locator ( '.endo-column-header-final-text' , { hasText : / n e w - c o l u m n / } ) ) . toBeVisible ( ) ;
45
+
46
+ await mito . getByTitle ( 'View a list of all the edits you\'ve made to your data.' ) . click ( ) ;
47
+ await expect ( mito . getByText ( 'Step History' ) ) . toBeVisible ( ) ;
48
+ await expect ( mito . getByText ( 'Imported' , { exact : true } ) ) . toBeVisible ( ) ;
49
+ await expect ( mito . getByText ( 'Added column' , { exact : true } ) ) . toBeVisible ( ) ;
50
+
51
+ // Click on a step and check that the column is removed
52
+ await mito . getByText ( 'Imported' , { exact : true } ) . click ( ) ;
53
+ await expect ( mito . locator ( '.endo-column-header-final-text' , { hasText : / n e w - c o l u m n / } ) ) . not . toBeVisible ( ) ;
54
+ await expect ( mito . getByText ( 'You are viewing a previous step, and cannot make any edits.' ) ) . toBeVisible ( ) ;
55
+
56
+ // Check that you can catch up to the latest step
57
+ await mito . getByText ( 'Catch up' ) . click ( ) ;
58
+ await expect ( mito . locator ( '.endo-column-header-final-text' , { hasText : / n e w - c o l u m n / } ) ) . toBeVisible ( ) ;
59
+ } )
60
+
61
+ test ( 'Help button' , async ( { page } ) => {
62
+ const mito = await getMitoFrameWithTestCSV ( page ) ;
63
+
64
+ const popupPromise = page . waitForEvent ( 'popup' ) ;
65
+ await mito . getByText ( 'Help' ) . click ( ) ;
66
+ const popup = await popupPromise ;
67
+ await expect ( popup . url ( ) ) . toBe ( 'https://discord.com/invite/XdJSZyejJU' ) ;
68
+ } ) ;
69
+
70
+ test ( 'Search button' , async ( { page } ) => {
71
+ const mito = await getMitoFrameWithTestCSV ( page ) ;
72
+
73
+ await mito . getByRole ( 'button' , { name : / S e a r c h f o r a v a l u e i n y o u r d a t a ./ } ) . click ( ) ;
74
+ await expect ( mito . getByPlaceholder ( 'Find...' ) ) . toBeVisible ( ) ;
75
+ } ) ;
76
+ } ) ;
0 commit comments