@@ -24,7 +24,6 @@ import { randUser } from '../utils/index.js'
2424const user = randUser ( )
2525
2626describe ( 'Workspace' , function ( ) {
27- let currentFolder
2827
2928 before ( function ( ) {
3029 cy . createUser ( user , 'password' )
@@ -36,17 +35,13 @@ describe('Workspace', function() {
3635 // Make sure it's the default otherwise.
3736 cy . modifyUser ( user , 'language' , 'en' )
3837 // isolate tests - each happens in its own folder
39- const retry = cy . state ( 'test' ) . currentRetry ( )
40- currentFolder = retry
41- ? `${ Cypress . currentTest . title } (${ retry } )`
42- : Cypress . currentTest . title
43- cy . createFolder ( currentFolder )
38+ cy . createTestFolder ( ) . as ( 'testFolder' )
4439 } )
4540
4641 it ( 'Hides the workspace when switching to another folder' , function ( ) {
47- cy . uploadFile ( 'test.md' , 'text/markdown' , `${ currentFolder } /README.md` )
48- cy . createFolder ( `${ currentFolder } /subdirectory` )
49- cy . visit ( `apps/files?dir=/ ${ encodeURIComponent ( currentFolder ) } ` )
42+ cy . uploadFile ( 'test.md' , 'text/markdown' , `${ this . testFolder } /README.md` )
43+ cy . createFolder ( `${ this . testFolder } /subdirectory` )
44+ cy . visitTestFolder ( )
5045 cy . getFile ( 'README.md' )
5146 cy . get ( '#rich-workspace .ProseMirror' )
5247 . should ( 'contain' , 'Hello world' )
@@ -56,8 +51,8 @@ describe('Workspace', function() {
5651 } )
5752
5853 it ( 'Hides the workspace when switching to another view' , function ( ) {
59- cy . uploadFile ( 'test.md' , 'text/markdown' , `${ currentFolder } /README.md` )
60- cy . visit ( `apps/files?dir=/ ${ encodeURIComponent ( currentFolder ) } ` )
54+ cy . uploadFile ( 'test.md' , 'text/markdown' , `${ this . testFolder } /README.md` )
55+ cy . visitTestFolder ( )
6156 cy . getFile ( 'README.md' )
6257 cy . get ( '#rich-workspace .ProseMirror' )
6358 . should ( 'contain' , 'Hello world' )
@@ -68,15 +63,15 @@ describe('Workspace', function() {
6863 } )
6964
7065 it ( 'adds a Readme.md' , function ( ) {
71- cy . createDescription ( currentFolder )
66+ cy . createDescription ( this . testFolder )
7267 openSidebar ( 'Readme.md' )
7368 cy . get ( '#rich-workspace .text-editor .text-editor__wrapper' )
7469 . should ( 'be.visible' )
7570 } )
7671
7772 it ( 'formats text' , function ( ) {
78- cy . visit ( `apps/files?dir=/ ${ encodeURIComponent ( currentFolder ) } ` )
79- cy . openWorkspace ( currentFolder )
73+ cy . visitTestFolder ( )
74+ cy . openWorkspace ( )
8075 const buttons = [
8176 [ 'bold' , 'strong' ] ,
8277 [ 'italic' , 'em' ] ,
@@ -90,8 +85,8 @@ describe('Workspace', function() {
9085 } )
9186
9287 it ( 'creates headings via submenu' , function ( ) {
93- cy . visit ( `apps/files?dir=/ ${ encodeURIComponent ( currentFolder ) } ` )
94- cy . openWorkspace ( currentFolder ) . type ( 'Heading' )
88+ cy . visitTestFolder ( )
89+ cy . openWorkspace ( ) . type ( 'Heading' )
9590 cy . getContent ( ) . type ( '{selectall}' )
9691 ; [ 'h1' , 'h2' , 'h3' , 'h4' , 'h5' , 'h6' ] . forEach ( ( heading ) => {
9792 const actionName = `headings-${ heading } `
@@ -111,8 +106,8 @@ describe('Workspace', function() {
111106 } )
112107
113108 it ( 'creates lists' , function ( ) {
114- cy . visit ( `apps/files?dir=/ ${ encodeURIComponent ( currentFolder ) } ` )
115- cy . openWorkspace ( currentFolder ) . type ( 'List me' )
109+ cy . visitTestFolder ( )
110+ cy . openWorkspace ( ) . type ( 'List me' )
116111 cy . getContent ( ) . type ( '{selectall}' )
117112 ; [
118113 [ 'unordered-list' , 'ul' ] ,
@@ -122,16 +117,16 @@ describe('Workspace', function() {
122117 } )
123118
124119 it ( 'takes README.md into account' , function ( ) {
125- cy . uploadFile ( 'test.md' , 'text/markdown' , `${ Cypress . currentTest . title } /README.md` )
126- cy . visit ( `apps/files?dir=/ ${ encodeURIComponent ( currentFolder ) } ` )
120+ cy . uploadFile ( 'test.md' , 'text/markdown' , `${ this . testFolder } /README.md` )
121+ cy . visitTestFolder ( )
127122 cy . getFile ( 'README.md' )
128123 cy . get ( '#rich-workspace .ProseMirror' )
129124 . should ( 'contain' , 'Hello world' )
130125 } )
131126
132127 it ( 'emoji picker' , ( ) => {
133- cy . visit ( `apps/files?dir=/ ${ encodeURIComponent ( currentFolder ) } ` )
134- cy . openWorkspace ( currentFolder )
128+ cy . visitTestFolder ( )
129+ cy . openWorkspace ( )
135130 . type ( '# Let\'s smile together{enter}## ' )
136131
137132 cy . getMenuEntry ( 'emoji-picker' )
@@ -147,13 +142,13 @@ describe('Workspace', function() {
147142 } )
148143
149144 it ( 'relative folder links' , ( ) => {
150- cy . createFolder ( `${ currentFolder } /sub-folder` )
151- cy . createFolder ( `${ currentFolder } /sub-folder/alpha` )
145+ cy . createFolder ( `${ this . testFolder } /sub-folder` )
146+ cy . createFolder ( `${ this . testFolder } /sub-folder/alpha` )
152147
153- cy . uploadFile ( 'test.md' , 'text/markdown' , `${ currentFolder } /sub-folder/alpha/test.md` )
154- cy . visit ( `apps/files?dir=/ ${ encodeURIComponent ( currentFolder ) } ` )
148+ cy . uploadFile ( 'test.md' , 'text/markdown' , `${ this . testFolder } /sub-folder/alpha/test.md` )
149+ cy . visitTestFolder ( )
155150
156- cy . openWorkspace ( currentFolder )
151+ cy . openWorkspace ( )
157152 . type ( 'link me' )
158153 cy . getContent ( )
159154 . type ( '{selectall}' )
@@ -169,7 +164,7 @@ describe('Workspace', function() {
169164 cy . getEditor ( )
170165 . find ( 'a' )
171166 . should ( 'have.attr' , 'href' )
172- . and ( 'contains' , `dir=/${ currentFolder } /sub-folder/alpha` )
167+ . and ( 'contains' , `dir=/${ this . testFolder } /sub-folder/alpha` )
173168 . and ( 'contains' , '#relPath=sub-folder/alpha/test.md' )
174169
175170 cy . getEditor ( )
@@ -190,8 +185,8 @@ describe('Workspace', function() {
190185 const types = [ 'info' , 'warn' , 'error' , 'success' ]
191186
192187 beforeEach ( function ( ) {
193- cy . visit ( `apps/files?dir=/ ${ encodeURIComponent ( currentFolder ) } ` )
194- cy . openWorkspace ( currentFolder ) . type ( 'Callout' )
188+ cy . visitTestFolder ( )
189+ cy . openWorkspace ( ) . type ( 'Callout' )
195190 } )
196191 // eslint-disable-next-line cypress/no-async-tests
197192 it ( 'create callout' , ( ) => {
@@ -239,17 +234,17 @@ describe('Workspace', function() {
239234 describe ( 'localize' , ( ) => {
240235 it ( 'takes localized file name into account' , function ( ) {
241236 cy . modifyUser ( user , 'language' , 'de_DE' )
242- cy . uploadFile ( 'test.md' , 'text/markdown' , `${ Cypress . currentTest . title } /Anleitung.md` )
243- cy . visit ( `apps/files?dir=/ ${ encodeURIComponent ( currentFolder ) } ` )
237+ cy . uploadFile ( 'test.md' , 'text/markdown' , `${ this . testFolder } /Anleitung.md` )
238+ cy . visitTestFolder ( )
244239 cy . getFile ( 'Anleitung.md' )
245240 cy . get ( '#rich-workspace .ProseMirror' )
246241 . should ( 'contain' , 'Hello world' )
247242 } )
248243
249244 it ( 'ignores localized file name in other language' , function ( ) {
250245 cy . modifyUser ( user , 'language' , 'fr' )
251- cy . uploadFile ( 'test.md' , 'text/markdown' , `${ Cypress . currentTest . title } /Anleitung.md` )
252- cy . visit ( `apps/files?dir=/ ${ encodeURIComponent ( currentFolder ) } ` )
246+ cy . uploadFile ( 'test.md' , 'text/markdown' , `${ this . testFolder } /Anleitung.md` )
247+ cy . visitTestFolder ( )
253248 cy . getFile ( 'Anleitung.md' )
254249 } )
255250 } )
@@ -265,21 +260,21 @@ describe('Workspace', function() {
265260 }
266261
267262 beforeEach ( ( ) => {
268- cy . visit ( `apps/files?dir=/ ${ encodeURIComponent ( currentFolder ) } ` )
263+ cy . visitTestFolder ( )
269264 } )
270265
271266 it ( 'click' , ( ) => {
272- cy . openWorkspace ( currentFolder ) . click ( )
267+ cy . openWorkspace ( ) . click ( )
273268 checkContent ( )
274269 } )
275270
276271 it ( 'enter' , ( ) => {
277- cy . openWorkspace ( currentFolder ) . type ( '{enter}' )
272+ cy . openWorkspace ( ) . type ( '{enter}' )
278273 checkContent ( )
279274 } )
280275
281276 it ( 'spacebar' , ( ) => {
282- cy . openWorkspace ( currentFolder )
277+ cy . openWorkspace ( )
283278 . trigger ( 'keyup' , {
284279 keyCode : 32 ,
285280 which : 32 ,
0 commit comments