From c3c189104548822135d5c8c7363cfa98078cb283 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Tue, 21 Mar 2023 11:37:53 +0100 Subject: [PATCH 1/7] test: Add cypress tests for resolving conflicts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- cypress/e2e/conflict.spec.js | 77 +++++++++++++++++++++++ src/components/CollisionResolveDialog.vue | 4 +- 2 files changed, 79 insertions(+), 2 deletions(-) diff --git a/cypress/e2e/conflict.spec.js b/cypress/e2e/conflict.spec.js index fcf7e4fe6de..be75f1d2f26 100644 --- a/cypress/e2e/conflict.spec.js +++ b/cypress/e2e/conflict.spec.js @@ -60,4 +60,81 @@ describe('Open test.md in viewer', function() { .should('contain', 'cruel conflicting') cy.screenshot() }) + + it('resolves conflict using current editing session', function() { + cy.openFile(fileName) + + cy.log('Inspect editor') + cy.getContent() + .type('Hello you cruel conflicting world') + cy.uploadFile('test.md', 'text/markdown') + + cy.get('#viewer .modal-header button.header-close').click() + cy.get('#viewer').should('not.exist') + cy.openFile('test.md') + cy.get('.text-editor .document-status .icon-error') + getWrapper() + .get('#read-only-editor h2') + .should('contain', 'Hello world') + getWrapper() + .get('.text-editor__main h2') + .should('contain', 'Hello world') + getWrapper() + .get('.text-editor__main') + .should('contain', 'cruel conflicting') + + cy.get('[data-cy="resolveThisVersion"]').click() + + getWrapper() + .get('#read-only-editor') + .should('not.exist') + + cy.get('[data-cy="resolveThisVersion"]') + .should('not.exist') + + cy.get('.text-editor__main h2') + .should('contain', 'Hello world') + cy.get('.text-editor__main') + .should('contain', 'cruel conflicting') + }) + + it('resolves conflict using server version', function() { + cy.openFile(fileName) + + cy.log('Inspect editor') + cy.getContent() + .type('Hello you cruel conflicting world') + cy.uploadFile('test.md', 'text/markdown') + + cy.get('#viewer .modal-header button.header-close').click() + cy.get('#viewer').should('not.exist') + cy.openFile('test.md') + cy.get('.text-editor .document-status .icon-error') + getWrapper() + .get('#read-only-editor h2') + .should('contain', 'Hello world') + getWrapper() + .get('.text-editor__main h2') + .should('contain', 'Hello world') + getWrapper() + .get('.text-editor__main') + .should('contain', 'cruel conflicting') + + getWrapper() + .get('[data-cy="resolveServerVersion"]') + .click() + + getWrapper() + .get('#read-only-editor') + .should('not.exist') + cy.get('[data-cy="resolveThisVersion"]') + .should('not.exist') + cy.get('[data-cy="resolveServerVersion"]') + .should('not.exist') + + cy.get('.text-editor__main h2') + .should('contain', 'Hello world') + cy.get('.text-editor__main') + .should('not.contain', 'cruel conflicting') + }) }) diff --git a/src/components/CollisionResolveDialog.vue b/src/components/CollisionResolveDialog.vue index e11b21f4813..2c782bd5b7a 100644 --- a/src/components/CollisionResolveDialog.vue +++ b/src/components/CollisionResolveDialog.vue @@ -22,10 +22,10 @@