11import { checkErrors } from '../../support' ;
22import { detailsPage } from '../../views/details-page' ;
3+ import { guidedTour } from '../../views/guided-tour' ;
34
45const MC_WITH_CONFIG_FILES = '00-master' ;
56const MC_WITHOUT_CONFIG_FILES = '99-master-ssh' ;
67const MC_DETAILS_PAGE_URL = '/k8s/cluster/machineconfiguration.openshift.io~v1~MachineConfig/' ;
78const MC_SECTION_HEADING = 'Configuration files' ;
89const MC_CONFIG_FILE_PATH_ID = 'config-file-path-0' ;
910const MC_C2C = '.co-copy-to-clipboard__text' ;
11+ const checkMachineConfigDetails = ( mode , overwrite , content ) => {
12+ cy . byTestID ( MC_CONFIG_FILE_PATH_ID ) . scrollIntoView ( ) ;
13+ cy . get ( 'button[aria-label="Info"]' ) . first ( ) . click ( ) ;
14+ cy . contains ( mode ) . should ( 'exist' ) ;
15+ cy . contains ( overwrite . toString ( ) ) . should ( 'exist' ) ;
16+ cy . get ( 'code' )
17+ . first ( )
18+ . should ( ( $code ) => {
19+ const text = $code . text ( ) ;
20+ expect ( text ) . to . include (
21+ decodeURIComponent ( content )
22+ . replace ( / ^ ( d a t a : , ) / , '' )
23+ . slice ( 0 , 30 ) ,
24+ ) ;
25+ } ) ;
26+ } ;
1027
1128describe ( 'MachineConfig resource details page' , ( ) => {
1229 before ( ( ) => {
1330 cy . login ( ) ;
31+ guidedTour . close ( ) ;
1432 cy . initAdmin ( ) ;
1533 } ) ;
1634
@@ -25,6 +43,20 @@ describe('MachineConfig resource details page', () => {
2543 cy . byTestSectionHeading ( MC_SECTION_HEADING ) . should ( 'exist' ) ;
2644 cy . byTestID ( MC_CONFIG_FILE_PATH_ID ) . should ( 'exist' ) ;
2745 cy . get ( MC_C2C ) . should ( 'exist' ) ;
46+ cy . exec ( `oc get mc ${ MC_WITH_CONFIG_FILES } -o jsonpath='{.spec.config.storage.files[0]}'` ) . then (
47+ ( result ) => {
48+ const mcContents = JSON . parse ( result . stdout ) ;
49+ expect ( mcContents ) . to . have . property ( 'contents' ) ;
50+ expect ( mcContents ) . to . have . property ( 'mode' ) ;
51+ expect ( mcContents ) . to . have . property ( 'overwrite' ) ;
52+ const {
53+ contents : { source } ,
54+ mode,
55+ overwrite,
56+ } = mcContents ;
57+ checkMachineConfigDetails ( mode , overwrite , source ) ;
58+ } ,
59+ ) ;
2860 } ) ;
2961
3062 it ( `${ MC_WITHOUT_CONFIG_FILES } does not display configuration files` , ( ) => {
0 commit comments