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.
TypeScript ai-agentai-resume-analyzerapplication-trackerapplication-tracking-systematscareerjob-applicationjob-automationjob-huntingjob-searchjob-seeker-toolsjob-trackerjob-trackingjobsearchjobseekersmcpollamaresumeresume-reviewself-hosted
feat: add Question Bank e2e tests; fix stale tag chip on edit
Khuram Niaz664f7d1aac94
diff --git a/e2e/fixtures.ts b/e2e/fixtures.tsindex 208092f..fa5ec1a 100644--- a/e2e/fixtures.ts+++ b/e2e/fixtures.ts@@ -118,6 +118,7 @@ export type CleanupRegistry = {job: (id: string) => void;resume: (title: string) => void;task: (title: string) => void;+ question: (text: string) => void;title: (name: string) => void;company: (name: string) => void;location: (name: string) => void;@@ -142,6 +143,7 @@ export const test = base.extend<Fixtures>({const jobIds: string[] = [];const resumes: string[] = [];const tasks: string[] = [];+ const questions: string[] = [];const titles: string[] = [];const companies: string[] = [];const locations: string[] = [];@@ -152,6 +154,7 @@ export const test = base.extend<Fixtures>({job: (id) => jobIds.push(id),resume: (title) => resumes.push(title),task: (title) => tasks.push(title),+ question: (text) => questions.push(text),title: (name) => titles.push(name),company: (name) => companies.push(name),location: (name) => locations.push(name),@@ -166,6 +169,7 @@ export const test = base.extend<Fixtures>({jobIds,resumes,tasks,+ questions,titles,companies,locations,diff --git a/e2e/questions.spec.ts b/e2e/questions.spec.tsnew file mode 100644index 0000000..9d86242--- /dev/null+++ b/e2e/questions.spec.ts@@ -0,0 +1,225 @@+import { type Page } from "@playwright/test";+import { test, expect, uniqueName, type CleanupRegistry } from "./fixtures";++async function navigateToQuestions(page: Page) {+ await page.goto("/dashboard/questions");+ await page.waitForLoadState("networkidle");+ await page+ .getByRole("button", { name: "New Question" })+ .waitFor({ state: "visible" });+}++async function createQuestion(+ page: Page,+ questionText: string,+ answerText: string,+ cleanup: CleanupRegistry,+ options?: { tag?: string },+) {+ await page.getByRole("button", { name: "New Question" }).click();+ await expect(page.getByTestId("question-form-dialog-title")).toBeVisible();+ await page.getByPlaceholder("Enter interview question").fill(questionText);++ if (options?.tag) {+ await page+ .getByRole("combobox", { name: "Search or add a skill..." })+ .click();+ await page.getByPlaceholder("Type a skill...").fill(options.tag);+ await page.getByText(`Create "${options.tag}"`).click();+ // Wait for the create server action to resolve and the field to update+ // (the badge only renders once the tag id lands in form state).+ await expect(page.getByText(options.tag, { exact: true })).toBeVisible();+ cleanup.tag(options.tag);+ }++ // Scope to the dialog: existing question cards render their answers+ // through a read-only TipTapContentViewer that also uses the ".tiptap"+ // class, so an unscoped locator matches those too.+ const answerEditor = page.getByRole("dialog").locator(".tiptap");+ await answerEditor.click();+ await answerEditor.fill(answerText);++ await page.getByRole("button", { name: "Save" }).click();+ await expect(+ page.getByTestId("question-form-dialog-title"),+ ).not.toBeVisible({ timeout: 10000 });+ cleanup.question(questionText);+}++function questionCard(page: Page, questionText: string) {+ return page.getByTestId("question-card").filter({ hasText: questionText });+}++test.describe("Question Bank", () => {+ test("should create a new question", async ({ page, cleanup }) => {+ const questionText = uniqueName("E2E Test Question");+ await navigateToQuestions(page);+ await createQuestion(+ page,+ questionText,+ "This is a test answer for e2e coverage.",+ cleanup,+ );++ await expect(+ page.getByRole("heading", { name: questionText }),+ ).toBeVisible({ timeout: 10000 });+ });++ test("should edit an existing question", async ({ page, cleanup }) => {+ const editQuestionText = uniqueName("E2E Edit Question");+ const updatedQuestionText = uniqueName("E2E Edit Question Updated");+ // Register the updated text too, since it's what the card becomes on success.+ cleanup.question(updatedQuestionText);+ await navigateToQuestions(page);+ await createQuestion(+ page,+ editQuestionText,+ "Original answer text for editing.",+ cleanup,+ );+ await expect(+ page.getByRole("heading", { name: editQuestionText }),+ ).toBeVisible({ timeout: 10000 });++ await questionCard(page, editQuestionText)+ .getByTestId("question-actions-menu-btn")+ .click();+ await page.getByRole("menuitem", { name: "Edit" }).click();+ await expect(page.getByTestId("question-form-dialog-title")).toBeVisible();+ await expect(+ page.getByPlaceholder("Enter interview question"),+ ).toHaveValue(editQuestionText);++ const questionInput = page.getByPlaceholder("Enter interview question");+ await questionInput.fill(updatedQuestionText);++ await page.getByRole("button", { name: "Save" }).click();+ await expect(+ page.getByTestId("question-form-dialog-title"),+ ).not.toBeVisible({ timeout: 10000 });++ await expect(+ page.getByRole("heading", { name: updatedQuestionText }),+ ).toBeVisible({ timeout: 10000 });+ });++ test("should delete a question", async ({ page, cleanup }) => {+ const deleteQuestionText = uniqueName("E2E Delete Question");+ await navigateToQuestions(page);+ await createQuestion(+ page,+ deleteQuestionText,+ "Answer text for a question we will delete.",+ cleanup,+ );+ await expect(+ page.getByRole("heading", { name: deleteQuestionText }),+ ).toBeVisible({ timeout: 10000 });++ await questionCard(page, deleteQuestionText)+ .getByTestId("question-actions-menu-btn")+ .click();+ await page.getByRole("menuitem", { name: "Delete" }).click();+ await page.getByRole("button", { name: "Delete" }).click();++ await expect(+ page.getByRole("heading", { name: deleteQuestionText }),+ ).not.toBeVisible();+ });++ test("should add and persist a skill tag on a question", async ({+ page,+ cleanup,+ }) => {+ const questionText = uniqueName("E2E Tag Question");+ const tagText = uniqueName("skill tag");+ await navigateToQuestions(page);+ await createQuestion(+ page,+ questionText,+ "Answer text for the tagged question.",+ cleanup,+ { tag: tagText },+ );++ const card = questionCard(page, questionText);+ await expect(card).toBeVisible({ timeout: 10000 });+ await expect(card.getByText(tagText, { exact: true })).toBeVisible();++ await card.getByTestId("question-actions-menu-btn").click();+ await page.getByRole("menuitem", { name: "Edit" }).click();+ await expect(page.getByTestId("question-form-dialog-title")).toBeVisible();+ // Scope to the dialog: the sidebar's tag filter button also renders the+ // same tag label now that the question has been saved with it.+ await expect(+ page.getByRole("dialog").getByText(tagText, { exact: true }),+ ).toBeVisible();+ });++ test("should filter questions by tag", async ({ page, cleanup }) => {+ const taggedQuestionText = uniqueName("E2E Filter Tagged Question");+ const untaggedQuestionText = uniqueName("E2E Filter Untagged Question");+ const tagText = uniqueName("filter tag");+ await navigateToQuestions(page);+ await createQuestion(+ page,+ taggedQuestionText,+ "Answer text for the filter-tagged question.",+ cleanup,+ { tag: tagText },+ );+ await createQuestion(+ page,+ untaggedQuestionText,+ "Answer text for the filter-untagged question.",+ cleanup,+ );+ await expect(+ page.getByRole("heading", { name: taggedQuestionText }),+ ).toBeVisible({ timeout: 10000 });+ await expect(+ page.getByRole("heading", { name: untaggedQuestionText }),+ ).toBeVisible({ timeout: 10000 });++ await page.getByRole("button", { name: tagText }).click();++ await expect(+ page.getByRole("heading", { name: taggedQuestionText }),+ ).toBeVisible();+ await expect(+ page.getByRole("heading", { name: untaggedQuestionText }),+ ).not.toBeVisible();++ await page.getByRole("button", { name: "All" }).click();+ await expect(+ page.getByRole("heading", { name: untaggedQuestionText }),+ ).toBeVisible();+ });++ test("should search questions", async ({ page, cleanup }) => {+ const searchableQuestionText = uniqueName("E2E Searchable Question");+ await navigateToQuestions(page);+ await createQuestion(+ page,+ searchableQuestionText,+ "Answer text for the searchable question.",+ cleanup,+ );+ await expect(+ page.getByRole("heading", { name: searchableQuestionText }),+ ).toBeVisible({ timeout: 10000 });++ await page+ .getByPlaceholder("Search questions...")+ .fill(uniqueName("no match"));+ await expect(+ page.getByRole("heading", { name: searchableQuestionText }),+ ).not.toBeVisible();++ await page.getByPlaceholder("Search questions...").fill(searchableQuestionText);+ await expect(+ page.getByRole("heading", { name: searchableQuestionText }),+ ).toBeVisible();+ });+});diff --git a/src/app/api/test/cleanup/route.ts b/src/app/api/test/cleanup/route.tsindex 111d92f..08572f3 100644--- a/src/app/api/test/cleanup/route.ts+++ b/src/app/api/test/cleanup/route.ts@@ -22,6 +22,7 @@ export async function POST(req: NextRequest) {jobIds = [],resumes = [],tasks = [],+ questions = [],titles = [],companies = [],locations = [],@@ -32,6 +33,7 @@ export async function POST(req: NextRequest) {jobIds?: string[];resumes?: string[];tasks?: string[];+ questions?: string[];titles?: string[];companies?: string[];locations?: string[];@@ -68,6 +70,14 @@ export async function POST(req: NextRequest) {}}+ // Delete questions before tags below — deleteTagsByName only removes a tag+ // once its question/job/skill reference count is zero.+ if (questions.length > 0) {+ await prisma.question.deleteMany({+ where: { question: { in: questions }, createdBy: userId },+ });+ }+// Sources are never created by the tests (they select the seeded "Indeed"),// so they are intentionally not cleaned up here.await deleteLibraryByName("jobTitle", titles, userId);diff --git a/src/components/questions/QuestionCard.tsx b/src/components/questions/QuestionCard.tsxindex 9a095d7..a582b4a 100644--- a/src/components/questions/QuestionCard.tsx+++ b/src/components/questions/QuestionCard.tsx@@ -49,6 +49,7 @@ export function QuestionCard({<divclassName="border rounded-lg p-4 hover:bg-accent/50 transition-colors cursor-pointer"onClick={() => setExpanded(!expanded)}+ data-testid="question-card"><div className="flex items-start justify-between gap-2"><h3 className="font-medium flex-1">{question.question}</h3>@@ -59,6 +60,7 @@ export function QuestionCard({size="sm"className="h-8 w-8 p-0"onClick={(e) => e.stopPropagation()}+ data-testid="question-actions-menu-btn"><MoreVertical className="h-4 w-4" /></Button>diff --git a/src/components/questions/QuestionForm.tsx b/src/components/questions/QuestionForm.tsxindex 58b0be1..5b347c4 100644--- a/src/components/questions/QuestionForm.tsx+++ b/src/components/questions/QuestionForm.tsx@@ -11,7 +11,7 @@ import { createQuestion, updateQuestion } from "@/actions/question.actions";import { Loader } from "lucide-react";import { Button } from "../ui/button";import { useForm } from "react-hook-form";-import { useEffect, useTransition } from "react";+import { useEffect, useState, useTransition } from "react";import { AddQuestionFormSchema } from "@/models/addQuestionForm.schema";import { zodResolver } from "@hookform/resolvers/zod";import { Question } from "@/models/question.model";@@ -48,6 +48,8 @@ export function QuestionForm({setDialogOpen,}: QuestionFormProps) {const [isPending, startTransition] = useTransition();+ const [localAvailableTags, setLocalAvailableTags] =+ useState<Tag[]>(availableTags);const form = useForm<z.infer<typeof AddQuestionFormSchema>>({resolver: zodResolver(AddQuestionFormSchema),defaultValues: {@@ -67,6 +69,18 @@ export function QuestionForm({answer: editQuestion.answer || "",tagIds: editQuestion.tags?.map((t) => t.id) || [],});+ // Merge the question's own tags into the local pool so they're+ // selectable/visible even if they aren't in the availableTags prop yet+ // (e.g. just created in the Add dialog earlier in this page session).+ if (editQuestion.tags && editQuestion.tags.length > 0) {+ setLocalAvailableTags((prev) => {+ const existing = new Set(prev.map((t) => t.id));+ const incoming = editQuestion.tags!.filter(+ (t) => !existing.has(t.id),+ );+ return incoming.length > 0 ? [...prev, ...incoming] : prev;+ });+ }} else {reset({question: "",@@ -114,7 +128,9 @@ export function QuestionForm({<DialogOverlay><DialogContent className="sm:max-w-[725px] max-h-[90vh] overflow-y-auto"><DialogHeader>- <DialogTitle>{pageTitle}</DialogTitle>+ <DialogTitle data-testid="question-form-dialog-title">+ {pageTitle}+ </DialogTitle></DialogHeader><Form {...form}><form@@ -143,7 +159,7 @@ export function QuestionForm({<FormLabel>Skill Tags</FormLabel><FormControl><TagInput- availableTags={availableTags}+ availableTags={localAvailableTags}selectedTagIds={field.value || []}onChange={field.onChange}/>