describe('Notification Flow', () => { let adminToken let authHeaders before(() => { cy.getAdminToken().then(token => { adminToken = token authHeaders = { Authorization: `Bearer ${token}` } }) }) it('fetches notifications', () => { cy.request({ url: '/api/notifications', headers: authHeaders }).then(res => { expect(res.status).to.eq(200) expect(res.body).to.be.an('array') }) }) it('each notification has required fields', () => { cy.request({ url: '/api/notifications', headers: authHeaders }).then(res => { if (res.body.length > 0) { const n = res.body[0] expect(n).to.have.property('title') expect(n).to.have.property('is_read') expect(n).to.have.property('created_at') } }) }) it('can mark all notifications as read', () => { cy.request({ method: 'POST', url: '/api/notifications/read-all', headers: authHeaders, body: {} }).then(res => { expect(res.status).to.eq(200) }) }) it('all notifications are now read', () => { cy.request({ url: '/api/notifications', headers: authHeaders }).then(res => { const unread = res.body.filter(n => !n.is_read) expect(unread).to.have.length(0) }) }) })