feat: 新功能改进 #20

Merged
hera merged 57 commits from feat/next-improvements into main 2026-04-10 20:30:37 +00:00
Showing only changes of commit 5a34b11720 - Show all commits

View File

@@ -1,8 +1,7 @@
// Helper: dismiss any modal that may cover the detail overlay (login modal, error dialog)
function dismissModals() {
cy.get('body').then($body => {
if ($body.find('.login-overlay').length) {
cy.get('.login-overlay').click('topLeft') // click backdrop to close
cy.get('.login-overlay').click('topLeft')
}
if ($body.find('.dialog-overlay').length) {
cy.get('.dialog-btn-primary').click()
@@ -60,51 +59,22 @@ describe('Recipe Detail', () => {
})
})
describe('Recipe Detail - Editor (Admin)', () => {
const ADMIN_TOKEN = 'c86ae7afbe10fabe3c1d5e1a7fee74feaadfd5dc7be2ab62'
describe('Recipe Detail - Card View', () => {
beforeEach(() => {
cy.visit('/', {
onBeforeLoad(win) {
win.localStorage.setItem('oil_auth_token', ADMIN_TOKEN)
}
})
cy.visit('/')
cy.get('.recipe-card', { timeout: 10000 }).should('have.length.gte', 1)
dismissModals()
})
it('shows editable ingredients table in editor tab', () => {
cy.get('.recipe-card').first().click()
dismissModals()
cy.get('.detail-overlay', { timeout: 5000 }).should('exist')
cy.get('.detail-overlay').then($el => {
if ($el.find(':contains("编辑")').filter('button').length) {
cy.contains('编辑').click()
cy.get('.editor-select, .editor-drops').should('exist')
} else {
cy.log('Edit button not available (not admin) — skipping')
}
})
})
it('shows add ingredient button in editor tab', () => {
cy.get('.recipe-card').first().click()
dismissModals()
cy.get('.detail-overlay', { timeout: 5000 }).should('exist')
cy.get('.detail-overlay').then($el => {
if ($el.find(':contains("编辑")').filter('button').length) {
cy.contains('编辑').click()
cy.contains('添加精油').should('exist')
} else {
cy.log('Edit button not available (not admin) — skipping')
}
})
it('shows export card with doTERRA branding', () => {
cy.get('.export-card').should('exist')
cy.contains('doTERRA').should('exist')
})
it('shows save image button', () => {
cy.get('.recipe-card').first().click()
dismissModals()
cy.get('.detail-overlay', { timeout: 5000 }).should('exist')
cy.contains('保存图片').should('exist')
it('shows language toggle', () => {
cy.contains('中文').should('exist')
cy.contains('English').should('exist')
})
})