Skip to content

feat: offer to restart workspace when ttl is changed #5391

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

Merged
merged 19 commits into from
Dec 21, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix test
  • Loading branch information
presleyp committed Dec 12, 2022
commit cf0b8fdf338687aa0480068187d07a7b4f6579fd
3 changes: 2 additions & 1 deletion site/src/pages/WorkspacePage/WorkspacePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export const WorkspacePage: FC = () => {
useParams()
const username = firstOrItem(usernameQueryParam, null)
const workspaceName = firstOrItem(workspaceQueryParam, null)
const shouldRestartWorkspace = useLocation().state?.shouldRestartWorkspace ?? false
const shouldRestartWorkspace =
useLocation().state?.shouldRestartWorkspace ?? false
const [workspaceState, workspaceSend] = useMachine(workspaceMachine)
const {
workspace,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { MockUser, MockWorkspace, renderWithAuth } from "testHelpers/renderHelpers"
import userEvent from "@testing-library/user-event"
import { screen } from "@testing-library/react"
import {
formValuesToAutoStartRequest,
formValuesToTTLRequest,
Expand Down Expand Up @@ -241,4 +244,24 @@ describe("WorkspaceSchedulePage", () => {
expect(ttlMsToAutoStop(ttlMs)).toEqual(autoStop)
})
})

describe("autoStop change dialog", () => {
it("shows if autoStop is changed", async () => {
renderWithAuth(<WorkspaceSchedulePage />, {
route: `/@${MockUser.username}/${MockWorkspace.name}/schedule`,
path: "/@:username/:workspace/schedule"
})
const user = userEvent.setup()
const autoStopToggle = await screen.findByLabelText(
FormLanguage.stopSwitch,
)
await user.click(autoStopToggle)
const submitButton = await screen.findByRole("button", { name: /submit/i })
await user.click(submitButton)
const dialog = await screen.findByText(PageLanguage.dialogTitle)
expect(dialog).toBeInTheDocument()
})


})
})
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
formValuesToTTLRequest,
} from "./formToRequest"

const Language = {
export const Language = {
forbiddenError:
"You don't have permissions to update the schedule for this workspace.",
getWorkspaceError: "Failed to fetch workspace.",
Expand Down
1 change: 1 addition & 0 deletions site/src/testHelpers/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export const handlers = [
const permissions = [
...Object.keys(permissionsToCheck),
"canUpdateTemplate",
"updateWorkspace"
]
const response = permissions.reduce((obj, permission) => {
return {
Expand Down