Some checks failed
PR Preview / teardown-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 5s
Test / build-check (push) Successful in 4s
PR Preview / test (pull_request) Successful in 5s
PR Preview / deploy-preview (pull_request) Successful in 12s
Test / e2e-test (push) Failing after 2m14s
根本原因: 所有测试硬编码了只在生产环境有效的admin token, CI创建新数据库时token不同导致全部认证失败。 修复: - CI: 设置已知ADMIN_TOKEN环境变量传给后端和Cypress - cypress/support/e2e.js: 新增cy.getAdminToken()动态获取token - 24个spec文件: 硬编码token改为cy.getAdminToken() - UI选择器: 适配管理页面从tab移到UserMenu、编辑器DOM变化 - API: create_recipe→share_recipe、ingredients格式、权限变化 - 超时: 300s→420s适应32个spec Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
87 lines
2.4 KiB
JavaScript
87 lines
2.4 KiB
JavaScript
describe('doTERRA 精油配方计算器 - 功能演示', () => {
|
|
let adminToken
|
|
|
|
before(() => {
|
|
cy.getAdminToken().then(token => { adminToken = token })
|
|
})
|
|
|
|
it('完整功能演示', { defaultCommandTimeout: 15000 }, () => {
|
|
// ===== 开场:首页加载 =====
|
|
cy.visit('/', {
|
|
onBeforeLoad(win) {
|
|
win.localStorage.setItem('oil_auth_token', adminToken)
|
|
}
|
|
})
|
|
cy.get('.app-header').should('be.visible')
|
|
cy.wait(1000)
|
|
|
|
// ===== 配方卡片列表 =====
|
|
cy.get('.recipe-card', { timeout: 10000 }).should('have.length.gte', 1)
|
|
cy.wait(500)
|
|
|
|
// ===== 搜索框输入 =====
|
|
cy.get('input[placeholder*="搜索"]').click()
|
|
cy.get('input[placeholder*="搜索"]').type('薰衣草', { delay: 100 })
|
|
cy.wait(500)
|
|
cy.get('input[placeholder*="搜索"]').clear()
|
|
cy.wait(500)
|
|
|
|
// ===== 点击配方卡片 =====
|
|
cy.get('.recipe-card').first().click()
|
|
cy.wait(1000)
|
|
|
|
// ===== 查看详情 =====
|
|
cy.get('[class*="overlay"], [class*="detail"]').should('be.visible')
|
|
cy.get('.detail-close-btn').first().click({ force: true })
|
|
cy.wait(500)
|
|
|
|
// ===== 切换精油价目 =====
|
|
cy.get('.nav-tab').contains('精油价目').click()
|
|
cy.wait(1000)
|
|
|
|
// ===== 精油页面 =====
|
|
cy.get('.oil-chip', { timeout: 10000 }).should('have.length.gte', 1)
|
|
|
|
// ===== 管理配方 =====
|
|
cy.get('.nav-tab').contains('管理配方').click()
|
|
cy.wait(1000)
|
|
|
|
// ===== 个人库存 =====
|
|
cy.get('.nav-tab').contains('个人库存').click()
|
|
cy.wait(1000)
|
|
|
|
// ===== Admin pages via direct URL =====
|
|
cy.visit('/audit', {
|
|
onBeforeLoad(win) {
|
|
win.localStorage.setItem('oil_auth_token', adminToken)
|
|
}
|
|
})
|
|
cy.contains('操作日志', { timeout: 10000 }).should('be.visible')
|
|
cy.wait(500)
|
|
|
|
cy.visit('/bugs', {
|
|
onBeforeLoad(win) {
|
|
win.localStorage.setItem('oil_auth_token', adminToken)
|
|
}
|
|
})
|
|
cy.contains('Bug', { timeout: 10000 }).should('be.visible')
|
|
cy.wait(500)
|
|
|
|
cy.visit('/users', {
|
|
onBeforeLoad(win) {
|
|
win.localStorage.setItem('oil_auth_token', adminToken)
|
|
}
|
|
})
|
|
cy.contains('用户管理', { timeout: 10000 }).should('be.visible')
|
|
cy.wait(500)
|
|
|
|
// ===== 回到首页 =====
|
|
cy.visit('/', {
|
|
onBeforeLoad(win) {
|
|
win.localStorage.setItem('oil_auth_token', adminToken)
|
|
}
|
|
})
|
|
cy.get('.recipe-card', { timeout: 10000 }).should('have.length.gte', 1)
|
|
})
|
|
})
|