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
Add job sources table
Khuram Niaz620dd6a2c571
diff --git a/__tests__/JobsContainer.spec.tsx b/__tests__/JobsContainer.spec.tsxindex 03ea4e9..ff332c3 100644--- a/__tests__/JobsContainer.spec.tsx+++ b/__tests__/JobsContainer.spec.tsx@@ -127,8 +127,8 @@ describe("JobsContainer Search Functionality", () => {];const mockSources = [- { id: "1", label: "Indeed", value: "indeed" },- { id: "2", label: "LinkedIn", value: "linkedin" },+ { id: "1", label: "Indeed", value: "indeed", createdBy: "user-1" },+ { id: "2", label: "LinkedIn", value: "linkedin", createdBy: "user-1" },];const mockJobs = [diff --git a/prisma/migrations/20260212202940_add_createdby_to_jobsource/migration.sql b/prisma/migrations/20260212202940_add_createdby_to_jobsource/migration.sqlnew file mode 100644index 0000000..eb1322a--- /dev/null+++ b/prisma/migrations/20260212202940_add_createdby_to_jobsource/migration.sql@@ -0,0 +1,22 @@+/*+ Warnings:++ - Added the required column `createdBy` to the `JobSource` table without a default value. This is not possible if the table is not empty.++*/+-- RedefineTables+PRAGMA defer_foreign_keys=ON;+PRAGMA foreign_keys=OFF;+CREATE TABLE "new_JobSource" (+ "id" TEXT NOT NULL PRIMARY KEY,+ "label" TEXT NOT NULL,+ "value" TEXT NOT NULL,+ "createdBy" TEXT NOT NULL,+ CONSTRAINT "JobSource_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE+);+INSERT INTO "new_JobSource" ("id", "label", "value", "createdBy") SELECT "id", "label", "value", (SELECT "id" FROM "User" LIMIT 1) FROM "JobSource" WHERE (SELECT COUNT(*) FROM "User") > 0;+DROP TABLE "JobSource";+ALTER TABLE "new_JobSource" RENAME TO "JobSource";+CREATE UNIQUE INDEX "JobSource_value_key" ON "JobSource"("value");+PRAGMA foreign_keys=ON;+PRAGMA defer_foreign_keys=OFF;diff --git a/prisma/schema.prisma b/prisma/schema.prismaindex 9743017..0dfe535 100644--- a/prisma/schema.prisma+++ b/prisma/schema.prisma@@ -22,6 +22,7 @@ model User {JobTitle JobTitle[]Location Location[]Company Company[]+ JobSource JobSource[]Contact Contact[]Profile Profile[]Activity Activity[]@@ -218,6 +219,8 @@ model JobSource {label Stringvalue String @uniquejobsApplied Job[]+ createdBy String // userId+ user User @relation(fields: [createdBy], references: [id])}model Interview {diff --git a/src/actions/job.actions.ts b/src/actions/job.actions.tsindex e9f0e26..8b7e282 100644--- a/src/actions/job.actions.ts+++ b/src/actions/job.actions.ts@@ -20,7 +20,15 @@ export const getStatusList = async (): Promise<any | undefined> => {export const getJobSourceList = async (): Promise<any | undefined> => {try {- const list = await prisma.jobSource.findMany();+ const user = await getCurrentUser();+ if (!user) {+ throw new Error("Not authenticated");+ }+ const list = await prisma.jobSource.findMany({+ where: {+ createdBy: user.id,+ },+ });return list;} catch (error) {const msg = "Failed to fetch job source list. ";diff --git a/src/actions/jobSource.actions.ts b/src/actions/jobSource.actions.tsnew file mode 100644index 0000000..eaccd8f--- /dev/null+++ b/src/actions/jobSource.actions.ts@@ -0,0 +1,97 @@+"use server";+import prisma from "@/lib/db";+import { handleError } from "@/lib/utils";+import { getCurrentUser } from "@/utils/user.utils";+import { APP_CONSTANTS } from "@/lib/constants";++export const getJobSourceList = async (+ page: number = 1,+ limit: number = APP_CONSTANTS.RECORDS_PER_PAGE,+ countBy?: string+): Promise<any | undefined> => {+ try {+ const user = await getCurrentUser();++ if (!user) {+ throw new Error("Not authenticated");+ }+ const skip = (page - 1) * limit;++ const [data, total] = await Promise.all([+ prisma.jobSource.findMany({+ where: {+ createdBy: user.id,+ },+ skip,+ take: limit,+ ...(countBy+ ? {+ select: {+ id: true,+ label: true,+ value: true,+ _count: {+ select: {+ jobsApplied: {+ where: {+ applied: true,+ },+ },+ },+ },+ },+ }+ : {}),+ orderBy: {+ jobsApplied: {+ _count: "desc",+ },+ },+ }),+ prisma.jobSource.count({+ where: {+ createdBy: user.id,+ },+ }),+ ]);+ return { data, total };+ } catch (error) {+ const msg = "Failed to fetch job source list. ";+ return handleError(error, msg);+ }+};++export const deleteJobSourceById = async (+ jobSourceId: string+): Promise<any | undefined> => {+ try {+ const user = await getCurrentUser();++ if (!user) {+ throw new Error("Not authenticated");+ }++ const jobs = await prisma.job.count({+ where: {+ jobSourceId,+ },+ });++ if (jobs > 0) {+ throw new Error(+ `Job source cannot be deleted due to ${jobs} number of associated jobs! `+ );+ }++ const res = await prisma.jobSource.delete({+ where: {+ id: jobSourceId,+ createdBy: user.id,+ },+ });+ return { res, success: true };+ } catch (error) {+ const msg = "Failed to delete job source.";+ return handleError(error, msg);+ }+};diff --git a/src/components/admin/AdminTabsContainer.tsx b/src/components/admin/AdminTabsContainer.tsxindex 6e7c5c3..a5801c5 100644--- a/src/components/admin/AdminTabsContainer.tsx+++ b/src/components/admin/AdminTabsContainer.tsx@@ -1,6 +1,7 @@"use client";import CompaniesContainer from "@/components/admin/CompaniesContainer";import JobLocationsContainer from "@/components/admin/JobLocationsContainer";+import JobSourcesContainer from "@/components/admin/JobSourcesContainer";import JobTitlesContainer from "@/components/admin/JobTitlesContainer";import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";import { usePathname, useRouter, useSearchParams } from "next/navigation";@@ -33,6 +34,7 @@ function AdminTabsContainer() {<TabsTrigger value="companies">Companies</TabsTrigger><TabsTrigger value="job-titles">Job Titles</TabsTrigger><TabsTrigger value="locations">Locations</TabsTrigger>+ <TabsTrigger value="sources">Sources</TabsTrigger></TabsList><TabsContent value="companies"><CompaniesContainer />@@ -43,6 +45,9 @@ function AdminTabsContainer() {<TabsContent value="locations"><JobLocationsContainer /></TabsContent>+ <TabsContent value="sources">+ <JobSourcesContainer />+ </TabsContent></Tabs>);}diff --git a/src/components/admin/JobSourcesContainer.tsx b/src/components/admin/JobSourcesContainer.tsxnew file mode 100644index 0000000..c82ef2b--- /dev/null+++ b/src/components/admin/JobSourcesContainer.tsx@@ -0,0 +1,102 @@+"use client";+import { useCallback, useEffect, useState } from "react";+import { Card, CardContent, CardHeader, CardTitle } from "../ui/card";+import { APP_CONSTANTS } from "@/lib/constants";+import { JobSource } from "@/models/job.model";+import JobSourcesTable from "./JobSourcesTable";+import { getJobSourceList } from "@/actions/jobSource.actions";+import Loading from "../Loading";+import { Button } from "../ui/button";+import { RecordsPerPageSelector } from "../RecordsPerPageSelector";+import { RecordsCount } from "../RecordsCount";++function JobSourcesContainer() {+ const [sources, setSources] = useState<JobSource[]>([]);+ const [totalJobSources, setTotalJobSources] = useState<number>(0);+ const [page, setPage] = useState<number>(1);+ const [loading, setLoading] = useState<boolean>(false);+ const [recordsPerPage, setRecordsPerPage] = useState<number>(+ APP_CONSTANTS.RECORDS_PER_PAGE,+ );++ const loadJobSources = useCallback(+ async (page: number) => {+ setLoading(true);+ const { data, total } = await getJobSourceList(+ page,+ recordsPerPage,+ "applied"+ );+ if (data) {+ setSources((prev) => (page === 1 ? data : [...prev, ...data]));+ setTotalJobSources(total);+ setPage(page);+ setLoading(false);+ }+ },+ [recordsPerPage]+ );++ const reloadJobSources = useCallback(async () => {+ await loadJobSources(1);+ }, [loadJobSources]);++ useEffect(() => {+ (async () => await loadJobSources(1))();+ }, [loadJobSources, recordsPerPage]);++ return (+ <>+ <div className="col-span-3">+ <Card x-chunk="dashboard-06-chunk-0">+ <CardHeader className="flex-row justify-between items-center">+ <CardTitle>Job Sources</CardTitle>+ <div className="flex items-center">+ <div className="ml-auto flex items-center gap-2">+ </div>+ </div>+ </CardHeader>+ <CardContent>+ {loading && <Loading />}+ {sources.length > 0 && (+ <>+ <JobSourcesTable+ jobSources={sources}+ reloadJobSources={reloadJobSources}+ />+ <div className="flex items-center justify-between mt-4">+ <RecordsCount+ count={sources.length}+ total={totalJobSources}+ label="job sources"+ />+ {totalJobSources > APP_CONSTANTS.RECORDS_PER_PAGE && (+ <RecordsPerPageSelector+ value={recordsPerPage}+ onChange={setRecordsPerPage}+ />+ )}+ </div>+ </>+ )}+ {sources.length < totalJobSources && (+ <div className="flex justify-center p-4">+ <Button+ size="sm"+ variant="outline"+ onClick={() => loadJobSources(page + 1)}+ disabled={loading}+ className="btn btn-primary"+ >+ {loading ? "Loading..." : "Load More"}+ </Button>+ </div>+ )}+ </CardContent>+ </Card>+ </div>+ </>+ );+}++export default JobSourcesContainer;diff --git a/src/components/admin/JobSourcesTable.tsx b/src/components/admin/JobSourcesTable.tsxnew file mode 100644index 0000000..a9caae7--- /dev/null+++ b/src/components/admin/JobSourcesTable.tsx@@ -0,0 +1,141 @@+"use client";+import { useState } from "react";+import { Button } from "../ui/button";++import {+ DropdownMenu,+ DropdownMenuContent,+ DropdownMenuItem,+ DropdownMenuLabel,+ DropdownMenuTrigger,+} from "../ui/dropdown-menu";+import {+ Table,+ TableBody,+ TableCell,+ TableHead,+ TableHeader,+ TableRow,+} from "../ui/table";+import { JobSource } from "@/models/job.model";+import { MoreHorizontal, Trash } from "lucide-react";+import { AlertDialog } from "@/models/alertDialog.model";+import { DeleteAlertDialog } from "../DeleteAlertDialog";+import { deleteJobSourceById } from "@/actions/jobSource.actions";+import { toast } from "../ui/use-toast";++type JobSourcesTableProps = {+ jobSources: JobSource[];+ reloadJobSources: () => void;+};++function JobSourcesTable({+ jobSources,+ reloadJobSources,+}: JobSourcesTableProps) {+ const [alert, setAlert] = useState<AlertDialog>({+ openState: false,+ deleteAction: false,+ });++ const onDeleteJobSource = (source: JobSource) => {+ if (source._count?.jobsApplied! > 0) {+ setAlert({+ openState: true,+ title: "Applied jobs exist!",+ description:+ "Associated jobs applied must be 0 to be able to delete this job source",+ deleteAction: false,+ });+ } else {+ setAlert({+ openState: true,+ deleteAction: true,+ itemId: source.id,+ });+ }+ };++ const deleteJobSource = async (sourceId: string) => {+ if (sourceId) {+ const { success, message } = await deleteJobSourceById(sourceId);+ if (success) {+ toast({+ variant: "success",+ description: `Job source has been deleted successfully`,+ });+ reloadJobSources();+ } else {+ toast({+ variant: "destructive",+ title: "Error!",+ description: message,+ });+ }+ }+ };++ return (+ <>+ <Table>+ <TableHeader>+ <TableRow>+ <TableHead>Source</TableHead>+ <TableHead className="hidden sm:table-cell">Value</TableHead>+ <TableHead>Jobs Applied</TableHead>+ <TableHead>Actions</TableHead>+ <TableHead>+ <span className="sr-only">Actions</span>+ </TableHead>+ </TableRow>+ </TableHeader>+ <TableBody>+ {jobSources.map((source: JobSource) => {+ return (+ <TableRow key={source.id}>+ <TableCell className="font-medium">{source.label}</TableCell>+ <TableCell className="font-medium hidden sm:table-cell">+ {source.value}+ </TableCell>+ <TableCell className="font-medium">+ {source._count?.jobsApplied}+ </TableCell>+ <TableCell>+ <DropdownMenu>+ <DropdownMenuTrigger asChild>+ <Button aria-haspopup="true" size="icon" variant="ghost">+ <MoreHorizontal className="h-4 w-4" />+ <span className="sr-only">Toggle menu</span>+ </Button>+ </DropdownMenuTrigger>+ <DropdownMenuContent align="end">+ <DropdownMenuLabel>Actions</DropdownMenuLabel>+ <DropdownMenuItem+ className="text-red-600 cursor-pointer"+ onClick={() => onDeleteJobSource(source)}+ >+ <Trash className="mr-2 h-4 w-4" />+ Delete+ </DropdownMenuItem>+ </DropdownMenuContent>+ </DropdownMenu>+ </TableCell>+ </TableRow>+ );+ })}+ </TableBody>+ </Table>+ <DeleteAlertDialog+ pageTitle="source"+ open={alert.openState}+ onOpenChange={() => setAlert({ openState: false, deleteAction: false })}+ onDelete={() => deleteJobSource(alert.itemId!)}+ alertTitle={alert.title}+ alertDescription={alert.description}+ deleteAction={alert.deleteAction}+ />+ </>+ );+}++export default JobSourcesTable;diff --git a/src/lib/data/jobSourcesData.ts b/src/lib/data/jobSourcesData.tsindex d2fb593..86f5d30 100644--- a/src/lib/data/jobSourcesData.ts+++ b/src/lib/data/jobSourcesData.ts@@ -3,45 +3,54 @@ export const JOB_SOURCES = [id: "1359dac4-a397-4461-b747-382706dcbe79",label: "Indeed",value: "indeed",+ createdBy: "",},{id: "a483e678-6e3d-41cf-8c6f-6540b02551eb",label: "Linkedin",value: "linkedin",+ createdBy: "",},{id: "8d941ed0-6882-4d88-b985-d614e9828576",label: "Monster",value: "monster",+ createdBy: "",},{id: "49a9a222-d5ac-452b-88d8-7258e2e58c07",label: "Glassdoor",value: "glassdoor",+ createdBy: "",},{id: "08642cf8-29f5-4535-ad58-63edbbace13f",label: "Company Career page",value: "careerpage",+ createdBy: "",},{id: "090eefe1-2f99-46d1-925f-d59e0e8f072c",label: "Google",value: "google",+ createdBy: "",},{id: "c0ae0c56-beed-471c-b7d3-4eb1f732fe8f",label: "ZipRecruiter",value: "ziprecruiter",+ createdBy: "",},{id: "108537a8-1d84-4bc3-8820-4a1cd71c5ccf",label: "Job Street",value: "jobstreet",+ createdBy: "",},{id: "ddd8aa2e-37c1-4dc8-b370-a844ff1ad82c",label: "Other",value: "other",+ createdBy: "",},];diff --git a/src/lib/data/myJobsData.ts b/src/lib/data/myJobsData.tsindex 1c5387f..0998788 100644--- a/src/lib/data/myJobsData.ts+++ b/src/lib/data/myJobsData.ts@@ -29,7 +29,7 @@ export const MY_JOBS_DATA: { data: JobResponse[]; total: number } = {createdBy: "xyz",},Status: { id: "1", label: "Draft", value: "draft" },- JobSource: { id: "1", label: "Indeed", value: "indeed" },+ JobSource: { id: "1", label: "Indeed", value: "indeed", createdBy: "xyz" },appliedDate: new Date("2024-06-19"),description:"<p>We are looking for a <strong>Full Stack Developer</strong> to join our team at Amazon. You will be responsible for developing and maintaining our web applications. Strong experience in both front-end and back-end technologies is required.</p>",@@ -63,7 +63,7 @@ export const MY_JOBS_DATA: { data: JobResponse[]; total: number } = {createdBy: "xyz",},Status: { id: "1", label: "Rejected", value: "rejected" },- JobSource: { id: "1", label: "Indeed", value: "indeed" },+ JobSource: { id: "1", label: "Indeed", value: "indeed", createdBy: "xyz" },appliedDate: new Date("2024-06-20"),description:"<p>Join our dynamic team at Google as a <strong>Full Stack Developer</strong>. You will be involved in the full software development lifecycle, from conception to deployment. Proficiency in JavaScript, Python, and cloud technologies is required.</p>",@@ -97,7 +97,7 @@ export const MY_JOBS_DATA: { data: JobResponse[]; total: number } = {createdBy: "xyz",},Status: { id: "1", label: "Applied", value: "applied" },- JobSource: { id: "1", label: "Indeed", value: "indeed" },+ JobSource: { id: "1", label: "Indeed", value: "indeed", createdBy: "xyz" },appliedDate: new Date("2024-06-19"),description:"<p>Facebook is seeking a talented <strong>Full Stack Developer</strong> to work on our cutting-edge social media platforms. Experience with React and Node.js is highly desirable. Work remotely with a team of top developers.</p>",@@ -131,7 +131,7 @@ export const MY_JOBS_DATA: { data: JobResponse[]; total: number } = {createdBy: "xyz",},Status: { id: "1", label: "Applied", value: "applied" },- JobSource: { id: "2", label: "Linkedin", value: "linkedin" },+ JobSource: { id: "2", label: "Linkedin", value: "linkedin", createdBy: "xyz" },appliedDate: new Date("2024-06-18"),description:"<p>Netflix is hiring a <strong>Full Stack Developer</strong> to enhance our streaming platform. You will work on both front-end and back-end features, ensuring a seamless user experience. Familiarity with cloud infrastructure is a plus.</p>",@@ -165,7 +165,7 @@ export const MY_JOBS_DATA: { data: JobResponse[]; total: number } = {createdBy: "xyz",},Status: { id: "1", label: "Applied", value: "applied" },- JobSource: { id: "1", label: "Indeed", value: "indeed" },+ JobSource: { id: "1", label: "Indeed", value: "indeed", createdBy: "xyz" },appliedDate: new Date("2024-06-18"),description:"<p>We are looking for a creative <strong>Frontend Developer</strong> at Apple to build intuitive interfaces for our products. Strong knowledge of HTML, CSS, and JavaScript is essential. Experience with design tools is a plus.</p>",@@ -199,7 +199,7 @@ export const MY_JOBS_DATA: { data: JobResponse[]; total: number } = {createdBy: "xyz",},Status: { id: "1", label: "Applied", value: "applied" },- JobSource: { id: "1", label: "Indeed", value: "indeed" },+ JobSource: { id: "1", label: "Indeed", value: "indeed", createdBy: "xyz" },appliedDate: new Date("2024-06-19"),description:"<p>Amazon is seeking a skilled <strong>DevOps Engineer</strong> to manage our deployment pipelines and infrastructure. Experience with AWS, Docker, and CI/CD tools is required. Join a fast-paced environment and help us scale.</p>",@@ -233,7 +233,7 @@ export const MY_JOBS_DATA: { data: JobResponse[]; total: number } = {createdBy: "xyz",},Status: { id: "1", label: "Applied", value: "applied" },- JobSource: { id: "1", label: "Indeed", value: "indeed" },+ JobSource: { id: "1", label: "Indeed", value: "indeed", createdBy: "xyz" },appliedDate: new Date("2024-06-19"),description:"<p>We are looking for an experienced <strong>Software Architect</strong> at Microsoft to design and oversee the development of complex software systems. Strong leadership and coding skills are essential. Work with the latest technologies and shape the future of our products.</p>",@@ -267,7 +267,7 @@ export const MY_JOBS_DATA: { data: JobResponse[]; total: number } = {createdBy: "xyz",},Status: { id: "1", label: "Applied", value: "applied" },- JobSource: { id: "1", label: "Indeed", value: "indeed" },+ JobSource: { id: "1", label: "Indeed", value: "indeed", createdBy: "xyz" },appliedDate: new Date("2024-06-19"),description:"<p>Netflix is seeking a talented <strong>Frontend Developer</strong> to join our team in Los Angeles. You will work on building responsive and interactive web applications. Experience with React and performance optimization is desired.</p>",@@ -301,7 +301,7 @@ export const MY_JOBS_DATA: { data: JobResponse[]; total: number } = {createdBy: "xyz",},Status: { id: "1", label: "Applied", value: "applied" },- JobSource: { id: "2", label: "Linkedin", value: "linkedin" },+ JobSource: { id: "2", label: "Linkedin", value: "linkedin", createdBy: "xyz" },appliedDate: new Date("2024-06-19"),description:"<p>Apple is hiring a <strong>Backend Developer</strong> to build and maintain our server-side applications. Expertise in server-side programming languages and database management is required. Work remotely and collaborate with our global team.</p>",diff --git a/src/lib/scraper/mapper.ts b/src/lib/scraper/mapper.tsindex da4a7fa..02af946 100644--- a/src/lib/scraper/mapper.ts+++ b/src/lib/scraper/mapper.ts@@ -37,7 +37,7 @@ export async function mapScrapedJobToJobRecord(const jobTitleId = await findOrCreateJobTitle(scrapedJob.title, userId);const locationId = await findOrCreateLocation(scrapedJob.location, userId);const companyId = await findOrCreateCompany(scrapedJob.company, userId);- const jobSourceId = await getOrCreateJobSource(scrapedJob.sourceBoard);+ const jobSourceId = await getOrCreateJobSource(scrapedJob.sourceBoard, userId);const statusId = await getDefaultJobStatus();return {@@ -176,7 +176,10 @@ async function findOrCreateCompany(return newCompany.id;}-async function getOrCreateJobSource(sourceBoard: string): Promise<string> {+async function getOrCreateJobSource(+ sourceBoard: string,+ userId: string+): Promise<string> {const normalized = sourceBoard.toLowerCase();let jobSource = await db.jobSource.findFirst({@@ -188,6 +191,7 @@ async function getOrCreateJobSource(sourceBoard: string): Promise<string> {data: {label: sourceBoard.charAt(0).toUpperCase() + sourceBoard.slice(1),value: normalized,+ createdBy: userId,},});}diff --git a/src/lib/seed.ts b/src/lib/seed.tsindex bee2ca1..7744032 100644--- a/src/lib/seed.ts+++ b/src/lib/seed.ts@@ -31,7 +31,7 @@ async function seedUser() {console.warn("[seed] USER_EMAIL not set, skipping user creation");- return;+ return null;}const existingUser = await prisma.user.findUnique({@@ -40,7 +40,7 @@ async function seedUser() {if (!existingUser) {const password = await bcrypt.hash(process.env.USER_PASSWORD || "", 10);- await prisma.user.create({+ const user = await prisma.user.create({data: {email,name: "Admin",@@ -48,7 +48,9 @@ async function seedUser() {},});console.log("[seed] Created user:", email);+ return user;}+ return existingUser;}async function seedStatuses() {@@ -63,12 +65,12 @@ async function seedStatuses() {console.log("[seed] Statuses ready");}-async function seedJobSources() {+async function seedJobSources(userId: string) {for (const source of JOB_SOURCES) {await prisma.jobSource.upsert({where: { value: source.value },update: { label: source.label, value: source.value },- create: { label: source.label, value: source.value },+ create: { label: source.label, value: source.value, createdBy: userId },});}console.log("[seed] Job sources ready");@@ -76,9 +78,11 @@ async function seedJobSources() {export async function runSeed() {try {- await seedUser();+ const user = await seedUser();await seedStatuses();- await seedJobSources();+ if (user) {+ await seedJobSources(user.id);+ }console.log("[seed] Database seeding complete");} catch (error) {console.error("[seed] Error during seeding:", error);diff --git a/src/models/job.model.ts b/src/models/job.model.tsindex 435d265..0b0e58b 100644--- a/src/models/job.model.ts+++ b/src/models/job.model.ts@@ -70,6 +70,10 @@ export interface JobSource {id: string;label: string;value: string;+ createdBy: string;+ _count?: {+ jobsApplied: number;+ };}export interface JobLocation {diff --git a/tests-examples/demo-todo-app-test.ts b/tests-examples/demo-todo-app-test.tsdeleted file mode 100644index 3fee590..0000000--- a/tests-examples/demo-todo-app-test.ts+++ /dev/null@@ -1,489 +0,0 @@-import { test, expect, type Page } from "@playwright/test";--test.beforeEach(async ({ page }) => {- await page.goto("https://demo.playwright.dev/todomvc");-});--const TODO_ITEMS = [- "buy some cheese",- "feed the cat",- "book a doctors appointment",-] as const;--test.describe("New Todo", () => {- test("should allow me to add todo items", async ({ page }) => {- // create a new todo locator- const newTodo = page.getByPlaceholder("What needs to be done?");-- // Create 1st todo.- await newTodo.fill(TODO_ITEMS[0]);- await newTodo.press("Enter");-- // Make sure the list only has one todo item.- await expect(page.getByTestId("todo-title")).toHaveText([TODO_ITEMS[0]]);-- // Create 2nd todo.- await newTodo.fill(TODO_ITEMS[1]);- await newTodo.press("Enter");-- // Make sure the list now has two todo items.- await expect(page.getByTestId("todo-title")).toHaveText([- TODO_ITEMS[0],- TODO_ITEMS[1],- ]);-- await checkNumberOfTodosInLocalStorage(page, 2);- });-- test("should clear text input field when an item is added", async ({- page,- }) => {- // create a new todo locator- const newTodo = page.getByPlaceholder("What needs to be done?");-- // Create one todo item.- await newTodo.fill(TODO_ITEMS[0]);- await newTodo.press("Enter");-- // Check that input is empty.- await expect(newTodo).toBeEmpty();- await checkNumberOfTodosInLocalStorage(page, 1);- });-- test("should append new items to the bottom of the list", async ({- page,- }) => {- // Create 3 items.- await createDefaultTodos(page);-- // create a todo count locator- const todoCount = page.getByTestId("todo-count");-- // Check test using different methods.- await expect(page.getByText("3 items left")).toBeVisible();- await expect(todoCount).toHaveText("3 items left");- await expect(todoCount).toContainText("3");- await expect(todoCount).toHaveText(/3/);-- // Check all items in one call.- await expect(page.getByTestId("todo-title")).toHaveText(TODO_ITEMS);- await checkNumberOfTodosInLocalStorage(page, 3);- });-});--test.describe("Mark all as completed", () => {- test.beforeEach(async ({ page }) => {- await createDefaultTodos(page);- await checkNumberOfTodosInLocalStorage(page, 3);- });-- test.afterEach(async ({ page }) => {- await checkNumberOfTodosInLocalStorage(page, 3);- });-- test("should allow me to mark all items as completed", async ({ page }) => {- // Complete all todos.- await page.getByLabel("Mark all as complete").check();-- // Ensure all todos have 'completed' class.- await expect(page.getByTestId("todo-item")).toHaveClass([- "completed",- "completed",- "completed",- ]);- await checkNumberOfCompletedTodosInLocalStorage(page, 3);- });-- test("should allow me to clear the complete state of all items", async ({- page,- }) => {- const toggleAll = page.getByLabel("Mark all as complete");- // Check and then immediately uncheck.- await toggleAll.check();- await toggleAll.uncheck();-- // Should be no completed classes.- await expect(page.getByTestId("todo-item")).toHaveClass(["", "", ""]);- });-- test("complete all checkbox should update state when items are completed / cleared", async ({- page,- }) => {- const toggleAll = page.getByLabel("Mark all as complete");- await toggleAll.check();- await expect(toggleAll).toBeChecked();- await checkNumberOfCompletedTodosInLocalStorage(page, 3);-- // Uncheck first todo.- const firstTodo = page.getByTestId("todo-item").nth(0);- await firstTodo.getByRole("checkbox").uncheck();-- // Reuse toggleAll locator and make sure its not checked.- await expect(toggleAll).not.toBeChecked();-- await firstTodo.getByRole("checkbox").check();- await checkNumberOfCompletedTodosInLocalStorage(page, 3);-- // Assert the toggle all is checked again.- await expect(toggleAll).toBeChecked();- });-});--test.describe("Item", () => {- test("should allow me to mark items as complete", async ({ page }) => {- // create a new todo locator- const newTodo = page.getByPlaceholder("What needs to be done?");-- // Create two items.- for (const item of TODO_ITEMS.slice(0, 2)) {- await newTodo.fill(item);- await newTodo.press("Enter");- }-- // Check first item.- const firstTodo = page.getByTestId("todo-item").nth(0);- await firstTodo.getByRole("checkbox").check();- await expect(firstTodo).toHaveClass("completed");-- // Check second item.- const secondTodo = page.getByTestId("todo-item").nth(1);- await expect(secondTodo).not.toHaveClass("completed");- await secondTodo.getByRole("checkbox").check();-- // Assert completed class.- await expect(firstTodo).toHaveClass("completed");- await expect(secondTodo).toHaveClass("completed");- });-- test("should allow me to un-mark items as complete", async ({ page }) => {- // create a new todo locator- const newTodo = page.getByPlaceholder("What needs to be done?");-- // Create two items.- for (const item of TODO_ITEMS.slice(0, 2)) {- await newTodo.fill(item);- await newTodo.press("Enter");- }-- const firstTodo = page.getByTestId("todo-item").nth(0);- const secondTodo = page.getByTestId("todo-item").nth(1);- const firstTodoCheckbox = firstTodo.getByRole("checkbox");-- await firstTodoCheckbox.check();- await expect(firstTodo).toHaveClass("completed");- await expect(secondTodo).not.toHaveClass("completed");- await checkNumberOfCompletedTodosInLocalStorage(page, 1);-- await firstTodoCheckbox.uncheck();- await expect(firstTodo).not.toHaveClass("completed");- await expect(secondTodo).not.toHaveClass("completed");- await checkNumberOfCompletedTodosInLocalStorage(page, 0);- });-- test("should allow me to edit an item", async ({ page }) => {- await createDefaultTodos(page);-- const todoItems = page.getByTestId("todo-item");- const secondTodo = todoItems.nth(1);- await secondTodo.dblclick();- await expect(secondTodo.getByRole("textbox", { name: "Edit" })).toHaveValue(- TODO_ITEMS[1]- );- await secondTodo- .getByRole("textbox", { name: "Edit" })- .fill("buy some sausages");- await secondTodo.getByRole("textbox", { name: "Edit" }).press("Enter");-- // Explicitly assert the new text value.- await expect(todoItems).toHaveText([- TODO_ITEMS[0],- "buy some sausages",- TODO_ITEMS[2],- ]);- await checkTodosInLocalStorage(page, "buy some sausages");- });-});--test.describe("Editing", () => {- test.beforeEach(async ({ page }) => {- await createDefaultTodos(page);- await checkNumberOfTodosInLocalStorage(page, 3);- });-- test("should hide other controls when editing", async ({ page }) => {- const todoItem = page.getByTestId("todo-item").nth(1);- await todoItem.dblclick();- await expect(todoItem.getByRole("checkbox")).not.toBeVisible();- await expect(- todoItem.locator("label", {- hasText: TODO_ITEMS[1],- })- ).not.toBeVisible();- await checkNumberOfTodosInLocalStorage(page, 3);- });-- test("should save edits on blur", async ({ page }) => {- const todoItems = page.getByTestId("todo-item");- await todoItems.nth(1).dblclick();- await todoItems- .nth(1)- .getByRole("textbox", { name: "Edit" })- .fill("buy some sausages");- await todoItems- .nth(1)- .getByRole("textbox", { name: "Edit" })- .dispatchEvent("blur");-- await expect(todoItems).toHaveText([- TODO_ITEMS[0],- "buy some sausages",- TODO_ITEMS[2],- ]);- await checkTodosInLocalStorage(page, "buy some sausages");- });-- test("should trim entered text", async ({ page }) => {- const todoItems = page.getByTestId("todo-item");- await todoItems.nth(1).dblclick();- await todoItems- .nth(1)- .getByRole("textbox", { name: "Edit" })- .fill(" buy some sausages ");- await todoItems- .nth(1)- .getByRole("textbox", { name: "Edit" })- .press("Enter");-- await expect(todoItems).toHaveText([- TODO_ITEMS[0],- "buy some sausages",- TODO_ITEMS[2],- ]);- await checkTodosInLocalStorage(page, "buy some sausages");- });-- test("should remove the item if an empty text string was entered", async ({- page,- }) => {- const todoItems = page.getByTestId("todo-item");- await todoItems.nth(1).dblclick();- await todoItems.nth(1).getByRole("textbox", { name: "Edit" }).fill("");- await todoItems- .nth(1)- .getByRole("textbox", { name: "Edit" })- .press("Enter");-- await expect(todoItems).toHaveText([TODO_ITEMS[0], TODO_ITEMS[2]]);- });-- test("should cancel edits on escape", async ({ page }) => {- const todoItems = page.getByTestId("todo-item");- await todoItems.nth(1).dblclick();- await todoItems- .nth(1)- .getByRole("textbox", { name: "Edit" })- .fill("buy some sausages");- await todoItems- .nth(1)- .getByRole("textbox", { name: "Edit" })- .press("Escape");- await expect(todoItems).toHaveText(TODO_ITEMS);- });-});--test.describe("Counter", () => {- test("should display the current number of todo items", async ({ page }) => {- // create a new todo locator- const newTodo = page.getByPlaceholder("What needs to be done?");-- // create a todo count locator- const todoCount = page.getByTestId("todo-count");-- await newTodo.fill(TODO_ITEMS[0]);- await newTodo.press("Enter");-- await expect(todoCount).toContainText("1");-- await newTodo.fill(TODO_ITEMS[1]);- await newTodo.press("Enter");- await expect(todoCount).toContainText("2");-- await checkNumberOfTodosInLocalStorage(page, 2);- });-});--test.describe("Clear completed button", () => {- test.beforeEach(async ({ page }) => {- await createDefaultTodos(page);- });-- test("should display the correct text", async ({ page }) => {- await page.locator(".todo-list li .toggle").first().check();- await expect(- page.getByRole("button", { name: "Clear completed" })- ).toBeVisible();- });-- test("should remove completed items when clicked", async ({ page }) => {- const todoItems = page.getByTestId("todo-item");- await todoItems.nth(1).getByRole("checkbox").check();- await page.getByRole("button", { name: "Clear completed" }).click();- await expect(todoItems).toHaveCount(2);- await expect(todoItems).toHaveText([TODO_ITEMS[0], TODO_ITEMS[2]]);- });-- test("should be hidden when there are no items that are completed", async ({- page,- }) => {- await page.locator(".todo-list li .toggle").first().check();- await page.getByRole("button", { name: "Clear completed" }).click();- await expect(- page.getByRole("button", { name: "Clear completed" })- ).toBeHidden();- });-});--test.describe("Persistence", () => {- test("should persist its data", async ({ page }) => {- // create a new todo locator- const newTodo = page.getByPlaceholder("What needs to be done?");-- for (const item of TODO_ITEMS.slice(0, 2)) {- await newTodo.fill(item);- await newTodo.press("Enter");- }-- const todoItems = page.getByTestId("todo-item");- const firstTodoCheck = todoItems.nth(0).getByRole("checkbox");- await firstTodoCheck.check();- await expect(todoItems).toHaveText([TODO_ITEMS[0], TODO_ITEMS[1]]);- await expect(firstTodoCheck).toBeChecked();- await expect(todoItems).toHaveClass(["completed", ""]);-- // Ensure there is 1 completed item.- await checkNumberOfCompletedTodosInLocalStorage(page, 1);-- // Now reload.- await page.reload();- await expect(todoItems).toHaveText([TODO_ITEMS[0], TODO_ITEMS[1]]);- await expect(firstTodoCheck).toBeChecked();- await expect(todoItems).toHaveClass(["completed", ""]);- });-});--test.describe("Routing", () => {- test.beforeEach(async ({ page }) => {- await createDefaultTodos(page);- // make sure the app had a chance to save updated todos in storage- // before navigating to a new view, otherwise the items can get lost :(- // in some frameworks like Durandal- await checkTodosInLocalStorage(page, TODO_ITEMS[0]);- });-- test("should allow me to display active items", async ({ page }) => {- const todoItem = page.getByTestId("todo-item");- await page.getByTestId("todo-item").nth(1).getByRole("checkbox").check();-- await checkNumberOfCompletedTodosInLocalStorage(page, 1);- await page.getByRole("link", { name: "Active" }).click();- await expect(todoItem).toHaveCount(2);- await expect(todoItem).toHaveText([TODO_ITEMS[0], TODO_ITEMS[2]]);- });-- test("should respect the back button", async ({ page }) => {- const todoItem = page.getByTestId("todo-item");- await page.getByTestId("todo-item").nth(1).getByRole("checkbox").check();-- await checkNumberOfCompletedTodosInLocalStorage(page, 1);-- await test.step("Showing all items", async () => {- await page.getByRole("link", { name: "All" }).click();- await expect(todoItem).toHaveCount(3);- });-- await test.step("Showing active items", async () => {- await page.getByRole("link", { name: "Active" }).click();- });-- await test.step("Showing completed items", async () => {- await page.getByRole("link", { name: "Completed" }).click();- });-- await expect(todoItem).toHaveCount(1);- await page.goBack();- await expect(todoItem).toHaveCount(2);- await page.goBack();- await expect(todoItem).toHaveCount(3);- });-- test("should allow me to display completed items", async ({ page }) => {- await page.getByTestId("todo-item").nth(1).getByRole("checkbox").check();- await checkNumberOfCompletedTodosInLocalStorage(page, 1);- await page.getByRole("link", { name: "Completed" }).click();- await expect(page.getByTestId("todo-item")).toHaveCount(1);- });-- test("should allow me to display all items", async ({ page }) => {- await page.getByTestId("todo-item").nth(1).getByRole("checkbox").check();- await checkNumberOfCompletedTodosInLocalStorage(page, 1);- await page.getByRole("link", { name: "Active" }).click();- await page.getByRole("link", { name: "Completed" }).click();- await page.getByRole("link", { name: "All" }).click();- await expect(page.getByTestId("todo-item")).toHaveCount(3);- });-- test("should highlight the currently applied filter", async ({ page }) => {- await expect(page.getByRole("link", { name: "All" })).toHaveClass(- "selected"- );-- //create locators for active and completed links- const activeLink = page.getByRole("link", { name: "Active" });- const completedLink = page.getByRole("link", { name: "Completed" });- await activeLink.click();-- // Page change - active items.- await expect(activeLink).toHaveClass("selected");- await completedLink.click();-- // Page change - completed items.- await expect(completedLink).toHaveClass("selected");- });-});--async function createDefaultTodos(page: Page) {- // create a new todo locator- const newTodo = page.getByPlaceholder("What needs to be done?");-- for (const item of TODO_ITEMS) {- await newTodo.fill(item);- await newTodo.press("Enter");- }-}--async function checkNumberOfTodosInLocalStorage(page: Page, expected: number) {- return await page.waitForFunction((e) => {- return JSON.parse(localStorage["react-todos"]).length === e;- }, expected);-}--async function checkNumberOfCompletedTodosInLocalStorage(- page: Page,- expected: number-) {- return await page.waitForFunction((e) => {- return (- JSON.parse(localStorage["react-todos"]).filter(- (todo: any) => todo.completed- ).length === e- );- }, expected);-}--async function checkTodosInLocalStorage(page: Page, title: string) {- return await page.waitForFunction((t) => {- return JSON.parse(localStorage["react-todos"])- .map((todo: any) => todo.title)- .includes(t);- }, title);-}