fix(vacay): enforce weekend blocking in toggleEntry service

With block_weekends on, toggling a weekend day via MCP or the plugin RPC
still added the entry and burned allowance — the guard lived only in the
web UI (mcp-smoke-test I-02). toggleEntry now rejects inserts and
in-place conversions on blocked days with { error: 'weekend_blocked' }
(the votePoll pattern); removing an existing entry stays allowed so
stray weekend entries remain cleanable. The controller maps the code to
a 400, the MCP tool to an isError result.
This commit is contained in:
jubnl
2026-08-12 00:38:41 +02:00
parent 705c3c08dd
commit 7e7277beb0
7 changed files with 149 additions and 15 deletions
+4 -3
View File
@@ -187,17 +187,18 @@ describe('Vacay entries', () => {
expect(res.status).toBe(200);
});
it('VACAY-004 — POST /api/addons/vacay/entries/toggle on weekend is allowed (no server-side weekend blocking)', async () => {
it('VACAY-004 — POST /api/addons/vacay/entries/toggle on a weekend is rejected when block_weekends is on', async () => {
const { user } = createUser(testDb);
await request(app).get('/api/addons/vacay/plan').set('Cookie', authCookie(user.id));
await request(app).post('/api/addons/vacay/years').set('Cookie', authCookie(user.id)).send({ year: 2025 });
// 2025-06-21 is a Saturday — server does not block weekends; client-side only
// 2025-06-21 is a Saturday and plans default to block_weekends = 1 (I-02)
const res = await request(app)
.post('/api/addons/vacay/entries/toggle')
.set('Cookie', authCookie(user.id))
.send({ date: '2025-06-21', year: 2025, type: 'vacation' });
expect(res.status).toBe(200);
expect(res.status).toBe(400);
expect(res.body).toEqual({ error: 'Weekend days are blocked on this plan' });
});
it('VACAY-006 — GET /api/addons/vacay/entries/:year returns vacation entries', async () => {