Skip to content

Commit

Permalink
ACQUI-149: Pinia store cypress tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mblenk committed Jun 27, 2024
1 parent e7ba10c commit 88c4139
Show file tree
Hide file tree
Showing 7 changed files with 996 additions and 34 deletions.
5 changes: 3 additions & 2 deletions cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ module.exports = defineConfig({
},
experimentalStudio: true,
baseUrl: "http://localhost:8081",
specPattern: "tests/cypress/e2e/**/*.*",
specPattern: "tests/cypress/specs/**/*.*",
supportFile: "tests/cypress/support/e2e.js",
video: false
video: false,
screenshotOnRunFailure: false
},
});
14 changes: 7 additions & 7 deletions src/stores/acquisitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const useAcquisitionsStore = defineStore("acquisitions", {
const { loggedInUser: { loggedInBranch, branchcode } } = this.user
return loggedInBranch ? loggedInBranch : branchcode
},
mapSubGroups(group, filteredGroups, branch, groupsToCheck) {
_mapSubGroups(group, filteredGroups, branch, groupsToCheck) {
let matched = false
if (group.libraries.find(lib => lib.branchcode === branch)) {
if(groupsToCheck && groupsToCheck.length && groupsToCheck.includes(group.id)) {
Expand All @@ -40,7 +40,7 @@ export const useAcquisitionsStore = defineStore("acquisitions", {
}
if(group.sub_groups && group.sub_groups.length) {
group.sub_groups.forEach(grp => {
const result = this.mapSubGroups(grp, filteredGroups, branch, groupsToCheck)
const result = this._mapSubGroups(grp, filteredGroups, branch, groupsToCheck)
matched = matched ? matched : result
})
}
Expand All @@ -50,9 +50,9 @@ export const useAcquisitionsStore = defineStore("acquisitions", {
const branch = this.determineBranch(branchcode)
const filteredGroups = {}
this.libraryGroups.forEach(group => {
const matched = this.mapSubGroups(group, filteredGroups, branch, groupsToCheck)
const matched = this._mapSubGroups(group, filteredGroups, branch, groupsToCheck)
// If a sub group has been matched but the parent level group did not, then we should add the parent level group as well
// This happens when a parent group doesn't have nay branchcodes assigned to it, only sub groups
// This happens when a parent group doesn't have any branchcodes assigned to it, only sub groups
if (matched && !Object.keys(filteredGroups).find(id => id === group.id)) {
filteredGroups[group.id] = group
}
Expand All @@ -61,7 +61,7 @@ export const useAcquisitionsStore = defineStore("acquisitions", {
return filteredGroups[key]
}).sort((a,b) => a.id - b.id)
},
findBranchcodesInGroup(groups) {
_findBranchCodesInGroup(groups) {
const codes = []
groups.forEach(group => {
group.libraries.forEach(lib => {
Expand Down Expand Up @@ -141,8 +141,8 @@ export const useAcquisitionsStore = defineStore("acquisitions", {
this.owners = permittedUsers
data.owner = null
} else {
const groups = libGroups.filter(group => e.includes(group.id))
const branchcodes = this.findBranchcodesInGroup(groups)
const filteredGroups = libGroups.filter(group => e.includes(group.id))
const branchcodes = this._findBranchCodesInGroup(filteredGroups)
this.owners = this.filterUsersByPermissions(this.currentPermission, false, branchcodes)
}
},
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -53,28 +53,28 @@ describe("Acquisitions settings", () => {

});

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"
}
]
);
});
// 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");
})
})
// 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");
// })
// })
Loading

0 comments on commit 88c4139

Please sign in to comment.