diff --git a/cypress/e2e/today.cy.js b/cypress/e2e/today.cy.js index 7332662..1f24450 100644 --- a/cypress/e2e/today.cy.js +++ b/cypress/e2e/today.cy.js @@ -29,4 +29,47 @@ describe('The today page', () => { cy.visit('/home') cy.get('a[href="/today"]').should('be.visible') }) + + it('lists scheduled nodes for today', () => { + const today = new Date() + const year = today.getFullYear() + const month = String(today.getMonth() + 1).padStart(2, '0') + const day = String(today.getDate()).padStart(2, '0') + const todayString = year + '-' + month + '-' + day + + cy.loginAsUser() + cy.request({ + method: 'POST', + url: '/api/plans', + body: { + textId: 0, + name: 'My reading plan', + dateStart: todayString, + dateEnd: todayString, + }, + }) + + cy.intercept('GET', '/api/scheduled-nodes*') + .as('getScheduledNodes') + cy.visit('/today') + cy.wait('@getScheduledNodes').then((interception) => { + expect(interception.request.url).to.include( + 'date=' + todayString + ) + }) + cy.get('#scheduled-nodes-list').should( + 'contain', + 'My reading plan' + ) + cy.get('#scheduled-nodes-list').should('contain', 'Bereishis') + }) + + it('shows an empty list when no nodes are scheduled today', () => { + cy.loginAsUser() + cy.intercept('GET', '/api/scheduled-nodes*') + .as('getScheduledNodes') + cy.visit('/today') + cy.wait('@getScheduledNodes') + cy.get('#scheduled-nodes-list li').should('have.length', 0) + }) })