@@ -6,70 +6,68 @@ const fs = require('fs');
66require ( 'dotenv' ) . config ( ) ;
77const os = require ( 'os' ) ;
88
9- let pageOne ;
9+ let page1 ;
1010let mobile ;
1111let browserstackMobile ;
1212let platform ;
1313const local = ! ! process . env . PW_URL . includes ( 'localhost' ) ;
1414let fileActions ;
15+ let fileActions1
1516
1617test . beforeEach ( async ( { page, isMobile } , testInfo ) => {
17- test . setTimeout ( 210000 ) ;
18+ test . setTimeout ( 90000 ) ;
1819 mobile = isMobile ;
1920 browserstackMobile = testInfo . project . name . match ( / b r o w s e r s t a c k - m o b i l e / ) ;
2021 platform = os . platform ( ) ;
21-
22- await page . goto ( `${ url } /code` ) ;
2322 fileActions = new FileActions ( page ) ;
24-
25- await fileActions . codeeditor . waitFor ( ) ;
23+ await fileActions . loadFileType ( "code" )
2624} ) ;
2725
2826test ( 'anon - code - input text #1367' , async ( { page } ) => {
2927 test . fixme ( mobile , 'mobile editor preview bug' ) ;
3028 try {
31- await fileActions . codeeditor . click ( ) ;
29+ await fileActions . codeEditor . click ( ) ;
3230 await fileActions . typeTestTextCode ( mobile , 'test text' ) ;
33- await expect ( fileActions . codeeditor . getByText ( 'test text' ) ) . toBeVisible ( ) ;
31+ await expect ( fileActions . codeEditor . getByText ( 'test text' ) ) . toBeVisible ( ) ;
3432 await expect ( fileActions . codepreview . getByText ( 'test text' ) ) . toBeVisible ( ) ;
3533
36- await page . evaluate ( _ => { } , `browserstack_executor: ${ JSON . stringify ( { action : 'setSessionStatus' , arguments : { name : ' code - input text' , status : 'passed' , reason : ' Can create Code document and input text' } } ) } ` ) ;
34+ await fileActions . toSuccess ( ' Can create Code document and input text') ;
3735 } catch ( e ) {
3836 console . log ( e ) ;
39- await page . evaluate ( _ => { } , `browserstack_executor: ${ JSON . stringify ( { action : 'setSessionStatus' , arguments : { name : 'code - input text' , status : 'failed' , reason : ' Can\'t acreate Code document and input text' } } ) } ` ) ;
37+ await fileActions . toFailure ( e , ' Can\'t acreate Code document and input text') ;
4038 }
4139} ) ;
4240
4341test ( 'code - file menu - history #1367' , async ( { page } ) => {
4442 test . fixme ( mobile , 'mobile editor preview bug' ) ;
4543 try {
46- await fileActions . codeeditor . click ( ) ;
44+ await fileActions . codeEditor . click ( ) ;
4745 await fileActions . typeTestTextCode ( mobile , 'test text' ) ;
48- await expect ( fileActions . codeeditor . getByText ( 'test text' ) ) . toBeVisible ( ) ;
46+ await expect ( fileActions . codeEditor . getByText ( 'test text' ) ) . toBeVisible ( ) ;
4947 await expect ( fileActions . codepreview . getByText ( 'test text' ) ) . toBeVisible ( ) ;
5048 await fileActions . history ( mobile ) ;
51- await page . frameLocator ( '#sbox-iframe' ) . locator ( '.cp-toolbar-history-previous' ) . first ( ) . click ( ) ;
52- await expect ( fileActions . codeeditor . getByText ( 'test text' ) ) . toHaveCount ( 0 ) ;
49+ await fileActions . historyPrevFirst . click ( ) ;
50+ await expect ( fileActions . codeEditor . getByText ( 'test text' ) ) . toHaveCount ( 0 ) ;
5351 await expect ( fileActions . codepreview . getByText ( 'test text' ) ) . toBeHidden ( ) ;
5452
55- await page . evaluate ( _ => { } , `browserstack_executor: ${ JSON . stringify ( { action : 'setSessionStatus' , arguments : { name : 'code - file menu - history' , status : 'passed' , reason : ' Can view Code document history' } } ) } ` ) ;
53+ await fileActions . toSuccess ( ' Can view Code document history') ;
5654 } catch ( e ) {
5755 console . log ( e ) ;
58- await page . evaluate ( _ => { } , `browserstack_executor: ${ JSON . stringify ( { action : 'setSessionStatus' , arguments : { name : 'code - file menu - history' , status : 'failed' , reason : ' Can\'t view Code document history' } } ) } ` ) ;
56+ await fileActions . toFailure ( e , ' Can\'t view Code document history') ;
5957 }
6058} ) ;
6159
6260test ( 'code - toggle toolbar #1367' , async ( { page } ) => {
6361 test . fixme ( mobile , 'mobile editor preview bug' ) ;
6462 try {
65- await expect ( page . frameLocator ( '#sbox-iframe' ) . locator ( '.cp-markdown-toolbar' ) ) . toBeHidden ( ) ;
66- await fileActions . toolbar . click ( ) ;
67- await expect ( page . frameLocator ( '#sbox-iframe' ) . locator ( '.cp-markdown-toolbar' ) ) . toBeVisible ( ) ;
63+ await expect ( fileActions . codeToolbar ) . toBeHidden ( ) ;
64+ await fileActions . toolbarButton . click ( ) ;
65+ await expect ( fileActions . codeToolbar ) . toBeVisible ( ) ;
6866
69- await page . evaluate ( _ => { } , `browserstack_executor: ${ JSON . stringify ( { action : 'setSessionStatus' , arguments : { name : 'code - toggle toolbar' , status : 'passed' , reason : ' Can toggle toolbar in Code document' } } ) } ` ) ;
67+ await fileActions . toSuccess ( ' Can toggle toolbar in Code document') ;
7068 } catch ( e ) {
7169 console . log ( e ) ;
72- await page . evaluate ( _ => { } , `browserstack_executor: ${ JSON . stringify ( { action : 'setSessionStatus' , arguments : { name : 'code - toggle toolbar' , status : 'failed' , reason : ' Can\'t toggle toolbar in Code document' } } ) } ` ) ;
70+ await fileActions . toFailure ( e , ' Can\'t toggle toolbar in Code document') ;
7371 }
7472} ) ;
7573
@@ -83,36 +81,37 @@ test('code - toggle preview #1367', async ({ page }) => {
8381
8482 await expect ( fileActions . codepreview . getByText ( 'test text' ) ) . toBeHidden ( ) ;
8583
86- await page . evaluate ( _ => { } , `browserstack_executor: ${ JSON . stringify ( { action : 'setSessionStatus' , arguments : { name : 'anon - code - toggle preview' , status : 'passed' , reason : ' Can toggle preview in Code document' } } ) } ` ) ;
84+ await fileActions . toSuccess ( ' Can toggle preview in Code document' ) ;
8785 } catch ( e ) {
8886 console . log ( e ) ;
89- await page . evaluate ( _ => { } , `browserstack_executor: ${ JSON . stringify ( { action : 'setSessionStatus' , arguments : { name : 'anon - code - toggle preview' , status : 'failed' , reason : ' Can\'t toggle preview in Code document' } } ) } ` ) ;
87+ await fileActions . toFailure ( e , ' Can\'t toggle preview in Code document') ;
9088 }
9189} ) ;
9290
9391test ( 'code - make a copy #1367' , async ( { page } ) => {
9492 test . fixme ( mobile , 'mobile editor preview bug' ) ;
9593 try {
96- await fileActions . codeeditor . click ( ) ;
94+ await fileActions . codeEditor . click ( ) ;
9795 await fileActions . typeTestTextCode ( mobile , 'test text' ) ;
9896
9997 await expect ( fileActions . codepreview . getByText ( 'test text' ) ) . toBeVisible ( ) ;
10098 await fileActions . filemenuClick ( mobile ) ;
10199 const [ page1 ] = await Promise . all ( [
102100 page . waitForEvent ( 'popup' ) ,
103- await fileActions . filecopy . click ( )
101+ await fileActions . fileMenuItem ( ' Make a copy' ) . click ( )
104102 ] ) ;
105103
106104 await expect ( page1 ) . toHaveURL ( new RegExp ( `^${ url } /code` ) , { timeout : 100000 } ) ;
105+ fileActions1 = new FileActions ( page1 ) ;
107106
108107 await page1 . waitForTimeout ( 4000 ) ;
109- await page1 . frameLocator ( '#sbox-iframe' ) . locator ( '#cp-app-code-preview-content' ) . getByText ( 'Test text' ) . waitFor ( ) ;
110- await expect ( page1 . frameLocator ( '#sbox-iframe' ) . locator ( '#cp-app-code-preview-content' ) . getByText ( 'test text' ) ) . toBeVisible ( ) ;
108+ await fileActions1 . codepreview . getByText ( 'Test text' ) . waitFor ( ) ;
109+ await expect ( fileActions1 . codepreview . getByText ( 'test text' ) ) . toBeVisible ( ) ;
111110
112- await page . evaluate ( _ => { } , `browserstack_executor: ${ JSON . stringify ( { action : 'setSessionStatus' , arguments : { name : 'code - make a copy' , status : 'passed' , reason : 'Can make a copy' } } ) } ` ) ;
111+ await fileActions . toSuccess ( 'Can make a copy of Code document' ) ;
113112 } catch ( e ) {
114113 console . log ( e ) ;
115- await page . evaluate ( _ => { } , `browserstack_executor: ${ JSON . stringify ( { action : 'setSessionStatus' , arguments : { name : 'code - make a copy' , status : 'failed' , reason : ' Can\'t make a copy' } } ) } ` ) ;
114+ await fileActions . toFailure ( e , ' Can\'t make a copy of Code document' ) ;
116115 }
117116} ) ;
118117
@@ -121,51 +120,45 @@ test('code - import file #1367', async ({ page, context }) => {
121120 test . skip ( browserstackMobile , 'browserstack mobile import incompatibility' ) ;
122121
123122 try {
124- await fileActions . codeeditor . waitFor ( ) ;
125- // // await page.waitForTimeout(10000);
123+ await fileActions . codeEditor . waitFor ( ) ;
126124 await fileActions . filemenuClick ( mobile ) ;
127125 const [ fileChooser ] = await Promise . all ( [
128126 page . waitForEvent ( 'filechooser' ) ,
129127 await fileActions . importClick ( )
130128 ] ) ;
131129
132- await fileChooser . setFiles ( 'e2e-test-suite/testdocuments/myfile.html' ) ;
133-
134- // // await page.waitForTimeout(3000);
135-
136- await expect ( fileActions . codeeditor . getByText ( 'Test text here' ) ) . toBeVisible ( ) ;
130+ await fileChooser . setFiles ( 'testdocuments/myfile.html' ) ;
131+ await expect ( fileActions . codeEditor . getByText ( 'Test text here' ) ) . toBeVisible ( ) ;
137132 await expect ( fileActions . codepreview . getByText ( 'Test text here' ) ) . toBeVisible ( ) ;
138133
139- await page . evaluate ( _ => { } , `browserstack_executor: ${ JSON . stringify ( { action : 'setSessionStatus' , arguments : { name : 'code - import file' , status : 'passed' , reason : ' Can import file into Code document' } } ) } ` ) ;
134+ await fileActions . toSuccess ( ' Can import file into Code document') ;
140135 } catch ( e ) {
141136 console . log ( e ) ;
142- await page . evaluate ( _ => { } , `browserstack_executor: ${ JSON . stringify ( { action : 'setSessionStatus' , arguments : { name : 'code - import file' , status : 'failed' , reason : ' Can\'t import file into Code document' } } ) } ` ) ;
137+ await fileActions . toFailure ( e , ' Can\'t import file into Code document') ;
143138 }
144139} ) ;
145140
146141test ( 'code - export (md)' , async ( { page } ) => {
147142 test . skip ( browserstackMobile , 'browserstack mobile download incompatibility' ) ;
148143
149144 try {
150- await fileActions . codeeditor . click ( ) ;
145+ await fileActions . codeEditor . click ( ) ;
151146 await fileActions . typeTestTextCode ( mobile , 'test text' ) ;
152- await expect ( fileActions . codeeditor . getByText ( 'test text' ) ) . toBeVisible ( ) ;
147+ await expect ( fileActions . codeEditor . getByText ( 'test text' ) ) . toBeVisible ( ) ;
153148 await fileActions . export ( mobile ) ;
154- await page . frameLocator ( '#sbox-iframe' ) . getByRole ( ' textbox' ) . fill ( 'test code' ) ;
149+ await fileActions . textbox . fill ( 'test code' ) ;
155150
156151 const [ download ] = await Promise . all ( [
157152 page . waitForEvent ( 'download' ) ,
158153 await fileActions . okButton . click ( )
159154 ] ) ;
160155
161156 await download . saveAs ( '/tmp/test code' ) ;
162-
163157 const readData = fs . readFileSync ( '/tmp/test code' , 'utf8' ) ;
164- console . log ( readData ) ;
165158 if ( readData . trim ( ) === 'test text' ) {
166- await page . evaluate ( _ => { } , `browserstack_executor: ${ JSON . stringify ( { action : 'setSessionStatus' , arguments : { name : 'code - export (md)' , status : 'passed' , reason : ' Can export Code document as .md' } } ) } ` ) ;
159+ await fileActions . toSuccess ( ' Can export Code document as .md') ;
167160 } else {
168- await page . evaluate ( _ => { } , `browserstack_executor: ${ JSON . stringify ( { action : 'setSessionStatus' , arguments : { name : 'code - export (md)' , status : 'failed' , reason : ' Can\'t export Code document as .md' } } ) } ` ) ;
161+ await fileActions . toFailure ( e , ' Can\'t export Code document as .md') ;
169162 }
170163 } catch ( e ) {
171164 console . log ( e ) ;
@@ -175,7 +168,7 @@ test('code - export (md)', async ({ page }) => {
175168
176169test ( 'code - share at a moment in history' , async ( { page, browser } ) => {
177170 try {
178- await fileActions . codeeditor . click ( ) ;
171+ await fileActions . codeEditor . click ( ) ;
179172 await page . keyboard . press ( 't' ) ;
180173 await page . keyboard . press ( 'e' ) ;
181174 await page . keyboard . press ( 's' ) ;
@@ -185,8 +178,7 @@ test('code - share at a moment in history', async ({ page, browser }) => {
185178 await page . keyboard . press ( 'e' ) ;
186179 await page . keyboard . press ( 'x' ) ;
187180 await page . keyboard . press ( 't' ) ;
188- // await page.waitForTimeout(7000);
189- await expect ( fileActions . codeeditor . getByText ( 'test text' ) ) . toBeVisible ( ) ;
181+ await expect ( fileActions . codeEditor . getByText ( 'test text' ) ) . toBeVisible ( ) ;
190182
191183
192184 let key ;
@@ -197,26 +189,19 @@ test('code - share at a moment in history', async ({ page, browser }) => {
197189 }
198190 await page . keyboard . press ( `${ key } +a` ) ;
199191 await page . keyboard . press ( 'Backspace' ) ;
200- await expect ( fileActions . codeeditor . getByText ( 'test text' ) ) . toHaveCount ( 0 ) ;
201-
202-
203- await fileActions . share ( mobile ) ;
204- // await fileActions.shareLink.click();
205- // await page.waitForTimeout(5000);
206- await fileActions . shareCopyLink . click ( ) ;
207- // await page.waitForTimeout(5000);
192+ await expect ( fileActions . codeEditor . getByText ( 'test text' ) ) . toHaveCount ( 0 ) ;
208193
209- const clipboardText = await page . evaluate ( ( ) => navigator . clipboard . readText ( ) ) ;
210- pageOne = await browser . newPage ( ) ;
194+ var clipboardText = await fileActions . getShareLink ( )
195+ page1 = await browser . newPage ( ) ;
211196
212- await pageOne . goto ( `${ clipboardText } ` ) ;
197+ await page1 . goto ( `${ clipboardText } ` ) ;
213198
214- await pageOne . frameLocator ( '#sbox-iframe' ) . locator ( '.CodeMirror-scroll' ) . waitFor ( ) ;
215- await expect ( fileActions . codeeditor . getByText ( 'test text' ) ) . toHaveCount ( 0 ) ;
199+ await page1 . frameLocator ( '#sbox-iframe' ) . locator ( '.CodeMirror-scroll' ) . waitFor ( ) ;
200+ await expect ( fileActions . codeEditor . getByText ( 'test text' ) ) . toHaveCount ( 0 ) ;
216201
217- await page . evaluate ( _ => { } , `browserstack_executor: ${ JSON . stringify ( { action : 'setSessionStatus' , arguments : { name : 'code - share at a moment in history' , status : 'passed' , reason : ' Can share code document at a specific moment in history' } } ) } ` ) ;
202+ await fileActions . toSuccess ( ' Can share code document at a specific moment in history')
218203 } catch ( e ) {
219204 console . log ( e ) ;
220- await page . evaluate ( _ => { } , `browserstack_executor: ${ JSON . stringify ( { action : 'setSessionStatus' , arguments : { name : 'code - share at a moment in history' , status : 'failed' , reason : ' Can\'t share code document at a specific moment in history' } } ) } ` ) ;
205+ await fileActions . toFailure ( e , ' Can\'t share code document at a specific moment in history' )
221206 }
222207} ) ;
0 commit comments