Skip to content

Commit 8e8aa25

Browse files
danbimclaude
andcommitted
feat: add E2E tests for job posting sites and generate screenshot
- Add sites.spec.ts with 8 tests covering CRUD, navigation, and links - Add test fixtures with 5 seeded job posting sites - Seed sites in PGLite test database - Add screenshot test generating docs/screenshots/sites.png - Fix formatLastChecked to handle future timestamps gracefully Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 02ead9e commit 8e8aa25

File tree

14 files changed

+232
-21
lines changed

14 files changed

+232
-21
lines changed

app/components/job-form.tsx

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,22 @@ export function JobForm({ job, errors, headerActions }: JobFormProps) {
111111
</div>
112112
</div>
113113

114-
<Tabs defaultValue="basic-info" className="mt-6 flex flex-col flex-1 min-h-0">
114+
<Tabs
115+
defaultValue="basic-info"
116+
className="mt-6 flex flex-col flex-1 min-h-0"
117+
>
115118
<TabsList className="w-full">
116119
<TabsTrigger value="basic-info">Basic Info</TabsTrigger>
117120
<TabsTrigger value="compensation">Compensation</TabsTrigger>
118121
<TabsTrigger value="work-location">Work Location</TabsTrigger>
119122
<TabsTrigger value="ratings">Ratings</TabsTrigger>
120123
</TabsList>
121124

122-
<TabsContent value="basic-info" forceMount className="data-[state=inactive]:hidden flex-1 min-h-0">
125+
<TabsContent
126+
value="basic-info"
127+
forceMount
128+
className="data-[state=inactive]:hidden flex-1 min-h-0"
129+
>
123130
<Card className="h-full">
124131
<CardContent className="pt-6 space-y-4 h-full flex flex-col">
125132
<div className="grid grid-cols-1 gap-4">
@@ -240,15 +247,20 @@ export function JobForm({ job, errors, headerActions }: JobFormProps) {
240247
id="dateOpened"
241248
name="dateOpened"
242249
type="date"
243-
defaultValue={job?.dateOpened ?? new Date().toISOString().split('T')[0]}
250+
defaultValue={
251+
job?.dateOpened ?? new Date().toISOString().split('T')[0]
252+
}
244253
/>
245254
</div>
246-
247255
</CardContent>
248256
</Card>
249257
</TabsContent>
250258

251-
<TabsContent value="compensation" forceMount className="data-[state=inactive]:hidden">
259+
<TabsContent
260+
value="compensation"
261+
forceMount
262+
className="data-[state=inactive]:hidden"
263+
>
252264
<Card>
253265
<CardContent className="pt-6 space-y-4">
254266
<div className="grid grid-cols-4 gap-4">
@@ -333,12 +345,19 @@ export function JobForm({ job, errors, headerActions }: JobFormProps) {
333345
</Card>
334346
</TabsContent>
335347

336-
<TabsContent value="work-location" forceMount className="data-[state=inactive]:hidden">
348+
<TabsContent
349+
value="work-location"
350+
forceMount
351+
className="data-[state=inactive]:hidden"
352+
>
337353
<Card>
338354
<CardContent className="pt-6 space-y-4">
339355
<div className="space-y-2">
340356
<Label htmlFor="workLocation">Work Type</Label>
341-
<Select name="workLocation" defaultValue={job?.workLocation ?? ''}>
357+
<Select
358+
name="workLocation"
359+
defaultValue={job?.workLocation ?? ''}
360+
>
342361
<SelectTrigger>
343362
<SelectValue placeholder="Select work type" />
344363
</SelectTrigger>
@@ -376,7 +395,11 @@ export function JobForm({ job, errors, headerActions }: JobFormProps) {
376395
</Card>
377396
</TabsContent>
378397

379-
<TabsContent value="ratings" forceMount className="data-[state=inactive]:hidden">
398+
<TabsContent
399+
value="ratings"
400+
forceMount
401+
className="data-[state=inactive]:hidden"
402+
>
380403
<Card>
381404
<CardContent className="pt-6 space-y-4">
382405
<div className="flex items-center space-x-2">
@@ -401,14 +424,15 @@ export function JobForm({ job, errors, headerActions }: JobFormProps) {
401424
key={name}
402425
name={name}
403426
label={label}
404-
defaultValue={job?.[name as keyof JobOpening] as number | null}
427+
defaultValue={
428+
job?.[name as keyof JobOpening] as number | null
429+
}
405430
/>
406431
))}
407432
</CardContent>
408433
</Card>
409434
</TabsContent>
410435
</Tabs>
411-
412436
</Form>
413437
)
414438
}

app/db/db.server.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@ export const db = await (async () => {
1616
await migrate(db, { migrationsFolder: './app/db/migrations' })
1717

1818
// Load and insert test data
19-
const { testFormulas, testJobs } = await import('../../e2e/fixtures')
19+
const { testFormulas, testJobs, testSites } = await import(
20+
'../../e2e/fixtures'
21+
)
2022
await db.insert(schema.scoringFormulas).values(testFormulas)
2123
await db.insert(schema.jobOpenings).values(testJobs)
24+
await db.insert(schema.jobPostingSites).values(testSites)
2225

2326
console.log('[PGLite] Initialized with test data')
2427
return db

app/repositories/job-posting-site.repository.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import type { PostgresJsDatabase } from 'drizzle-orm/postgres-js'
33
import type * as schema from '~/db/schema'
44
import {
55
type JobPostingSite,
6-
type NewJobPostingSite,
76
jobPostingSites,
7+
type NewJobPostingSite,
88
} from '~/db/schema'
99

1010
export class JobPostingSiteRepository {
@@ -14,9 +14,7 @@ export class JobPostingSiteRepository {
1414
return this.db
1515
.select()
1616
.from(jobPostingSites)
17-
.orderBy(
18-
sql`${jobPostingSites.lastCheckedAt} ASC NULLS FIRST`,
19-
)
17+
.orderBy(sql`${jobPostingSites.lastCheckedAt} ASC NULLS FIRST`)
2018
}
2119

2220
async findById(id: string): Promise<JobPostingSite | undefined> {

app/routes/sites.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ function formatLastChecked(date: string | null): string {
9090
const diffMs = now.getTime() - checked.getTime()
9191
const diffDays = Math.floor(diffMs / (1000 * 60 * 60 * 24))
9292

93-
if (diffDays === 0) return 'Today'
93+
if (diffDays <= 0) return 'Today'
9494
if (diffDays === 1) return 'Yesterday'
9595
if (diffDays < 7) return `${diffDays} days ago`
9696
if (diffDays < 30) {

app/services/job-posting-site.service.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
import type {
2-
JobPostingSite,
3-
NewJobPostingSite,
4-
} from '~/db/schema'
1+
import type { JobPostingSite, NewJobPostingSite } from '~/db/schema'
52
import type { JobPostingSiteRepository } from '~/repositories/job-posting-site.repository'
63

74
export class JobPostingSiteService {

docs/screenshots/filters.png

500 Bytes
Loading

docs/screenshots/job-form.png

-3.34 KB
Loading

docs/screenshots/job-list.png

1.54 KB
Loading

docs/screenshots/notes-panel.png

1.04 KB
Loading

docs/screenshots/sites.png

48.6 KB
Loading

0 commit comments

Comments
 (0)