mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-01 08:53:13 +00:00
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:
@@ -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 () => {
|
||||
|
||||
Reference in New Issue
Block a user