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.
- Loading branch information
Showing
9 changed files
with
82 additions
and
15 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 |
---|---|---|
|
@@ -5,20 +5,24 @@ const SPRUCE_URLS = { | |
userPatches: `/user/${USER_ID}/patches`, | ||
cli: `/preferences/cli`, | ||
}; | ||
const legacyBase = "http://localhost:9090"; | ||
const LEGACY_URLS = { | ||
version: `/version/${PATCH_ID}`, | ||
userPatches: `/patches/user/${USER_ID}`, | ||
distros: `/distros`, | ||
version: `${legacyBase}/version/${PATCH_ID}`, | ||
userPatches: `${legacyBase}/patches/user/${USER_ID}`, | ||
distros: `${legacyBase}/distros`, | ||
admin: `${legacyBase}/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 +32,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 +47,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 +104,31 @@ 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: { | ||
canUpdateAdminSettings: false, | ||
}, | ||
}, | ||
}, | ||
}; | ||
cy.overwriteGQL("User", userData); | ||
cy.visit(SPRUCE_URLS.version); | ||
cy.dataCy("admin-link").should("not.exist"); | ||
}); | ||
|
||
it("Should show Admin button to admins", () => { | ||
cy.visit(SPRUCE_URLS.version); | ||
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
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: { | ||
canUpdateAdminSettings: 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 { | ||
canUpdateAdminSettings | ||
} | ||
userId | ||
} | ||
} |