@@ -11,7 +11,9 @@ type YfmTableActionKind =
1111 | 'add-column-after'
1212 | 'add-row-before'
1313 | 'add-row-after'
14- | 'header-toggle' ;
14+ | 'header-toggle'
15+ | 'row-cell-bg-open'
16+ | 'column-cell-bg-open' ;
1517
1618type MarkdownEditorToolbarsLocators = Record <
1719 'main' | 'additional' | 'selection' | 'commandMenu' ,
@@ -142,6 +144,7 @@ class YfmNote {
142144class YfmTable {
143145 readonly buttonPlusRowLocator ;
144146 readonly buttonPlusColumnLocator ;
147+ readonly cellBgPaletteLocator : Locator ;
145148 private readonly tableLocator ;
146149
147150 private readonly rowButtonLocator ;
@@ -169,7 +172,10 @@ class YfmTable {
169172 'remove-row' : page . getByTestId ( 'g-md-yfm-table-action-remove-row' ) ,
170173 'remove-table' : page . getByTestId ( 'g-md-yfm-table-action-remove-table' ) ,
171174 'header-toggle' : page . getByTestId ( 'g-md-yfm-table-row-header-toggle' ) ,
175+ 'row-cell-bg-open' : page . getByTestId ( 'g-md-yfm-table-row-cell-bg' ) ,
176+ 'column-cell-bg-open' : page . getByTestId ( 'g-md-yfm-table-column-cell-bg' ) ,
172177 } ;
178+ this . cellBgPaletteLocator = page . locator ( '.g-md-yfm-table-cell-bg-palette' ) ;
173179 }
174180
175181 getMenuLocator ( type : YfmTableCellMenuType ) {
@@ -225,6 +231,31 @@ class YfmTable {
225231 await firstCell . waitFor ( { state : 'visible' } ) ;
226232 await firstCell . click ( ) ;
227233 }
234+
235+ getCellBgSwatchLocator ( label : string ) {
236+ return this . cellBgPaletteLocator . getByLabel ( label , { exact : true } ) ;
237+ }
238+
239+ async openCellBgPalette ( menuType : YfmTableCellMenuType ) {
240+ const menu = this . cellMenus [ menuType ] ;
241+ await menu . waitFor ( { state : 'visible' } ) ;
242+ const actionKey : YfmTableActionKind =
243+ menuType === 'row' ? 'row-cell-bg-open' : 'column-cell-bg-open' ;
244+ await menu . locator ( this . cellMenuActions [ actionKey ] ) . hover ( ) ;
245+ await this . cellBgPaletteLocator . waitFor ( { state : 'visible' } ) ;
246+ }
247+
248+ async selectCellBg ( menuType : YfmTableCellMenuType , swatchLabel : string ) {
249+ await this . openCellBgPalette ( menuType ) ;
250+ await this . getCellBgSwatchLocator ( swatchLabel ) . click ( ) ;
251+ }
252+
253+ async closeMenu ( menuType : YfmTableCellMenuType ) {
254+ const button =
255+ menuType === 'row' ? this . rowButtonLocator . first ( ) : this . columnButtonLocator . first ( ) ;
256+ await button . click ( ) ;
257+ await this . cellMenus [ menuType ] . waitFor ( { state : 'hidden' } ) ;
258+ }
228259}
229260
230261class SearchPanel {
0 commit comments