Skip to content

Job application tracker and AI-powered job search assistant. Helps job seekers manage their search journey with AI resume review, job matching, task logging, and application analytics, all while keeping your data private.

Add buttons to start and resume activity in BreakModal

Khuram Niaza946648bb29f
diff --git a/__tests__/activityBreak.spec.tsx b/__tests__/activityBreak.spec.tsx
index 3b6c7d1..6a05168 100644
--- a/__tests__/activityBreak.spec.tsx
+++ b/__tests__/activityBreak.spec.tsx
@@ -164,6 +164,33 @@ describe("BreakModal", () => {
expect(onClose).toHaveBeenCalled();
});
+ it("ends a running break from the Resume Activity button", async () => {
+ const value = contextValue();
+ const onClose = vi.fn();
+ (useActivity as any).mockReturnValue(value);
+
+ renderModal({ onClose });
+ await user.click(screen.getByRole("button", { name: "Resume Activity" }));
+
+ expect(value.endBreak).toHaveBeenCalled();
+ expect(onClose).toHaveBeenCalled();
+ });
+
+ it("starts the break from the Start Break button", async () => {
+ const value = notStartedValue();
+ const onClose = vi.fn();
+ (useActivity as any).mockReturnValue(value);
+
+ renderModal({ onClose });
+ expect(
+ screen.queryByRole("button", { name: "Resume Activity" }),
+ ).not.toBeInTheDocument();
+ await user.click(screen.getByRole("button", { name: "Start Break" }));
+
+ expect(value.startBreak).toHaveBeenCalledWith(15);
+ expect(onClose).not.toHaveBeenCalled();
+ });
+
it("stops the activity only after the confirmation is accepted", async () => {
const value = contextValue();
const onClose = vi.fn();
diff --git a/e2e/activities.spec.ts b/e2e/activities.spec.ts
index ce6c137..80e8e9e 100644
--- a/e2e/activities.spec.ts
+++ b/e2e/activities.spec.ts
@@ -176,12 +176,15 @@ test.describe.serial("Activities Management", () => {
await expect(breakDialog.getByText("Break", { exact: true })).toBeVisible();
await expect(breakDialog.getByText("15:00")).toBeVisible();
- await breakDialog.getByRole("button", { name: "Start break" }).click();
+ await breakDialog
+ .getByRole("button", { name: "Start break", exact: true })
+ .click();
// The centre control flipping to Resume proves the server opened the
// break: the context only re-renders from the action's returned activity.
const resumeButton = breakDialog.getByRole("button", {
name: "Resume activity",
+ exact: true,
});
await expect(resumeButton).toBeVisible({ timeout: 10000 });
// A running break drops the close X — Resume and Stop are the only exits.
diff --git a/src/components/activities/BreakModal.tsx b/src/components/activities/BreakModal.tsx
index 22ef59d..14945e3 100644
--- a/src/components/activities/BreakModal.tsx
+++ b/src/components/activities/BreakModal.tsx
@@ -219,6 +219,19 @@ export function BreakModal({ open, onClose }: BreakModalProps) {
</div>
<div className="flex w-full gap-2">
+ <Button
+ variant="outline"
+ className="flex-1"
+ disabled={pending}
+ onClick={isOnBreak ? handleResume : handleStart}
+ >
+ {isOnBreak ? (
+ <Pause className="mr-2 size-4" />
+ ) : (
+ <Play className="mr-2 size-4" />
+ )}
+ {isOnBreak ? "Resume Activity" : "Start Break"}
+ </Button>
<Button
variant="outline"
className="flex-1"