From 95cee604dd0087bf568bbd67184b303f6294a83b Mon Sep 17 00:00:00 2001 From: Max Date: Fri, 13 Dec 2024 11:49:21 +0100 Subject: [PATCH] fix(cy): create user once and upload files once Signed-off-by: Max --- cypress/e2e/openreadonly.spec.js | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/cypress/e2e/openreadonly.spec.js b/cypress/e2e/openreadonly.spec.js index ddd30c01d1e..1ec73da3a58 100644 --- a/cypress/e2e/openreadonly.spec.js +++ b/cypress/e2e/openreadonly.spec.js @@ -11,27 +11,31 @@ const user = randUser() describe('Open read-only mode', function() { + before(function() { + cy.createUser(user) + cy.login(user) + cy.uploadFile('test.md', 'text/markdown') + cy.uploadFile('test.md', 'text/markdown', 'test.txt') + }) + const setReadOnlyMode = function(mode) { cy.login(admin) cy.setAppConfig('open_read_only_enabled', mode) - cy.logout() } describe('Disabled', function() { const checkMenubar = function() { cy.get('.text-editor--readonly-bar').should('not.exist') - cy.get('.text-menubar').getActionEntry('done').should('not.exist') + cy.get('.text-menubar', { timeout: 10000 }) + .getActionEntry('done').should('not.exist') } - beforeEach(function() { + before(function() { setReadOnlyMode(0) + }) - cy.createUser(user) + beforeEach(function() { cy.login(user) - - cy.uploadFile('test.md', 'text/markdown') - cy.uploadFile('test.md', 'text/markdown', 'test.txt') - cy.visit('/apps/files') }) @@ -57,18 +61,12 @@ describe('Open read-only mode', function() { cy.get('.text-menubar').getActionEntry('done').should('exist') } - beforeEach(function() { + before(function() { setReadOnlyMode(1) + }) - cy.createUser(user) + beforeEach(function() { cy.login(user) - - cy.removeFile('test.md') - cy.removeFile('test.txt') - - cy.uploadFile('test.md', 'text/markdown') - cy.uploadFile('test.md', 'text/plain', 'test.txt') - cy.visit('/apps/files') })