@@ -32,13 +32,10 @@ describe('Open test.md in viewer', function() {
3232
3333 // Upload test files
3434 cy . uploadFile ( 'test.md' , 'text/markdown' )
35- cy . visit ( '/apps/files' )
36-
37- // wait a bit for things to be settled
38- cy . wait ( 1000 )
3935 } )
40- after ( function ( ) {
41- cy . logout ( )
36+
37+ beforeEach ( function ( ) {
38+ cy . login ( randUser , 'password' )
4239 } )
4340
4441 it ( 'See test.md in the list' , function ( ) {
@@ -47,41 +44,33 @@ describe('Open test.md in viewer', function() {
4744 } )
4845
4946 it ( 'Open the viewer on file click' , function ( ) {
50- cy . visit ( '/apps/files' )
5147 cy . openFile ( 'test.md' )
52- cy . get ( '#viewer' ) . should ( 'be.visible' )
53- cy . get ( '#viewer .modal-title' ) . should ( 'contain' , 'test.md' )
54- cy . get ( '#viewer .modal-header button.action-item__menutoggle' ) . should ( 'be.visible' )
55- cy . get ( '#viewer .modal-header button.header-close' ) . should ( 'be.visible' )
5648
57- cy . wait ( 2000 )
58- cy . get ( '#viewer' , { timeout : 4000 } )
59- . should ( 'be.visible' )
49+ cy . log ( 'Inspect viewer' )
50+ const viewer = cy . get ( '#viewer' )
51+ viewer . should ( 'be.visible' )
6052 . and ( 'have.class' , 'modal-mask' )
6153 . and ( 'not.have.class' , 'icon-loading' )
62- } )
54+ viewer . get ( '.modal-title' ) . should ( 'contain' , 'test.md' )
55+ viewer . get ( '.modal-header button.action-item__menutoggle' )
56+ . should ( 'be.visible' )
6357
64- it ( 'Has opened the file' , function ( ) {
65- cy . get ( '#viewer # editor .ProseMirror' ) . should ( 'contain' , 'Hello world ')
66- cy . get ( '#viewer # editor .ProseMirror h2' ) . should ( 'contain' , 'Hello world' )
67- } )
58+ cy . log ( 'Inspect editor' )
59+ const editor = viewer . get ( '#editor .ProseMirror' )
60+ editor . should ( 'contain' , 'Hello world' )
61+ editor . get ( 'h2' ) . should ( 'contain' , 'Hello world' )
6862
69- it ( 'Shows the menu bar icons' , function ( ) {
70- // FIXME those checks are failing since the parent container is currently at 0x0 size
71- // due to the way we make the text app be a full screen viewer
72- // cy .get('#viewer-content #editor .menubar .menubar-icons . icon-undo ').should('be.visible')
73- // cy.get('#viewer-content #editor .menubar .menubar-icons .icon-redo').should('be.visible')
74- // cy.get('#viewer-content #editor .menubar .menubar-icons .icon-bold').should('be.visible' )
63+ cy . log ( 'Inspect menubar' )
64+ const menubar = editor . get ( '.menubar .menubar-icons' )
65+ menubar . get ( '.icon-undo' ) . should ( 'be.visible' )
66+ menubar . get ( '. icon-bold ' ) . should ( 'be.visible' )
67+
68+ cy . screenshot ( )
7569 } )
7670
7771 it ( 'Closes the editor' , function ( ) {
78- cy . get ( '.modal-header button.header-close' ) . click ( )
72+ cy . openFile ( 'test.md' )
73+ cy . get ( '#viewer .modal-header button.header-close' ) . click ( )
7974 cy . get ( '#viewer' ) . should ( 'not.exist' )
8075 } )
81-
82- it ( 'Take screenshot' , function ( ) {
83- // gif is impossible to match with existing screenshot
84- // just taking a screenshot to manually compare if needed
85- cy . screenshot ( )
86- } )
8776} )
0 commit comments