From 3fd2093646364e4bda204ba6fd9be09efb9a6497 Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 24 Jul 2024 13:04:19 +0200 Subject: [PATCH] fix(conflict): no conflict dialogue in read only mode Signed-off-by: Max --- cypress/e2e/conflict.spec.js | 44 +++++++++++++++++++++++- src/components/Editor.vue | 8 +++-- src/components/Editor/DocumentStatus.vue | 6 +++- src/components/Editor/Wrapper.vue | 12 +++---- 4 files changed, 58 insertions(+), 12 deletions(-) diff --git a/cypress/e2e/conflict.spec.js b/cypress/e2e/conflict.spec.js index 6c194275f87..cd7d8ff6b71 100644 --- a/cypress/e2e/conflict.spec.js +++ b/cypress/e2e/conflict.spec.js @@ -15,7 +15,7 @@ const variants = [ variants.forEach(function({ fixture, mime }) { const fileName = fixture describe(`${mime} (${fileName})`, function() { - const getWrapper = () => cy.get('.viewer__content .text-editor__wrapper.has-conflicts') + const getWrapper = () => cy.get('.text-editor__wrapper.has-conflicts') before(() => { initUserAndFiles(user, fileName) @@ -25,6 +25,34 @@ variants.forEach(function({ fixture, mime }) { cy.login(user) }) + it('no actual conflict - just reload', function() { + // start with different content + cy.uploadFile('frontmatter.md', mime, fileName) + // just a read only session opened + cy.shareFile(`/${fileName}`) + .then((token) => { + cy.visit(`/s/${token}`) + }) + cy.get('.text-editor__main') + .should('contain', 'Heading') + cy.intercept({ method: 'POST', url: '**/session/*/push' }) + .as('push') + cy.wait('@push') + cy.uploadFile(fileName, mime) + cy.get('#editor-container .document-status', { timeout: 30000 }) + .should('contain', 'session has expired') + // Reload button works + cy.get('#editor-container .document-status a.button') + .contains('Reload') + .click() + getWrapper() + .should('not.exist') + cy.getContent() + .should('contain', 'Hello world') + cy.getContent() + .should('not.contain', 'Heading') + }) + it('displays conflicts', function() { createConflict(fileName, mime) @@ -77,6 +105,20 @@ variants.forEach(function({ fixture, mime }) { cy.get('.text-editor__main') .should('not.contain', 'cruel conflicting') }) + + it('hides conflict in read only session', function() { + createConflict(fileName, mime) + cy.shareFile(`/${fileName}`) + .then((token) => { + cy.logout() + cy.visit(`/s/${token}`) + }) + cy.get('.text-editor__main') + .should('contain', 'cruel conflicting') + getWrapper() + .should('not.exist') + }) + }) }) diff --git a/src/components/Editor.vue b/src/components/Editor.vue index 6965c5135f8..711353b9843 100644 --- a/src/components/Editor.vue +++ b/src/components/Editor.vue @@ -13,13 +13,14 @@ - @@ -258,6 +259,9 @@ export default { isRichWorkspace() { return this.richWorkspace }, + isResolvingConflict() { + return this.hasSyncCollission && !this.readOnly + }, hasSyncCollission() { return this.syncError && this.syncError.type === ERROR_TYPE.SAVE_COLLISSION }, diff --git a/src/components/Editor/DocumentStatus.vue b/src/components/Editor/DocumentStatus.vue index 79a9810c6ac..b0930f5876b 100644 --- a/src/components/Editor/DocumentStatus.vue +++ b/src/components/Editor/DocumentStatus.vue @@ -34,7 +34,7 @@

- + @@ -72,6 +72,10 @@ export default { type: Boolean, require: true, }, + isResolvingConflict: { + type: Boolean, + require: true, + }, }, data() { diff --git a/src/components/Editor/Wrapper.vue b/src/components/Editor/Wrapper.vue index 854f73418e9..5c5bdd0b89f 100644 --- a/src/components/Editor/Wrapper.vue +++ b/src/components/Editor/Wrapper.vue @@ -6,7 +6,7 @@