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.
tests: add cypress tests for document creation
* Add tests to check document creation field by field. * Moves api requests commands in corresponding resource file. * Improves some tests for easier maintenance. * Fix broken tests. Co-Authored-by: Alicia Zangger <alicia.zangger@rero.ch>
- Loading branch information
1 parent
2955915
commit 6392a25
Showing
11 changed files
with
541 additions
and
73 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
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
111 changes: 111 additions & 0 deletions
111
tests/e2e/cypress/cypress/integration/editor/document/create-document-prov-activity.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,111 @@ | ||
/// <reference types="Cypress" /> | ||
/* | ||
RERO ILS | ||
Copyright (C) 2021 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('documents').then(function (documents) { | ||
this.documents = documents; | ||
}); | ||
cy.fixture('users').then(function (userData) { | ||
this.users = userData; | ||
}); | ||
cy.fixture('common').then(function (commonData) { | ||
this.common = commonData; | ||
}); | ||
}) | ||
|
||
describe('Create a document with provision activity', function() { | ||
let documentPid; | ||
let documentTitleSuffix = ' ' + cy.getCurrentDateAndHour(); | ||
before('Login as a professional and create a simple document', function() { | ||
this.spock = this.users.librarians.spock; | ||
// Login as librarian | ||
cy.adminLogin(this.spock.email, this.common.uniquePwd); | ||
cy.apiCreateDocument(this.documents.book, documentTitleSuffix); | ||
cy.get('@getDocumentPid').then((pid) => { | ||
documentPid = pid; | ||
}); | ||
}); | ||
|
||
beforeEach('Preserve logged user', function() { | ||
// Preserve authentication information between the tests | ||
Cypress.Cookies.preserveOnce('session'); | ||
}); | ||
|
||
after('Clean data: remove document', function() { | ||
// Delete document | ||
cy.apiDeleteResources('documents', 'pid:"'+ documentPid + '"'); | ||
cy.logout(); | ||
cy.log('End of the test'); | ||
}); | ||
|
||
it('Add provision activity', function() { | ||
cy.intercept('/api/permissions/documents/' + documentPid).as('getDocPermission'); | ||
// Go to document editor | ||
cy.visit('/professional/records/documents/edit/' + documentPid); | ||
cy.wait('@getDocPermission'); | ||
// Add date 2 | ||
cy.get('#provisionActivity-0').click(); | ||
cy.get('#dropdown-basic > :nth-child(2)').click(); | ||
cy.get('#provisionActivity-0-endDate').type(this.documents.book.provisionActivity.publicationDate2); | ||
// Add places | ||
cy.get('#provisionActivity-0-place-0-country').select(this.documents.book.provisionActivity.place); | ||
// Add statements | ||
cy.get('#provisionActivity-0-statement-0-type').select('Place'); | ||
cy.get('#provisionActivity-0-statement-0-label-0-value').clear(); | ||
cy.get('#provisionActivity-0-statement-0-label-0-value').type(this.documents.book.provisionActivity.statement.place); | ||
cy.get('#provisionActivity-0-statement-1-type').select('agent'); | ||
cy.get('#provisionActivity-0-statement-1-label-0-value').clear(); | ||
cy.get('#provisionActivity-0-statement-1-label-0-value').type(this.documents.book.provisionActivity.statement.agent); | ||
cy.get('#provisionActivity-0-statement-2-type').select('Date'); | ||
cy.get('#provisionActivity-0-statement-2-label-0-value').clear(); | ||
cy.get('#provisionActivity-0-statement-2-label-0-value').type(this.documents.book.provisionActivity.statement.date); | ||
// Save | ||
cy.get('#editor-save-button').click(); | ||
|
||
// Check document detail view | ||
cy.checkDocumentEssentialFields(this.documents.book); | ||
cy.get('#doc-publication-statement-0').should('contain', this.documents.book.provisionActivity.statement.place + ' : ' | ||
+ this.documents.book.provisionActivity.statement.agent + ', ' | ||
+ this.documents.book.provisionActivity.statement.date); | ||
}); | ||
|
||
it('Change provision activity', function() { | ||
cy.intercept('/api/permissions/documents/' + documentPid).as('getDocPermission'); | ||
// Go to document editor | ||
cy.visit('/professional/records/documents/edit/' + documentPid); | ||
cy.wait('@getDocPermission'); | ||
// Changes provision activity type to publication | ||
cy.get('#provisionActivity-0-type').select(this.documents.bookPublication.provisionActivity.type); | ||
// Change statements | ||
cy.get('#provisionActivity-0-statement-0-label-0-value').clear(); | ||
cy.get('#provisionActivity-0-statement-0-label-0-value').type(this.documents.bookPublication.provisionActivity.statement.place1); | ||
cy.get('#provisionActivity-0-statement-2-clone-button').click(); | ||
cy.get('#provisionActivity-0-statement-3-type').select('Place'); | ||
cy.get('#provisionActivity-0-statement-3-label-0-value').type(this.documents.bookPublication.provisionActivity.statement.place2); | ||
// Save | ||
cy.get('#editor-save-button').click(); | ||
|
||
// Check document detail view | ||
cy.checkDocumentEssentialFields(this.documents.bookPublication); | ||
cy.get('#doc-publication-statement-0').should('contain', this.documents.bookPublication.provisionActivity.statement.place1 + ' : ' | ||
+ this.documents.bookPublication.provisionActivity.statement.agent + ', ' | ||
+ this.documents.bookPublication.provisionActivity.statement.date + ' ; ' | ||
+ this.documents.bookPublication.provisionActivity.statement.place2); | ||
}); | ||
}) |
86 changes: 86 additions & 0 deletions
86
tests/e2e/cypress/cypress/integration/editor/document/create-document-resp-statement.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,86 @@ | ||
/// <reference types="Cypress" /> | ||
/* | ||
RERO ILS | ||
Copyright (C) 2021 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('documents').then(function (documents) { | ||
this.documents = documents; | ||
}); | ||
cy.fixture('users').then(function (userData) { | ||
this.users = userData; | ||
}); | ||
cy.fixture('common').then(function (commonData) { | ||
this.common = commonData; | ||
}); | ||
}) | ||
|
||
describe('Create a document with responsibility statement', function() { | ||
let documentPid; | ||
let documentTitleSuffix = ' ' + cy.getCurrentDateAndHour(); | ||
before('Login as a professional and create a simple document', function() { | ||
this.spock = this.users.librarians.spock; | ||
// Login as librarian | ||
cy.adminLogin(this.spock.email, this.common.uniquePwd); | ||
cy.apiCreateDocument(this.documents.book, documentTitleSuffix); | ||
cy.get('@getDocumentPid').then((pid) => { | ||
documentPid = pid; | ||
}); | ||
}); | ||
|
||
beforeEach('Preserve logged user', function() { | ||
// Preserve authentication information between the tests | ||
Cypress.Cookies.preserveOnce('session'); | ||
}); | ||
|
||
after('Clean data: remove document', function() { | ||
// Delete document | ||
cy.apiDeleteResources('documents', 'pid:"'+ documentPid + '"'); | ||
cy.logout(); | ||
cy.log('End of the test'); | ||
}); | ||
|
||
it('Add responsibility statement', function() { | ||
cy.intercept('/api/permissions/documents/' + documentPid).as('getDocPermission'); | ||
// Go to document editor | ||
cy.visit('/professional/records/documents/edit/' + documentPid); | ||
cy.wait('@getDocPermission'); | ||
// Remove provision activity statement | ||
cy.get('#provisionActivity-0-statement-remove-button').click(); | ||
// Display responsibility statement and fill the fields | ||
cy.get('#add-field-8').click(); | ||
cy.get('#responsibilityStatement-0-0').click(); | ||
cy.get('.dropdown-item').click(); | ||
cy.get('#responsibilityStatement-0-0-value').type(this.documents.book.responsibilityStatement[0].value); | ||
cy.get('#responsibilityStatement-0-0-language').select(this.documents.book.responsibilityStatement[0].language); | ||
// Add value (same level) | ||
cy.get('#responsibilityStatement-0-0-clone-button').click(); | ||
cy.get('#responsibilityStatement-0-1-value').type(this.documents.book.responsibilityStatement[1].value); | ||
// Add statement | ||
cy.get('#responsibilityStatement-0-clone-button').click(); | ||
cy.get('#responsibilityStatement-1-0-value').type(this.documents.book.responsibilityStatement[2].value); | ||
|
||
// Save | ||
cy.get('#editor-save-button').click(); | ||
|
||
// Check document detail view | ||
cy.checkDocumentEssentialFields(this.documents.book); | ||
cy.get('.row > :nth-child(2)').should('contain', this.documents.book.responsibilityStatement[0].value); | ||
cy.get('.row > :nth-child(4)').should('contain', this.documents.book.responsibilityStatement[1].value); | ||
cy.get('.row > :nth-child(6)').should('contain', this.documents.book.responsibilityStatement[2].value); | ||
}); | ||
}) |
Oops, something went wrong.