diff --git a/site/src/components/WorkspaceScheduleButton/WorkspaceScheduleButton.test.tsx b/site/src/components/WorkspaceScheduleButton/WorkspaceScheduleButton.test.tsx
index 5ee401f7be..8e504bfa11 100644
--- a/site/src/components/WorkspaceScheduleButton/WorkspaceScheduleButton.test.tsx
+++ b/site/src/components/WorkspaceScheduleButton/WorkspaceScheduleButton.test.tsx
@@ -1,8 +1,13 @@
+import { screen } from "@testing-library/react"
import dayjs from "dayjs"
import utc from "dayjs/plugin/utc"
+import { render } from "testHelpers/renderHelpers"
import * as TypesGen from "../../api/typesGenerated"
import * as Mocks from "../../testHelpers/entities"
-import { canEditDeadline } from "./WorkspaceScheduleButton"
+import {
+ canEditDeadline,
+ WorkspaceScheduleButton,
+} from "./WorkspaceScheduleButton"
dayjs.extend(utc)
@@ -24,4 +29,60 @@ describe("WorkspaceScheduleButton", () => {
expect(canEditDeadline(workspace)).toBeTruthy()
})
})
+ describe("enabling plus and minus buttons", () => {
+ it("should enable plus and minus buttons when deadline can be changed in either direction", async () => {
+ render(
+ ,
+ )
+ const plusButton = await screen.findByLabelText("Add hours to deadline")
+ const minusButton = await screen.findByLabelText(
+ "Subtract hours from deadline",
+ )
+ expect(plusButton).toBeEnabled()
+ expect(minusButton).toBeEnabled()
+ })
+ it("should disable plus button when deadline can't be extended", async () => {
+ render(
+ ,
+ )
+ const plusButton = await screen.findByLabelText("Add hours to deadline")
+ const minusButton = await screen.findByLabelText(
+ "Subtract hours from deadline",
+ )
+ expect(plusButton).toBeDisabled()
+ expect(minusButton).toBeEnabled()
+ })
+ it("should disable minus button when deadline can't be reduced", async () => {
+ render(
+ ,
+ )
+ const plusButton = await screen.findByLabelText("Add hours to deadline")
+ const minusButton = await screen.findByLabelText(
+ "Subtract hours from deadline",
+ )
+ expect(plusButton).toBeEnabled()
+ expect(minusButton).toBeDisabled()
+ })
+ })
})