Chores: weekly goals with custom reward tiers (everyone or chosen people)
build-container / build (push) Successful in 3m53s
build-container / build (push) Successful in 3m53s
- Admin-set reward tiers; points count Monday to Sunday and restart each week - Per-person weekly totals, chores done, progress bar toward the next reward, week history - Mark given / undo when a reward is handed over - Rewards can be for everyone or only chosen people - "This week" card on the family board - Tests and README updated Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0df1ff5705
commit
17a282054a
8 files changed
+73
-13
No files matched your search
@@ -36,6 +36,14 @@ const hub = http.createServer((req, res) => users.runAs(P[req.headers['x-user']
|
||||
assert.equal((await post('/claim', { chore: sweep.id, date: today }, 'c')).status, 409, 'someone else cannot take it too'); assert.equal((await post('/done', { chore: sweep.id, date: today }, 'c')).status, 403, 'or tick it off');
|
||||
assert.equal((await post('/claim', { chore: sweep.id, date: today, undo: true }, 'c')).status, 403, 'or put it back'); assert.equal((await post('/claim', { chore: sweep.id, date: today, undo: true }, 'b')).status, 200); assert.equal((await board('b')).find(x => x.title === 'Sweep').claimable, true, 'put back in the pool');
|
||||
await post('/claim', { chore: sweep.id, date: today }, 'c'); assert.equal((await post('/done', { chore: sweep.id, date: today }, 'c')).status, 200); sw = (await board('b')).find(x => x.title === 'Sweep'); assert.ok(sw.done && sw.user === P.c.id, 'done by the one who took it'); assert.equal((await post('/claim', { chore: sweep.id, date: today, undo: true }, 'c')).status, 200); assert.equal((await post('/claim', { chore: dishes.id, date: today }, 'b')).status, 400, 'only pool chores');
|
||||
// weekly goals: tiers, a Monday-to-Sunday week, what each person did, handing a reward over
|
||||
assert.equal((await post('/reward', { title: 'Pick the movie', points: 5 }, 'b')).status, 403, 'only an admin sets rewards'); assert.equal((await post('/reward', { title: '', points: 5 })).status, 400); assert.equal((await post('/reward', { title: 'x', points: 0 })).status, 400);
|
||||
const r5 = await j(await post('/reward', { title: 'Pick the movie', points: 5 })), r50 = await j(await post('/reward', { title: 'A trip', points: 50 })); let wk = await j(await call('/week?date=' + today, {}, 'a')); assert.equal(wk.from, chores.addDays(wk.from, 0)); assert.equal(new Date(wk.from + 'T12:00:00Z').getUTCDay(), 1, 'a week starts on Monday'); assert.equal(wk.tiers.length, 2);
|
||||
const wb = wk.people.find(x => x.name === 'Bob'), wy = wk.people.find(x => x.name === 'Cy'); assert.ok(wb.points >= 8 && wb.done.some(x => x.title === 'Fix the gate'), 'what Bob did this week is listed'); assert.ok(wb.earned.includes(r5.id) && !wb.earned.includes(r50.id), 'tiers reached'); assert.equal(wb.given.length, 0);
|
||||
assert.equal((await post('/give', { user: P.b.id, reward: r50.id }, 'a')).status, 400, 'cannot give what is not earned'); assert.equal((await post('/give', { user: P.b.id, reward: r5.id }, 'b')).status, 403); assert.equal((await post('/give', { user: P.b.id, reward: r5.id })).status, 200); wk = await j(await call('/week?date=' + today, {}, 'a')); assert.deepEqual(wk.people.find(x => x.name === 'Bob').given, [r5.id]);
|
||||
assert.equal((await j(await call('/week?date=' + chores.addDays(today, -7), {}, 'a'))).people.every(x => x.points === 0), true, 'last week had no points: they start again each week');
|
||||
const rc = await j(await post('/reward', { title: 'Bake together', points: 3, for: [P.c.id] })); wk = await j(await call('/week?date=' + today, {}, 'a')); assert.ok(wk.people.find(x => x.name === 'Cy').earned.includes(rc.id), 'a reward just for Cy: Cy earns it'); assert.ok(!wk.people.find(x => x.name === 'Bob').tiers.includes(rc.id), 'and it is not on Bob\'s list'); assert.equal((await post('/reward', { title: 'x', points: 3, for: [] })).status, 400, 'someone has to be chosen'); await post('/reward', { id: rc.id, remove: true });
|
||||
assert.equal((await post('/give', { user: P.b.id, reward: r5.id, undo: true })).status, 200); assert.equal((await j(await call('/week?date=' + today, {}, 'a'))).people.find(x => x.name === 'Bob').given.length, 0);
|
||||
// delete removes its history
|
||||
assert.equal((await call('/' + once.id, { method: 'DELETE' }, 'b')).status, 403); assert.equal((await call('/' + once.id, { method: 'DELETE' })).status, 200); assert.equal((await j(await call('/summary', {}, 'a'))).people.find(x => x.name === 'Bob').points, 3);
|
||||
assert.equal((await call('/?date=nope')).status, 400);
|
||||
|
||||
Reference in new issue
Block a user