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. * Renames 'templates' in 'examples' in order to avoid confusion with rero-ils template resource. * Adds cookies preservation to keep authentication information between tests. * Improves login and logout methods. * Allows language preservation in professional interface. * Closes rero#1220. Co-Authored-by: Alicia Zangger <[email protected]>
- Loading branch information
Alicia Zangger
committed
Oct 28, 2020
1 parent
b623f17
commit accfbab
Showing
13 changed files
with
354 additions
and
76 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 | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
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,43 @@ | ||
/// <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('Describe test suite here', function() { | ||
afterEach('Add description if needed', function() { | ||
cy.logout(); | ||
}); | ||
|
||
it('Login as a librarian', function() { | ||
cy.adminLogin(this.users.librarians.leonard.email, this.common.uniquePwd); | ||
|
||
}); | ||
|
||
it('Login as a patron', function() { | ||
cy.login(this.users.patrons.james.email, this.common.uniquePwd); | ||
}); | ||
}); |
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); | ||
}); | ||
}); |
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
54 changes: 54 additions & 0 deletions
54
tests/e2e/cypress/cypress/integration/examples/empty-template.spec.js.disabled
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,54 @@ | ||
/// <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 () { | ||
// Run once before all | ||
// Use to load fixtures and set variable needed in all tests | ||
}); | ||
|
||
describe('Describe test suite here', function() { | ||
// Run once before all tests in the block | ||
// These steps are not part of the test, but need to be done in order to have | ||
// the app in the right state to run the test | ||
before('Login and prepare app for tests', function() { | ||
// Create server to watch api requests (if needed) | ||
cy.server(); | ||
// Open app on frontpage | ||
cy.visit(''); | ||
// Check language and force to english | ||
cy.setLanguageToEnglish(); | ||
}); | ||
|
||
beforeEach('Add description if needed', function() { | ||
// Preserve authentication information between the tests | ||
Cypress.Cookies.preserveOnce('session'); | ||
}); | ||
|
||
afterEach('Add description if needed', function() { | ||
}); | ||
|
||
after('Clean data: ...', function() { | ||
|
||
}); | ||
|
||
it('Describe the test here', function() { | ||
|
||
}); | ||
}); |
Oops, something went wrong.