@@ -2,26 +2,33 @@ import path from 'path';
22
33import { expect , test } from '@playwright/test' ;
44
5- import { CONFIG , createDoc , overrideConfig } from './utils-common' ;
5+ import {
6+ CONFIG ,
7+ createDoc ,
8+ getCurrentConfig ,
9+ overrideConfig ,
10+ } from './utils-common' ;
611
712test . describe ( 'Config' , ( ) => {
8- test ( 'it checks that sentry is trying to init from config endpoint' , async ( {
9- page,
10- } ) => {
11- await overrideConfig ( page , {
12- SENTRY_DSN : 'https://sentry.io/123' ,
13+ if ( process . env . IS_INSTANCE !== 'true' ) {
14+ test ( 'it checks that sentry is trying to init from config endpoint' , async ( {
15+ page,
16+ } ) => {
17+ await overrideConfig ( page , {
18+ SENTRY_DSN : 'https://sentry.io/123' ,
19+ } ) ;
20+
21+ const invalidMsg = 'Invalid Sentry Dsn: https://sentry.io/123' ;
22+ const consoleMessage = page . waitForEvent ( 'console' , {
23+ timeout : 5000 ,
24+ predicate : ( msg ) => msg . text ( ) . includes ( invalidMsg ) ,
25+ } ) ;
26+
27+ await page . goto ( '/' ) ;
28+
29+ expect ( ( await consoleMessage ) . text ( ) ) . toContain ( invalidMsg ) ;
1330 } ) ;
14-
15- const invalidMsg = 'Invalid Sentry Dsn: https://sentry.io/123' ;
16- const consoleMessage = page . waitForEvent ( 'console' , {
17- timeout : 5000 ,
18- predicate : ( msg ) => msg . text ( ) . includes ( invalidMsg ) ,
19- } ) ;
20-
21- await page . goto ( '/' ) ;
22-
23- expect ( ( await consoleMessage ) . text ( ) ) . toContain ( invalidMsg ) ;
24- } ) ;
31+ }
2532
2633 test ( 'it checks that media server is configured from config endpoint' , async ( {
2734 page,
@@ -55,7 +62,7 @@ test.describe('Config', () => {
5562
5663 // Check src of image
5764 expect ( await image . getAttribute ( 'src' ) ) . toMatch (
58- / h t t p : \/ \/ l o c a l h o s t : 8 0 8 3 \/ m e d i a \ / .* \ /a t t a c h m e n t s \ / .* .p n g / ,
65+ new RegExp ( ` ${ process . env . MEDIA_BASE_URL } / media/.*? /attachments/.*? .png` ) ,
5966 ) ;
6067 } ) ;
6168
@@ -71,23 +78,36 @@ test.describe('Config', () => {
7178 . click ( ) ;
7279
7380 const webSocket = await page . waitForEvent ( 'websocket' , ( webSocket ) => {
74- return webSocket . url ( ) . includes ( 'ws://localhost:4444/collaboration/ws/' ) ;
81+ return webSocket . url ( ) . includes ( ` ${ process . env . COLLABORATION_WS_URL } ` ) ;
7582 } ) ;
76- expect ( webSocket . url ( ) ) . toContain ( 'ws://localhost:4444/collaboration/ws/' ) ;
83+ expect ( webSocket . url ( ) ) . toContain ( ` ${ process . env . COLLABORATION_WS_URL } ` ) ;
7784 } ) ;
7885
79- test ( 'it checks that Crisp is trying to init from config endpoint' , async ( {
80- page,
81- } ) => {
82- await overrideConfig ( page , {
83- CRISP_WEBSITE_ID : '1234' ,
86+ if ( process . env . IS_INSTANCE !== 'true' ) {
87+ test ( 'it checks that Crisp is trying to init from config endpoint' , async ( {
88+ page,
89+ } ) => {
90+ await overrideConfig ( page , {
91+ CRISP_WEBSITE_ID : '1234' ,
92+ } ) ;
93+
94+ await page . goto ( '/' ) ;
95+
96+ await expect (
97+ page . locator ( '#crisp-chatbox' ) . getByText ( 'Invalid website' ) ,
98+ ) . toBeVisible ( ) ;
8499 } ) ;
100+ }
85101
86- await page . goto ( '/' ) ;
102+ test ( 'it checks that Crisp is initialized' , async ( { page } ) => {
103+ const currentConfig = await getCurrentConfig ( page ) ;
87104
88- await expect (
89- page . locator ( '#crisp-chatbox' ) . getByText ( 'Invalid website' ) ,
90- ) . toBeVisible ( ) ;
105+ test . skip (
106+ ! currentConfig . CRISP_WEBSITE_ID ,
107+ 'CRISP_WEBSITE_ID is not set in config, skipping Crisp initialization test' ,
108+ ) ;
109+
110+ await expect ( page . locator ( '#crisp-chatbox' ) ) . toBeVisible ( ) ;
91111 } ) ;
92112
93113 test ( 'it checks FRONTEND_CSS_URL config' , async ( { page } ) => {
@@ -118,20 +138,22 @@ test.describe('Config', () => {
118138 ) . toBeAttached ( ) ;
119139 } ) ;
120140
121- test ( 'it checks the config api is called' , async ( { page } ) => {
122- const responsePromise = page . waitForResponse (
123- ( response ) =>
124- response . url ( ) . includes ( '/config/' ) && response . status ( ) === 200 ,
125- ) ;
141+ if ( process . env . IS_INSTANCE !== 'true' ) {
142+ test ( 'it checks the config api is called' , async ( { page } ) => {
143+ const responsePromise = page . waitForResponse (
144+ ( response ) =>
145+ response . url ( ) . includes ( '/config/' ) && response . status ( ) === 200 ,
146+ ) ;
126147
127- await page . goto ( '/' ) ;
148+ await page . goto ( '/' ) ;
128149
129- const response = await responsePromise ;
130- expect ( response . ok ( ) ) . toBeTruthy ( ) ;
150+ const response = await responsePromise ;
151+ expect ( response . ok ( ) ) . toBeTruthy ( ) ;
131152
132- const json = ( await response . json ( ) ) as typeof CONFIG ;
133- expect ( json ) . toStrictEqual ( CONFIG ) ;
134- } ) ;
153+ const json = ( await response . json ( ) ) as typeof CONFIG ;
154+ expect ( json ) . toStrictEqual ( CONFIG ) ;
155+ } ) ;
156+ }
135157} ) ;
136158
137159test . describe ( 'Config: Not logged' , ( ) => {
0 commit comments