Drop the direct apply path the calendar no longer uses

Applying a plan by itself stopped being something the interface does once
every edit began recomputing and saving in one call. The hook that posted
straight to the apply endpoint had no caller left, nor did its request type
or its fixture.

The response decoder stays, since the sync response embeds the same object,
and the two tests being deleted were the only ones checking how its collision
and rejection fields are renamed — that coverage moved onto the sync test
rather than leaving with the code it happened to live next to.
This commit is contained in:
2026-09-18 01:12:26 +02:00
parent d245390886
commit 9ac67933d4
8 changed files with 30 additions and 309 deletions
+30 -74
View File
@@ -1432,78 +1432,6 @@ describe('endpoint functions (representative coverage)', () => {
})
})
it('applyPlan maps rejections to messageKey/data (§3.5)', async () => {
fetchMock.mockResolvedValue({
ok: true,
status: 200,
json: async () => ({
accepted: false,
created_count: 0,
skipped_identical_count: 0,
skipped_free_count: 0,
replaced_count: 0,
collisions: [],
rejections: [
{
message_key: 'planApply.rejection.insufficientBalance',
data: { tier: 'sjukpenning', needed: 2, remaining: 1 },
},
],
created_days: [],
}),
})
const result = await api.applyPlan('ws1', [], false)
expect(result.accepted).toBe(false)
expect(result.rejections).toEqual([
{
messageKey: 'planApply.rejection.insufficientBalance',
data: { tier: 'sjukpenning', needed: 2, remaining: 1 },
},
])
})
it('applyPlan maps a populated collisions array to camelCase (§3.5)', async () => {
// The only other applyPlan mapping test passes collisions: [], so
// existing_day_type/proposed_day_type were never checked against real
// data — this exercises the actual field renames.
fetchMock.mockResolvedValue({
ok: true,
status: 200,
json: async () => ({
accepted: false,
created_count: 0,
skipped_identical_count: 0,
skipped_free_count: 0,
replaced_count: 0,
collisions: [
{
date: '2026-06-15',
parent_personal_data_uuid: 'pd1',
child_id: 'child1',
existing_day_type: 'vacation',
proposed_day_type: 'sjukpenning',
},
],
rejections: [],
created_days: [],
}),
})
const result = await api.applyPlan('ws1', [], false)
expect(result.collisions).toEqual([
{
date: '2026-06-15',
parentPersonalDataUuid: 'pd1',
childId: 'child1',
existingDayType: 'vacation',
proposedDayType: 'sjukpenning',
},
])
})
it('syncPlan posts the workspace id and maps the nested proposal/applyResult/changes', async () => {
fetchMock.mockResolvedValue({
ok: true,
@@ -1524,8 +1452,21 @@ describe('endpoint functions (representative coverage)', () => {
skipped_identical_count: 0,
skipped_free_count: 0,
replaced_count: 1,
collisions: [],
rejections: [],
collisions: [
{
date: '2026-06-15',
parent_personal_data_uuid: 'pd1',
child_id: 'child1',
existing_day_type: 'vacation',
proposed_day_type: 'sjukpenning',
},
],
rejections: [
{
message_key: 'planApply.rejection.insufficientBalance',
data: { tier: 'sjukpenning', needed: 2, remaining: 1 },
},
],
created_days: [],
},
changes: [
@@ -1563,6 +1504,21 @@ describe('endpoint functions (representative coverage)', () => {
expect(lastRequestBody()).toEqual({ workspace_id: 'ws1' })
expect(result.applyResult.createdCount).toBe(2)
expect(result.applyResult.replacedCount).toBe(1)
expect(result.applyResult.collisions).toEqual([
{
date: '2026-06-15',
parentPersonalDataUuid: 'pd1',
childId: 'child1',
existingDayType: 'vacation',
proposedDayType: 'sjukpenning',
},
])
expect(result.applyResult.rejections).toEqual([
{
messageKey: 'planApply.rejection.insufficientBalance',
data: { tier: 'sjukpenning', needed: 2, remaining: 1 },
},
])
expect(result.changes).toHaveLength(2)
expect(result.changes[0]).toEqual({
kind: 'retyped',