Skip to content

fix: use template default ttl when enabling auto-stop #5494

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 6 commits into from
Dec 22, 2022
Merged
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
Add test
  • Loading branch information
presleyp committed Dec 22, 2022
commit 154dd2e298055c4ba114efe06db847a9f194de4e
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import {
} from "components/WorkspaceScheduleForm/WorkspaceScheduleForm"
import { WorkspaceSchedulePage } from "./WorkspaceSchedulePage"
import i18next from "i18next"
import { server } from "testHelpers/server"
import { rest } from "msw"

const { t } = i18next

Expand Down Expand Up @@ -295,4 +297,37 @@ describe("WorkspaceSchedulePage", () => {
expect(dialog).not.toBeInTheDocument()
})
})

describe("autostop", () => {
it("uses template default ttl when first enabled", async () => {
// have auto-stop disabled
server.use(
rest.get(
"/api/v2/users/:userId/workspace/:workspaceName",
(req, res, ctx) => {
return res(
ctx.status(200),
ctx.json({ ...MockWorkspace, ttl_ms: 0 }),
)
},
),
)
renderWithAuth(<WorkspaceSchedulePage />, {
route: `/@${MockUser.username}/${MockWorkspace.name}/schedule`,
path: "/@:username/:workspace/schedule",
})
const user = userEvent.setup()
const autoStopToggle = await screen.findByLabelText(
FormLanguage.stopSwitch,
)
// enable auto-stop
await user.click(autoStopToggle)
// find helper text that describes the mock template's 24 hour default
const autoStopHelperText = await screen.findByText(
"Your workspace will shut down a day after",
{ exact: false },
)
expect(autoStopHelperText).toBeDefined()
})
})
})