From e3ed7b398fa3705d2ee2a60539f1018c4b0395f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Wed, 14 Aug 2024 13:04:54 +0200 Subject: [PATCH] test(cypress): Isolate conflict tests 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 | 75 +++++++++++++++++++++--------------- 1 file changed, 43 insertions(+), 32 deletions(-) diff --git a/cypress/e2e/conflict.spec.js b/cypress/e2e/conflict.spec.js index fc5e81f6603..e3638500412 100644 --- a/cypress/e2e/conflict.spec.js +++ b/cypress/e2e/conflict.spec.js @@ -14,40 +14,45 @@ const variants = [ variants.forEach(function({ fixture, mime }) { const fileName = fixture + const prefix = mime.replaceAll('/', '-') describe(`${mime} (${fileName})`, function() { const getWrapper = () => cy.get('.text-editor__wrapper.has-conflicts') before(() => { - initUserAndFiles(user, fileName) + initUserAndFiles(user) }) beforeEach(function() { cy.login(user) + cy.isolateTest({ sourceFile: fileName }) }) - 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.getContent().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(prefix + ': no actual conflict - just reload', function() { + cy.testName().then(testName => { + // start with different content + cy.uploadFile('frontmatter.md', mime, `${testName}/${fileName}`) + // just a read only session opened + cy.shareFile(`${testName}/${fileName}`) + .then((token) => { + cy.visit(`/s/${token}`) + }) + cy.getContent().should('contain', 'Heading') + + cy.uploadFile(fileName, mime, testName + '/' + fileName) + cy.get('#editor-container .document-status', { timeout: 40000 }) + .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() { + it(prefix + ': displays conflicts', function() { createConflict(fileName, mime) cy.openFile(fileName) @@ -65,10 +70,13 @@ variants.forEach(function({ fixture, mime }) { .should('contain', 'cruel conflicting') }) - it('resolves conflict using current editing session', function() { + it(prefix + ': resolves conflict using current editing session', function() { createConflict(fileName, mime) cy.openFile(fileName) + cy.intercept({ method: 'POST', url: '**/session/*/push' }) + .as('push') + cy.wait('@push') cy.get('[data-cy="resolveThisVersion"]').click() getWrapper().should('not.exist') @@ -78,7 +86,7 @@ variants.forEach(function({ fixture, mime }) { cy.getContent().should('contain', 'cruel conflicting') }) - it('resolves conflict using server version', function() { + it(prefix + ': resolves conflict using server version', function() { createConflict(fileName, mime) cy.openFile(fileName) @@ -94,13 +102,15 @@ variants.forEach(function({ fixture, mime }) { cy.getContent().should('not.contain', 'cruel conflicting') }) - it('hides conflict in read only session', function() { + it(prefix + ': hides conflict in read only session', function() { createConflict(fileName, mime) - cy.shareFile(`/${fileName}`) - .then((token) => { - cy.logout() - cy.visit(`/s/${token}`) - }) + cy.testName().then(testName => { + cy.shareFile(`/${testName}/${fileName}`) + .then((token) => { + cy.logout() + cy.visit(`/s/${token}`) + }) + }) cy.getContent().should('contain', 'cruel conflicting') getWrapper().should('not.exist') }) @@ -113,13 +123,14 @@ variants.forEach(function({ fixture, mime }) { * @param {string} mime - mimetype */ function createConflict(fileName, mime) { - cy.visit('/apps/files') cy.openFile(fileName) cy.log('Inspect editor') cy.getEditor().find('.ProseMirror').should('have.attr', 'contenteditable', 'true') cy.getContent() .type('Hello you cruel conflicting world') - cy.uploadFile(fileName, mime) + cy.testName().then(testName => { + cy.uploadFile(fileName, mime, testName + '/' + fileName) + }) cy.get('#viewer .modal-header button.header-close').click() cy.get('#viewer').should('not.exist') }