5a306f51a1
Introduces pipeline.ts (mirrors backend JobPipeline) as the one frontend source of truth for canonical stages, synonym normalization, tone, and localized labels. Replaces the status list/logic previously duplicated across KanbanBoard, JobTable, AddJobModal and EditJobDialog. - KanbanBoard/AddJobModal/EditJobDialog render from PIPELINE_STATUSES - JobTable uses shared statusTone + statusLabel (status chips now localized; NB gets proper labels, English unchanged) - Edit dialog status dropdown is now localized too - 5 unit tests; full frontend suite green (19 suites / 41 tests) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
38 lines
1.7 KiB
TypeScript
38 lines
1.7 KiB
TypeScript
import { normalizeStatus, statusTone, statusLabel, PIPELINE_STATUSES } from './pipeline';
|
|
|
|
describe('pipeline', () => {
|
|
test('normalizeStatus canonicalizes casing and synonyms', () => {
|
|
expect(normalizeStatus('applied')).toBe('Applied');
|
|
expect(normalizeStatus(' OFFER ')).toBe('Offer');
|
|
expect(normalizeStatus('Interviewing')).toBe('Interview');
|
|
expect(normalizeStatus('declined')).toBe('Rejected');
|
|
});
|
|
|
|
test('normalizeStatus preserves unknown as Other and empty as Applied', () => {
|
|
expect(normalizeStatus('Take-home')).toBe('Other');
|
|
expect(normalizeStatus('')).toBe('Applied');
|
|
expect(normalizeStatus(null)).toBe('Applied');
|
|
});
|
|
|
|
test('statusTone maps stages to palette keys', () => {
|
|
expect(statusTone('Offer')).toBe('success');
|
|
expect(statusTone('Rejected')).toBe('error');
|
|
expect(statusTone('Waiting')).toBe('warning');
|
|
expect(statusTone('Ghosted')).toBe('warning');
|
|
expect(statusTone('Interview')).toBe('info');
|
|
expect(statusTone('Applied')).toBe('primary');
|
|
expect(statusTone('Take-home')).toBe('default');
|
|
});
|
|
|
|
test('statusLabel localizes canonical and passes through custom', () => {
|
|
const t = (key: string) => ({ statusApplied: 'Applied', statusOffer: 'Offer' } as Record<string, string>)[key] ?? key;
|
|
expect(statusLabel(t, 'Applied')).toBe('Applied');
|
|
expect(statusLabel(t, 'Interviewing')).toBe('statusInterview'); // maps to canonical key
|
|
expect(statusLabel(t, 'Take-home assignment')).toBe('Take-home assignment');
|
|
});
|
|
|
|
test('canonical stage list is stable and ordered', () => {
|
|
expect(PIPELINE_STATUSES).toEqual(['Applied', 'Waiting', 'Interview', 'Offer', 'Rejected', 'Ghosted']);
|
|
});
|
|
});
|