@@ -27,43 +27,37 @@ export const CURRENT_TENANT = {
2727} ;
2828
2929// Overwrite default backend endpoint to customized one, remember set to original value after tests complete.
30- export const currentBackendEndpoint = ( ( ) => {
31- let currentEndpoint = BACKEND_BASE_PATH ;
32- const DEFAULT_ENDPOINT = BACKEND_BASE_PATH ;
33- const REMOTE_NO_AUTH_ENDPOINT = Cypress . env ( 'remoteDataSourceNoAuthUrl' ) ;
34-
35- return Object . freeze ( {
36- DEFAULT : DEFAULT_ENDPOINT ,
37- REMOTE_NO_AUTH : REMOTE_NO_AUTH_ENDPOINT ,
38- /**
39- * Change current backend endpoint
40- * @param {* } changedEndPoint
41- * @param {* } immediately set immediately false to change tenant after all pending promise be invoked,
42- * useful for reset backend endpoint after all tests run.
43- */
44- set ( changedEndPoint , immediately = true ) {
45- if (
46- ! [ DEFAULT_ENDPOINT , REMOTE_NO_AUTH_ENDPOINT ] . includes ( changedEndPoint )
47- ) {
48- throw new Error ( `Invalid endpoint:${ changedEndPoint } ` ) ;
49- }
50- const updateEndpoint = ( ) => {
51- currentEndpoint = changedEndPoint ;
52- cy . log (
53- `Current backend endpoint has been changed to: ${ currentEndpoint } `
54- ) ;
55- } ;
56- if ( immediately ) {
57- updateEndpoint ( ) ;
58- } else {
59- cy . wrap ( ) . then ( updateEndpoint ) ;
60- }
61- } ,
62- get ( ) {
63- return currentEndpoint ;
64- } ,
65- } ) ;
66- } ) ( ) ;
30+ export const currentBackendEndpoint = Object . freeze ( {
31+ DEFAULT : BACKEND_BASE_PATH ,
32+ REMOTE_NO_AUTH : Cypress . env ( 'remoteDataSourceNoAuthUrl' ) ,
33+ /**
34+ * Change current backend endpoint
35+ * @param {* } changedEndPoint
36+ * @param {* } immediately set immediately false to change tenant after all pending promise be invoked,
37+ * useful for reset backend endpoint after all tests run.
38+ */
39+ set ( changedEndPoint , immediately = true ) {
40+ if (
41+ ! [ DEFAULT_ENDPOINT , REMOTE_NO_AUTH_ENDPOINT ] . includes ( changedEndPoint )
42+ ) {
43+ throw new Error ( `Invalid endpoint:${ changedEndPoint } ` ) ;
44+ }
45+ const updateEndpoint = ( ) => {
46+ Cypress . env ( 'currentBackendEndpoint' , changedEndPoint ) ;
47+ cy . log (
48+ `Current backend endpoint has been changed to: ${ changedEndPoint } `
49+ ) ;
50+ } ;
51+ if ( immediately ) {
52+ updateEndpoint ( ) ;
53+ } else {
54+ cy . wrap ( ) . then ( updateEndpoint ) ;
55+ }
56+ } ,
57+ get ( ) {
58+ return Cypress . env ( 'currentBackendEndpoint' ) || DEFAULT_ENDPOINT ;
59+ } ,
60+ } ) ;
6761
6862export const supressNoRequestOccurred = ( ) => {
6963 cy . on ( 'fail' , ( err ) => {
0 commit comments