describe('Reminders (提醒)', () => { beforeEach(() => { cy.visit('/reminders', { onBeforeLoad(win) { win.localStorage.setItem('sp_login_expires', String(Date.now() + 86400000)) } }) cy.get('header').should('be.visible') }) it('shows reminders page with add button', () => { cy.get('.section-header').should('contain', '提醒') cy.get('.btn-accent').should('contain', '新提醒') }) it('opens add reminder form', () => { cy.get('.btn-accent').contains('新提醒').click() cy.get('.edit-form').should('be.visible') cy.get('.edit-form input').should('have.length.gte', 2) cy.get('.edit-form select').should('exist') }) it('creates a reminder', () => { cy.get('.btn-accent').contains('新提醒').click() cy.get('.edit-form input').first().type('喝水提醒') cy.get('.edit-form input[type="time"]').type('14:00') cy.get('.edit-form select').select('daily') cy.get('.btn-accent').contains('保存').click() cy.get('.reminder-card').should('contain', '喝水提醒') cy.get('.reminder-meta').should('contain', '14:00') cy.get('.reminder-meta').should('contain', '每天') }) it('creates reminder with different repeat options', () => { cy.get('.btn-accent').contains('新提醒').click() cy.get('.edit-form input').first().type('周报提醒') cy.get('.edit-form select').select('weekly') cy.get('.btn-accent').contains('保存').click() cy.get('.reminder-card').should('contain', '周报提醒') cy.get('.reminder-meta').should('contain', '每周') }) it('toggles reminder enabled/disabled', () => { cy.get('.btn-accent').contains('新提醒').click() cy.get('.edit-form input').first().type('开关测试') cy.get('.btn-accent').contains('保存').click() cy.get('.reminder-toggle').first().click() cy.get('.reminder-toggle').first().should('contain', '🔕') cy.get('.reminder-toggle').first().click() cy.get('.reminder-toggle').first().should('contain', '🔔') }) it('deletes a reminder', () => { cy.get('.btn-accent').contains('新提醒').click() cy.get('.edit-form input').first().type('待删除提醒') cy.get('.btn-accent').contains('保存').click() cy.get('.reminder-card').contains('待删除提醒').parents('.reminder-card').find('.remove-btn').click() cy.get('.reminder-card').should('not.contain', '待删除提醒') }) it('cancel button closes form without saving', () => { cy.get('.btn-accent').contains('新提醒').click() cy.get('.edit-form input').first().type('取消测试') cy.get('.btn-close').contains('取消').click() cy.get('.edit-form').should('not.exist') cy.get('.reminder-card').should('not.contain', '取消测试') }) it('shows empty hint when no reminders', () => { // Just verify component handles both states gracefully cy.get('.reminders-layout').should('be.visible') }) })