Skip to content

Commit

Permalink
tests: fix cypress tests
Browse files Browse the repository at this point in the history
* Fixes cypress tests according to new features.
* Adds fixtures for item status and actions.

Co-Authored-by: Alicia Zangger <alicia.zangger@rero.ch>
  • Loading branch information
Alicia Zangger authored and AoNoOokami committed Feb 8, 2021
1 parent 1e9f227 commit 93fbc54
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 19 deletions.
12 changes: 11 additions & 1 deletion tests/e2e/cypress/cypress/fixtures/common.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
{
"uniquePwd": "123456"
"uniquePwd": "123456",
"itemStatus": {
"transit": "in transit",
"onShelf": "on shelf",
"atDesk": "at desk"
},
"itemAction": {
"checkedIn": "checked in",
"checkedOut": "checked out",
"receive": "receive"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,16 @@ describe('Circulation scenario A: standard loan', function() {
/**
* James makes a request on item, to be picked up at Starfleet library.
*/
cy.intercept('POST', '/api/item/request').as('itemRequest');
cy.login(this.users.patrons.james.email, this.common.uniquePwd);
// Search for the item
cy.goToPublicDocumentDetailView(documentPid);
// Request the item
cy.get('#' + this.itemBarcode + '-dropdownMenu').click();
cy.get('#item-request-' + itemPid + ' .btn').click();
// Select pickup location (force because menu can go over browser view)
cy.get('#' + this.items.starfleetStandardLoan.code).click({force: true});
cy.get('#pickup').select(this.items.starfleetStandardLoan.pickupName);
cy.get('#pickup-location-' + itemPid + ' .btn').click();
cy.wait('@itemRequest');
// Go to user profile, on requests-tab
cy.visit('/global/patrons/profile');
cy.get('#requests-tab').click();
Expand All @@ -100,6 +103,7 @@ describe('Circulation scenario A: standard loan', function() {
/**
* Leonard validates James' request.
*/
cy.intercept('POST', '/api/item/validate_request').as('validateRequest');
cy.adminLogin(this.users.librarians.leonard.email, this.common.uniquePwd);
// Go to requests list
cy.get('#user-services-menu').click();
Expand All @@ -108,7 +112,7 @@ describe('Circulation scenario A: standard loan', function() {
cy.get('#request-' + this.itemBarcode + ' [name="barcode"]').should('contain', this.itemBarcode);
// Enter the barcode and validate
cy.get('#search').type(this.itemBarcode).type('{enter}');

cy.wait('@validateRequest');
// The item should be marked as available in user profile view
// Go to patrons list
cy.get('#user-services-menu').click();
Expand All @@ -133,6 +137,7 @@ describe('Circulation scenario A: standard loan', function() {
cy.scanPatronBarcodeThenItemBarcode(this.users.patrons.james, this.itemBarcode);
// Item barcode should be present
cy.get('#item-' + this.itemBarcode).should('contain', this.itemBarcode);
cy.get('#item-' + this.itemBarcode).should('contain', this.common.itemAction.checkedOut);
});

it('4. The item is returned at owning library', function() {
Expand All @@ -148,7 +153,7 @@ describe('Circulation scenario A: standard loan', function() {
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');
cy.get('#item-' + this.itemBarcode).should('contain', this.common.itemStatus.onShelf);
cy.get('#item-' + this.itemBarcode).should('contain', this.common.itemAction.checkedIn);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,16 @@ describe('Circulation scenario B: standard loan with transit', function() {
/**
* James makes a request on item, to be picked up at Starfleet library
*/
cy.intercept('POST', '/api/item/request').as('itemRequest');
// Login as patron
cy.login(this.users.patrons.james.email, this.common.uniquePwd);
// Search for the item
cy.goToPublicDocumentDetailView(documentPid);
// Request the item
cy.get('#' + this.itemBarcode + '-dropdownMenu').click();
cy.get('#item-request-' + itemPid + ' .btn').click();
// Select pickup location (force because menu can go over browser view)
cy.get('#' + this.items.starfleetStandardLoanWithTransit.code).click({force: true});
cy.get('#pickup').select(this.items.starfleetStandardLoanWithTransit.pickupName);
cy.get('#pickup-location-' + itemPid + ' .btn').click(); cy.wait('@itemRequest');
// Go to user profile, directly on requests-tab
cy.visit('/global/patrons/profile');
cy.get('#requests-tab').click();
Expand All @@ -116,7 +118,7 @@ describe('Circulation scenario B: standard loan with transit', function() {
// Go to document detail view
cy.goToProfessionalDocumentDetailView(documentPid);
// Check that the item is in transit
cy.get('#item-' + this.itemBarcode + ' > [name="status"]').should('contain', 'transit');
cy.get('#item-' + this.itemBarcode + ' [name="status"]').should('contain', 'transit');
});

it('3. The item is received at destination library', function() {
Expand All @@ -129,7 +131,7 @@ describe('Circulation scenario B: standard loan with transit', function() {
// Enter item barcode for receive
cy.get('#search').type(this.itemBarcode).type('{enter}');
// Check that the item has been received
cy.get('#item-' + this.itemBarcode + ' [name="action-done"]').should('contain', 'receive');
cy.get('#item-' + this.itemBarcode + ' [name="action-done"]').should('contain', this.common.itemAction.receive);
});

it('4. The item is checked out for patron at second library', function() {
Expand All @@ -143,8 +145,8 @@ describe('Circulation scenario B: standard loan with transit', function() {
// Checkout
cy.scanPatronBarcodeThenItemBarcode(james, this.itemBarcode)
// Check that the checkout has been done
cy.get('#item-' + this.itemBarcode + ' [name="action-done"] > i')
.should('have.class', 'fa-arrow-circle-o-right')
cy.get('#item-' + this.itemBarcode + ' [name="action-done"]')
.should('contain', this.common.itemAction.checkedOut)
});

it('5. The item is returned at second library', function() {
Expand All @@ -157,11 +159,11 @@ describe('Circulation scenario B: standard loan with transit', function() {
// Checkin
cy.scanItemBarcode(this.itemBarcode);
// Check that the checkin has been done
cy.get('#item-' + this.itemBarcode + ' [name="action-done"] > i')
.should('have.class', 'fa-arrow-circle-o-down');
cy.get('#item-' + this.itemBarcode + ' [name="action-done"]')
.should('contain', this.common.itemAction.checkedIn);
// Check that the item is in transit
cy.get('#item-' + this.itemBarcode + ' [name="circ-info"] [name="status"]')
.should('contain', 'in transit');
.should('contain', this.common.itemStatus.transit);
});

it('6. The item is received at owning library', function() {
Expand All @@ -174,9 +176,9 @@ describe('Circulation scenario B: standard loan with transit', function() {
// Receive
cy.scanItemBarcode(this.itemBarcode);
// Check that the item has been received
cy.get('#item-' + this.itemBarcode + ' [name="action-done"]').should('contain', 'receive');
cy.get('#item-' + this.itemBarcode + ' [name="action-done"]').should('contain', this.common.itemAction.receive);
// Check that the item is on shelf
cy.get('#item-' + this.itemBarcode + ' [name="circ-info"] [name="status"]')
.should('contain', 'on shelf');
.should('contain', this.common.itemStatus.onShelf);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,15 @@ describe(`Test 'less than one day' checkout`, function() {
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', '/'));
cy.get('#item-' + this.itemBarcode + ' [name=action-done').should('contain', this.common.itemAction.checkedOut);
});

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');
cy.get('#item-' + this.itemBarcode).should('contain', this.common.itemStatus.onShelf);
cy.get('#item-' + this.itemBarcode).should('contain', this.common.itemAction.checkedIn);
});
});

0 comments on commit 93fbc54

Please sign in to comment.