@@ -9,6 +9,8 @@ declare global {
99 ) : Cypress . Chainable < any > ;
1010 clickNavLink ( path : string [ ] ) : Chainable < Element > ;
1111 changeNamespace ( namespace : string ) : Chainable < Element > ;
12+ aboutModal ( ) : Chainable < Element > ;
13+ podImage ( pod : string , namespace : string ) : Chainable < Element > ;
1214 }
1315 }
1416 }
@@ -54,6 +56,7 @@ Cypress.Commands.add('waitUntilWithCustomTimeout', (
5456 } ) ;
5557
5658 Cypress . Commands . add ( 'changeNamespace' , ( namespace : string ) => {
59+ cy . log ( 'Changing Namespace to: ' + namespace ) ;
5760 cy . byLegacyTestID ( 'namespace-bar-dropdown' ) . find ( 'button' ) . scrollIntoView ( ) . should ( 'be.visible' ) . click ( ) ;
5861 cy . get ( '[data-test="showSystemSwitch"]' ) . then ( ( $element ) => {
5962 if ( $element . attr ( 'data-checked-state' ) !== 'true' ) {
@@ -62,5 +65,46 @@ Cypress.Commands.add('waitUntilWithCustomTimeout', (
6265 } ) ;
6366 cy . byTestID ( 'dropdown-text-filter' ) . type ( namespace ) ;
6467 cy . byTestID ( 'dropdown-menu-item-link' ) . contains ( namespace ) . should ( 'be.visible' ) . click ( ) ;
65-
68+ cy . log ( 'Namespace changed to: ' + namespace ) ;
6669 } ) ;
70+
71+ Cypress . Commands . add ( 'aboutModal' , ( ) => {
72+ cy . log ( 'Getting OCP version' ) ;
73+ cy . byTestID ( 'help-dropdown-toggle' ) . should ( 'be.visible' ) . click ( ) ;
74+ cy . byTestID ( 'application-launcher-item' ) . contains ( 'About' ) . should ( 'be.visible' ) . click ( ) ;
75+ cy . byAriaLabel ( 'About modal' ) . find ( 'div[class*="co-select-to-copy"]' ) . eq ( 0 ) . should ( 'be.visible' ) . then ( ( $ocpversion ) => {
76+ cy . log ( 'OCP version: ' + $ocpversion . text ( ) ) ;
77+ } ) ;
78+ cy . byAriaLabel ( 'Close Dialog' ) . should ( 'be.visible' ) . click ( ) ;
79+
80+ } ) ;
81+
82+ Cypress . Commands . overwrite ( 'log' , ( log , ...args ) => {
83+ if ( Cypress . browser . isHeadless && Cypress . env ( 'DEBUG' ) ) {
84+ // Log to the terminal using the custom task
85+ return cy . task ( 'log' , args , { log : false } ) . then ( ( ) => {
86+ // The original cy.log is still executed but its output is hidden from the
87+ // command log in headless mode
88+ return log ( ...args ) ;
89+ } ) ;
90+ } else {
91+ // In headed mode, use the original cy.log behavior
92+ return log ( ...args ) ;
93+ }
94+ } ) ;
95+
96+ Cypress . Commands . add ( 'podImage' , ( pod : string , namespace : string ) => {
97+ cy . log ( 'Get pod image' ) ;
98+ cy . clickNavLink ( [ 'Workloads' , 'Pods' ] ) ;
99+ cy . changeNamespace ( namespace ) ;
100+ cy . byTestID ( 'name-filter-input' ) . should ( 'be.visible' ) . type ( pod ) ;
101+ cy . get ( `a[data-test^="${ pod } "]` ) . eq ( 0 ) . as ( 'podLink' ) . click ( ) ;
102+ cy . get ( '@podLink' ) . should ( 'be.visible' ) . click ( ) ;
103+ cy . byPFRole ( 'rowgroup' ) . find ( 'td' ) . eq ( 1 ) . scrollIntoView ( ) . should ( 'be.visible' ) . then ( ( $td ) => {
104+ cy . log ( 'Pod image: ' + $td . text ( ) ) ;
105+
106+ } ) ;
107+ cy . log ( 'Get pod image completed' ) ;
108+ } ) ;
109+
110+
0 commit comments