1
+ import { expect , test } from '@playwright/test' ;
2
+ import { getMitoFrameWithTestCSV } from '../utils' ;
3
+
4
+ test . describe ( 'Formatting' , ( ) => {
5
+ test ( 'Add a suggested style' , async ( { page } ) => {
6
+ const mito = await getMitoFrameWithTestCSV ( page ) ;
7
+ await mito . getByRole ( 'button' , { name : 'Format' , exact : true } ) . click ( ) ;
8
+
9
+ // Update to the second suggested style (the first is default)
10
+ await mito . locator ( '.mito-suggested-style' ) . nth ( 1 ) . click ( ) ;
11
+ await expect ( mito . locator ( '.endo-column-header-container:not(.endo-column-header-container-selected)' ) . first ( ) ) . toHaveCSS ( 'background-color' , 'rgb(155, 155, 157)' )
12
+
13
+ // Update to the third suggested style
14
+ await mito . locator ( '.mito-suggested-style' ) . nth ( 2 ) . click ( ) ;
15
+ await expect ( mito . locator ( '.endo-column-header-container:not(.endo-column-header-container-selected)' ) . first ( ) ) . toHaveCSS ( 'background-color' , 'rgb(84, 157, 58)' )
16
+ await expect ( mito . locator ( '.mito-grid-row-even' ) . first ( ) ) . toHaveCSS ( 'background-color' , 'rgb(208, 227, 201)' )
17
+ await expect ( mito . locator ( '.mito-grid-row-odd' ) . first ( ) ) . toHaveCSS ( 'background-color' , 'rgb(255, 255, 255)' )
18
+ } ) ;
19
+
20
+ test ( 'Add a custom style to column headers' , async ( { page } ) => {
21
+ const mito = await getMitoFrameWithTestCSV ( page ) ;
22
+ await mito . getByRole ( 'button' , { name : 'Format' , exact : true } ) . click ( ) ;
23
+
24
+ await mito . getByText ( 'Column Headers' ) . click ( ) ;
25
+ await mito . locator ( '.spacing-row' , { hasText : 'Background Color' } ) . locator ( '.color-input' ) . fill ( '#2b4eee' ) ;
26
+ await expect ( mito . locator ( '.endo-column-header-container:not(.endo-column-header-container-selected)' ) . first ( ) ) . toHaveCSS ( 'background-color' , 'rgb(43, 78, 238)' )
27
+
28
+ await mito . locator ( '.spacing-row' , { hasText : 'Text Color' } ) . locator ( '.color-input' ) . fill ( '#ffffff' ) ;
29
+ await expect ( mito . locator ( '.endo-column-header-container:not(.endo-column-header-container-selected)' ) . first ( ) ) . toHaveCSS ( 'color' , 'rgb(255, 255, 255)' )
30
+ } ) ;
31
+
32
+ test ( 'Add a custom style to rows' , async ( { page } ) => {
33
+ const mito = await getMitoFrameWithTestCSV ( page ) ;
34
+ await mito . getByRole ( 'button' , { name : 'Format' , exact : true } ) . click ( ) ;
35
+
36
+ await mito . locator ( '.mito-blue-container' , { hasText : 'Rows' } ) . click ( ) ;
37
+ await mito . locator ( '.spacing-row' , { hasText : 'Even Row: Background Color' } ) . locator ( '.color-input' ) . fill ( '#2b4eee' ) ;
38
+ await expect ( mito . locator ( '.mito-grid-row-even' ) . first ( ) ) . toHaveCSS ( 'background-color' , 'rgb(43, 78, 238)' )
39
+
40
+ await mito . locator ( '.spacing-row' , { hasText : 'Even Row: Text Color' } ) . locator ( '.color-input' ) . fill ( '#ffffff' ) ;
41
+ await expect ( mito . locator ( '.mito-grid-row-even' ) . first ( ) ) . toHaveCSS ( 'color' , 'rgb(255, 255, 255)' )
42
+
43
+ await mito . locator ( '.spacing-row' , { hasText : 'Odd Row: Background Color' } ) . locator ( '.color-input' ) . fill ( '#ffffff' ) ;
44
+ await expect ( mito . locator ( '.mito-grid-row-odd' ) . first ( ) ) . toHaveCSS ( 'background-color' , 'rgb(255, 255, 255)' )
45
+
46
+ await mito . locator ( '.spacing-row' , { hasText : 'Odd Row: Text Color' } ) . locator ( '.color-input' ) . fill ( '#000000' ) ;
47
+ await expect ( mito . locator ( '.mito-grid-row-odd' ) . first ( ) ) . toHaveCSS ( 'color' , 'rgb(0, 0, 0)' )
48
+ } ) ;
49
+
50
+ } ) ;
0 commit comments