11import {
22 validate_200_Status ,
33 validate_401_Status ,
4- getTokenKey ,
54 getAPIBaseURL ,
6- getXACLHeaders ,
75 validate_expected_status ,
86} from '../../support/commands' ;
97
@@ -13,14 +11,6 @@ describe('To Validate & test Organization APIs via API call (V3)', function () {
1311 const timeout = 180000 ;
1412 const local = Cypress . env ( 'LOCAL' ) ;
1513
16- let bearerToken : string = null ;
17- before ( ( ) => {
18- getTokenKey ( bearerToken ) ;
19- cy . window ( ) . then ( ( win ) => {
20- bearerToken = win . localStorage . getItem ( 'bearerToken' ) ;
21- } ) ;
22- } ) ;
23-
2414 it ( 'Search Organization by company name - Record should return 200 Response' , function ( ) {
2515 const companyName = 'Linux Foundation' ;
2616 cy . request ( {
@@ -29,11 +19,12 @@ describe('To Validate & test Organization APIs via API call (V3)', function () {
2919 timeout : timeout ,
3020 failOnStatusCode : allowFail ,
3121 } ) . then ( ( response ) => {
32- validate_200_Status ( response ) ;
33- expect ( response . body ) . to . be . an ( 'object' ) ;
34- if ( response . body . list ) {
22+ return cy . logJson ( ' response' , response ) . then ( ( ) => {
23+ validate_200_Status ( response ) ;
24+ expect ( response . body ) . to . be . an ( 'object' ) ;
3525 expect ( response . body . list ) . to . be . an ( 'array' ) ;
36- }
26+ expect ( response . body . list . length ) . to . be . greaterThan ( 0 ) ;
27+ } ) ;
3728 } ) ;
3829 } ) ;
3930
@@ -43,13 +34,14 @@ describe('To Validate & test Organization APIs via API call (V3)', function () {
4334 method : 'GET' ,
4435 url : `${ claEndpoint } organization/search?websiteName=${ encodeURIComponent ( websiteName ) } ` ,
4536 timeout : timeout ,
46- failOnStatusCode : allowFail ,
37+ failOnStatusCode : false , // Handle connection issues for local
4738 } ) . then ( ( response ) => {
48- validate_200_Status ( response ) ;
49- expect ( response . body ) . to . be . an ( 'object' ) ;
50- if ( response . body . list ) {
39+ return cy . logJson ( ' response' , response ) . then ( ( ) => {
40+ validate_200_Status ( response ) ;
41+ expect ( response . body ) . to . be . an ( 'object' ) ;
5142 expect ( response . body . list ) . to . be . an ( 'array' ) ;
52- }
43+ expect ( response . body . list . length ) . to . be . greaterThan ( 0 ) ;
44+ } ) ;
5345 } ) ;
5446 } ) ;
5547
@@ -62,11 +54,29 @@ describe('To Validate & test Organization APIs via API call (V3)', function () {
6254 timeout : timeout ,
6355 failOnStatusCode : allowFail ,
6456 } ) . then ( ( response ) => {
65- validate_200_Status ( response ) ;
66- expect ( response . body ) . to . be . an ( 'object' ) ;
67- if ( response . body . list ) {
57+ return cy . logJson ( 'response' , response ) . then ( ( ) => {
58+ validate_200_Status ( response ) ;
59+ expect ( response . body ) . to . be . an ( 'object' ) ;
60+ expect ( response . body . list ) . to . be . an ( 'array' ) ;
61+ expect ( response . body . list . length ) . to . be . greaterThan ( 0 ) ;
62+ } ) ;
63+ } ) ;
64+ } ) ;
65+
66+ it ( 'Search Organization by non-existing company name - Record should return 200 Response' , function ( ) {
67+ const companyName = 'Non-existing XYZ' ;
68+ cy . request ( {
69+ method : 'GET' ,
70+ url : `${ claEndpoint } organization/search?companyName=${ encodeURIComponent ( companyName ) } ` ,
71+ timeout : timeout ,
72+ failOnStatusCode : allowFail ,
73+ } ) . then ( ( response ) => {
74+ return cy . logJson ( 'response' , response ) . then ( ( ) => {
75+ validate_200_Status ( response ) ;
76+ expect ( response . body ) . to . be . an ( 'object' ) ;
6877 expect ( response . body . list ) . to . be . an ( 'array' ) ;
69- }
78+ expect ( response . body . list . length ) . to . eq ( 0 ) ;
79+ } ) ;
7080 } ) ;
7181 } ) ;
7282
@@ -86,7 +96,7 @@ describe('To Validate & test Organization APIs via API call (V3)', function () {
8696 method : 'GET' ,
8797 url : `${ claEndpoint } organization/search` ,
8898 expectedStatus : 400 ,
89- expectedMessage : 'companyName or websiteName' ,
99+ expectedMessage : 'companyName or websiteName or filter at least one required ' ,
90100 expectedMessageContains : true ,
91101 } ,
92102 {
@@ -96,6 +106,7 @@ describe('To Validate & test Organization APIs via API call (V3)', function () {
96106 expectedStatus : 422 ,
97107 expectedMessage : 'websiteName in query should match' ,
98108 expectedMessageContains : true ,
109+ expectedCode : 605 ,
99110 } ,
100111 ] ;
101112
0 commit comments