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.
DEVPROD-808: Use basic user to test non-admin views
- Loading branch information
Showing
4 changed files
with
34 additions
and
86 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 |
---|---|---|
@@ -1,83 +1,44 @@ | ||
describe("with various permission levels", () => { | ||
describe("distro permissions", () => { | ||
beforeEach(() => { | ||
cy.logout(); | ||
cy.login({ isAdmin: false }); | ||
}); | ||
|
||
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('input[type="checkbox"]').should( | ||
"have.attr", | ||
"aria-disabled", | ||
"true", | ||
); | ||
cy.get("textarea").should("be.disabled"); | ||
cy.get("button").should("have.attr", "aria-disabled", "true"); | ||
}); | ||
}); | ||
|
||
it("enables fields if user has edit permissions for a particular distro", () => { | ||
cy.visit("/distro/localhost/settings/general"); | ||
cy.dataCy("distro-settings-page").within(() => { | ||
cy.get('input[type="checkbox"]').should( | ||
"have.attr", | ||
"aria-disabled", | ||
"false", | ||
); | ||
cy.get("textarea").should("not.be.disabled"); | ||
}); | ||
}); | ||
}); |
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 |
---|---|---|
|
@@ -109,19 +109,8 @@ describe("Nav Bar", () => { | |
|
||
describe("Admin settings", () => { | ||
it("Should not show Admin button to non-admins", () => { | ||
const userData = { | ||
data: { | ||
user: { | ||
userId: "admin", | ||
displayName: "Evergreen Admin", | ||
emailAddress: "[email protected]", | ||
permissions: { | ||
canEditAdminSettings: false, | ||
}, | ||
}, | ||
}, | ||
}; | ||
cy.overwriteGQL("User", userData); | ||
cy.logout(); | ||
cy.login({ isAdmin: false }); | ||
cy.visit(SPRUCE_URLS.version); | ||
cy.dataCy("user-dropdown-link").click(); | ||
cy.dataCy("admin-link").should("not.exist"); | ||
|
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