diff --git a/frontend/website/cypress/e2e/today-assignments.cy.ts b/frontend/website/cypress/e2e/today-assignments.cy.ts index 553c57c..cc79fca 100644 --- a/frontend/website/cypress/e2e/today-assignments.cy.ts +++ b/frontend/website/cypress/e2e/today-assignments.cy.ts @@ -26,7 +26,7 @@ describe("today's assignments", () => { interceptDashboardRequests() }) - it('uses the browser date and links every assignment to its schedule', () => { + it('shows only the earliest due assignment for each schedule', () => { cy.intercept('GET', `**/api/assignments?date=${browserToday}`, (request) => { expect(request.headers.accept).to.equal('application/json') request.reply({ @@ -60,6 +60,58 @@ describe("today's assignments", () => { path: ['Introduction'], }, }, + { + id: 14, + scheduledDate: browserToday, + schedule: { + id: 73, + set: { name: 'Bible' }, + }, + element: { + name: 'Chapter 2', + kind: 'Chapter_sections-v2', + path: ['Genesis', 'The garden', 'Chapter 2'], + }, + }, + { + id: 15, + scheduledDate: browserToday, + schedule: { + id: 73, + set: { name: 'Bible' }, + }, + element: { + name: 'Chapter 3', + kind: 'Chapter_sections-v2', + path: ['Genesis', 'The fall', 'Chapter 3'], + }, + }, + { + id: 16, + scheduledDate: browserToday, + schedule: { + id: 73, + set: { name: 'Bible' }, + }, + element: { + name: 'Chapter 4', + kind: 'Chapter_sections-v2', + path: ['Genesis', 'Cain and Abel', 'Chapter 4'], + }, + }, + { + id: 17, + scheduledDate: browserToday, + schedule: { + id: 73, + set: { name: 'Bible' }, + }, + element: { + name: 'Chapter 5', + kind: 'Chapter_sections-v2', + path: ['Genesis', 'Generations', 'Chapter 5'], + }, + }, ], }, }) @@ -89,6 +141,40 @@ describe("today's assignments", () => { cy.get('[data-today-assignment="13"] .today-assignment__overdue').should( 'not.exist', ) + cy.get('[data-today-assignment="14"]').should('not.exist') + cy.get('[data-today-assignment="15"]').should('not.exist') + cy.get('[data-today-assignment="16"]').should('not.exist') + cy.get('[data-today-assignment="17"]').should('not.exist') + cy.get('[data-today-schedule="73"]') + .should('have.attr', 'data-due-count', '5') + .and('contain.text', '5 due now') + .and('have.class', 'today-assignment-stack--queued') + .within(() => { + cy.get('[data-stack-layer]').should('have.length', 3) + }) + .then(($stack) => { + const stack = $stack[0] + if (stack === undefined) { + throw new Error('today assignment stack not found') + } + + const assignmentCard = stack.querySelector('.today-assignment') + const backgroundCard = stack.querySelector('[data-stack-layer]') + if (assignmentCard === null || backgroundCard === null) { + throw new Error('today assignment stack cards not found') + } + + expect(backgroundCard.getBoundingClientRect().left).to.be.lessThan( + assignmentCard.getBoundingClientRect().left, + ) + }) + cy.get('[data-today-schedule="81"]') + .should('have.attr', 'data-due-count', '1') + .and('not.have.class', 'today-assignment-stack--queued') + .within(() => { + cy.get('.today-assignment__queue-count').should('not.exist') + cy.get('[data-stack-layer]').should('not.exist') + }) cy.contains('a', 'Genesis / Creation / Chapter 1') .should('contain.text', 'Bible') .and('have.attr', 'href', '/schedules/73') @@ -144,6 +230,19 @@ describe("today's assignments", () => { path: ['Genesis', 'Chapter 1'], }, }, + { + id: 13, + scheduledDate: browserToday, + schedule: { + id: 73, + set: { name: 'Bible' }, + }, + element: { + name: 'Chapter 2', + kind: 'chapter', + path: ['Genesis', 'Chapter 2'], + }, + }, ], }, }).as('todayAssignments') @@ -169,25 +268,52 @@ describe("today's assignments", () => { }, }) }) + cy.intercept('PATCH', '**/api/assignments/13', (request) => { + expect(request.body).to.deep.equal({ completed: true }) + request.reply({ + delay: 400, + statusCode: 200, + body: { + assignment: { + id: 13, + completedAt: '2026-08-15T12:35:00+00:00', + }, + }, + }) + }).as('nextCompletion') cy.visit('/dashboard') cy.wait('@me') cy.wait('@todayAssignments') cy.get('[data-today-assignment="12"]').within(() => { + cy.get('[data-stack-layer]').should('have.length', 1) cy.contains('button', 'Mark complete').click() cy.contains('button', 'Completing...').should('be.disabled') }) cy.wait('@completion1') cy.get('[data-today-assignment="12"]') .should('contain.text', "We couldn't update this assignment.") + .and('contain.text', '2 due now') .within(() => { + cy.get('[data-stack-layer]').should('have.length', 1) cy.contains('button', 'Mark complete').click() cy.contains('button', 'Completing...').should('be.disabled') }) cy.wait('@completion2') cy.get('[data-today-assignment="12"]').should('not.exist') + cy.get('[data-today-assignment="13"]') + .should('be.visible') + .and('have.attr', 'data-due-count', '1') + .within(() => { + cy.get('.today-assignment__queue-count').should('not.exist') + cy.get('[data-stack-layer]').should('not.exist') + cy.contains('button', 'Mark complete').click() + }) + cy.wait('@nextCompletion') + + cy.get('[data-today-assignment="13"]').should('not.exist') cy.get('.today-assignments [role="status"]').should( 'contain.text', 'Nothing is due today.', diff --git a/frontend/website/src/views/DashboardView.vue b/frontend/website/src/views/DashboardView.vue index 7d1eeaf..422dcf5 100644 --- a/frontend/website/src/views/DashboardView.vue +++ b/frontend/website/src/views/DashboardView.vue @@ -1,17 +1,40 @@