@@ -5,10 +5,10 @@ const {
5
5
acceptedApplications,
6
6
} = require ( '../../mock-data/applications' ) ;
7
7
const { superUserForAudiLogs } = require ( '../../mock-data/users' ) ;
8
-
9
- const SITE_URL = 'http://localhost:8000' ;
10
- // helper/loadEnv.js file causes API_BASE_URL to be stagin-api on local env url in taskRequest/index.html
11
- const API_BASE_URL = 'https://staging-api.realdevsquad.com' ;
8
+ const {
9
+ STAGING_API_URL ,
10
+ LOCAL_TEST_PAGE_URL ,
11
+ } = require ( '../../mock-data/constants' ) ;
12
12
13
13
describe ( 'Applications page' , ( ) => {
14
14
let browser ;
@@ -22,19 +22,19 @@ describe('Applications page', () => {
22
22
ignoreHTTPSErrors : true ,
23
23
args : [ '--incognito' , '--disable-web-security' ] ,
24
24
} ) ;
25
- } ) ;
26
- beforeEach ( async ( ) => {
25
+
27
26
page = await browser . newPage ( ) ;
28
27
29
28
await page . setRequestInterception ( true ) ;
30
29
31
- page . on ( 'request' , ( request ) => {
30
+ page . on ( 'request' , ( interceptedRequest ) => {
31
+ const url = interceptedRequest . url ( ) ;
32
32
if (
33
- request . url ( ) === `${ API_BASE_URL } /applications?size=6` ||
34
- request . url ( ) ===
35
- `${ API_BASE_URL } /applications?next=YwTi6zFNI3GlDsZVjD8C&size=6`
33
+ url === `${ STAGING_API_URL } /applications?size=6` ||
34
+ url ===
35
+ `${ STAGING_API_URL } /applications?next=YwTi6zFNI3GlDsZVjD8C&size=6`
36
36
) {
37
- request . respond ( {
37
+ interceptedRequest . respond ( {
38
38
status : 200 ,
39
39
contentType : 'application/json' ,
40
40
body : JSON . stringify ( {
@@ -48,9 +48,9 @@ describe('Applications page', () => {
48
48
} ,
49
49
} ) ;
50
50
} else if (
51
- request . url ( ) === `${ API_BASE_URL } /applications?size=6&status=accepted`
51
+ url === `${ STAGING_API_URL } /applications?size=6&status=accepted`
52
52
) {
53
- request . respond ( {
53
+ interceptedRequest . respond ( {
54
54
status : 200 ,
55
55
contentType : 'application/json' ,
56
56
body : JSON . stringify ( { applications : acceptedApplications } ) ,
@@ -60,8 +60,8 @@ describe('Applications page', () => {
60
60
'Access-Control-Allow-Headers' : 'Content-Type, Authorization' ,
61
61
} ,
62
62
} ) ;
63
- } else if ( request . url ( ) === `${ API_BASE_URL } /users/self` ) {
64
- request . respond ( {
63
+ } else if ( url === `${ STAGING_API_URL } /users/self` ) {
64
+ interceptedRequest . respond ( {
65
65
status : 200 ,
66
66
contentType : 'application/json' ,
67
67
headers : {
@@ -72,9 +72,9 @@ describe('Applications page', () => {
72
72
body : JSON . stringify ( superUserForAudiLogs ) ,
73
73
} ) ;
74
74
} else if (
75
- request . url ( ) === `${ API_BASE_URL } /applications/lavEduxsb2C6Bl4s289P`
75
+ url === `${ STAGING_API_URL } /applications/lavEduxsb2C6Bl4s289P`
76
76
) {
77
- request . respond ( {
77
+ interceptedRequest . respond ( {
78
78
status : 200 ,
79
79
contentType : 'application/json' ,
80
80
body : JSON . stringify ( {
@@ -87,10 +87,10 @@ describe('Applications page', () => {
87
87
} ,
88
88
} ) ;
89
89
} else if (
90
- request . url ( ) ===
91
- `${ API_BASE_URL } /applications?size=6&status=accepted&dev=true`
90
+ url ===
91
+ `${ STAGING_API_URL } /applications?size=6&status=accepted&dev=true`
92
92
) {
93
- request . respond ( {
93
+ interceptedRequest . respond ( {
94
94
status : 200 ,
95
95
contentType : 'application/json' ,
96
96
body : JSON . stringify ( {
@@ -104,10 +104,9 @@ describe('Applications page', () => {
104
104
} ,
105
105
} ) ;
106
106
} else if (
107
- request . url ( ) ===
108
- `${ API_BASE_URL } /applications?size=6&status=pending&dev=true`
107
+ url === `${ STAGING_API_URL } /applications?size=6&status=pending&dev=true`
109
108
) {
110
- request . respond ( {
109
+ interceptedRequest . respond ( {
111
110
status : 200 ,
112
111
contentType : 'application/json' ,
113
112
body : JSON . stringify ( {
@@ -121,10 +120,10 @@ describe('Applications page', () => {
121
120
} ,
122
121
} ) ;
123
122
} else {
124
- request . continue ( ) ;
123
+ interceptedRequest . continue ( ) ;
125
124
}
126
125
} ) ;
127
- await page . goto ( `${ SITE_URL } /applications` ) ;
126
+ await page . goto ( `${ LOCAL_TEST_PAGE_URL } /applications` ) ;
128
127
await page . waitForNetworkIdle ( ) ;
129
128
} ) ;
130
129
@@ -147,13 +146,15 @@ describe('Applications page', () => {
147
146
} ) ;
148
147
149
148
it ( 'should render the index of pending applications under dev flag === true' , async function ( ) {
150
- await page . goto ( `${ SITE_URL } /applications?dev=true&status=pending` ) ;
149
+ await page . goto (
150
+ `${ LOCAL_TEST_PAGE_URL } /applications?dev=true&status=pending` ,
151
+ ) ;
151
152
const indexOfApplication = await page . $$ ( '[data-testid="user-index"]' ) ;
152
153
expect ( indexOfApplication ) . toBeTruthy ( ) ;
153
154
} ) ;
154
155
155
156
it ( 'should render the initial UI elements under dev flag === true' , async function ( ) {
156
- await page . goto ( `${ SITE_URL } /applications?dev=true` ) ;
157
+ await page . goto ( `${ LOCAL_TEST_PAGE_URL } /applications?dev=true` ) ;
157
158
const title = await page . $ ( '.header h1' ) ;
158
159
const filterButton = await page . $ ( '.filter-button' ) ;
159
160
const applicationCards = await page . $$ ( '.application-card' ) ;
@@ -191,7 +192,7 @@ describe('Applications page', () => {
191
192
} ) ;
192
193
193
194
it ( 'should load and render the accepted application requests when accept filter is selected from filter under dev flag === true along with the total count of the accepted applications' , async function ( ) {
194
- await page . goto ( `${ SITE_URL } /applications?dev=true` ) ;
195
+ await page . goto ( `${ LOCAL_TEST_PAGE_URL } /applications?dev=true` ) ;
195
196
await page . click ( '.filter-button' ) ;
196
197
197
198
await page . $eval ( 'input[name="status"][value="accepted"]' , ( radio ) =>
@@ -234,7 +235,7 @@ describe('Applications page', () => {
234
235
} ) ;
235
236
236
237
it ( 'under feature flag should open application details modal for application, when user click on card' , async function ( ) {
237
- await page . goto ( `${ SITE_URL } /applications/?dev=true` ) ;
238
+ await page . goto ( `${ LOCAL_TEST_PAGE_URL } /applications/?dev=true` ) ;
238
239
await page . waitForNetworkIdle ( ) ;
239
240
const applicationDetailsModal = await page . $ ( '.application-details' ) ;
240
241
expect (
0 commit comments