forked from rero/rero-ils
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cypress: create test for collections
* Creates e2e tests for collections. * Replaces 'goToMenu' custom command in order not to go to the frontpage each time we navigate in the app. * Adds an empty template to re-use for test creation. * Adds cookies preservation to keep authentication information between tests. * Changes login and logout commands in order to use API calls instead of UI actions. * Adds a test for login and logout (UI actions). * Allows language preservation in professional interface. * Closes rero#1220. Co-Authored-by: Alicia Zangger <[email protected]>
- Loading branch information
Alicia Zangger
committed
Nov 2, 2020
1 parent
6e1e31e
commit 3b2fb13
Showing
15 changed files
with
420 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{ | ||
"course": { | ||
"collection_id": "CRS 1", | ||
"title": "Course number 1", | ||
"collection_type": "course", | ||
"teachers": [ | ||
{ | ||
"name": "Pr. Smith, John" | ||
} | ||
], | ||
"libraries": [ | ||
{ | ||
"$ref": "https://ils.rero.ch/api/libraries/22" | ||
} | ||
], | ||
"description": "List of items for course 1", | ||
"subjects": [ | ||
{ | ||
"name": "Anne Nonyme" | ||
}, | ||
{ | ||
"name": "geographic" | ||
} | ||
], | ||
"start_date": "2020-09-01", | ||
"end_date": "2020-12-31", | ||
"organisation": { | ||
"$ref": "https://ils.rero.ch/api/organisations/4" | ||
}, | ||
"published": true | ||
}, | ||
"exhibition": { | ||
"collection_id": "Expo 1", | ||
"title": "Expo \u2013 The Number 1", | ||
"collection_type": "exhibition", | ||
"description": "List of items for the exhibition", | ||
"start_date": "2020-10-01", | ||
"end_date": "2021-06-30", | ||
"organisation": { | ||
"$ref": "https://ils.rero.ch/api/organisations/4" | ||
}, | ||
"published": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,27 +4,31 @@ | |
"email": "[email protected]", | ||
"first_name": "James", | ||
"last_name": "Kirk", | ||
"barcode": "cypress-1" | ||
"barcode": "cypress-1", | ||
"initials": "JK" | ||
}, | ||
"nyota": { | ||
"email": "[email protected]", | ||
"first_name": "Nyota", | ||
"last_name": "Uhura", | ||
"barcode": "cypress-2" | ||
"barcode": "cypress-2", | ||
"initials": "NU" | ||
} | ||
}, | ||
"librarians": { | ||
"spock": { | ||
"email": "[email protected]", | ||
"first_name": "Spock", | ||
"last_name": "Grayson", | ||
"libraryPid": "23" | ||
"libraryPid": "23", | ||
"initials": "SG" | ||
}, | ||
"leonard": { | ||
"email": "[email protected]", | ||
"first_name": "Leonard", | ||
"last_name": "McCoy", | ||
"libraryPid": "22" | ||
"libraryPid": "22", | ||
"initials": "LM" | ||
} | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
tests/e2e/cypress/cypress/integration/application/test-login-logout.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/// <reference types="Cypress" /> | ||
/* | ||
RERO ILS | ||
Copyright (C) 2020 RERO | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Affero General Public License as published by | ||
the Free Software Foundation, version 3 of the License. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Affero General Public License for more details. | ||
You should have received a copy of the GNU Affero General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
before(function () { | ||
cy.fixture('users').then(function (userData) { | ||
this.users = userData; | ||
}); | ||
cy.fixture('common').then(function (commonData) { | ||
this.common = commonData; | ||
}); | ||
}); | ||
|
||
describe('Login and logout', function() { | ||
before('Go to frontpage', function() { | ||
cy.visit('/lang/en'); | ||
}); | ||
|
||
after('Logout', function() { | ||
cy.logout(); | ||
}); | ||
|
||
it('Login as a librarian', function() { | ||
// Login | ||
cy.get('#my-account-menu').click(); | ||
cy.wait(1000); | ||
cy.get('#login-menu').click(); | ||
// Fill the form and submit | ||
cy.get('#email').type(this.users.librarians.leonard.email); | ||
cy.get('#password').type(this.common.uniquePwd); | ||
cy.get('form[name="login_user_form"]').submit(); | ||
// Check that the user is logged | ||
cy.get('#my-account-menu').should('contain', this.users.librarians.leonard.initials); | ||
// Check professional interface access | ||
cy.visit('/professional'); | ||
cy.get('body').should('contain','RERO ILS administration'); | ||
|
||
//Logout | ||
// Click on username | ||
cy.get('#my-account-menu').click() | ||
// Wait for the menu to open | ||
cy.wait(1000) | ||
// Click on logout | ||
cy.get('#logout-menu').click(); | ||
// Raise an error if something went wrong | ||
cy.contains('My account'); | ||
|
||
}); | ||
|
||
it('Login as a patron', function() { | ||
cy.get('#my-account-menu').click(); | ||
cy.wait(1000); | ||
cy.get('#login-menu').click(); | ||
// Fill the form | ||
cy.get('#email').type(this.users.patrons.james.email); | ||
cy.get('#password').type(this.common.uniquePwd); | ||
cy.get('form[name="login_user_form"]').submit(); | ||
// Check that the user is logged | ||
cy.get('#my-account-menu').should('contain', this.users.patrons.james.initials); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
tests/e2e/cypress/cypress/integration/collections/test-collections.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/// <reference types="Cypress" /> | ||
/* | ||
RERO ILS | ||
Copyright (C) 2020 RERO | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Affero General Public License as published by | ||
the Free Software Foundation, version 3 of the License. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Affero General Public License for more details. | ||
You should have received a copy of the GNU Affero General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
before(function () { | ||
cy.fixture('users').then(function (userData) { | ||
this.users = userData; | ||
}); | ||
cy.fixture('common').then(function (commonData) { | ||
this.common = commonData; | ||
}); | ||
cy.fixture('collections').then(function (collections) { | ||
this.collections = collections; | ||
}); | ||
}); | ||
|
||
describe('Collections', function() { | ||
/** | ||
* DESCRIPTION | ||
* | ||
*/ | ||
before('Login as a professional', function() { | ||
Cypress.Cookies.debug(true); | ||
this.spock = this.users.librarians.spock; | ||
// Create server to watch api requests | ||
cy.server(); | ||
// Open app on frontpage | ||
cy.visit(''); | ||
// Check language and force to english | ||
cy.setLanguageToEnglish(); | ||
// Login as librarian | ||
cy.adminLogin(this.spock.email, this.common.uniquePwd); | ||
// Create a course | ||
cy.createCollection(this.collections.course); | ||
// Check the course | ||
cy.checkCollection(this.collections.course); | ||
}); | ||
|
||
beforeEach(() => { | ||
Cypress.Cookies.preserveOnce('session'); | ||
}); | ||
|
||
after('Clean data: remove collection', function() { | ||
// Delete collection and confirm | ||
cy.get('#detail-delete-button').click(); | ||
cy.get('#modal-confirm-button').click(); | ||
cy.logout(); | ||
}); | ||
|
||
it('Create a collection', function() { | ||
// Create a course | ||
cy.createCollection(this.collections.course); | ||
// Check the course | ||
cy.checkCollection(this.collections.course); | ||
}); | ||
|
||
it('Edit a collection', function() { | ||
// Edit a collection to change it as an exhibition | ||
cy.editCollection(this.collections.exhibition); | ||
// Check the exhibition | ||
cy.checkCollection(this.collections.exhibition); | ||
}); | ||
}); |
Oops, something went wrong.