Make PTO creation immediately approved, add PTO deletion, and ensure cache invalidation updates individual/team/revenue capacity consistently. Harden holiday duplicate handling (422), support PTO-day availability overrides without disabling edits, and align tests plus OpenSpec artifacts with the new behavior.
41 lines
980 B
TypeScript
41 lines
980 B
TypeScript
import { describe, expect, it, vi } from 'vitest';
|
|
|
|
vi.mock('$lib/services/api', () => ({
|
|
api: {
|
|
get: vi.fn()
|
|
}
|
|
}));
|
|
|
|
import { getTeamCapacity } from '$lib/api/capacity';
|
|
import { api } from '$lib/services/api';
|
|
|
|
describe('capacity api mapping', () => {
|
|
it('maps legacy team capacity payload keys', async () => {
|
|
vi.mocked(api.get).mockResolvedValueOnce({
|
|
month: '2026-02',
|
|
person_days: 10.5,
|
|
hours: 84,
|
|
members: []
|
|
});
|
|
|
|
const payload = await getTeamCapacity('2026-02');
|
|
|
|
expect(payload.total_person_days).toBe(10.5);
|
|
expect(payload.total_hours).toBe(84);
|
|
});
|
|
|
|
it('maps new team capacity payload keys', async () => {
|
|
vi.mocked(api.get).mockResolvedValueOnce({
|
|
month: '2026-03',
|
|
total_person_days: 12,
|
|
total_hours: 96,
|
|
members: []
|
|
});
|
|
|
|
const payload = await getTeamCapacity('2026-03');
|
|
|
|
expect(payload.total_person_days).toBe(12);
|
|
expect(payload.total_hours).toBe(96);
|
|
});
|
|
});
|