-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: create cypress tests to check 0 day checkout
* Adds a test to control that the 'zero day checkout' works correctly. * Adds a test to check the creation of a cipo. Co-Authored-by: Alicia Zangger <[email protected]>
- Loading branch information
Alicia Zangger
committed
Dec 10, 2020
1 parent
d4e4814
commit bcf3270
Showing
18 changed files
with
670 additions
and
22 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,51 @@ | ||
{ | ||
"on_site": { | ||
"organisation_pid": 4, | ||
"name": "On site", | ||
"allow_requests": false, | ||
"allow_checkout": true, | ||
"checkout_duration": 0, | ||
"policy_library_level": false, | ||
"is_default": false | ||
}, | ||
"extended": { | ||
"organisation_pid": 4, | ||
"name":"Extended", | ||
"description":"Extended loan (3 months).", | ||
"allow_requests":true, | ||
"allow_checkout":true, | ||
"checkout_duration":84, | ||
"number_of_days_after_due_date":5, | ||
"number_of_days_before_due_date":5, | ||
"number_renewals":3, | ||
"renewal_duration":84, | ||
"reminder_fee_amount":2, | ||
"policy_library_level":false, | ||
"is_default":false | ||
}, | ||
"default": { | ||
"pid": 7, | ||
"organisation_pid": 4, | ||
"name":"Default", | ||
"description":"Default circulation policy.", | ||
"allow_requests":true, | ||
"allow_checkout":true, | ||
"checkout_duration":30, | ||
"number_of_days_after_due_date":5, | ||
"number_of_days_before_due_date":5, | ||
"number_renewals":3, | ||
"renewal_duration":30, | ||
"reminder_fee_amount":2, | ||
"policy_library_level":false, | ||
"is_default":true | ||
}, | ||
"no_checkout": { | ||
"organisation_pid": 4, | ||
"name":"No checkout", | ||
"description":"Ebooks circulation policy.", | ||
"allow_requests":false, | ||
"allow_checkout":false, | ||
"policy_library_level":false, | ||
"is_default":false | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"on_site": { | ||
"pid": 11, | ||
"type": "standard", | ||
"name": "On site", | ||
"description": "On site consultation", | ||
"organisation_pid": 4 | ||
}, | ||
"default": { | ||
"pid": 11, | ||
"type": "standard", | ||
"name": "Default", | ||
"description": "Default item type", | ||
"organisation_pid": 4 | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"visitors": { | ||
"name": "Visitor", | ||
"description": "Visitor for on site consultation.", | ||
"organisation_pid": 4 | ||
}, | ||
"standard": { | ||
"name": "Standard", | ||
"description": "Standard patron.", | ||
"organisation_pid": 4, | ||
"pid": 7 | ||
} | ||
} |
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 |
---|---|---|
@@ -1,18 +1,34 @@ | ||
{ | ||
"patrons": { | ||
"james": { | ||
"patron":{ | ||
"barcode": "cypress-1" | ||
}, | ||
"email": "[email protected]", | ||
"first_name": "James", | ||
"last_name": "Kirk", | ||
"barcode": "cypress-1", | ||
"initials": "JK" | ||
}, | ||
"nyota": { | ||
"email": "[email protected]", | ||
"first_name": "Nyota", | ||
"last_name": "Uhura", | ||
"barcode": "cypress-2", | ||
"initials": "NU" | ||
"patron": { | ||
"barcode":"cypress-2", | ||
"communication_channel":"email", | ||
"communication_language":"eng", | ||
"expiration_date":"2023-10-07", | ||
"type": 7 | ||
}, | ||
"birth_date":"1932-12-28", | ||
"city":"Betelgeuse", | ||
"email":"[email protected]", | ||
"first_name":"Nyota", | ||
"last_name":"Uhura", | ||
"phone":"+41324883123", | ||
"pid":"53", | ||
"postal_code":"4242", | ||
"roles":["patron"], | ||
"street":"Milky Way street", | ||
"user_id":56, | ||
"username":"Nyota" | ||
} | ||
}, | ||
"librarians": { | ||
|
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
144 changes: 144 additions & 0 deletions
144
tests/e2e/cypress/cypress/integration/circulation/test-on-site-cipo.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,144 @@ | ||
/// <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 | ||
cy.fixture('users').then(function (users) { | ||
this.users = users; | ||
}); | ||
cy.fixture('common').then(function (common) { | ||
this.common = common; | ||
}); | ||
cy.fixture('patron_types').then(function (patronTypes) { | ||
this.patronTypes = patronTypes; | ||
}); | ||
cy.fixture('cipo').then(function (cipo) { | ||
this.cipo = cipo; | ||
}); | ||
cy.fixture('item_types').then(function (itemTypes) { | ||
this.itemTypes = itemTypes; | ||
}); | ||
cy.fixture('items').then(function (items) { | ||
this.items = items; | ||
}); | ||
cy.fixture('documents').then(function (documents) { | ||
this.documents = documents; | ||
}); | ||
this.currentDate = cy.getCurrentDateAndHour(); | ||
this.itemBarcode = 'on-site-' + this.currentDate; | ||
this.nameSuffix = ' ' + this.currentDate; | ||
}); | ||
|
||
describe(`Test 'less than one day' checkout`, function() { | ||
let cipoPid; | ||
let itemTypePid; | ||
let documentPid; | ||
let itemPid; | ||
let patronTypePid; | ||
|
||
before('Login and prepare app for tests', function() { | ||
// Login as librarian (Leonard) | ||
cy.adminLogin(this.users.librarians.leonard.email, this.common.uniquePwd); | ||
// Create patron type | ||
cy.apiCreatePatronType(this.patronTypes.visitors, this.nameSuffix); | ||
cy.get('@getPatronTypePid').then((pid) => { | ||
// Store pid | ||
patronTypePid = pid; | ||
// Apply patron type to a patron | ||
cy.apiUpdatePatron(this.users.patrons.nyota, patronTypePid); | ||
// Create an item type | ||
cy.apiCreateItemType(this.itemTypes.on_site, this.nameSuffix); | ||
cy.get('@getItemTypePid').then((pid) => { | ||
// Store pid | ||
itemTypePid = pid; | ||
// Create 'on site' circulation policy | ||
cy.apiCreateCipo(this.cipo.on_site, patronTypePid, itemTypePid, this.nameSuffix); | ||
cy.get('@getCipoPid').then((pid) => { | ||
// Store pid | ||
cipoPid = pid; | ||
}); | ||
// Create a document | ||
cy.apiCreateDocument(this.documents.book, this.nameSuffix); | ||
cy.get('@getDocumentPid').then((pid) => { | ||
// Store pid | ||
documentPid = pid; | ||
// Create item | ||
cy.apiCreateItem(this.items.starfleet_on_site, this.itemBarcode, pid, itemTypePid); | ||
}); | ||
cy.get('@getItemPid').then((pid) => { | ||
// Store item pid | ||
itemPid = pid; | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
beforeEach('Preserve cookies', function() { | ||
// Preserve authentication information between the tests | ||
Cypress.Cookies.preserveOnce('session'); | ||
}); | ||
|
||
after('Clean data', function() { | ||
// Remove cipo | ||
cy.apiDeleteResources('circ_policies', cipoPid); | ||
// Link patron with 'standard' patron type to allow 'visitor' patron type deletion | ||
cy.apiUpdatePatron(this.users.patrons.nyota, this.users.patrons.nyota.patron.type); | ||
// Remove patron type | ||
cy.apiDeleteResources('patron_types', patronTypePid); | ||
// Remove item | ||
cy.apiDeleteResources('items', 'pid:"'+ itemPid + '"'); | ||
// Remove item type | ||
cy.apiDeleteResources('item_types', itemTypePid); | ||
// Remove document | ||
cy.apiDeleteResources('documents', 'pid:"'+ documentPid + '"'); | ||
cy.logout(); | ||
}); | ||
|
||
it('The item cannot be requested', function() { | ||
// Go to document detailed view | ||
cy.goToProfessionalDocumentDetailView(documentPid); | ||
// Create a request | ||
cy.get('#item-' + this.itemBarcode + ' > [name=buttons] > [name=request]').click(); | ||
cy.get('#patronBarcode').type(this.users.patrons.nyota.patron.barcode); | ||
cy.get('#pickupPid').select(this.items.starfleet_on_site.pickupName); | ||
// Assert that the circ policy doesn't allow the request | ||
cy.get('formly-validation-message').should('contain', 'Circulation policy disallows the operation.'); | ||
cy.get('#new-request-button').should('be.disabled'); | ||
cy.get('.close').click(); | ||
}); | ||
|
||
it('Checkout the item', function() { | ||
// Go to circulation view and do a checkout | ||
cy.get('#user-services-menu').click(); | ||
cy.get('#circulation-menu').click(); | ||
cy.scanPatronBarcodeThenItemBarcode(this.users.patrons.nyota, this.itemBarcode); | ||
cy.get('#item-' + this.itemBarcode + ' [name=circ-info').should('contain', cy.getDateDisplayed(this.currentDate, 'en', '/')); | ||
}); | ||
|
||
it('Checkin the item', function() { | ||
// Checkin | ||
cy.scanItemBarcode(this.itemBarcode); | ||
// Assert that the item was checked in and that it is on shelf | ||
cy.get('#item-' + this.itemBarcode).should('contain', this.itemBarcode); | ||
cy.get('#item-' + this.itemBarcode).should('contain', 'on shelf'); | ||
cy.get('#item-' + this.itemBarcode).should('contain', 'checked in'); | ||
}); | ||
}); |
Oops, something went wrong.