@@ -87,54 +87,60 @@ describe("EquipmentTable Component Tests", () => {
8787 } ) ;
8888
8989 it ( "displays data from the Vuex store" , ( ) => {
90- cy . get ( ".p-datatable-tbody" )
91- . find ( "tr" )
92- . eq ( 0 )
93- . within ( ( ) => {
94- cy . get ( "td" ) . eq ( 0 ) . should ( "contain.text" , "" ) ;
95- cy . get ( "td" ) . eq ( 1 ) . should ( "contain.text" , "equipment1" ) ;
96- cy . get ( "td" ) . eq ( 3 ) . should ( "contain.text" , "Equipment One" ) ;
97- cy . get ( "td" ) . eq ( 4 ) . should ( "contain.text" , "9/1/2023" ) ;
98- cy . get ( "td" ) . eq ( 5 ) . should ( "contain.text" , "Warehouse A" ) ;
99- cy . get ( "td" ) . eq ( 6 ) . find ( ".avatar" ) . should ( "have.length" , 1 ) ;
100- } ) ;
90+ cy . getColumnIndices ( { checkbox : 0 } ) . then ( ( columnIndices ) => {
91+ // First row - equipment1
92+ cy . get ( ".p-datatable-tbody" )
93+ . find ( "tr" )
94+ . eq ( 0 )
95+ . within ( ( ) => {
96+ cy . get ( "td" ) . eq ( columnIndices [ "ID" ] ) . should ( "contain.text" , "equipment1" ) ;
97+ cy . get ( "td" ) . eq ( columnIndices [ "Name" ] ) . should ( "contain.text" , "Equipment One" ) ;
98+ cy . get ( "td" ) . eq ( columnIndices [ "Date" ] ) . should ( "contain.text" , "9/1/2023" ) ;
99+ cy . get ( "td" ) . eq ( columnIndices [ "Location" ] ) . should ( "contain.text" , "Warehouse A" ) ;
100+ cy . get ( "td" ) . eq ( columnIndices [ "Maintainers" ] ) . find ( ".avatar" ) . should ( "have.length" , 1 ) ;
101+ } ) ;
101102
102- cy . get ( ".p-datatable-tbody" )
103- . find ( "tr" )
104- . eq ( 1 )
105- . within ( ( ) => {
106- cy . get ( "td" ) . eq ( 0 ) . should ( "contain.text" , "" ) ;
107- cy . get ( "td" ) . eq ( 1 ) . should ( "contain.text" , "equipment2" ) ;
108- cy . get ( "td" ) . eq ( 3 ) . should ( "contain.text" , "Equipment Two" ) ;
109- cy . get ( "td" ) . eq ( 4 ) . should ( "contain.text" , "8/15/2023" ) ;
110- cy . get ( "td" ) . eq ( 5 ) . should ( "contain.text" , "Warehouse B" ) ;
111- cy . get ( "td" ) . eq ( 6 ) . find ( ".avatar" ) . should ( "have.length" , 2 ) ;
112- } ) ;
103+ // Second row - equipment2
104+ cy . get ( ".p-datatable-tbody" )
105+ . find ( "tr" )
106+ . eq ( 1 )
107+ . within ( ( ) => {
108+ cy . get ( "td" ) . eq ( columnIndices [ "ID" ] ) . should ( "contain.text" , "equipment2" ) ;
109+ cy . get ( "td" ) . eq ( columnIndices [ "Name" ] ) . should ( "contain.text" , "Equipment Two" ) ;
110+ cy . get ( "td" ) . eq ( columnIndices [ "Date" ] ) . should ( "contain.text" , "8/15/2023" ) ;
111+ cy . get ( "td" ) . eq ( columnIndices [ "Location" ] ) . should ( "contain.text" , "Warehouse B" ) ;
112+ cy . get ( "td" ) . eq ( columnIndices [ "Maintainers" ] ) . find ( ".avatar" ) . should ( "have.length" , 2 ) ;
113+ } ) ;
114+ } ) ;
113115 } ) ;
114116
115117 it ( "renders the component FormattedItemName" , ( ) => {
116- cy . get ( ".p-datatable-tbody tr" )
117- . eq ( 0 )
118- . within ( ( ) => {
119- cy . get ( "td" ) . eq ( 1 ) . find ( ".formatted-item-name" ) . should ( "exist" ) ;
120- } ) ;
121- cy . get ( ".p-datatable-tbody tr" )
122- . eq ( 1 )
123- . within ( ( ) => {
124- cy . get ( "td" ) . eq ( 1 ) . find ( ".formatted-item-name" ) . should ( "exist" ) ;
125- } ) ;
118+ cy . getColumnIndices ( { checkbox : 0 } ) . then ( ( columnIndices ) => {
119+ cy . get ( ".p-datatable-tbody tr" )
120+ . eq ( 0 )
121+ . within ( ( ) => {
122+ cy . get ( "td" ) . eq ( columnIndices [ "ID" ] ) . find ( ".formatted-item-name" ) . should ( "exist" ) ;
123+ } ) ;
124+ cy . get ( ".p-datatable-tbody tr" )
125+ . eq ( 1 )
126+ . within ( ( ) => {
127+ cy . get ( "td" ) . eq ( columnIndices [ "ID" ] ) . find ( ".formatted-item-name" ) . should ( "exist" ) ;
128+ } ) ;
129+ } ) ;
126130 } ) ;
127131
128132 it ( "renders the component Creators" , ( ) => {
129- cy . get ( ".p-datatable-tbody tr" )
130- . eq ( 0 )
131- . within ( ( ) => {
132- cy . get ( "td" ) . eq ( 6 ) . find ( ".avatar" ) . should ( "exist" ) ;
133- } ) ;
134- cy . get ( ".p-datatable-tbody tr" )
135- . eq ( 1 )
136- . within ( ( ) => {
137- cy . get ( "td" ) . eq ( 6 ) . find ( ".avatar" ) . should ( "exist" ) ;
138- } ) ;
133+ cy . getColumnIndices ( { checkbox : 0 } ) . then ( ( columnIndices ) => {
134+ cy . get ( ".p-datatable-tbody tr" )
135+ . eq ( 0 )
136+ . within ( ( ) => {
137+ cy . get ( "td" ) . eq ( columnIndices [ "Maintainers" ] ) . find ( ".avatar" ) . should ( "exist" ) ;
138+ } ) ;
139+ cy . get ( ".p-datatable-tbody tr" )
140+ . eq ( 1 )
141+ . within ( ( ) => {
142+ cy . get ( "td" ) . eq ( columnIndices [ "Maintainers" ] ) . find ( ".avatar" ) . should ( "exist" ) ;
143+ } ) ;
144+ } ) ;
139145 } ) ;
140146} ) ;
0 commit comments