-
Notifications
You must be signed in to change notification settings - Fork 889
feat: add workspaces banner for impending deletion #7538
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export * from "./useClickable" | ||
export * from "./useClickableTableRow" | ||
export * from "./useClipboard" | ||
export * from "./useFeatureVisibility" | ||
export * from "./useFilter" | ||
export * from "./useLocalStorage" | ||
export * from "./useMe" | ||
export * from "./useOrganizationId" | ||
export * from "./usePagination" | ||
export * from "./usePermissions" | ||
export * from "./useTab" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
interface UseLocalStorage { | ||
saveLocal: (arg0: string, arg1: string) => void | ||
getLocal: (arg0: string) => string | undefined | ||
clearLocal: (arg0: string) => void | ||
} | ||
|
||
export const useLocalStorage = (): UseLocalStorage => { | ||
return { | ||
saveLocal, | ||
getLocal, | ||
clearLocal, | ||
} | ||
} | ||
|
||
const saveLocal = (itemKey: string, itemValue: string): void => { | ||
window.localStorage.setItem(itemKey, itemValue) | ||
} | ||
|
||
const getLocal = (itemKey: string): string | undefined => { | ||
return localStorage.getItem(itemKey) ?? undefined | ||
} | ||
|
||
const clearLocal = (itemKey: string): void => { | ||
localStorage.removeItem(itemKey) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,11 +4,15 @@ import * as CreateDayString from "utils/createDayString" | |
import { | ||
MockWorkspace, | ||
MockWorkspacesResponse, | ||
} from "../../testHelpers/entities" | ||
import { history, render } from "../../testHelpers/renderHelpers" | ||
import { server } from "../../testHelpers/server" | ||
MockEntitlementsWithScheduling, | ||
MockWorkspacesResponseWithDeletions, | ||
} from "testHelpers/entities" | ||
import { history, renderWithAuth } from "testHelpers/renderHelpers" | ||
import { server } from "testHelpers/server" | ||
import WorkspacesPage from "./WorkspacesPage" | ||
import { i18n } from "i18n" | ||
import * as API from "api/api" | ||
import userEvent from "@testing-library/user-event" | ||
|
||
const { t } = i18n | ||
|
||
|
@@ -29,19 +33,39 @@ describe("WorkspacesPage", () => { | |
) | ||
|
||
// When | ||
render(<WorkspacesPage />) | ||
renderWithAuth(<WorkspacesPage />) | ||
|
||
// Then | ||
const text = t("emptyCreateWorkspaceMessage", { ns: "workspacesPage" }) | ||
await screen.findByText(text) | ||
}) | ||
|
||
it("renders a filled workspaces page", async () => { | ||
render(<WorkspacesPage />) | ||
renderWithAuth(<WorkspacesPage />) | ||
await screen.findByText(`${MockWorkspace.name}1`) | ||
const templateDisplayNames = await screen.findAllByText( | ||
`${MockWorkspace.template_display_name}`, | ||
) | ||
expect(templateDisplayNames).toHaveLength(MockWorkspacesResponse.count) | ||
}) | ||
|
||
it("displays banner for impending deletions", async () => { | ||
jest | ||
.spyOn(API, "getEntitlements") | ||
.mockResolvedValue(MockEntitlementsWithScheduling) | ||
|
||
jest | ||
.spyOn(API, "getWorkspaces") | ||
.mockResolvedValue(MockWorkspacesResponseWithDeletions) | ||
|
||
renderWithAuth(<WorkspacesPage />) | ||
|
||
const banner = await screen.findByText( | ||
"You have workspaces that will be deleted soon.", | ||
) | ||
const user = userEvent.setup() | ||
await user.click(screen.getByTestId("dismiss-banner-btn")) | ||
|
||
expect(banner).toBeEmptyDOMElement | ||
}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks like a rendering test - the test you want to check if something is rendered or not - do you think we should move this to the storybook? I feel this would be better to add it to jest. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test is checking flow - that the banner is visible until the user clicks 'Dismiss' and then it is hidden. However, adding a storybook is a great idea so I'll do that. |
||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️