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.
Merge branch 'main' into EVG-20806-2
- Loading branch information
Showing
41 changed files
with
716 additions
and
634 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,7 @@ | ||
// Mock focus-trap-react to prevent errors in tests that use modals. focus-trap-react is a package used | ||
// by LeafyGreen and is not a direct dependency of Spruce. | ||
const lib = jest.requireActual("focus-trap-react"); | ||
|
||
lib.prototype.setupFocusTrap = () => null; | ||
|
||
module.exports = lib; |
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,16 @@ | ||
// https://github.com/focus-trap/tabbable#testing-in-jsdom | ||
const lib = jest.requireActual("tabbable"); | ||
|
||
const tabbable = { | ||
...lib, | ||
tabbable: (node, options) => | ||
lib.tabbable(node, { ...options, displayCheck: "none" }), | ||
focusable: (node, options) => | ||
lib.focusable(node, { ...options, displayCheck: "none" }), | ||
isFocusable: (node, options) => | ||
lib.isFocusable(node, { ...options, displayCheck: "none" }), | ||
isTabbable: (node, options) => | ||
lib.isTabbable(node, { ...options, displayCheck: "none" }), | ||
}; | ||
|
||
module.exports = tabbable; |
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 |
---|---|---|
@@ -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
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
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
Oops, something went wrong.