@@ -4,6 +4,7 @@ import TableCell from "../../src/TableCell.js";
44import TableRow from "../../src/TableRow.js" ;
55import TableSelection from "../../src/TableSelection.js" ;
66import TableHeaderCell from "../../src/TableHeaderCell.js" ;
7+ import TableHeaderCellActionAI from "../../src/TableHeaderCellActionAI.js" ;
78import Label from "../../src/Label.js" ;
89import Input from "../../src/Input.js" ;
910import Bar from "../../src/Bar.js" ;
@@ -663,3 +664,102 @@ describe("Table - Navigated Rows", () => {
663664 } ) ;
664665 } ) ;
665666} ) ;
667+
668+ describe ( "Table - HeaderCell" , ( ) => {
669+ beforeEach ( ( ) => {
670+ cy . mount (
671+ < Table overflow-mode = "Popin" >
672+ < TableHeaderRow slot = "headerRow" >
673+ < TableHeaderCell min-width = "300px" > Column A</ TableHeaderCell >
674+ < TableHeaderCell min-width = "200px" sort-indicator = "Ascending" >
675+ < Label required wrappingType = "None" > Column B</ Label >
676+ < TableHeaderCellActionAI slot = "action" > </ TableHeaderCellActionAI >
677+ </ TableHeaderCell >
678+ < TableHeaderCell min-width = "150px" popin-text = "Popin Text" >
679+ < Label required > Column C</ Label >
680+ </ TableHeaderCell >
681+ </ TableHeaderRow >
682+ < TableRow >
683+ < TableCell > Cell A</ TableCell >
684+ < TableCell > Cell B</ TableCell >
685+ < TableCell > Cell C</ TableCell >
686+ </ TableRow >
687+ < TableRow >
688+ < TableCell > Cell A</ TableCell >
689+ < TableCell > Cell B</ TableCell >
690+ < TableCell > Cell C</ TableCell >
691+ </ TableRow >
692+ </ Table >
693+ ) ;
694+ cy . get ( "[ui5-table]" ) . as ( "table" ) . children ( "ui5-table-row" ) . as ( "rows" ) ;
695+ cy . get ( "@table" ) . children ( "ui5-table-header-row" ) . first ( ) . as ( "headerRow" ) ;
696+ cy . get ( "@headerRow" ) . get ( "ui5-table-header-cell" ) . each ( ( $headerCell , index ) => {
697+ cy . wrap ( $headerCell ) . as ( `headerCell${ index + 1 } ` ) ;
698+ } ) ;
699+ cy . get ( "@rows" ) . each ( ( $row , index ) => {
700+ cy . wrap ( $row ) . as ( `row${ index + 1 } ` ) ;
701+ } ) ;
702+ } ) ;
703+
704+ it ( "should render header-cell correctly" , ( ) => {
705+ cy . get ( "@headerCell1" ) . contains ( "Column A" ) ;
706+ cy . get ( "@headerCell2" ) . should ( "have.attr" , "aria-sort" , "ascending" ) ;
707+ cy . get ( "@headerCell2" ) . find ( "ui5-table-header-cell-action-ai" ) . as ( "actionB" ) ;
708+ cy . get ( "@actionB" ) . shadow ( ) . find ( "ui5-button" ) . as ( "actionBbutton" ) ;
709+ cy . get ( "@actionBbutton" ) . should ( "have.attr" , "icon" , "ai" ) ;
710+ cy . get ( "@actionBbutton" ) . should ( "have.attr" , "tooltip" , "Generated by AI" ) ;
711+ cy . get ( "@actionB" ) . invoke ( "on" , "click" , cy . stub ( ) . as ( "actionBclick" ) ) ;
712+ cy . get ( "@actionBbutton" ) . realClick ( ) ;
713+ cy . get ( "@actionBclick" ) . should ( "have.been.calledOnce" ) ;
714+ cy . get ( "@headerCell2" ) . shadow ( ) . find ( "ui5-icon" ) . as ( "actionBicon" ) ;
715+ cy . get ( "@actionBicon" ) . should ( "have.attr" , "name" , "sort-ascending" ) ;
716+
717+ cy . get ( "@headerCell2" ) . invoke ( "attr" , "sort-indicator" , "Descending" ) ;
718+ cy . get ( "@headerCell2" ) . shadow ( ) . find ( "ui5-icon" ) . should ( "have.attr" , "name" , "sort-descending" ) ;
719+ cy . get ( "@actionBicon" ) . should ( "have.attr" , "name" , "sort-descending" ) ;
720+ cy . get ( "@headerCell2" ) . should ( "have.attr" , "aria-sort" , "descending" ) ;
721+
722+ cy . get ( "@headerCell2" ) . invoke ( "attr" , "sort-indicator" , "None" ) ;
723+ cy . get ( "@headerCell2" ) . shadow ( ) . find ( "ui5-icon" ) . should ( "not.exist" ) ;
724+ cy . get ( "@headerCell2" ) . should ( "not.have.attr" , "aria-sort" ) ;
725+
726+ cy . get ( "@table" ) . invoke ( "css" , "width" , "250px" ) ;
727+ // eslint-disable-next-line cypress/no-unnecessary-waiting
728+ cy . wait ( 50 ) ;
729+
730+ cy . get ( "@row1" ) . find ( "ui5-table-cell[_popin]" ) . as ( "row1popins" ) ;
731+ cy . get ( "@row1popins" ) . first ( ) . as ( "row1popinB" ) ;
732+ cy . get ( "@row1popinB" ) . shadow ( ) . find ( "ui5-table-header-cell-action-ai" ) . as ( "row1popinBaction" ) ;
733+ cy . get ( "@row1popinBaction" ) . shadow ( ) . find ( "ui5-button" ) . as ( "row1popinBbutton" ) ;
734+ cy . get ( "@row1popinBbutton" ) . should ( "have.attr" , "icon" , "ai" ) ;
735+ cy . get ( "@row1popinBbutton" ) . should ( "have.attr" , "design" , "Transparent" ) ;
736+ cy . get ( "@row1popinBbutton" ) . should ( "have.attr" , "tooltip" , "Generated by AI" ) ;
737+ cy . get ( "@row1popinBbutton" ) . realClick ( ) ;
738+ cy . get ( "@actionBclick" ) . invoke ( "getCall" , 1 ) . its ( "args.0.detail.targetRef" ) . as ( "actionBclickTarget" ) ;
739+ cy . get ( "@actionBclickTarget" ) . should ( "have.attr" , "icon" , "ai" ) ;
740+ cy . get ( "@actionBclickTarget" ) . should ( "have.attr" , "design" , "Transparent" ) ;
741+ cy . get ( "@actionBclickTarget" ) . should ( "have.attr" , "tooltip" , "Generated by AI" ) ;
742+
743+ cy . get ( "@row1popinB" ) . shadow ( ) . find ( "ui5-label" ) . as ( "row1popinBlabel" ) ;
744+ cy . get ( "@row1popinBlabel" ) . contains ( "Column B" ) ;
745+ cy . get ( "@row1popinBlabel" ) . should ( "have.attr" , "wrapping-type" , "None" ) ;
746+ cy . get ( "@row1popinBlabel" ) . should ( "have.attr" , "required" ) ;
747+
748+ cy . get ( "@row1popins" ) . last ( ) . as ( "row1popinC" ) ;
749+ cy . get ( "@row1popinC" ) . shadow ( ) . find ( "ui5-label" ) . should ( "not.exist" ) ;
750+ cy . get ( "@row1popinC" ) . shadow ( ) . should ( "have.text" , "Popin Text:" ) ;
751+ cy . get ( "@row1popinC" ) . should ( "have.text" , "Cell C" ) ;
752+
753+ cy . get ( "@row2" ) . find ( "ui5-table-cell[_popin]" ) . as ( "row2popins" ) ;
754+ cy . get ( "@row2popins" ) . first ( ) . as ( "row2popinB" ) ;
755+ cy . get ( "@row2popinB" ) . shadow ( ) . find ( "ui5-table-header-cell-action-ai" ) . as ( "row2popinBaction" ) ;
756+ cy . get ( "@row2popinBaction" ) . shadow ( ) . find ( "ui5-button" ) . as ( "row2popinBbutton" ) ;
757+ cy . get ( "@row2popinBbutton" ) . should ( "have.attr" , "icon" , "ai" ) ;
758+ cy . get ( "@row2popinBbutton" ) . should ( "have.attr" , "tooltip" , "Generated by AI" ) ;
759+ cy . get ( "@row2popinBbutton" ) . realClick ( ) ;
760+ cy . get ( "@actionBclick" ) . invoke ( "getCall" , 2 ) . its ( "args.0.detail.targetRef" ) . as ( "actionBclickTarget" ) ;
761+ cy . get ( "@actionBclickTarget" ) . should ( "have.attr" , "icon" , "ai" ) ;
762+ cy . get ( "@actionBclickTarget" ) . should ( "have.attr" , "design" , "Transparent" ) ;
763+ cy . get ( "@actionBclickTarget" ) . should ( "have.attr" , "tooltip" , "Generated by AI" ) ;
764+ } ) ;
765+ } ) ;
0 commit comments