Skip to content

Commit cf0b8fd

Browse files
committed
Fix test
1 parent 1729f2b commit cf0b8fd

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

site/src/pages/WorkspacePage/WorkspacePage.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ export const WorkspacePage: FC = () => {
1515
useParams()
1616
const username = firstOrItem(usernameQueryParam, null)
1717
const workspaceName = firstOrItem(workspaceQueryParam, null)
18-
const shouldRestartWorkspace = useLocation().state?.shouldRestartWorkspace ?? false
18+
const shouldRestartWorkspace =
19+
useLocation().state?.shouldRestartWorkspace ?? false
1920
const [workspaceState, workspaceSend] = useMachine(workspaceMachine)
2021
const {
2122
workspace,

site/src/pages/WorkspaceSchedulePage/WorkspaceSchedulePage.test.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import { MockUser, MockWorkspace, renderWithAuth } from "testHelpers/renderHelpers"
2+
import userEvent from "@testing-library/user-event"
3+
import { screen } from "@testing-library/react"
14
import {
25
formValuesToAutoStartRequest,
36
formValuesToTTLRequest,
@@ -241,4 +244,24 @@ describe("WorkspaceSchedulePage", () => {
241244
expect(ttlMsToAutoStop(ttlMs)).toEqual(autoStop)
242245
})
243246
})
247+
248+
describe("autoStop change dialog", () => {
249+
it("shows if autoStop is changed", async () => {
250+
renderWithAuth(<WorkspaceSchedulePage />, {
251+
route: `/@${MockUser.username}/${MockWorkspace.name}/schedule`,
252+
path: "/@:username/:workspace/schedule"
253+
})
254+
const user = userEvent.setup()
255+
const autoStopToggle = await screen.findByLabelText(
256+
FormLanguage.stopSwitch,
257+
)
258+
await user.click(autoStopToggle)
259+
const submitButton = await screen.findByRole("button", { name: /submit/i })
260+
await user.click(submitButton)
261+
const dialog = await screen.findByText(PageLanguage.dialogTitle)
262+
expect(dialog).toBeInTheDocument()
263+
})
264+
265+
266+
})
244267
})

site/src/pages/WorkspaceSchedulePage/WorkspaceSchedulePage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
formValuesToTTLRequest,
1717
} from "./formToRequest"
1818

19-
const Language = {
19+
export const Language = {
2020
forbiddenError:
2121
"You don't have permissions to update the schedule for this workspace.",
2222
getWorkspaceError: "Failed to fetch workspace.",

site/src/testHelpers/handlers.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ export const handlers = [
125125
const permissions = [
126126
...Object.keys(permissionsToCheck),
127127
"canUpdateTemplate",
128+
"updateWorkspace"
128129
]
129130
const response = permissions.reduce((obj, permission) => {
130131
return {

0 commit comments

Comments
 (0)