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. * Creates 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
1 parent
95b124b
commit 9247147
Showing
14 changed files
with
413 additions
and
111 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 | ||
} | ||
} |
82 changes: 82 additions & 0 deletions
82
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,82 @@ | ||
/// <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'); | ||
}); | ||
|
||
beforeEach('Add description if needed', function() { | ||
// Preserve authentication information between the tests | ||
Cypress.Cookies.preserveOnce('session'); | ||
}); | ||
|
||
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'); | ||
}); | ||
|
||
it('Logout', function() { | ||
// 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(); | ||
// Check that the user is logged out | ||
cy.get('body').should('contain','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
76 changes: 76 additions & 0 deletions
76
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,76 @@ | ||
/// <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() { | ||
// Login as librarian (Leonard) | ||
cy.adminLogin(this.users.librarians.spock.email, this.common.uniquePwd); | ||
}); | ||
|
||
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 course', function() { | ||
let course = this.collections.course; | ||
// Go to collection list | ||
cy.get('#user-services-menu').click(); | ||
cy.get('#collections-menu').click(); | ||
// Click add button | ||
cy.get('#search-add-button').click(); | ||
// Fill in the form | ||
cy.fillCollectionEditor(course); | ||
// Check the course | ||
cy.checkCollection(course); | ||
}); | ||
|
||
it('Edit a collection to change it as an exhibition', function() { | ||
let exhibition = this.collections.exhibition; | ||
// Go to editor | ||
cy.get('#detail-edit-button').click(); | ||
// Fill in the form | ||
cy.fillCollectionEditor(exhibition); | ||
// Check the exhibition | ||
cy.checkCollection(exhibition); | ||
}); | ||
}); |
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
Oops, something went wrong.