Skip to content

Commit

Permalink
add login and logout for all tests run as admin
Browse files Browse the repository at this point in the history
  • Loading branch information
schiwaa committed Jul 26, 2024
1 parent 85dab05 commit 1e1db4a
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 10 deletions.
13 changes: 11 additions & 2 deletions frontend-e2e/cypress/e2e/role_admin/sections.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,23 @@ reordering of sections. Functionalities to be tested:
*/

import test_traditions from '../../fixtures/test_traditions.json';
import users from '../../fixtures/users.json';
const admin = users.filter(({username}) => username === '[email protected]')[0];

beforeEach(() => {
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 ) );
cy.loginViaUi(admin);
});

afterEach(() => {
cy.logoutViaUi();
});

// count sections of each (public) tradition is correct
describe('Each tradition should have the right number of sections listed in the toc', () => {
it.skip('under construction', () => { // to do: user rights and db initial state.
it.skip('under construction', () => { // to do: db initial state.
// TODO: number of sections currently varies in course of other test(s)
// TODO: switch the lines (to filter 'Public' traditions) when user rights are implemented:
// test_traditions.filter(({access}) => access === 'Public').forEach((tradition) => {
Expand All @@ -46,7 +55,7 @@ describe('Each tradition should have the right number of sections listed in the
// assert that the number of sections visible in the toc correponds to that in the list of traditions

// TODO: add issue to scroll tradition-list, otherwise it is
// not possible to access tratition titles and sections at the
// not possible to access tradition titles and sections at the
// bottom of the list. Preliminary solution here: lengthen viewport.
cy.viewport(1000, 990);

Expand Down
23 changes: 15 additions & 8 deletions frontend-e2e/cypress/e2e/role_admin/stemwebdialog.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ const admin = users.filter(({username}) => username === '[email protected]')[0];
beforeEach(() => {
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 ) );
cy.loginViaUi(admin);
});

afterEach(() => {
cy.logoutViaUi();
});

describe('Stemweb dialog should work properly', () => {
Expand Down Expand Up @@ -281,24 +287,25 @@ describe('stemma editor tools and svg work properly', () => {
// get the graph's svg again and assert the number of its edges to be one more than before
cy.get('div#graph > svg').find('g.edge').should('have.length', countedges+1); // 21

// save it -- needs login
// reset v at the end // cy.log('old val: ' + v);
// TODO: save it -- needs login
// TODO: reset v at the end // cy.log('old val: ' + v);
});
});
});

describe('stemma editing error feedback in message console works properly', () => {
it('passes', () => { // needs login
if (Cypress.env('CY_MODE') === 'headed') { // only log in if headed. dont run this test headless because it needs to be logged in // TODO: also for headless mode
// if (Cypress.env('CY_MODE') === 'headed') { // only log in if headed. dont run this test headless because it needs to be logged in // TODO: also for headless mode
// TODO: when fitted also for healess mode, merge with previous test (partly duplicate)
cy.loginViaUi(admin);
// cy.loginViaUi(admin);

// To do: assert that the message console lists unexpected errors
// TODO: assert that the message console lists unexpected errors
// when editing a stemma and e.g. removing [class=extant] after one of the nodes,
// it should not be possible to save it, and
// there should appear a message in the console panel saying "Error: BAD REQUEST; Witness [witness name here] not marked as either hypothetical or extant"

// access stemma dot for editing
// TODO: test a tradition with a smaller graph / shorter dot file, for speeding up test
let tradition = test_traditions.find(trad => trad.title.startsWith('Notre besoin'));
cy.log('tradition.title: ' + tradition.title);
// click on the tradition title within the tradition list
Expand Down Expand Up @@ -395,10 +402,10 @@ describe('stemma editing error feedback in message console works properly', () =
cy.get('#message-console-text-panel').contains(msg_err);
cy.get('#message-console-text-panel').contains(msg_ok);

// Test also the CANCEL button
// TODO: Test also the CANCEL button
});

cy.logoutViaUi();
}
// cy.logoutViaUi();
// }
});
});
9 changes: 9 additions & 0 deletions frontend-e2e/cypress/e2e/role_admin/traditions.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,18 @@ Cypress tests to be added:
*/

import test_traditions from '../../fixtures/test_traditions.json';
import users from '../../fixtures/users.json';
const admin = users.filter(({username}) => username === '[email protected]')[0];

beforeEach(() => {
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 ) );
cy.loginViaUi(admin);
});

afterEach(() => {
cy.logoutViaUi();
});

// count sections of each (public) tradition is correct
Expand Down

0 comments on commit 1e1db4a

Please sign in to comment.