This repository has been archived by the owner on Jul 2, 2024. It is now read-only.
-
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.
EVG-21009: Make distro settings page readonly if user lacks edit perm…
…issions (#2086)
- Loading branch information
Showing
6 changed files
with
110 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
describe("with various permission levels", () => { | ||
it("hides the new distro button when a user cannot create distros", () => { | ||
const userData = { | ||
data: { | ||
user: { | ||
userId: "admin", | ||
permissions: { | ||
canCreateDistro: false, | ||
distroPermissions: { | ||
admin: true, | ||
edit: true, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; | ||
cy.overwriteGQL("UserDistroSettingsPermissions", userData); | ||
cy.visit("/distro/rhel71-power8-large/settings/general"); | ||
cy.dataCy("new-distro-button").should("not.exist"); | ||
cy.dataCy("delete-distro-button").should( | ||
"not.have.attr", | ||
"aria-disabled", | ||
"true" | ||
); | ||
cy.get("textarea").should("not.be.disabled"); | ||
}); | ||
|
||
it("disables the delete button when user lacks admin permissions", () => { | ||
const userData = { | ||
data: { | ||
user: { | ||
userId: "admin", | ||
permissions: { | ||
canCreateDistro: false, | ||
distroPermissions: { | ||
admin: false, | ||
edit: true, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; | ||
cy.overwriteGQL("UserDistroSettingsPermissions", userData); | ||
cy.visit("/distro/rhel71-power8-large/settings/general"); | ||
cy.dataCy("new-distro-button").should("not.exist"); | ||
cy.dataCy("delete-distro-button").should( | ||
"have.attr", | ||
"aria-disabled", | ||
"true" | ||
); | ||
cy.get("textarea").should("not.be.disabled"); | ||
}); | ||
|
||
it("disables fields when user lacks edit permissions", () => { | ||
const userData = { | ||
data: { | ||
user: { | ||
userId: "admin", | ||
permissions: { | ||
canCreateDistro: false, | ||
distroPermissions: { | ||
admin: false, | ||
edit: false, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; | ||
cy.overwriteGQL("UserDistroSettingsPermissions", userData); | ||
cy.visit("/distro/rhel71-power8-large/settings/general"); | ||
cy.dataCy("new-distro-button").should("not.exist"); | ||
cy.dataCy("delete-distro-button").should( | ||
"have.attr", | ||
"aria-disabled", | ||
"true" | ||
); | ||
cy.dataCy("distro-settings-page").within(() => { | ||
cy.get("input").should("be.disabled"); | ||
cy.get("textarea").should("be.disabled"); | ||
cy.get("button").should("have.attr", "aria-disabled", "true"); | ||
}); | ||
}); | ||
}); |
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
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