From 9dc97c9053aa4ef4db4a31c80d01eb764e19f529 Mon Sep 17 00:00:00 2001 From: duncdrum Date: Wed, 20 Dec 2023 22:47:53 +0100 Subject: [PATCH] refactor(auth): code cleanup --- .../e2e/{auth_old.spec.js => auth.spec.js} | 86 +++++++++---------- 1 file changed, 43 insertions(+), 43 deletions(-) rename cypress/e2e/{auth_old.spec.js => auth.spec.js} (54%) diff --git a/cypress/e2e/auth_old.spec.js b/cypress/e2e/auth.spec.js similarity index 54% rename from cypress/e2e/auth_old.spec.js rename to cypress/e2e/auth.spec.js index 150acd1d..0b54b45f 100644 --- a/cypress/e2e/auth_old.spec.js +++ b/cypress/e2e/auth.spec.js @@ -1,102 +1,102 @@ const indexPage = 'http://localhost:8080/exist/apps/eXide/index.html' const loginPage = 'http://localhost:8080/exist/apps/eXide/login.html' -describe.skip('with guest=yes (default)', function() { - before(function () { +describe('with guest=yes (default)', () => { + before(() => { cy.setConf(true, true); }) - describe('as guest user', function() { - it('login page should redirect guest to index.html', function() { - cy.visit('/eXide/login.html') + describe('as guest user', () => { + it('login page should redirect guest to index.html', () => { + cy.visit('/login.html') cy.url().should('eq', indexPage) }) - it('index page should show editor', function () { - cy.visit('/eXide/index.html') + it('index page should show editor', () => { + cy.visit('/index.html') cy.url().should('eq', indexPage) }) }) - describe('as admin user', function() { - it('login page should redirect admin to index.html', function() { + describe('as admin user', () => { + it('login page should redirect admin to index.html', () => { cy.loginXHR('admin', '') - cy.visit('/eXide/login.html') + cy.visit('/login.html') cy.url().should('eq', indexPage) }) - it('index page should show editor', function () { + it('index page should show editor', () => { cy.loginXHR('admin', '') - cy.visit('/eXide/index.html') + cy.visit('/index.html') cy.url().should('eq', indexPage) }) - it('reload after logout still shows editor', function () { + it('reload after logout still shows editor', () => { cy.loginXHR('guest', 'guest') - cy.visit('/eXide/index.html') + cy.visit('/index.html') cy.url().should('eq', indexPage) }) }) }) -describe('with guest=no', function() { - before(function () { +describe('with guest=no', () => { + before(() => { cy.setConf(true, false); }) - after(function () { + after(() => { cy.setConf(true, true); }) - describe('as guest', function() { - before(function () { cy.loginXHR('guest', 'guest') }) - it('login page should show', function() { - cy.visit('/eXide/login.html') + describe('as guest', () => { + before(() => { cy.loginXHR('guest', 'guest') }) + it('login page should show', () => { + cy.visit('/login.html') // cy.reload(true) cy.url().should('eq', loginPage) }) - it('index page should redirect to login', function () { - cy.visit('/eXide/index.html') + it('index page should redirect to login', () => { + cy.visit('/index.html') cy.url().should('eq', loginPage) }) }) - describe('as admin', function() { - it('login page should redirect admin to index.html', function() { + describe('as admin', () => { + it('login page should redirect admin to index.html', () => { cy.loginXHR('admin', '') - cy.visit('/eXide/login.html') + cy.visit('/login.html') cy.url().should('eq', indexPage) }) - it('index page should show editor', function () { + it('index page should show editor', () => { cy.loginXHR('admin', '') - cy.visit('/eXide/index.html') + cy.visit('/index.html') cy.url().should('eq', indexPage) }) }) }) -describe('login using form', function () { - before(function () { +describe('login using form', () => { + before(() => { cy.setConf(true, false); }) - beforeEach(function () { + beforeEach(() => { cy.loginXHR('guest', 'guest') }) - after(function () { + after(() => { cy.setConf(true, true); cy.loginXHR('guest', 'guest') }) - it('login page should show', function() { - cy.visit('/eXide/login.html') + it('login page should show', () => { + cy.visit('/login.html') cy.url().should('eq', loginPage) }) - describe('with valid admin credentials', function () { - it('should login in', function() { + describe('with valid admin credentials', () => { + it('should login in', () => { cy.session(['form', 'admin', ''], () => { - cy.visit('/eXide/login.html') + cy.visit('/login.html') cy.get('[name=user]').type('admin') // this will throw an error as .type cannot handle an empty string // cy.get('[name=password]').type('') @@ -105,10 +105,10 @@ describe('login using form', function () { }) }) }) - describe('with invalid admin credentials', function () { - it('should not allow access', function() { + describe('with invalid admin credentials', () => { + it('should not allow access', () => { cy.session(['form', 'admin', 'nimda'], () => { - cy.visit('/eXide/login.html') + cy.visit('/login.html') cy.get('[name=user]').type('admin') // this will throw an error as .type cannot handle an empty string cy.get('[name=password]').type('nimda') @@ -117,10 +117,10 @@ describe('login using form', function () { }) }) }) - describe('with valid guest credentials', function () { - it('should still not allow guest', function() { + describe('with valid guest credentials', () => { + it('should still not allow guest', () => { cy.session(['form', 'guest', 'guest'], () => { - cy.visit('/eXide/login.html') + cy.visit('/login.html') cy.get('[name=user]').type('guest') // this will throw an error as .type cannot handle an empty string cy.get('[name=password]').type('guest')