forked from evergreen-ci/spruce
-
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.
EVG-20177: Show Admin button to EVG admins (evergreen-ci#2035)
- Loading branch information
Showing
15 changed files
with
98 additions
and
24 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,2 @@ | ||
export const EVG_BASE_URL = "http://localhost:9090"; | ||
export const GQL_URL = `${EVG_BASE_URL}/graphql/query`; |
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,3 +1,5 @@ | ||
import { EVG_BASE_URL } from "../constants"; | ||
|
||
const PATCH_ID = "5e4ff3abe3c3317e352062e4"; | ||
const USER_ID = "admin"; | ||
const SPRUCE_URLS = { | ||
|
@@ -6,19 +8,22 @@ const SPRUCE_URLS = { | |
cli: `/preferences/cli`, | ||
}; | ||
const LEGACY_URLS = { | ||
version: `/version/${PATCH_ID}`, | ||
userPatches: `/patches/user/${USER_ID}`, | ||
distros: `/distros`, | ||
version: `${EVG_BASE_URL}/version/${PATCH_ID}`, | ||
userPatches: `${EVG_BASE_URL}/patches/user/${USER_ID}`, | ||
distros: `${EVG_BASE_URL}/distros`, | ||
admin: `${EVG_BASE_URL}/admin`, | ||
}; | ||
describe("Nav Bar", () => { | ||
const projectCookie = "mci-project-cookie"; | ||
|
||
it("Should have a nav bar linking to the proper page on the legacy UI", () => { | ||
cy.visit(SPRUCE_URLS.version); | ||
cy.dataCy("legacy-ui-link").should("exist"); | ||
cy.dataCy("legacy-ui-link") | ||
.should("have.attr", "href") | ||
.and("include", LEGACY_URLS.version); | ||
cy.dataCy("legacy-ui-link").should( | ||
"have.attr", | ||
"href", | ||
LEGACY_URLS.version | ||
); | ||
}); | ||
it("Navigating to a different page should change the nav link to the legacy UI", () => { | ||
cy.visit(SPRUCE_URLS.version); | ||
|
@@ -28,9 +33,11 @@ describe("Nav Bar", () => { | |
.and("include", LEGACY_URLS.version); | ||
cy.visit(SPRUCE_URLS.userPatches); | ||
cy.dataCy("legacy-ui-link").should("exist"); | ||
cy.dataCy("legacy-ui-link") | ||
.should("have.attr", "href") | ||
.and("include", LEGACY_URLS.userPatches); | ||
cy.dataCy("legacy-ui-link").should( | ||
"have.attr", | ||
"href", | ||
LEGACY_URLS.userPatches | ||
); | ||
}); | ||
it("Visiting a page with no legacy equivalent should not display a nav link", () => { | ||
cy.visit(SPRUCE_URLS.cli); | ||
|
@@ -41,9 +48,7 @@ describe("Nav Bar", () => { | |
cy.dataCy("legacy_route").should("not.exist"); | ||
cy.dataCy("auxiliary-dropdown-link").click(); | ||
cy.dataCy("legacy_route").should("exist"); | ||
cy.dataCy("legacy_route") | ||
.should("have.attr", "href") | ||
.and("include", LEGACY_URLS.distros); | ||
cy.dataCy("legacy_route").should("have.attr", "href", LEGACY_URLS.distros); | ||
}); | ||
it("Nav Dropdown should link to patches page of most recent project if cookie exists", () => { | ||
cy.setCookie(projectCookie, "spruce"); | ||
|
@@ -100,4 +105,33 @@ describe("Nav Bar", () => { | |
); | ||
cy.getCookie(projectCookie).should("have.property", "value", "spruce"); | ||
}); | ||
|
||
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.visit(SPRUCE_URLS.version); | ||
cy.dataCy("user-dropdown-link").click(); | ||
cy.dataCy("admin-link").should("not.exist"); | ||
}); | ||
|
||
it("Should show Admin button to admins", () => { | ||
cy.visit(SPRUCE_URLS.version); | ||
cy.dataCy("user-dropdown-link").click(); | ||
cy.dataCy("admin-link") | ||
.should("be.visible") | ||
.should("have.attr", "href", LEGACY_URLS.admin); | ||
}); | ||
}); | ||
}); |
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
3 changes: 2 additions & 1 deletion
3
cypress/integration/version/unscheduled_patch/configure_patch.ts
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
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
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 |
---|---|---|
|
@@ -14,6 +14,9 @@ export const getUserMock: ApolloMock<UserQuery, UserQueryVariables> = { | |
userId: "admin", | ||
displayName: "Evergreen Admin", | ||
emailAddress: "[email protected]", | ||
permissions: { | ||
canEditAdminSettings: 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,9 @@ query User { | |
user { | ||
displayName | ||
emailAddress | ||
permissions { | ||
canEditAdminSettings | ||
} | ||
userId | ||
} | ||
} |