fix: visual-check去掉cy.screenshot和cy.wait,改为纯功能断言
All checks were successful
PR Preview / test (pull_request) Has been skipped
Deploy Production / test (push) Successful in 6s
Test / unit-test (push) Successful in 5s
PR Preview / teardown-preview (pull_request) Successful in 15s
PR Preview / deploy-preview (pull_request) Has been skipped
Test / build-check (push) Successful in 4s
Deploy Production / deploy (push) Successful in 7s
Test / e2e-test (push) Successful in 2m56s
All checks were successful
PR Preview / test (pull_request) Has been skipped
Deploy Production / test (push) Successful in 6s
Test / unit-test (push) Successful in 5s
PR Preview / teardown-preview (pull_request) Successful in 15s
PR Preview / deploy-preview (pull_request) Has been skipped
Test / build-check (push) Successful in 4s
Deploy Production / deploy (push) Successful in 7s
Test / e2e-test (push) Successful in 2m56s
cy.screenshot()在CI headless环境超时。截图是视觉检查本地跑即可。 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit was merged in pull request #33.
This commit is contained in:
@@ -1,57 +1,44 @@
|
|||||||
describe('Visual Check - Screenshots', () => {
|
describe('Visual Check', () => {
|
||||||
let adminToken
|
let adminToken
|
||||||
|
|
||||||
before(() => {
|
before(() => {
|
||||||
cy.getAdminToken().then(token => { adminToken = token })
|
cy.getAdminToken().then(token => { adminToken = token })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('homepage with recipes', () => {
|
it('homepage loads with recipes', () => {
|
||||||
cy.visit('/', { onBeforeLoad(win) { win.localStorage.setItem('oil_auth_token', adminToken) } })
|
cy.visit('/', { onBeforeLoad(win) { win.localStorage.setItem('oil_auth_token', adminToken) } })
|
||||||
cy.get('.recipe-card', { timeout: 10000 }).should('have.length.gte', 1)
|
cy.get('.recipe-card', { timeout: 10000 }).should('have.length.gte', 1)
|
||||||
cy.wait(1000)
|
|
||||||
cy.screenshot('01-homepage')
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('recipe detail overlay', () => {
|
it('oil reference loads with chips', () => {
|
||||||
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.visit('/oils', { onBeforeLoad(win) { win.localStorage.setItem('oil_auth_token', adminToken) } })
|
||||||
cy.get('.oil-chip', { timeout: 10000 }).should('have.length.gte', 1)
|
cy.get('.oil-chip', { timeout: 10000 }).should('have.length.gte', 1)
|
||||||
cy.wait(500)
|
|
||||||
cy.screenshot('03-oil-reference')
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('manage recipes page', () => {
|
it('manage recipes page loads', () => {
|
||||||
cy.visit('/manage', { onBeforeLoad(win) { win.localStorage.setItem('oil_auth_token', adminToken) } })
|
cy.visit('/manage', { onBeforeLoad(win) { win.localStorage.setItem('oil_auth_token', adminToken) } })
|
||||||
cy.wait(2000)
|
cy.get('.recipe-manager', { timeout: 10000 }).should('exist')
|
||||||
cy.screenshot('04-manage-recipes')
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('inventory page', () => {
|
it('inventory page loads', () => {
|
||||||
cy.visit('/inventory', { onBeforeLoad(win) { win.localStorage.setItem('oil_auth_token', adminToken) } })
|
cy.visit('/inventory', { onBeforeLoad(win) { win.localStorage.setItem('oil_auth_token', adminToken) } })
|
||||||
cy.wait(1500)
|
cy.get('.inventory-page', { timeout: 10000 }).should('exist')
|
||||||
cy.screenshot('05-inventory')
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('check if recipe cards show price > 0', () => {
|
it('recipe cards show price > 0', () => {
|
||||||
cy.visit('/', { onBeforeLoad(win) { win.localStorage.setItem('oil_auth_token', adminToken) } })
|
cy.visit('/', { onBeforeLoad(win) { win.localStorage.setItem('oil_auth_token', adminToken) } })
|
||||||
cy.get('.recipe-card', { timeout: 10000 }).should('have.length.gte', 1)
|
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.get('.recipe-card').first().invoke('text').then(text => {
|
||||||
cy.log('First card text: ' + text)
|
|
||||||
const priceMatch = text.match(/¥\s*(\d+\.?\d*)/)
|
const priceMatch = text.match(/¥\s*(\d+\.?\d*)/)
|
||||||
if (priceMatch) {
|
if (priceMatch) {
|
||||||
cy.log('Price found: ¥' + priceMatch[1])
|
expect(parseFloat(priceMatch[1])).to.be.gt(0)
|
||||||
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')
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('recipe detail overlay opens', () => {
|
||||||
|
cy.visit('/', { onBeforeLoad(win) { win.localStorage.setItem('oil_auth_token', adminToken) } })
|
||||||
|
cy.get('.recipe-card', { timeout: 10000 }).first().click()
|
||||||
|
cy.get('.detail-overlay', { timeout: 10000 }).should('exist')
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user