Files
schedule-planner/frontend/cypress/e2e/docs-flow.cy.js
Hera Zhao d3f3b4f37b
Some checks failed
Test / build-check (push) Successful in 3s
PR Preview / test (pull_request) Successful in 3s
PR Preview / teardown-preview (pull_request) Has been skipped
Test / e2e-test (push) Failing after 55s
PR Preview / deploy-preview (pull_request) Failing after 40s
Refactor to Vue 3 + FastAPI + SQLite architecture
- Backend: FastAPI + SQLite (WAL mode), 22 tables, ~40 API endpoints
- Frontend: Vue 3 + Vite + Pinia + Vue Router, 8 views, 3 stores
- Database: migrate from JSON file to SQLite with proper schema
- Dockerfile: multi-stage build (node + python)
- Deploy: K8s manifests (namespace, deployment, service, ingress, pvc, backup)
- CI/CD: Gitea Actions (test, deploy, PR preview at pr-$id.planner.oci.euphon.net)
- Tests: 20 Cypress E2E test files, 196 test cases, ~85% coverage
- Doc: test-coverage.md with full feature coverage report

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 21:18:22 +00:00

106 lines
4.1 KiB
JavaScript

describe('Docs (文档)', () => {
beforeEach(() => {
cy.visit('/docs', {
onBeforeLoad(win) {
win.localStorage.setItem('sp_login_expires', String(Date.now() + 86400000))
}
})
cy.get('header').should('be.visible')
})
it('shows docs page with header', () => {
cy.contains('个人文档').should('be.visible')
cy.contains('随手记会自动识别内容').should('be.visible')
})
it('shows add document button', () => {
cy.get('.btn-accent').should('contain', '新建文档')
})
it('opens new document form', () => {
cy.get('.btn-accent').contains('新建文档').click()
cy.get('.edit-panel').should('be.visible')
cy.contains('文档名称').should('be.visible')
cy.contains('图标').should('be.visible')
cy.contains('关键词').should('be.visible')
cy.contains('提取规则').should('be.visible')
})
it('creates a document', () => {
cy.get('.btn-accent').contains('新建文档').click()
cy.get('.edit-panel input').first().type('读书记录')
cy.get('.emoji-pick').contains('📖').click()
cy.get('.edit-panel input').eq(1).type('读完,看完')
cy.get('.btn-accent').contains('保存').click()
cy.get('.doc-card').should('contain', '读书记录')
cy.get('.doc-card').should('contain', '📖')
})
it('shows 0 entries for new document', () => {
cy.get('.btn-accent').contains('新建文档').click()
cy.get('.edit-panel input').first().type('空文档')
cy.get('.btn-accent').contains('保存').click()
cy.get('.doc-card').contains('空文档').parent().should('contain', '0 条')
})
it('opens document detail on click', () => {
cy.get('.btn-accent').contains('新建文档').click()
cy.get('.edit-panel input').first().type('详情测试')
cy.get('.btn-accent').contains('保存').click()
cy.get('.doc-card').contains('详情测试').click()
cy.get('.overlay.open').should('be.visible')
cy.get('.panel').should('contain', '详情测试')
})
it('closes document detail', () => {
cy.get('.btn-accent').contains('新建文档').click()
cy.get('.edit-panel input').first().type('关闭测试')
cy.get('.btn-accent').contains('保存').click()
cy.get('.doc-card').contains('关闭测试').click()
cy.get('.btn-close').contains('关闭').click()
cy.get('.overlay.open').should('not.exist')
})
it('edits a document from detail view', () => {
cy.get('.btn-accent').contains('新建文档').click()
cy.get('.edit-panel input').first().type('编辑前')
cy.get('.btn-accent').contains('保存').click()
cy.get('.doc-card').contains('编辑前').click()
cy.get('.btn-close').contains('编辑').click()
cy.get('.edit-panel input').first().clear().type('编辑后')
cy.get('.btn-accent').contains('保存').click()
cy.get('.doc-card').should('contain', '编辑后')
})
it('deletes a document from detail view', () => {
cy.get('.btn-accent').contains('新建文档').click()
cy.get('.edit-panel input').first().type('待删除文档')
cy.get('.btn-accent').contains('保存').click()
cy.get('.doc-card').contains('待删除文档').click()
cy.get('.btn-close').contains('删除').click()
cy.get('.doc-card').should('not.contain', '待删除文档')
})
it('cancel button closes form without saving', () => {
cy.get('.btn-accent').contains('新建文档').click()
cy.get('.edit-panel input').first().type('取消测试')
cy.get('.btn-close').contains('取消').click()
cy.get('.edit-panel').should('not.exist')
cy.get('.doc-card').should('not.contain', '取消测试')
})
it('emoji picker works', () => {
cy.get('.btn-accent').contains('新建文档').click()
cy.get('.emoji-pick').should('have.length.gte', 10)
cy.get('.emoji-pick').contains('🌙').click()
cy.get('.emoji-pick').contains('🌙').should('have.class', 'active')
})
it('extract rule dropdown has options', () => {
cy.get('.btn-accent').contains('新建文档').click()
cy.get('.edit-panel select option').should('have.length', 3)
cy.get('.edit-panel select').select('sleep')
cy.get('.edit-panel select').should('have.value', 'sleep')
})
})