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>
58 lines
2.0 KiB
JavaScript
58 lines
2.0 KiB
JavaScript
describe('Visual Check - Screenshots', () => {
|
|
let adminToken
|
|
|
|
before(() => {
|
|
cy.getAdminToken().then(token => { adminToken = token })
|
|
})
|
|
|
|
it('homepage with recipes', () => {
|
|
cy.visit('/', { onBeforeLoad(win) { win.localStorage.setItem('oil_auth_token', adminToken) } })
|
|
cy.get('.recipe-card', { timeout: 10000 }).should('have.length.gte', 1)
|
|
cy.wait(1000)
|
|
cy.screenshot('01-homepage')
|
|
})
|
|
|
|
it('recipe detail overlay', () => {
|
|
cy.visit('/', { onBeforeLoad(win) { win.localStorage.setItem('oil_auth_token', adminToken) } })
|
|
cy.get('.recipe-card', { timeout: 10000 }).first().click()
|
|
cy.wait(1000)
|
|
cy.screenshot('02-recipe-detail')
|
|
})
|
|
|
|
it('oil reference page', () => {
|
|
cy.visit('/oils', { onBeforeLoad(win) { win.localStorage.setItem('oil_auth_token', adminToken) } })
|
|
cy.get('.oil-chip', { timeout: 10000 }).should('have.length.gte', 1)
|
|
cy.wait(500)
|
|
cy.screenshot('03-oil-reference')
|
|
})
|
|
|
|
it('manage recipes page', () => {
|
|
cy.visit('/manage', { onBeforeLoad(win) { win.localStorage.setItem('oil_auth_token', adminToken) } })
|
|
cy.wait(2000)
|
|
cy.screenshot('04-manage-recipes')
|
|
})
|
|
|
|
it('inventory page', () => {
|
|
cy.visit('/inventory', { onBeforeLoad(win) { win.localStorage.setItem('oil_auth_token', adminToken) } })
|
|
cy.wait(1500)
|
|
cy.screenshot('05-inventory')
|
|
})
|
|
|
|
it('check if recipe cards show price > 0', () => {
|
|
cy.visit('/', { onBeforeLoad(win) { win.localStorage.setItem('oil_auth_token', adminToken) } })
|
|
cy.get('.recipe-card', { timeout: 10000 }).should('have.length.gte', 1)
|
|
// Check if any card shows a non-zero price
|
|
cy.get('.recipe-card').first().invoke('text').then(text => {
|
|
cy.log('First card text: ' + text)
|
|
const priceMatch = text.match(/¥\s*(\d+\.?\d*)/)
|
|
if (priceMatch) {
|
|
cy.log('Price found: ¥' + priceMatch[1])
|
|
const price = parseFloat(priceMatch[1])
|
|
expect(price, 'Recipe card should show price > 0').to.be.gt(0)
|
|
} else {
|
|
cy.log('WARNING: No price found on recipe card')
|
|
}
|
|
})
|
|
})
|
|
})
|