From 1b91ab5f34b89d63cd098a0b16b85a0b2615ff30 Mon Sep 17 00:00:00 2001 From: schiwaa Date: Fri, 24 Jan 2025 17:25:12 +0100 Subject: [PATCH] adding and deleting sections ok in local headless and headed mode --- frontend-e2e/cypress/e2e/role_admin/sections.cy.js | 12 +++++------- frontend-e2e/cypress/support/commands.js | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/frontend-e2e/cypress/e2e/role_admin/sections.cy.js b/frontend-e2e/cypress/e2e/role_admin/sections.cy.js index 33b5b69..aabcfe4 100644 --- a/frontend-e2e/cypress/e2e/role_admin/sections.cy.js +++ b/frontend-e2e/cypress/e2e/role_admin/sections.cy.js @@ -33,6 +33,7 @@ import users from '../../fixtures/users.json'; const admin = users.filter(({username}) => username === 'admin@example.org')[0]; beforeEach(() => { + cy.reseedDB(); cy.visit(`${Cypress.env('CY_STEMMAWEB_FRONTEND_URL')}/`); cy.viewport(1600, 900); test_traditions.sort( (tradition_a, tradition_b) => tradition_a.title.localeCompare( tradition_b.title ) ); @@ -68,17 +69,13 @@ describe('Each tradition should have the right number of sections listed in the }); describe('Section handling works correcly in the tradition list and the section properties area', () => { - it('passes in local headed mode', () => { // under construction: relative path to sections file in headless mode - // reseed db - cy.reseedDB(); - + it('passes', () => { // input string for the test section to be added const new_section_name = 'NEW SECTION BY CY'; - // relative path starting from frontend-e2e folder in local headed mode - const new_section_rel_path = './../bin/init-data/stemmarest/data/florilegium_z.csv'; - // TODO: check if there is a standard cy way to refer to relative paths + // relative path to the section file which is going to be added for teesting + const new_section_rel_path = (Cypress.browser.isHeaded) ? './../bin/init-data/stemmarest/data/florilegium_z.csv' : './cypress/.initdata4headless/data/florilegium_z.csv'; // test with one tradition which has a few sections // add and delete a section so that the final sections and their orders equal the initial ones @@ -169,6 +166,7 @@ describe('Section handling works correcly in the tradition list and the section expect($ele.text().trim()).not.contains(new_section_name); }); */ + cy.wait(1000); // obviously necessary here before logout }); }); }); diff --git a/frontend-e2e/cypress/support/commands.js b/frontend-e2e/cypress/support/commands.js index 8805c71..c59b845 100644 --- a/frontend-e2e/cypress/support/commands.js +++ b/frontend-e2e/cypress/support/commands.js @@ -30,6 +30,7 @@ Cypress.Commands.add('loginViaUi', (userObj) => { cy.contains('header a', 'Sign in').click(); cy.get('#loginEmail').wait(500).type(userObj.username, { delay: 50 }); cy.get('#loginPassword').wait(500).type(userObj.password, { delay: 50 }); + cy.wait(500); cy.get('button').contains('Sign in').wait(500).click(); cy.get('#authModal').should('not.be.visible'); cy.contains('Logged in as ' + userObj.username); @@ -40,7 +41,6 @@ Cypress.Commands.add('loginViaUi', (userObj) => { // Logout via user interface Cypress.Commands.add('logoutViaUi', () => { - cy.log("Cypress.browser.isHeaded? " + Cypress.browser.isHeaded); cy.contains('header a', 'Sign out').click(); cy.contains('header a', 'Sign in'); cy.get('header').should('not.contain', 'Sign out');