@@ -2,7 +2,7 @@ import path from 'path';
2
2
3
3
import { expect , test } from '@playwright/test' ;
4
4
5
- import { CONFIG , createDoc } from './common' ;
5
+ import { CONFIG , createDoc , overrideConfig } from './common' ;
6
6
7
7
test . describe ( 'Config' , ( ) => {
8
8
test ( 'it checks the config api is called' , async ( { page } ) => {
@@ -16,24 +16,19 @@ test.describe('Config', () => {
16
16
const response = await responsePromise ;
17
17
expect ( response . ok ( ) ) . toBeTruthy ( ) ;
18
18
19
- expect ( await response . json ( ) ) . toStrictEqual ( CONFIG ) ;
19
+ const json = ( await response . json ( ) ) as typeof CONFIG ;
20
+ const { theme_customization, ...configApi } = json ;
21
+ expect ( theme_customization ) . toBeDefined ( ) ;
22
+ const { theme_customization : _ , ...CONFIG_LEFT } = CONFIG ;
23
+
24
+ expect ( configApi ) . toStrictEqual ( CONFIG_LEFT ) ;
20
25
} ) ;
21
26
22
27
test ( 'it checks that sentry is trying to init from config endpoint' , async ( {
23
28
page,
24
29
} ) => {
25
- await page . route ( '**/api/v1.0/config/' , async ( route ) => {
26
- const request = route . request ( ) ;
27
- if ( request . method ( ) . includes ( 'GET' ) ) {
28
- await route . fulfill ( {
29
- json : {
30
- ...CONFIG ,
31
- SENTRY_DSN : 'https://sentry.io/123' ,
32
- } ,
33
- } ) ;
34
- } else {
35
- await route . continue ( ) ;
36
- }
30
+ await overrideConfig ( page , {
31
+ SENTRY_DSN : 'https://sentry.io/123' ,
37
32
} ) ;
38
33
39
34
const invalidMsg = 'Invalid Sentry Dsn: https://sentry.io/123' ;
@@ -98,18 +93,8 @@ test.describe('Config', () => {
98
93
page,
99
94
browserName,
100
95
} ) => {
101
- await page . route ( '**/api/v1.0/config/' , async ( route ) => {
102
- const request = route . request ( ) ;
103
- if ( request . method ( ) . includes ( 'GET' ) ) {
104
- await route . fulfill ( {
105
- json : {
106
- ...CONFIG ,
107
- AI_FEATURE_ENABLED : false ,
108
- } ,
109
- } ) ;
110
- } else {
111
- await route . continue ( ) ;
112
- }
96
+ await overrideConfig ( page , {
97
+ AI_FEATURE_ENABLED : false ,
113
98
} ) ;
114
99
115
100
await page . goto ( '/' ) ;
@@ -129,18 +114,8 @@ test.describe('Config', () => {
129
114
test ( 'it checks that Crisp is trying to init from config endpoint' , async ( {
130
115
page,
131
116
} ) => {
132
- await page . route ( '**/api/v1.0/config/' , async ( route ) => {
133
- const request = route . request ( ) ;
134
- if ( request . method ( ) . includes ( 'GET' ) ) {
135
- await route . fulfill ( {
136
- json : {
137
- ...CONFIG ,
138
- CRISP_WEBSITE_ID : '1234' ,
139
- } ,
140
- } ) ;
141
- } else {
142
- await route . continue ( ) ;
143
- }
117
+ await overrideConfig ( page , {
118
+ CRISP_WEBSITE_ID : '1234' ,
144
119
} ) ;
145
120
146
121
await page . goto ( '/' ) ;
@@ -151,18 +126,8 @@ test.describe('Config', () => {
151
126
} ) ;
152
127
153
128
test ( 'it checks FRONTEND_CSS_URL config' , async ( { page } ) => {
154
- await page . route ( '**/api/v1.0/config/' , async ( route ) => {
155
- const request = route . request ( ) ;
156
- if ( request . method ( ) . includes ( 'GET' ) ) {
157
- await route . fulfill ( {
158
- json : {
159
- ...CONFIG ,
160
- FRONTEND_CSS_URL : 'http://localhost:123465/css/style.css' ,
161
- } ,
162
- } ) ;
163
- } else {
164
- await route . continue ( ) ;
165
- }
129
+ await overrideConfig ( page , {
130
+ FRONTEND_CSS_URL : 'http://localhost:123465/css/style.css' ,
166
131
} ) ;
167
132
168
133
await page . goto ( '/' ) ;
0 commit comments