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.

fix failings tests

Khuram Niaz21212835e457
diff --git a/__tests__/AddJob.spec.tsx b/__tests__/AddJob.spec.tsx
index 9a78b2f..8742591 100644
--- a/__tests__/AddJob.spec.tsx
+++ b/__tests__/AddJob.spec.tsx
@@ -261,7 +261,7 @@ describe("AddJob Component", () => {
dateApplied: undefined,
salaryRange: "1",
jobDescription: "<p>New Job Description</p>",
- jobUrl: undefined,
+ jobUrl: "",
applied: false,
tags: [],
});
diff --git a/__tests__/JobsAppliedCard.spec.tsx b/__tests__/JobsAppliedCard.spec.tsx
index 89e0889..dd48c0b 100644
--- a/__tests__/JobsAppliedCard.spec.tsx
+++ b/__tests__/JobsAppliedCard.spec.tsx
@@ -15,20 +15,20 @@ describe("JobsAppliedCard", () => {
(useRouter as any).mockReturnValue({ push: mockPush });
});
- it("should navigate to myjobs with add-job=true when New Job button is clicked", async () => {
+ it("should navigate to myjobs with add-job=true when Job button is clicked", async () => {
const user = userEvent.setup();
render(<JobsAppliedCard />);
- await user.click(screen.getByRole("button", { name: /new job/i }));
+ await user.click(screen.getByRole("button", { name: /^job$/i }));
expect(mockPush).toHaveBeenCalledWith("/dashboard/myjobs?add-job=true");
});
- it("should navigate to tasks page with add-task=true when New Task button is clicked", async () => {
+ it("should navigate to tasks page with add-task=true when Task button is clicked", async () => {
const user = userEvent.setup();
render(<JobsAppliedCard />);
- await user.click(screen.getByRole("button", { name: /new task/i }));
+ await user.click(screen.getByRole("button", { name: /^task$/i }));
expect(mockPush).toHaveBeenCalledWith("/dashboard/tasks?add-task=true");
});
diff --git a/e2e/dashboard.spec.ts b/e2e/dashboard.spec.ts
index 5ad1dcb..c88362f 100644
--- a/e2e/dashboard.spec.ts
+++ b/e2e/dashboard.spec.ts
@@ -3,21 +3,41 @@ import {
test,
expect,
createNewJob,
+ selectOrCreate,
uniqueName,
type CleanupRegistry,
} from "./fixtures";
async function navigateToDashboard(page: Page) {
await page.goto("/dashboard");
- await page.waitForLoadState("networkidle");
await expect(
page.getByRole("heading", { name: "Dashboard", exact: true }),
).toBeVisible();
}
+// The running activity is a per-user singleton and specs run in parallel
+// against one shared user, so a concurrently running spec can interleave a
+// switch-confirm around our stop click. Retry the whole click/confirm
+// handshake until the Stop button actually disappears.
+async function stopRunningActivity(page: Page) {
+ const stopButton = page.getByRole("button", {
+ name: "Stop Activity",
+ exact: true,
+ });
+ const confirmSwitchBtn = page.getByRole("button", { name: "Stop & Start" });
+ await expect(async () => {
+ if (await stopButton.isVisible().catch(() => false)) {
+ await stopButton.click({ force: true });
+ }
+ if (await confirmSwitchBtn.isVisible().catch(() => false)) {
+ await confirmSwitchBtn.click({ force: true });
+ }
+ await expect(stopButton).not.toBeVisible({ timeout: 2000 });
+ }).toPass({ timeout: 10000 });
+}
+
async function navigateToTasks(page: Page) {
await page.goto("/dashboard/tasks");
- await page.waitForLoadState("networkidle");
await page.getByTestId("add-task-btn").waitFor({ state: "visible" });
}
@@ -63,6 +83,38 @@ async function createTaskWithActivityType(
cleanup.task(title);
}
+// The New Activity dialog pre-fills valid start/end times (now .. now+5m),
+// so this creates a completed activity that lands directly in the recent
+// activities list without waiting on ACTIVITY_MIN_DURATION_MINUTES.
+async function createCompletedActivity(
+ page: Page,
+ activityName: string,
+ activityType: string,
+ cleanup: CleanupRegistry,
+) {
+ await page.goto("/dashboard/activities");
+ await page.getByTestId("add-activity-btn").waitFor({ state: "visible" });
+ await page.getByTestId("add-activity-btn").click();
+ await expect(page.getByText("Add New Activity")).toBeVisible();
+
+ await page
+ .getByPlaceholder("Ex: Job Search, Learning skill, etc")
+ .fill(activityName);
+ await selectOrCreate(
+ page,
+ "Activity Type",
+ "Create or Search activityType",
+ activityType,
+ );
+ cleanup.activityType(activityType);
+
+ await page.getByTestId("save-activity-btn").click();
+ await expect(page.getByText("Add New Activity")).not.toBeVisible({
+ timeout: 10000,
+ });
+ cleanup.activity(activityName);
+}
+
test.describe("Dashboard page", () => {
test("should display all dashboard sections and reflect a newly applied job", async ({
page,
@@ -117,7 +169,7 @@ test.describe("Dashboard page", () => {
).toBeVisible();
});
- test("should navigate to create a new job and a new task from dashboard quick actions", async ({
+ test("should navigate to create a new job, task, question, and automation from dashboard quick actions", async ({
page,
}) => {
await page.getByRole("button", { name: "Job", exact: true }).click();
@@ -129,6 +181,26 @@ test.describe("Dashboard page", () => {
await navigateToDashboard(page);
await page.getByRole("button", { name: "Task", exact: true }).click();
await expect(page).toHaveURL(/\/dashboard\/tasks/);
+ await expect(page.getByTestId("task-form-dialog-title")).toBeVisible();
+ await page.getByRole("button", { name: "Cancel" }).click();
+ await expect(page.getByTestId("task-form-dialog-title")).not.toBeVisible();
+
+ await navigateToDashboard(page);
+ await page.getByRole("button", { name: "Question", exact: true }).click();
+ await expect(page).toHaveURL(/\/dashboard\/questions/);
+ await expect(page.getByTestId("question-form-dialog-title")).toBeVisible();
+ await page.getByRole("button", { name: "Cancel" }).click();
+ await expect(
+ page.getByTestId("question-form-dialog-title"),
+ ).not.toBeVisible();
+
+ await navigateToDashboard(page);
+ await page.getByRole("button", { name: "Automation", exact: true }).click();
+ await expect(page).toHaveURL(/\/dashboard\/automations/);
+ const wizard = page.getByRole("dialog");
+ await expect(wizard.getByText("Step 1 of 6")).toBeVisible();
+ await wizard.getByRole("button", { name: "Close" }).click();
+ await expect(wizard).not.toBeVisible();
});
test("should toggle the recent, weekly, jobs and activities cards", async ({
@@ -187,13 +259,10 @@ test.describe("Dashboard page", () => {
// No conflicting activity, continue.
}
await expect(
- page.getByRole("button", { name: "Stop" }),
+ page.getByRole("button", { name: "Stop Activity", exact: true }),
).toBeVisible({ timeout: 10000 });
- await page.getByRole("button", { name: "Stop" }).click({ force: true });
- await expect(page.getByRole("button", { name: "Stop" })).not.toBeVisible({
- timeout: 10000,
- });
+ await stopRunningActivity(page);
await navigateToDashboard(page);
await page
@@ -202,4 +271,47 @@ test.describe("Dashboard page", () => {
.click();
await expect(page.getByText(taskTitle, { exact: true })).not.toBeVisible();
});
+
+ test("should start an activity from the dashboard's recent activities list", async ({
+ page,
+ cleanup,
+ }) => {
+ const activityName = uniqueName("E2E Recent Activity");
+ const activityType = uniqueName("E2E Recent Activity Type");
+ await createCompletedActivity(page, activityName, activityType, cleanup);
+
+ await navigateToDashboard(page);
+ await page
+ .getByTestId("recent-card-toggle-group")
+ .getByRole("button", { name: "Activities" })
+ .click();
+
+ const activityRow = page
+ .getByTestId("recent-activity-row")
+ .filter({ hasText: activityName });
+ await expect(activityRow).toBeVisible({ timeout: 10000 });
+
+ // The play button is hover-revealed (opacity-0 -> opacity-100 on
+ // group-hover), so hover the row before clicking it.
+ await activityRow.hover();
+ await activityRow
+ .getByTestId("recent-activity-start-btn")
+ .click({ force: true });
+
+ // If another activity was already running (e.g. from a concurrently
+ // running spec), confirm the switch instead of hanging on the dialog.
+ const confirmSwitchBtn = page.getByRole("button", { name: "Stop & Start" });
+ try {
+ await confirmSwitchBtn.waitFor({ state: "visible", timeout: 3000 });
+ await confirmSwitchBtn.click();
+ } catch {
+ // No conflicting activity, continue.
+ }
+
+ await expect(
+ page.getByRole("button", { name: "Stop Activity", exact: true }),
+ ).toBeVisible({ timeout: 10000 });
+
+ await stopRunningActivity(page);
+ });
});
diff --git a/src/components/automations/AutomationContainer.tsx b/src/components/automations/AutomationContainer.tsx
index 892ca3f..7c439bd 100644
--- a/src/components/automations/AutomationContainer.tsx
+++ b/src/components/automations/AutomationContainer.tsx
@@ -1,6 +1,6 @@
"use client";
-import { useCallback, useEffect, useState } from "react";
+import { useCallback, useEffect, useRef, useState } from "react";
import { useRouter, useSearchParams } from "next/navigation";
import { Card, CardContent, CardTitle } from "@/components/ui/card";
import { ResponsiveCardHeader } from "@/components/ResponsiveCardHeader";
@@ -30,6 +30,7 @@ export function AutomationContainer({ resumes }: AutomationContainerProps) {
const [wizardOpen, setWizardOpen] = useState(false);
const [editAutomation, setEditAutomation] =
useState<AutomationWithResume | null>(null);
+ const autoOpenHandled = useRef(false);
const loadAutomations = useCallback(async () => {
setLoading(true);
@@ -52,7 +53,9 @@ export function AutomationContainer({ resumes }: AutomationContainerProps) {
}, [loadAutomations]);
useEffect(() => {
- if (!wizardOpen && searchParams.get("add-automation") === "true") {
+ if (autoOpenHandled.current) return;
+ if (searchParams.get("add-automation") === "true") {
+ autoOpenHandled.current = true;
setWizardOpen(true);
const params = new URLSearchParams(searchParams.toString());
params.delete("add-automation");
@@ -61,7 +64,7 @@ export function AutomationContainer({ resumes }: AutomationContainerProps) {
: window.location.pathname;
router.replace(newPath);
}
- }, [wizardOpen, router, searchParams]);
+ }, [router, searchParams]);
const handleEdit = (automation: AutomationWithResume) => {
setEditAutomation(automation);
diff --git a/src/components/dashboard/RecentCardToggle.tsx b/src/components/dashboard/RecentCardToggle.tsx
index 5096366..da6a27a 100644
--- a/src/components/dashboard/RecentCardToggle.tsx
+++ b/src/components/dashboard/RecentCardToggle.tsx
@@ -156,10 +156,12 @@ export default function RecentCardToggle({
{dateActivities.map((activity) => (
<div
key={activity.id}
+ data-testid="recent-activity-row"
className="group relative flex items-center gap-1"
>
<Button
title="Start Activity"
+ data-testid="recent-activity-start-btn"
size="icon"
variant="ghost"
onClick={() => requestStart(() => startActivity(activity.id))}
diff --git a/src/components/myjobs/AddJob.tsx b/src/components/myjobs/AddJob.tsx
index 7295acc..605f5d2 100644
--- a/src/components/myjobs/AddJob.tsx
+++ b/src/components/myjobs/AddJob.tsx
@@ -104,6 +104,7 @@ export function AddJob({
dueDate: addDays(new Date(), 3),
status: jobStatuses[0]?.id,
salaryRange: "1",
+ jobUrl: "",
};
const form = useForm<z.infer<typeof AddJobFormSchema>>({
@@ -153,7 +154,7 @@ export function AddJob({
salaryRange: editJob.salaryRange,
jobDescription: editJob.description,
applied: editJob.applied,
- jobUrl: editJob.jobUrl ?? undefined,
+ jobUrl: editJob.jobUrl ?? "",
dateApplied: editJob.appliedDate ?? undefined,
resume: editJob.Resume?.id ?? undefined,
coverLetter: editJob.CoverLetter?.id ?? undefined,
diff --git a/src/components/questions/QuestionsContainer.tsx b/src/components/questions/QuestionsContainer.tsx
index b35bedc..63210bc 100644
--- a/src/components/questions/QuestionsContainer.tsx
+++ b/src/components/questions/QuestionsContainer.tsx
@@ -46,6 +46,7 @@ function QuestionsContainer({
const [dialogOpen, setDialogOpen] = useState(false);
const [searchTerm, setSearchTerm] = useState("");
const hasSearched = useRef(false);
+ const autoOpenHandled = useRef(false);
const loadQuestions = useCallback(
async (pageNum: number, filter?: string, search?: string) => {
@@ -99,7 +100,9 @@ function QuestionsContainer({
};
useEffect(() => {
- if (!dialogOpen && searchParams.get("add-question") === "true") {
+ if (autoOpenHandled.current) return;
+ if (searchParams.get("add-question") === "true") {
+ autoOpenHandled.current = true;
setDialogOpen(true);
const params = new URLSearchParams(searchParams.toString());
params.delete("add-question");
@@ -108,7 +111,7 @@ function QuestionsContainer({
: window.location.pathname;
router.replace(newPath);
}
- }, [dialogOpen, router, searchParams]);
+ }, [router, searchParams]);
useEffect(() => {
loadQuestions(1, filterKey, searchTerm || undefined);
diff --git a/src/components/tasks/TasksContainer.tsx b/src/components/tasks/TasksContainer.tsx
index d7dc38d..e6558da 100644
--- a/src/components/tasks/TasksContainer.tsx
+++ b/src/components/tasks/TasksContainer.tsx
@@ -82,6 +82,7 @@ function TasksContainer({
const [searchTerm, setSearchTerm] = useState("");
const hasSearched = useRef(false);
const sentinelRef = useRef<HTMLDivElement>(null);
+ const autoOpenHandled = useRef(false);
const [mounted, setMounted] = useState(false);
// Avoid hydration mismatch with Radix UI components
@@ -178,7 +179,9 @@ function TasksContainer({
};
useEffect(() => {
- if (!dialogOpen && searchParams.get("add-task") === "true") {
+ if (autoOpenHandled.current) return;
+ if (searchParams.get("add-task") === "true") {
+ autoOpenHandled.current = true;
setDialogOpen(true);
const params = new URLSearchParams(searchParams.toString());
params.delete("add-task");
@@ -187,7 +190,7 @@ function TasksContainer({
: window.location.pathname;
router.replace(newPath);
}
- }, [dialogOpen, router, searchParams]);
+ }, [router, searchParams]);
useEffect(() => {
(async () =>