@@ -29,6 +29,7 @@ const {
2929const config = buildScenarioConfig ( '44' ) ;
3030const reportName = buildUniqueName ( 'Playwright Regression' , process . env . REPORT_NAME ) ;
3131const dataloadName = 'Test Dataload' ;
32+ const customColumnValues = [ 'Solar' , 'Manual month' ] ;
3233
3334( async ( ) => {
3435 const browser = await chromium . launch ( { headless : config . headless } ) ;
@@ -63,23 +64,76 @@ const dataloadName = 'Test Dataload';
6364 await page . locator ( '.analyticsDialogHeader, #analyticsDialogContainer h2' ) . filter ( { hasText : 'Column Picker' } ) . first ( )
6465 . waitFor ( { state : 'visible' , timeout : 10000 } ) ;
6566 await page . locator ( '[id="1"]' ) . first ( ) . check ( ) ;
66- await page . locator ( '[id="2"]' ) . first ( ) . check ( ) ;
67- await page . locator ( '[id="4"]' ) . first ( ) . check ( ) ;
68- await page . locator ( '#sortable-list > li:nth-child(2)' ) . dragTo ( page . locator ( '#sortable-list > li:nth-child(1)' ) ) ;
67+ for ( const value of customColumnValues ) {
68+ await clickFirst ( page , [ '#addColumnButton' ] , 'add custom column' ) ;
69+ const customEditor = page . locator ( '#sortable-list > li' ) . filter ( { hasText : 'Custom Column' } ) . locator ( 'span[contenteditable]' ) . last ( ) ;
70+ await customEditor . fill ( value ) ;
71+ }
6972 await clickFirst ( page , [ '#analyticsDialogBtnGo' , '.oc-dialog-buttonrow > .primary' ] , 'column picker confirm' ) ;
7073
7174 const columnsValue = await page . locator ( '#columns' ) . first ( ) . inputValue ( ) ;
72- if ( columnsValue !== '2,1,4' ) {
73- throw new Error ( `Expected selected columns "2,1,4 ", got "${ columnsValue } "` ) ;
75+ if ( columnsValue !== `1, ${ customColumnValues . join ( ',' ) } ` ) {
76+ throw new Error ( `Expected selected columns "1, ${ customColumnValues . join ( ',' ) } ", got "${ columnsValue } "` ) ;
7477 }
7578
7679 await capture ( 'dataload_csv_column_picker' ) ;
7780
78- steps . push ( 'update and execute local csv dataload' ) ;
81+ steps . push ( 'update local csv dataload' ) ;
7982 await clickFirst ( page , [ '#dataloadUpdateButton' ] , 'update dataload' ) ;
8083 await waitForToastAndDismiss ( page ) ;
84+
85+ steps . push ( 'reopen custom columns in column picker' ) ;
86+ await openReportAutomationTab ( page , reportName ) ;
87+ await openDataloadEntry ( page , dataloadName ) ;
88+ await clickFirst ( page , [ '#columns' ] , 'columns dialog with custom columns' ) ;
89+ await page . locator ( '.analyticsDialogHeader, #analyticsDialogContainer h2' ) . filter ( { hasText : 'Column Picker' } ) . first ( )
90+ . waitFor ( { state : 'visible' , timeout : 10000 } ) ;
91+
92+ const customRows = page . locator ( '#sortable-list > li' ) . filter ( { hasText : 'Custom Column' } ) ;
93+ await customRows . first ( ) . waitFor ( { state : 'visible' , timeout : 10000 } ) ;
94+ const customRowCount = await customRows . count ( ) ;
95+ if ( customRowCount !== customColumnValues . length ) {
96+ throw new Error ( `Expected ${ customColumnValues . length } custom column rows, got ${ customRowCount } ` ) ;
97+ }
98+ for ( let index = 0 ; index < customColumnValues . length ; index += 1 ) {
99+ const row = customRows . nth ( index ) ;
100+ const editor = row . locator ( 'span[contenteditable]' ) . first ( ) ;
101+ const editorText = await editor . textContent ( ) ;
102+ if ( editorText !== customColumnValues [ index ] ) {
103+ throw new Error ( `Expected custom column value "${ customColumnValues [ index ] } ", got "${ editorText } "` ) ;
104+ }
105+ const backgroundColor = await row . evaluate ( ( node ) => getComputedStyle ( node ) . backgroundColor ) ;
106+ const expectedColor = await row . evaluate ( ( ) => getComputedStyle ( document . documentElement ) . getPropertyValue ( '--color-warning-hover' ) . trim ( ) ) ;
107+ const expectedColorProbe = await page . evaluate ( ( color ) => {
108+ const probe = document . createElement ( 'div' ) ;
109+ probe . style . backgroundColor = color ;
110+ document . body . appendChild ( probe ) ;
111+ const computedColor = getComputedStyle ( probe ) . backgroundColor ;
112+ probe . remove ( ) ;
113+ return computedColor ;
114+ } , expectedColor ) ;
115+ if ( backgroundColor !== expectedColorProbe ) {
116+ throw new Error ( `Expected custom column warning background "${ expectedColorProbe } ", got "${ backgroundColor } "` ) ;
117+ }
118+ }
119+ const obsoleteHintIdCount = await page . locator ( '#addColumnHint' ) . count ( ) ;
120+ const obsoleteHintTextCount = await page . getByText ( / P r e v i o u s V a l u e s | V o r h e r i g e W e r t e / ) . count ( ) ;
121+ if ( obsoleteHintIdCount !== 0 || obsoleteHintTextCount !== 0 ) {
122+ throw new Error ( 'Previous Values hint should not be shown for editable custom columns' ) ;
123+ }
124+ await capture ( 'dataload_csv_column_picker_custom_columns' ) ;
125+ await customRows . first ( ) . locator ( 'span[contenteditable]' ) . first ( ) . fill ( 'Solar edited' ) ;
126+ await clickFirst ( page , [ '#analyticsDialogBtnGo' , '.oc-dialog-buttonrow > .primary' ] , 'column picker custom confirm' ) ;
127+ const editedColumnsValue = await page . locator ( '#columns' ) . first ( ) . inputValue ( ) ;
128+ if ( editedColumnsValue !== '1,Solar edited,Manual month' ) {
129+ throw new Error ( `Expected edited custom columns "1,Solar edited,Manual month", got "${ editedColumnsValue } "` ) ;
130+ }
131+ await clickFirst ( page , [ '#dataloadUpdateButton' ] , 'update edited custom dataload' ) ;
132+ await waitForToastAndDismiss ( page ) ;
133+
134+ steps . push ( 'execute local csv dataload' ) ;
81135 await clickFirst ( page , [ '#dataloadExecuteButton' ] , 'execute dataload' ) ;
82- await assertSimulationData ( page , '[["import 44"," 2022-09-06","44b"],["import 55", "2022-09-07","55c "]]' ) ;
136+ await assertSimulationData ( page , '[["2022-09-06","Solar edited","Manual month"],[ "2022-09-07","Solar edited","Manual month "]]' ) ;
83137 await closeAnalyticsDialog ( page ) ;
84138
85139 steps . push ( 'persist schedule and reopen entry' ) ;
0 commit comments