@@ -32,28 +32,43 @@ const variants = [
3232variants . forEach ( function ( { fixture, mime } ) {
3333 const fileName = fixture
3434 describe ( `${ mime } (${ fileName } )` , function ( ) {
35- const getWrapper = ( ) => cy . get ( '.viewer__content . text-editor__wrapper.has-conflicts' )
35+ const getWrapper = ( ) => cy . get ( '.text-editor__wrapper.has-conflicts' )
3636
3737 before ( ( ) => {
3838 initUserAndFiles ( user , fileName )
3939 } )
4040
4141 beforeEach ( function ( ) {
4242 cy . login ( user )
43- cy . visit ( '/apps/files' )
4443 } )
4544
46- it ( 'displays conflicts' , function ( ) {
47- cy . openFile ( fileName )
48-
49- cy . log ( 'Inspect editor' )
50- cy . getContent ( )
51- . type ( 'Hello you cruel conflicting world' )
45+ it ( 'no actual conflict - just reload' , function ( ) {
46+ // start with different content
47+ cy . uploadFile ( 'frontmatter.md' , mime , fileName )
48+ // just a read only session opened
49+ cy . shareFile ( `/${ fileName } ` )
50+ . then ( token => cy . visit ( `/s/${ token } ` ) )
51+ cy . getContent ( ) . should ( 'contain' , 'Heading' )
52+ cy . intercept ( { method : 'POST' , url : '**/session/*/push' } )
53+ . as ( 'push' )
54+ cy . wait ( '@push' )
5255 cy . uploadFile ( fileName , mime )
56+ cy . get ( '#editor-container .document-status' , { timeout : 30000 } )
57+ . should ( 'contain' , 'session has expired' )
58+ // Reload button works
59+ cy . get ( '#editor-container .document-status a.button' )
60+ . contains ( 'Reload' )
61+ . click ( )
62+ getWrapper ( ) . should ( 'not.exist' )
63+ cy . getContent ( ) . should ( 'contain' , 'Hello world' )
64+ cy . getContent ( ) . should ( 'not.contain' , 'Heading' )
65+ } )
66+
67+ it ( 'displays conflicts' , function ( ) {
68+ createConflict ( fileName , mime )
5369
54- cy . get ( '#viewer .modal-header button.header-close' ) . click ( )
55- cy . get ( '#viewer' ) . should ( 'not.exist' )
5670 cy . openFile ( fileName )
71+
5772 cy . get ( '.text-editor .document-status' )
5873 . should ( 'contain' , 'Document has been changed outside of the editor.' )
5974 getWrapper ( )
@@ -68,57 +83,55 @@ variants.forEach(function({ fixture, mime }) {
6883 } )
6984
7085 it ( 'resolves conflict using current editing session' , function ( ) {
71- cy . openFile ( fileName )
72-
73- cy . log ( 'Inspect editor' )
74- cy . getContent ( )
75- . type ( 'Hello you cruel conflicting world' )
76- cy . uploadFile ( fileName , mime )
86+ createConflict ( fileName , mime )
7787
78- cy . get ( '#viewer .modal-header button.header-close' ) . click ( )
79- cy . get ( '#viewer' ) . should ( 'not.exist' )
8088 cy . openFile ( fileName )
81-
8289 cy . get ( '[data-cy="resolveThisVersion"]' ) . click ( )
8390
84- getWrapper ( )
85- . should ( 'not.exist' )
86-
91+ getWrapper ( ) . should ( 'not.exist' )
8792 cy . get ( '[data-cy="resolveThisVersion"]' )
8893 . should ( 'not.exist' )
89-
90- cy . get ( '.text-editor__main' )
91- . should ( 'contain' , 'Hello world' )
92- cy . get ( '.text-editor__main' )
93- . should ( 'contain' , 'cruel conflicting' )
94+ cy . getContent ( ) . should ( 'contain' , 'Hello world' )
95+ cy . getContent ( ) . should ( 'contain' , 'cruel conflicting' )
9496 } )
9597
9698 it ( 'resolves conflict using server version' , function ( ) {
97- cy . openFile ( fileName )
98-
99- cy . log ( 'Inspect editor' )
100- cy . getContent ( )
101- . type ( 'Hello you cruel conflicting world' )
102- cy . uploadFile ( fileName , mime )
99+ createConflict ( fileName , mime )
103100
104- cy . get ( '#viewer .modal-header button.header-close' ) . click ( )
105- cy . get ( '#viewer' ) . should ( 'not.exist' )
106101 cy . openFile ( fileName )
107-
108102 cy . get ( '[data-cy="resolveServerVersion"]' )
109103 . click ( )
110104
111- getWrapper ( )
112- . should ( 'not.exist' )
105+ getWrapper ( ) . should ( 'not.exist' )
113106 cy . get ( '[data-cy="resolveThisVersion"]' )
114107 . should ( 'not.exist' )
115108 cy . get ( '[data-cy="resolveServerVersion"]' )
116109 . should ( 'not.exist' )
110+ cy . getContent ( ) . should ( 'contain' , 'Hello world' )
111+ cy . getContent ( ) . should ( 'not.contain' , 'cruel conflicting' )
112+ } )
117113
118- cy . get ( '.text-editor__main' )
119- . should ( 'contain' , 'Hello world' )
120- cy . get ( '.text-editor__main' )
121- . should ( 'not.contain' , 'cruel conflicting' )
114+ it ( 'hides conflict in read only session' , function ( ) {
115+ createConflict ( fileName , mime )
116+ cy . shareFile ( `/${ fileName } ` )
117+ . then ( ( token ) => {
118+ cy . logout ( )
119+ cy . visit ( `/s/${ token } ` )
120+ } )
121+ cy . getContent ( ) . should ( 'contain' , 'cruel conflicting' )
122+ getWrapper ( ) . should ( 'not.exist' )
122123 } )
124+
123125 } )
124126} )
127+
128+ function createConflict ( fileName , mime ) {
129+ cy . visit ( '/apps/files' )
130+ cy . openFile ( fileName )
131+ cy . log ( 'Inspect editor' )
132+ cy . getContent ( )
133+ . type ( 'Hello you cruel conflicting world' )
134+ cy . uploadFile ( fileName , mime )
135+ cy . get ( '#viewer .modal-header button.header-close' ) . click ( )
136+ cy . get ( '#viewer' ) . should ( 'not.exist' )
137+ }
0 commit comments