@@ -4,160 +4,166 @@ import { expect, test } from '@playwright/test';
44
55import { CONFIG , createDoc , overrideConfig } from './utils-common' ;
66
7- test . 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' ,
7+ if ( process . env . TEST_INSTANCE_ONLY !== 'true' ) {
8+ test . describe ( 'Config' , ( ) => {
9+ test ( 'it checks that sentry is trying to init from config endpoint' , async ( {
10+ page,
11+ } ) => {
12+ await overrideConfig ( page , {
13+ SENTRY_DSN : 'https://sentry.io/123' ,
14+ } ) ;
15+
16+ const invalidMsg = 'Invalid Sentry Dsn: https://sentry.io/123' ;
17+ const consoleMessage = page . waitForEvent ( 'console' , {
18+ timeout : 5000 ,
19+ predicate : ( msg ) => msg . text ( ) . includes ( invalidMsg ) ,
20+ } ) ;
21+
22+ await page . goto ( '/' ) ;
23+
24+ expect ( ( await consoleMessage ) . text ( ) ) . toContain ( invalidMsg ) ;
1325 } ) ;
1426
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- } ) ;
25-
26- test ( 'it checks that media server is configured from config endpoint' , async ( {
27- page,
28- browserName,
29- } ) => {
30- await page . goto ( '/' ) ;
27+ test ( 'it checks that media server is configured from config endpoint' , async ( {
28+ page,
29+ browserName,
30+ } ) => {
31+ await page . goto ( '/' ) ;
3132
32- await createDoc ( page , 'doc-media' , browserName , 1 ) ;
33+ await createDoc ( page , 'doc-media' , browserName , 1 ) ;
3334
34- const fileChooserPromise = page . waitForEvent ( 'filechooser' ) ;
35+ const fileChooserPromise = page . waitForEvent ( 'filechooser' ) ;
3536
36- await page . locator ( '.bn-block-outer' ) . last ( ) . fill ( 'Anything' ) ;
37- await page . locator ( '.bn-block-outer' ) . last ( ) . fill ( '/' ) ;
38- await page . getByText ( 'Resizable image with caption' ) . click ( ) ;
39- await page . getByText ( 'Upload image' ) . click ( ) ;
37+ await page . locator ( '.bn-block-outer' ) . last ( ) . fill ( 'Anything' ) ;
38+ await page . locator ( '.bn-block-outer' ) . last ( ) . fill ( '/' ) ;
39+ await page . getByText ( 'Resizable image with caption' ) . click ( ) ;
40+ await page . getByText ( 'Upload image' ) . click ( ) ;
4041
41- const fileChooser = await fileChooserPromise ;
42- await fileChooser . setFiles (
43- path . join ( __dirname , 'assets/logo-suite-numerique.png' ) ,
44- ) ;
42+ const fileChooser = await fileChooserPromise ;
43+ await fileChooser . setFiles (
44+ path . join ( __dirname , 'assets/logo-suite-numerique.png' ) ,
45+ ) ;
4546
46- const image = page
47- . locator ( '.--docs--editor-container img.bn-visual-media' )
48- . first ( ) ;
47+ const image = page
48+ . locator ( '.--docs--editor-container img.bn-visual-media' )
49+ . first ( ) ;
4950
50- await expect ( image ) . toBeVisible ( ) ;
51-
52- // Wait for the media-check to be processed
53-
54- await page . waitForTimeout ( 1000 ) ;
55-
56- // Check src of image
57- 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 / ,
59- ) ;
60- } ) ;
51+ await expect ( image ) . toBeVisible ( ) ;
6152
62- test ( 'it checks that collaboration server is configured from config endpoint' , async ( {
63- page,
64- } ) => {
65- await page . goto ( '/' ) ;
53+ // Wait for the media-check to be processed
6654
67- void page
68- . getByRole ( 'button' , {
69- name : 'New doc' ,
70- } )
71- . click ( ) ;
55+ await page . waitForTimeout ( 1000 ) ;
7256
73- const webSocket = await page . waitForEvent ( 'websocket' , ( webSocket ) => {
74- return webSocket . url ( ) . includes ( 'ws://localhost:4444/collaboration/ws/' ) ;
57+ // Check src of image
58+ expect ( await image . getAttribute ( 'src' ) ) . toMatch (
59+ / 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 / ,
60+ ) ;
7561 } ) ;
76- expect ( webSocket . url ( ) ) . toContain ( 'ws://localhost:4444/collaboration/ws/' ) ;
77- } ) ;
7862
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' ,
63+ test ( 'it checks that collaboration server is configured from config endpoint' , async ( {
64+ page,
65+ } ) => {
66+ await page . goto ( '/' ) ;
67+
68+ void page
69+ . getByRole ( 'button' , {
70+ name : 'New doc' ,
71+ } )
72+ . click ( ) ;
73+
74+ const webSocket = await page . waitForEvent ( 'websocket' , ( webSocket ) => {
75+ return webSocket
76+ . url ( )
77+ . includes ( 'ws://localhost:4444/collaboration/ws/' ) ;
78+ } ) ;
79+ expect ( webSocket . url ( ) ) . toContain (
80+ 'ws://localhost:4444/collaboration/ws/' ,
81+ ) ;
8482 } ) ;
8583
86- await page . goto ( '/' ) ;
84+ test ( 'it checks that Crisp is trying to init from config endpoint' , async ( {
85+ page,
86+ } ) => {
87+ await overrideConfig ( page , {
88+ CRISP_WEBSITE_ID : '1234' ,
89+ } ) ;
8790
88- await expect (
89- page . locator ( '#crisp-chatbox' ) . getByText ( 'Invalid website' ) ,
90- ) . toBeVisible ( ) ;
91- } ) ;
91+ await page . goto ( '/' ) ;
9292
93- test ( 'it checks FRONTEND_CSS_URL config' , async ( { page } ) => {
94- await overrideConfig ( page , {
95- FRONTEND_CSS_URL : 'http://localhost:123465/css/style.css' ,
93+ await expect (
94+ page . locator ( '#crisp-chatbox' ) . getByText ( 'Invalid website' ) ,
95+ ) . toBeVisible ( ) ;
9696 } ) ;
9797
98- await page . goto ( '/' ) ;
98+ test ( 'it checks FRONTEND_CSS_URL config' , async ( { page } ) => {
99+ await overrideConfig ( page , {
100+ FRONTEND_CSS_URL : 'http://localhost:123465/css/style.css' ,
101+ } ) ;
99102
100- await expect (
101- page
102- . locator ( 'head link[href="http://localhost:123465/css/style.css"]' )
103- . first ( ) ,
104- ) . toBeAttached ( ) ;
105- } ) ;
103+ await page . goto ( '/' ) ;
106104
107- test ( 'it checks FRONTEND_JS_URL config' , async ( { page } ) => {
108- await overrideConfig ( page , {
109- FRONTEND_JS_URL : 'http://localhost:123465/js/script.js' ,
105+ await expect (
106+ page
107+ . locator ( 'head link[href="http://localhost:123465/css/style.css"]' )
108+ . first ( ) ,
109+ ) . toBeAttached ( ) ;
110110 } ) ;
111111
112- await page . goto ( '/' ) ;
112+ test ( 'it checks FRONTEND_JS_URL config' , async ( { page } ) => {
113+ await overrideConfig ( page , {
114+ FRONTEND_JS_URL : 'http://localhost:123465/js/script.js' ,
115+ } ) ;
113116
114- await expect (
115- page
116- . locator ( 'script[src="http://localhost:123465/js/script.js"]' )
117- . first ( ) ,
118- ) . toBeAttached ( ) ;
119- } ) ;
117+ await page . goto ( '/' ) ;
120118
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- ) ;
119+ await expect (
120+ page
121+ . locator ( 'script[src="http://localhost:123465/js/script.js"]' )
122+ . first ( ) ,
123+ ) . toBeAttached ( ) ;
124+ } ) ;
126125
127- await page . goto ( '/' ) ;
126+ test ( 'it checks the config api is called' , async ( { page } ) => {
127+ const responsePromise = page . waitForResponse (
128+ ( response ) =>
129+ response . url ( ) . includes ( '/config/' ) && response . status ( ) === 200 ,
130+ ) ;
128131
129- const response = await responsePromise ;
130- expect ( response . ok ( ) ) . toBeTruthy ( ) ;
132+ await page . goto ( '/' ) ;
131133
132- const json = ( await response . json ( ) ) as typeof CONFIG ;
133- expect ( json ) . toStrictEqual ( CONFIG ) ;
134+ const response = await responsePromise ;
135+ expect ( response . ok ( ) ) . toBeTruthy ( ) ;
136+
137+ const json = ( await response . json ( ) ) as typeof CONFIG ;
138+ expect ( json ) . toStrictEqual ( CONFIG ) ;
139+ } ) ;
134140 } ) ;
135- } ) ;
136141
137- test . describe ( 'Config: Not logged' , ( ) => {
138- test . use ( { storageState : { cookies : [ ] , origins : [ ] } } ) ;
142+ test . describe ( 'Config: Not logged' , ( ) => {
143+ test . use ( { storageState : { cookies : [ ] , origins : [ ] } } ) ;
139144
140- test ( 'it checks that theme is configured from config endpoint' , async ( {
141- page,
142- } ) => {
143- await page . goto ( '/' ) ;
145+ test ( 'it checks that theme is configured from config endpoint' , async ( {
146+ page,
147+ } ) => {
148+ await page . goto ( '/' ) ;
144149
145- await expect (
146- page . getByText ( 'Collaborative writing, Simplified.' ) ,
147- ) . toHaveCSS ( 'font-family' , / R o b o t o / i, {
148- timeout : 10000 ,
149- } ) ;
150+ await expect (
151+ page . getByText ( 'Collaborative writing, Simplified.' ) ,
152+ ) . toHaveCSS ( 'font-family' , / R o b o t o / i, {
153+ timeout : 10000 ,
154+ } ) ;
150155
151- await overrideConfig ( page , {
152- FRONTEND_THEME : 'dsfr' ,
153- } ) ;
156+ await overrideConfig ( page , {
157+ FRONTEND_THEME : 'dsfr' ,
158+ } ) ;
154159
155- await page . goto ( '/' ) ;
160+ await page . goto ( '/' ) ;
156161
157- await expect (
158- page . getByText ( 'Collaborative writing, Simplified.' ) ,
159- ) . toHaveCSS ( 'font-family' , / M a r i a n n e / i, {
160- timeout : 10000 ,
162+ await expect (
163+ page . getByText ( 'Collaborative writing, Simplified.' ) ,
164+ ) . toHaveCSS ( 'font-family' , / M a r i a n n e / i, {
165+ timeout : 10000 ,
166+ } ) ;
161167 } ) ;
162168 } ) ;
163- } ) ;
169+ }
0 commit comments