-
Notifications
You must be signed in to change notification settings - Fork 310
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
web: don't display account menu item when offline snapshots are enabl…
…ed (#5799)
- Loading branch information
1 parent
8da4bc6
commit 9a6593a
Showing
5 changed files
with
174 additions
and
78 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
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,42 +1,85 @@ | ||
import { render, screen } from "@testing-library/react" | ||
import React from "react" | ||
import ReactModal from "react-modal" | ||
import { AccountMenuContent } from "./AccountMenu" | ||
import { AccountMenuContent, AccountMenuDialog } from "./AccountMenu" | ||
import Features, { FeaturesTestProvider, Flag } from "./feature" | ||
|
||
beforeEach(() => { | ||
// Note: `body` is used as the app element _only_ in a test env | ||
// since the app root element isn't available; in prod, it should | ||
// be set as the app root so that accessibility features are set correctly | ||
ReactModal.setAppElement(document.body) | ||
}) | ||
describe("AccountMenuDialog", () => { | ||
it("does render when offline snapshot creation is NOT enabled", () => { | ||
const features = new Features({ [Flag.OfflineSnapshotCreation]: false }) | ||
render( | ||
<AccountMenuDialog | ||
open={true} | ||
onClose={() => {}} | ||
anchorEl={document.body} | ||
tiltCloudUsername="" | ||
tiltCloudSchemeHost="http://cloud.tilt.dev" | ||
tiltCloudTeamID="" | ||
tiltCloudTeamName="" | ||
/>, | ||
{ | ||
wrapper: ({ children }) => ( | ||
<FeaturesTestProvider value={features} children={children} /> | ||
), | ||
} | ||
) | ||
|
||
it("renders Sign Up button when user is not signed in", () => { | ||
render( | ||
<AccountMenuContent | ||
tiltCloudUsername="" | ||
tiltCloudSchemeHost="http://cloud.tilt.dev" | ||
tiltCloudTeamID="" | ||
tiltCloudTeamName="" | ||
isSnapshot={false} | ||
/> | ||
) | ||
expect( | ||
screen.getByRole("button", { name: "Link Tilt to Tilt Cloud" }) | ||
).toBeInTheDocument() | ||
}) | ||
|
||
expect( | ||
screen.getByRole("button", { name: "Link Tilt to Tilt Cloud" }) | ||
).toBeInTheDocument() | ||
}) | ||
it("does NOT render when offline snapshot creation is enabled", () => { | ||
const features = new Features({ [Flag.OfflineSnapshotCreation]: true }) | ||
render( | ||
<AccountMenuDialog | ||
open={true} | ||
onClose={() => {}} | ||
anchorEl={document.body} | ||
tiltCloudUsername="" | ||
tiltCloudSchemeHost="http://cloud.tilt.dev" | ||
tiltCloudTeamID="" | ||
tiltCloudTeamName="" | ||
/>, | ||
{ | ||
wrapper: ({ children }) => ( | ||
<FeaturesTestProvider value={features} children={children} /> | ||
), | ||
} | ||
) | ||
|
||
expect( | ||
screen.queryByRole("button", { name: "Link Tilt to Tilt Cloud" }) | ||
).toBeNull() | ||
}) | ||
|
||
describe("AccountMenuContent", () => { | ||
it("renders Sign Up button when user is not signed in", () => { | ||
render( | ||
<AccountMenuContent | ||
tiltCloudUsername="" | ||
tiltCloudSchemeHost="http://cloud.tilt.dev" | ||
tiltCloudTeamID="" | ||
tiltCloudTeamName="" | ||
/> | ||
) | ||
|
||
expect( | ||
screen.getByRole("button", { name: "Link Tilt to Tilt Cloud" }) | ||
).toBeInTheDocument() | ||
}) | ||
|
||
it("renders TiltCloud button when user is signed in", () => { | ||
render( | ||
<AccountMenuContent | ||
tiltCloudUsername="amaia" | ||
tiltCloudSchemeHost="http://cloud.tilt.dev" | ||
tiltCloudTeamID="cactus inc" | ||
tiltCloudTeamName="" | ||
isSnapshot={false} | ||
/> | ||
) | ||
expect( | ||
screen.getByRole("link", { name: "View Tilt Cloud" }) | ||
).toBeInTheDocument() | ||
it("renders TiltCloud button when user is signed in", () => { | ||
render( | ||
<AccountMenuContent | ||
tiltCloudUsername="amaia" | ||
tiltCloudSchemeHost="http://cloud.tilt.dev" | ||
tiltCloudTeamID="cactus inc" | ||
tiltCloudTeamName="" | ||
/> | ||
) | ||
expect( | ||
screen.getByRole("link", { name: "View Tilt Cloud" }) | ||
).toBeInTheDocument() | ||
}) | ||
}) | ||
}) |
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