@davoodmehraban89 / LifeMate / commits / fa134f3
Fork 0

LifeMate — Personal, Family & Learning Companion

test: verify offline sync application and reminder outbox

davoodmehraban89 committed Oct 5, 2026 at 15:13 UTC fa134f3ff638f5cff43af63814ad2a34a9eb4813
1 file changed +33
backend/tests/phase3.test.js
+33
@@ -215,6 +215,15 @@ test('phase 3 planner school family vertical slice', async () => {
215 assert.equal(sync1.status,200);
216 assert.equal(sync1.body.results[0].status,'accepted');
217
218 + const syncedRow = await pool.query(
219 + 'select due_at from plan_item where id=$1',
220 + [privateTask.body.id],
221 + );
222 + assert.equal(
223 + new Date(syncedRow.rows[0].due_at).toISOString(),
224 + new Date(rescheduled).toISOString(),
225 + );
226 +
227 const sync2 = await request('/v1/sync/mutations',{
228 method:'POST', token:teen.token,
229 body:{mutations:[{
@@ -224,4 +233,28 @@ test('phase 3 planner school family vertical slice', async () => {
233 }]},
234 });
235 assert.equal(sync2.body.results[0].status,'already_applied');
236 +
237 + const reminderItem = await request('/v1/plan-items',{
238 + method:'POST', token:teen.token,
239 + body:{
240 + kind:'task',
241 + title:'یادآوری آزمایشی',
242 + visibility:'private',
243 + dueAt:new Date(Date.now()-60*1000).toISOString(),
244 + reminderMinutesBefore:[0],
245 + },
246 + });
247 + assert.equal(reminderItem.status,201);
248 + const claimed = await request('/v1/reminders/claim-due',{
249 + method:'POST', token:teen.token, body:{limit:10},
250 + });
251 + assert.equal(claimed.status,200);
252 + assert.ok(claimed.body.claimed >= 1);
253 + const notifications = await request('/v1/notification-outbox',{token:teen.token});
254 + assert.equal(notifications.status,200);
255 + assert.ok(
256 + notifications.body.notifications.some(
257 + (item)=>item.payload.planItemId===reminderItem.body.id,
258 + ),
259 + );
260 });