mirror of
https://github.com/coder/coder.git
synced 2026-11-13 20:29:32 +08:00
* add workspace deletion dialog * add deleting_by query param * added test * filtering on workspaces to be deleted * cleaned up form * added story * added banner filter * PR feedback * fix lint and stories * PR feedback * added enterprise test * added unit tests in search_test.go * remove unused fn * unstaged changes
45 lines
1.4 KiB
TypeScript
45 lines
1.4 KiB
TypeScript
import { screen } from "@testing-library/react"
|
|
import { rest } from "msw"
|
|
import * as CreateDayString from "utils/createDayString"
|
|
import { MockWorkspace, MockWorkspacesResponse } from "testHelpers/entities"
|
|
import { history, renderWithAuth } from "testHelpers/renderHelpers"
|
|
import { server } from "testHelpers/server"
|
|
import WorkspacesPage from "./WorkspacesPage"
|
|
import { i18n } from "i18n"
|
|
|
|
const { t } = i18n
|
|
|
|
describe("WorkspacesPage", () => {
|
|
beforeEach(() => {
|
|
history.replace("/workspaces")
|
|
// Mocking the dayjs module within the createDayString file
|
|
const mock = jest.spyOn(CreateDayString, "createDayString")
|
|
mock.mockImplementation(() => "a minute ago")
|
|
})
|
|
|
|
it("renders an empty workspaces page", async () => {
|
|
// Given
|
|
server.use(
|
|
rest.get("/api/v2/workspaces", async (req, res, ctx) => {
|
|
return res(ctx.status(200), ctx.json({ workspaces: [], count: 0 }))
|
|
}),
|
|
)
|
|
|
|
// When
|
|
renderWithAuth(<WorkspacesPage />)
|
|
|
|
// Then
|
|
const text = t("emptyCreateWorkspaceMessage", { ns: "workspacesPage" })
|
|
await screen.findByText(text)
|
|
})
|
|
|
|
it("renders a filled workspaces page", async () => {
|
|
renderWithAuth(<WorkspacesPage />)
|
|
await screen.findByText(`${MockWorkspace.name}1`)
|
|
const templateDisplayNames = await screen.findAllByText(
|
|
`${MockWorkspace.template_display_name}`,
|
|
)
|
|
expect(templateDisplayNames).toHaveLength(MockWorkspacesResponse.count)
|
|
})
|
|
})
|