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="public~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 , 5 ) ,
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,17 @@ 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+ const {
50+ contents : { source } ,
51+ mode,
52+ overwrite,
53+ } = mcContents ;
54+ checkMachineConfigDetails ( mode , overwrite , source ) ;
55+ } ,
56+ ) ;
2857 } ) ;
2958
3059 it ( `${ MC_WITHOUT_CONFIG_FILES } does not display configuration files` , ( ) => {
0 commit comments