Skip to content

Commit b1ccb60

Browse files
committed
fix: various issues with conflict display
* only import prosemirror css once. * disconnect after receiving a 409 response in polling backend. * clean up remains of `RichtextOptions`. * use the `isRichEditor` prop in Reader. * add cypress test for conflict display. Signed-off-by: Max <max@nextcloud.com>
1 parent 36730c2 commit b1ccb60

File tree

5 files changed

+60
-10
lines changed

5 files changed

+60
-10
lines changed

cypress/e2e/conflict.spec.js

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/**
2+
* @copyright Copyright (c) 2019 John Molakvoæ <skjnldsv@protonmail.com>
3+
*
4+
* @author John Molakvoæ <skjnldsv@protonmail.com>
5+
*
6+
* @license GNU AGPL version 3 or any later version
7+
*
8+
* This program is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU Affero General Public License as
10+
* published by the Free Software Foundation, either version 3 of the
11+
* License, or (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU Affero General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU Affero General Public License
19+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
20+
*
21+
*/
22+
23+
import { randHash } from '../utils/'
24+
const randUser = randHash()
25+
26+
describe('Open test.md in viewer', function() {
27+
before(function() {
28+
// Init user
29+
cy.nextcloudCreateUser(randUser, 'password')
30+
cy.login(randUser, 'password')
31+
32+
// Upload test files
33+
cy.uploadFile('test.md', 'text/markdown')
34+
})
35+
36+
beforeEach(function() {
37+
cy.login(randUser, 'password')
38+
})
39+
40+
it('displays conflicts', function() {
41+
cy.openFile('test.md')
42+
43+
cy.log('Inspect editor')
44+
const viewer = cy.get('#viewer')
45+
const editor = viewer.get('#editor .ProseMirror')
46+
editor.type('Hello you cruel conflicting world')
47+
cy.uploadFile('test.md', 'text/markdown')
48+
49+
cy.get('#viewer .modal-header button.header-close').click()
50+
cy.get('#viewer').should('not.exist')
51+
cy.openFile('test.md')
52+
cy.get('#editor-container .document-status .icon-error')
53+
const wrapper = cy.get('#editor-wrapper.has-conflicts.is-rich-editor ')
54+
wrapper.get('#read-only-editor h2').should('contain', 'Hello world')
55+
wrapper.get('#editor h2').should('contain', 'Hello world')
56+
cy.screenshot()
57+
})
58+
})

src/components/EditorWrapper.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@
7777
</EditorMidiaHandler>
7878
<Reader v-if="hasSyncCollission"
7979
:content="syncError.data.outsideChange"
80-
:rich-text-options="richTextOptions"
8180
:is-rich-editor="isRichEditor" />
8281
</div>
8382

@@ -563,7 +562,6 @@ export default {
563562
}),
564563
],
565564
enableRichEditing: this.isRichEditor,
566-
...this.richTextOptions,
567565
})
568566
this.$editor.on('focus', () => {
569567
this.$emit('focus')

src/components/Reader.vue

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
-->
2222

2323
<template>
24-
<RichTextReader v-if="isRichText"
24+
<RichTextReader v-if="isRichEditor"
2525
:content="content" />
2626
<PlainTextReader v-else
2727
:content="content" />
@@ -65,6 +65,3 @@ export default {
6565
}
6666
6767
</style>
68-
<style lang="scss">
69-
@import './../../css/prosemirror';
70-
</style>

src/components/RichTextReader.vue

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,3 @@ export default {
5555
5656
}
5757
</script>
58-
59-
<style lang="scss">
60-
@import './../../css/prosemirror';
61-
</style>

src/services/PollingBackend.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ class PollingBackend {
190190
outsideChange: e.response.data.outsideChange,
191191
},
192192
})
193+
this.disconnect()
193194
} else if (e.response.status === 403) {
194195
this._authority.emit('error', { type: ERROR_TYPE.SOURCE_NOT_FOUND, data: {} })
195196
this.disconnect()

0 commit comments

Comments
 (0)