-
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.
ACQUI-42: Add cypress tests for the settings module
- Loading branch information
Showing
3 changed files
with
213 additions
and
2 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,131 @@ | ||
|
||
describe("modulesEnabled", () => { | ||
beforeEach(() => { | ||
cy.login(); | ||
cy.title().should("eq", "Koha staff interface"); | ||
cy.intercept( | ||
"GET", | ||
"/api/v1/contrib/acquire/settings", | ||
[ | ||
{ | ||
"explanation": "Select which modules you wish to use in the acquisitions portal", | ||
"options": "", | ||
"type": "multiple", | ||
"value": "", | ||
"variable": "modulesEnabled" | ||
} | ||
] | ||
); | ||
}); | ||
|
||
it("Should correctly show the modules in modulesEnabled settings", () => { | ||
cy.intercept( | ||
"GET", | ||
"/api/v1/contrib/acquire/settings", | ||
[ | ||
{ | ||
"explanation": "Select which modules you wish to use in the acquisitions portal", | ||
"options": "", | ||
"type": "multiple", | ||
"value": "", | ||
"variable": "modulesEnabled" | ||
} | ||
] | ||
); | ||
cy.visit("/acquisitions/settings/general"); | ||
cy.get("#modulesEnabled").find(".vs__actions").click(); | ||
cy.get("#modulesEnabled").find("li").as("options"); | ||
cy.get("@options").should("have.length", 1); | ||
|
||
cy.get("#modulesEnabled .vs__open-indicator").click(); | ||
cy.get("#modulesEnabled .vs__dropdown-menu li:first").should( | ||
"have.text", | ||
"Funds and ledgers" | ||
); | ||
}) | ||
|
||
it("Should show newly selected modules on the settings homepage", () => { | ||
cy.intercept( | ||
"GET", | ||
"/api/v1/contrib/acquire/settings", | ||
[ | ||
{ | ||
"explanation": "Select which modules you wish to use in the acquisitions portal", | ||
"options": "", | ||
"type": "multiple", | ||
"value": "", | ||
"variable": "modulesEnabled" | ||
} | ||
] | ||
); | ||
cy.visit("/acquisitions/settings/general"); | ||
cy.get("#modulesEnabled .vs__search").type( | ||
"Funds and ledgers" + "{enter}", | ||
{ force: true } | ||
); | ||
|
||
cy.intercept( | ||
"GET", | ||
"/api/v1/contrib/acquire/settings", | ||
[ | ||
{ | ||
"explanation": "Select which modules you wish to use in the acquisitions portal", | ||
"options": "", | ||
"type": "multiple", | ||
"value": "funds", | ||
"variable": "modulesEnabled" | ||
} | ||
] | ||
); | ||
cy.get("#settingsForm > fieldset.action > input[type=submit]").click(); | ||
|
||
//Should navigate back to the settings homepage and show the new module | ||
cy.get("h1").contains("Settings"); | ||
cy.get(".navPanesGrid").children().should("have.length", 4); | ||
cy.get(".navPanesGrid > a:nth-child(3) > span").contains("Funds and ledgers"); | ||
}) | ||
|
||
it("Should show newly selected modules in the left hand menu", () => { | ||
cy.intercept( | ||
"GET", | ||
"/api/v1/contrib/acquire/settings", | ||
[ | ||
{ | ||
"explanation": "Select which modules you wish to use in the acquisitions portal", | ||
"options": "", | ||
"type": "multiple", | ||
"value": "", | ||
"variable": "modulesEnabled" | ||
} | ||
] | ||
); | ||
cy.visit("/acquisitions/settings/general"); | ||
cy.get("#modulesEnabled .vs__search").type( | ||
"Funds and ledgers" + "{enter}", | ||
{ force: true } | ||
); | ||
|
||
cy.intercept( | ||
"GET", | ||
"/api/v1/contrib/acquire/settings", | ||
[ | ||
{ | ||
"explanation": "Select which modules you wish to use in the acquisitions portal", | ||
"options": "", | ||
"type": "multiple", | ||
"value": "funds", | ||
"variable": "modulesEnabled" | ||
} | ||
] | ||
); | ||
cy.get("#settingsForm > fieldset.action > input[type=submit]").click(); | ||
|
||
//Should navigate back to the settings homepage and include the new module in the left hand menu | ||
cy.get("h1").contains("Settings"); | ||
cy.get("#navmenulist > h5").contains("Acquisitions"); | ||
cy.get("#navmenulist > ul").children().should("have.length", 3); | ||
cy.get("#navmenulist > ul > li:nth-child(1) > span > a > span").contains("Funds and ledgers"); | ||
cy.get("#navmenulist > ul > li:nth-child(2) > span > a > span").contains("Tasks"); | ||
cy.get("#navmenulist > ul > li:nth-child(3) > span > a > span").contains("Settings"); | ||
}) | ||
}); |
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,80 @@ | ||
describe("Acquisitions settings", () => { | ||
beforeEach(() => { | ||
cy.login(); | ||
cy.title().should("eq", "Koha staff interface"); | ||
cy.intercept( | ||
"GET", | ||
"/api/v1/contrib/acquire/settings", | ||
[ | ||
{ | ||
"explanation": "Select which modules you wish to use in the acquisitions portal", | ||
"options": "", | ||
"type": "multiple", | ||
"value": "", | ||
"variable": "modulesEnabled" | ||
} | ||
] | ||
); | ||
}); | ||
|
||
it("Should load the settings homepage", () => { | ||
cy.visit("/acquisitions/settings"); | ||
cy.get("h1").contains("Settings"); | ||
}); | ||
|
||
it("Should only show active modules and base modules", () => { | ||
cy.visit("/acquisitions/settings"); | ||
cy.get(".navPanesGrid").children().should("have.length", 3); | ||
cy.get(".navPanesGrid > a:nth-child(1) > span").contains("General"); | ||
cy.get(".navPanesGrid > a:nth-child(2) > span").contains("Task management"); | ||
cy.get(".navPanesGrid > a:nth-child(3) > span").contains("Manual"); | ||
}) | ||
|
||
it("Should show module settings in each Module", () => { | ||
// We'll use the general module for testing | ||
cy.intercept( | ||
"GET", | ||
"/api/v1/contrib/acquire/settings", | ||
[ | ||
{ | ||
"explanation": "Select which modules you wish to use in the acquisitions portal", | ||
"options": "", | ||
"type": "multiple", | ||
"value": "", | ||
"variable": "modulesEnabled" | ||
} | ||
] | ||
); | ||
cy.visit("/acquisitions/settings/general"); | ||
cy.get("h1").contains("General settings"); | ||
cy.get("#settingsList").children().should("have.length", 1); | ||
cy.get("#settingsList > li:nth-child(1) > label").contains("modulesEnabled:"); | ||
}) | ||
|
||
}); | ||
|
||
describe("Acquisitions settings for a user with no settings permissions", () => { | ||
beforeEach(() => { | ||
cy.login('CPLmanage_budgets', 'Test1234'); | ||
cy.title().should("eq", "Koha staff interface"); | ||
cy.intercept( | ||
"GET", | ||
"/api/v1/contrib/acquire/settings", | ||
[ | ||
{ | ||
"explanation": "Select which modules you wish to use in the acquisitions portal", | ||
"options": "", | ||
"type": "multiple", | ||
"value": "", | ||
"variable": "modulesEnabled" | ||
} | ||
] | ||
); | ||
}); | ||
|
||
it("Should only show the manual", () => { | ||
cy.visit("/acquisitions/settings"); | ||
cy.get(".navPanesGrid").children().should("have.length", 1); | ||
cy.get(".navPanesGrid > a:nth-child(1) > span").contains("Manual"); | ||
}) | ||
}) |