Fix CI: exclude demo/visual specs, fix oil-card→oil-chip selectors
Some checks failed
PR Preview / teardown-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 4s
Test / build-check (push) Successful in 4s
PR Preview / test (pull_request) Successful in 5s
PR Preview / deploy-preview (pull_request) Successful in 13s
Test / e2e-test (push) Has been cancelled

- Grep pattern now matches full filenames (demo-walkthrough, visual-check)
- Updated all test files to use .oil-chip (new OilReference class name)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-06 22:28:17 +00:00
parent f88521c9be
commit a27c30ea7c
6 changed files with 135 additions and 66 deletions

View File

@@ -42,7 +42,7 @@ jobs:
# Run cypress from frontend dir # Run cypress from frontend dir
cd frontend cd frontend
SPECS=$(ls cypress/e2e/*.cy.js | grep -v demo | grep -v visual | grep -v check | tr '\n' ',') SPECS=$(ls cypress/e2e/*.cy.js | grep -v demo-walkthrough | grep -v visual-check | grep -v check-price | tr '\n' ',')
npx cypress run --spec "$SPECS" --config video=false npx cypress run --spec "$SPECS" --config video=false
EXIT_CODE=$? EXIT_CODE=$?

View File

@@ -1,32 +1,32 @@
describe('Oil Reference Page', () => { describe('Oil Reference Page', () => {
beforeEach(() => { beforeEach(() => {
cy.visit('/oils') cy.visit('/oils')
cy.get('.oil-card, .oils-grid', { timeout: 10000 }).should('exist') cy.get('.oil-chip, .oils-grid', { timeout: 10000 }).should('exist')
}) })
it('displays oil grid with items', () => { it('displays oil grid with items', () => {
cy.contains('精油价目').should('be.visible') cy.contains('精油价目').should('be.visible')
cy.get('.oil-card').should('have.length.gte', 10) cy.get('.oil-chip').should('have.length.gte', 10)
}) })
it('shows oil name and price on each chip', () => { it('shows oil name and price on each chip', () => {
cy.get('.oil-card').first().should('contain', '¥') cy.get('.oil-chip').first().should('contain', '¥')
}) })
it('filters oils by search', () => { it('filters oils by search', () => {
cy.get('.oil-card').then($chips => { cy.get('.oil-chip').then($chips => {
const initial = $chips.length const initial = $chips.length
cy.get('input[placeholder*="搜索精油"]').type('薰衣草') cy.get('input[placeholder*="搜索精油"]').type('薰衣草')
cy.wait(300) cy.wait(300)
cy.get('.oil-card').should('have.length.lt', initial) cy.get('.oil-chip').should('have.length.lt', initial)
}) })
}) })
it('toggles between bottle and drop price view', () => { it('toggles between bottle and drop price view', () => {
cy.get('.oil-card').first().invoke('text').then(textBefore => { cy.get('.oil-chip').first().invoke('text').then(textBefore => {
cy.contains('滴价').click() cy.contains('滴价').click()
cy.wait(300) cy.wait(300)
cy.get('.oil-card').first().invoke('text').should('not.eq', textBefore) cy.get('.oil-chip').first().invoke('text').should('not.eq', textBefore)
}) })
}) })
}) })

View File

@@ -38,7 +38,7 @@ describe('Performance', () => {
it('oil reference page loads within 3 seconds', () => { it('oil reference page loads within 3 seconds', () => {
const start = Date.now() const start = Date.now()
cy.visit('/oils') cy.visit('/oils')
cy.get('.oil-card', { timeout: 3000 }).should('have.length.gte', 1) cy.get('.oil-chip', { timeout: 3000 }).should('have.length.gte', 1)
cy.then(() => { cy.then(() => {
expect(Date.now() - start).to.be.lt(3000) expect(Date.now() - start).to.be.lt(3000)
}) })

View File

@@ -35,7 +35,7 @@ describe('Responsive Design', () => {
it('oil reference page works on mobile', () => { it('oil reference page works on mobile', () => {
cy.visit('/oils') cy.visit('/oils')
cy.contains('精油价目').should('be.visible') cy.contains('精油价目').should('be.visible')
cy.get('.oil-card').should('have.length.gte', 1) cy.get('.oil-chip').should('have.length.gte', 1)
}) })
}) })
@@ -51,7 +51,7 @@ describe('Responsive Design', () => {
it('oil grid shows multiple columns', () => { it('oil grid shows multiple columns', () => {
cy.visit('/oils') cy.visit('/oils')
cy.get('.oil-card', { timeout: 10000 }).should('have.length.gte', 1) cy.get('.oil-chip', { timeout: 10000 }).should('have.length.gte', 1)
}) })
}) })

View File

@@ -18,7 +18,7 @@ describe('Visual Check - Screenshots', () => {
it('oil reference page', () => { it('oil reference page', () => {
cy.visit('/oils', { onBeforeLoad(win) { win.localStorage.setItem('oil_auth_token', ADMIN_TOKEN) } }) cy.visit('/oils', { onBeforeLoad(win) { win.localStorage.setItem('oil_auth_token', ADMIN_TOKEN) } })
cy.get('.oil-card', { timeout: 10000 }).should('have.length.gte', 1) cy.get('.oil-chip', { timeout: 10000 }).should('have.length.gte', 1)
cy.wait(500) cy.wait(500)
cy.screenshot('03-oil-reference') cy.screenshot('03-oil-reference')
}) })

View File

@@ -6,26 +6,31 @@
<span v-for="tag in recipe.tags" :key="tag" class="card-tag">{{ tag }}</span> <span v-for="tag in recipe.tags" :key="tag" class="card-tag">{{ tag }}</span>
</div> </div>
<div class="card-oils"> <div v-if="recipe.note" class="card-note">{{ recipe.note }}</div>
<span v-for="(ing, i) in recipe.ingredients" :key="i" class="card-oil">
{{ ing.oil }} <div class="card-ingredients">
</span> <div v-for="(ing, i) in recipe.ingredients" :key="i" class="card-ing-row">
<span class="card-oil-name">{{ ing.oil }}</span>
<span class="card-oil-drops">{{ ing.drops }}</span>
</div>
</div> </div>
<div class="card-bottom"> <div class="card-total">
<span class="card-price"> <div class="card-total-inner">
{{ priceInfo.cost }} <span class="card-total-label">成本</span>
<span v-if="priceInfo.hasRetail" class="card-retail">零售 {{ priceInfo.retail }}</span> <span class="card-total-price">{{ priceInfo.cost }}</span>
</span> </div>
<button <span v-if="priceInfo.hasRetail" class="card-retail">零售 {{ priceInfo.retail }}</span>
class="card-star"
:class="{ favorited: isFav }"
@click.stop="$emit('toggle-fav', recipe._id)"
:title="isFav ? '取消收藏' : '收藏'"
>
{{ isFav ? '★' : '☆' }}
</button>
</div> </div>
<button
class="card-star"
:class="{ favorited: isFav }"
@click.stop="$emit('toggle-fav', recipe._id)"
:title="isFav ? '取消收藏' : '收藏'"
>
{{ isFav ? '★' : '☆' }}
</button>
</div> </div>
</template> </template>
@@ -50,88 +55,151 @@ const isFav = computed(() => recipesStore.isFavorite(props.recipe))
<style scoped> <style scoped>
.recipe-card { .recipe-card {
background: #fff; background: linear-gradient(145deg, #faf7f0 0%, #f5ede0 100%);
border-radius: 14px; border-radius: 16px;
padding: 18px 16px 14px; padding: 20px 18px 16px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
cursor: pointer; cursor: pointer;
transition: box-shadow 0.2s, transform 0.15s; border: 2px solid transparent;
transition: all 0.2s;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 8px; gap: 6px;
position: relative;
overflow: hidden;
}
.recipe-card::before {
content: '';
position: absolute;
top: -30px;
right: -30px;
width: 120px;
height: 120px;
background: radial-gradient(circle, rgba(122, 158, 126, 0.12) 0%, transparent 70%);
border-radius: 50%;
pointer-events: none;
} }
.recipe-card:hover { .recipe-card:hover {
box-shadow: 0 4px 18px rgba(0, 0, 0, 0.1); transform: translateY(-3px);
transform: translateY(-1px); box-shadow: 0 6px 24px rgba(0, 0, 0, 0.1);
border-color: #b8d4c0;
} }
.card-name { .card-name {
font-family: 'Noto Serif SC', serif; font-family: 'Noto Serif SC', serif;
font-size: 16px; font-size: 17px;
font-weight: 600; font-weight: 700;
color: #3e3a44; color: #3e3a44;
line-height: 1.3; line-height: 1.3;
padding-right: 28px;
} }
.card-tags { .card-tags {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
gap: 5px; gap: 5px;
margin-bottom: 2px;
} }
.card-tag { .card-tag {
font-size: 11px; font-size: 11px;
padding: 2px 8px; padding: 2px 9px;
border-radius: 8px; border-radius: 8px;
background: #f0ece4; background: rgba(122, 158, 126, 0.15);
color: #8a7e6b; color: #5a7d5e;
font-weight: 500;
} }
.card-oils { .card-note {
display: flex;
flex-wrap: wrap;
gap: 4px;
}
.card-oil {
font-size: 12px; font-size: 12px;
color: #6b6375; color: #8a7e6b;
background: #f8f7f5; background: rgba(201, 168, 76, 0.1);
padding: 2px 7px;
border-radius: 6px; border-radius: 6px;
padding: 4px 8px;
line-height: 1.4;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
} }
.card-bottom { .card-ingredients {
display: flex;
flex-direction: column;
gap: 0;
margin: 4px 0;
}
.card-ing-row {
display: flex;
align-items: center;
padding: 6px 0;
border-bottom: 1px solid rgba(180, 150, 100, 0.15);
font-size: 13px;
}
.card-ing-row:last-child {
border-bottom: none;
}
.card-oil-name {
flex: 1;
color: #3e3a44;
font-weight: 500;
}
.card-oil-drops {
color: #5a7d5e;
font-size: 12px;
font-weight: 500;
}
.card-total {
background: linear-gradient(135deg, #7ec6a4, #4a9d7e);
border-radius: 10px;
padding: 10px 14px;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
margin-top: auto; margin-top: 4px;
padding-top: 6px;
} }
.card-price { .card-total-inner {
font-size: 14px; display: flex;
font-weight: 600; align-items: center;
color: #4a9d7e; gap: 8px;
}
.card-total-label {
color: rgba(255, 255, 255, 0.8);
font-size: 12px;
letter-spacing: 0.5px;
}
.card-total-price {
color: #fff;
font-size: 17px;
font-weight: 700;
} }
.card-retail { .card-retail {
font-size: 11px; font-size: 11px;
font-weight: 400; color: rgba(255, 255, 255, 0.75);
color: #999;
margin-left: 6px;
} }
.card-star { .card-star {
position: absolute;
top: 14px;
right: 12px;
background: none; background: none;
border: none; border: none;
font-size: 20px; font-size: 22px;
cursor: pointer; cursor: pointer;
color: #ccc; color: #d4cfc7;
padding: 2px 4px; padding: 2px;
line-height: 1; line-height: 1;
transition: color 0.2s; transition: color 0.2s, transform 0.15s;
z-index: 1;
} }
.card-star.favorited { .card-star.favorited {
@@ -140,5 +208,6 @@ const isFav = computed(() => recipesStore.isFavorite(props.recipe))
.card-star:hover { .card-star:hover {
color: #f5a623; color: #f5a623;
transform: scale(1.15);
} }
</style> </style>