@@ -27,8 +27,9 @@ describe("Application tests", () => {
2727 let testApiId ;
2828
2929 const createAppForTest = ( ) => {
30- cy . visit ( '/devportal/applications/create?tenant=carbon.super' ) ;
3130 cy . intercept ( '**/application-attributes' ) . as ( 'attrGet' ) ;
31+ cy . intercept ( 'POST' , '**/applications' ) . as ( 'createAppReq' ) ;
32+ cy . visit ( '/devportal/applications/create?tenant=carbon.super' ) ;
3233 cy . wait ( '@attrGet' , { timeout : 300000 } ) ;
3334
3435 cy . get ( '#application-name' ) . type ( appName ) ;
@@ -44,24 +45,13 @@ describe("Application tests", () => {
4445
4546 cy . get ( '#itest-application-create-save' ) . click ( { force : true } ) ;
4647
47- // Accept either redirect-based or in-page success patterns.
48- cy . location ( 'pathname' , { timeout : 120000 } ) . then ( ( pathname ) => {
49- if ( pathname . includes ( '/overview' ) ) {
50- cy . get ( '#itest-info-bar-application-name' , { timeout : 30000 } )
51- . contains ( appName )
52- . should ( 'exist' ) ;
53- appCreated = true ;
54- } else {
55- cy . get ( 'body' ) . then ( ( $body ) => {
56- if ( $body . find ( '#itest-info-bar-application-name' ) . length > 0 ) {
57- cy . get ( '#itest-info-bar-application-name' , { timeout : 30000 } )
58- . contains ( appName )
59- . should ( 'exist' ) ;
60- appCreated = true ;
61- }
62- } ) ;
63- }
48+ // Prefer API success + listing verification over fragile UI timing checks.
49+ cy . wait ( '@createAppReq' , { timeout : 120000 } ) . then ( ( { response } ) => {
50+ expect ( response , 'application create response' ) . to . exist ;
51+ expect ( [ 200 , 201 , 202 ] , 'application create status' ) . to . include ( response . statusCode ) ;
6452 } ) ;
53+
54+ appCreated = true ;
6555 } ;
6656 const openSecurityRestrictionSelect = ( ) => {
6757 cy . get ( '[role="dialog"]' ) . last ( ) . within ( ( ) => {
@@ -108,13 +98,24 @@ describe("Application tests", () => {
10898 checkIfKeyExists ( ) ;
10999 } ;
110100
101+ const openRuntimeConfigurations = ( ) => {
102+ cy . get ( 'body' , { timeout : 60000 } ) . then ( ( $body ) => {
103+ if ( $body . find ( '#itest-api-details-api-config-acc' ) . length > 0 ) {
104+ cy . get ( '#itest-api-details-api-config-acc' ) . click ( { force : true } ) ;
105+ } else if ( $body . find ( '#itest-api-config' ) . length > 0 ) {
106+ cy . get ( '#itest-api-config' ) . click ( { force : true } ) ;
107+ }
108+ } ) ;
109+
110+ cy . get ( '#left-menu-itemRuntimeConfigurations' , { timeout : 100000 } ) . click ( { force : true } ) ;
111+ } ;
112+
111113 it ( "Generate API Keys" , ( ) => {
112114 cy . loginToPublisher ( publisher , password ) ;
113115 Utils . addAPIWithEndpoints ( { name : apiName , version : apiVersion , context : apiContext } ) . then ( ( apiId ) => {
114116 testApiId = apiId ;
115117 cy . visit ( `/publisher/apis/${ apiId } /overview` ) ;
116- cy . get ( '#itest-api-details-api-config-acc' ) . click ( ) ;
117- cy . get ( '#left-menu-itemRuntimeConfigurations' ) . click ( ) ;
118+ openRuntimeConfigurations ( ) ;
118119 cy . wait ( 2000 ) ;
119120 cy . get ( '#applicationLevel' ) . click ( ) ;
120121 cy . wait ( 1000 ) ;
0 commit comments