-
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.
cypress: split commands.js in several files
* Splits commands.js in several files for better readability. * Adds circulation custom commands. Co-Authored-by: Alicia Zangger <alicia.zangger@rero.ch>
- Loading branch information
Alicia Zangger
committed
Aug 12, 2020
1 parent
8f4782e
commit a019cc3
Showing
7 changed files
with
211 additions
and
138 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/// <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/>. | ||
*/ | ||
// Scan the patron barcode, then the item barcode (this does a checkout) | ||
Cypress.Commands.add('scanPatronBarcodeThenItemBarcode', (patronBarcode, patronName, itemBarcode) => { | ||
// Enter patron barcode | ||
cy.get('#search').type(patronBarcode).type('{enter}'); | ||
// Assert that patron info is displayed | ||
cy.wait(3000) | ||
cy.get(':nth-child(2) > :nth-child(1) > .col-md-10', {timeout: 3000}) | ||
.should('contain', patronName) | ||
// Enter item barcode for checkout | ||
cy.get('#search').type(itemBarcode).type('{enter}'); | ||
}); | ||
|
||
// Scan the barcode of an item (this can do a checkin, a receive or "nothing", depending on context) | ||
Cypress.Commands.add('scanItemBarcode', (itemBarcode) => { | ||
// Enter item barcode for checkout | ||
cy.get('#search').type(itemBarcode).type('{enter}'); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/// <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/>. | ||
*/ | ||
// Go to user profile (using menus) | ||
// tabId: (not mandatory). If exists: go directly to given tabId | ||
Cypress.Commands.add("userProfile", (tabId) => { | ||
// we should be already connected | ||
cy.get('#my-account-menu').click() | ||
cy.get('#my-profile-menu').click() | ||
cy.wait(2500) | ||
// Go to tabId if exist | ||
if (tabId !== undefined) { | ||
cy.get('#' + tabId).click() | ||
} | ||
}) | ||
|
||
// Go to a specific menu from professional homepage | ||
// menuId: `id=` attribute content | ||
Cypress.Commands.add("goToMenu", (menuId) => { | ||
// Go to professional homepage | ||
cy.get('#homepage-logo').click() | ||
// if already on professional, do nothing | ||
cy.url().then((url) => { | ||
if (!url.includes('/professional/')) { | ||
cy.get('#my-account-menu').click() | ||
cy.get('#professional-interface-menu').click() | ||
cy.wait(800) | ||
} | ||
}) | ||
|
||
// Check we're on admin page | ||
cy.url().should('include', '/professional/') | ||
// Click on 'menuTitle' from Catalog menu | ||
cy.get('#' + menuId).click() | ||
}) | ||
|
||
Cypress.Commands.add("goToItem", (itemBarcode) => { | ||
// Go to homepage | ||
cy.get('#homepage-logo').click() | ||
cy.wait(800) | ||
cy.url().then((url) => { | ||
if (url.includes('/professional/')) { | ||
// on professional context | ||
cy.get('.form-control').type(itemBarcode).type('{enter}') | ||
} | ||
else { | ||
// on public context | ||
cy.get('.d-none > main-search-bar > .flex-grow-1 > .rero-ils-autocomplete > .form-control').type(itemBarcode).type('{enter}') | ||
} | ||
}) | ||
// Use first element | ||
cy.get('.card-title > a').click() | ||
}) |
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 @@ | ||
/// <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/>. | ||
*/ | ||
Cypress.Commands.add("createItem", (barcode, itemType, localisation) => { | ||
// Go to Catalog > Documents | ||
cy.goToMenu('documents-menu-frontpage') | ||
// Use one document (between first and tenth) | ||
let randomInteger = Math.floor((Math.random() * 9) + 1); | ||
cy.wait(2100) // because ngx-spinner hide the menu with a black transparent filter | ||
cy.get(':nth-child(' + randomInteger.toString() + ') > ng-core-record-search-result > admin-documents-brief-view > .card-title > a').click() | ||
// Click on "Add…" button to add an item | ||
cy.get('.col > .btn').click() | ||
// Fill in Item barcode | ||
cy.get('#barcode').type(barcode) | ||
// Wait that barcode to be checked (by API) | ||
cy.wait(800) | ||
// Fill in Item Call number with barcode content | ||
cy.get('#call_number').type(barcode) | ||
// Fill in Item Category | ||
cy.get('select').first().select(itemType) | ||
// Fill in localisation (could be 0, 1, etc. to select first element from select list) | ||
cy.get('select').eq(1).select(localisation) | ||
|
||
// Validate the form | ||
cy.get('.mt-4 > [type="submit"]').click() | ||
|
||
// Assert that the item has been created | ||
cy.contains(barcode, {timeout: 8000}) | ||
}) | ||
|
||
Cypress.Commands.add("deleteRecordFromDetailView", () => { | ||
// Delete record and confirm deletion | ||
cy.get('#detail-delete-button').click(); | ||
cy.get('#modal-confirm-button').click(); | ||
}); |
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,49 @@ | ||
/// <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/>. | ||
*/ | ||
// Logout | ||
Cypress.Commands.add("logout", () => { | ||
// click on username | ||
cy.get('#my-account-menu').click() | ||
// then click on Logout link | ||
cy.get('#logout-menu').click() | ||
}) | ||
|
||
Cypress.Commands.add("login", (email, password) => { | ||
// click on "My account" | ||
cy.get('#my-account-menu').click() | ||
cy.get('#login-menu').click() | ||
cy.get('#email').type(email) | ||
cy.get('#password').type(password) | ||
cy.get('form[name="login_user_form"]').submit() | ||
}) | ||
|
||
// Login to professional interface | ||
Cypress.Commands.add("adminLogin", (email, password) => { | ||
cy.login(email, password) | ||
cy.wait(1000) | ||
|
||
// set language to english BEFORE going to professional interface | ||
cy.setLanguageToEnglish() | ||
|
||
// go to professional interface | ||
cy.get('#my-account-menu').click() | ||
cy.get('#professional-interface-menu').click() | ||
cy.url().should('include', '/professional/') | ||
}) |