- Vitest unit tests: smart paste parsing (37), cost calculations (21),
oil translation (16), dialog system (12), with production data fixtures
- Cypress E2E tests: API CRUD (27), auth flow (8), recipe detail (10),
search (12), oil reference (4), favorites (6), inventory (6),
recipe management (10), diary (11), bug tracker (8), user management (13),
cost parity (6), data integrity (8), responsive (9), performance (6),
navigation (8), admin flow (5)
- Test coverage doc with prioritized gap analysis
- Found backend bug: POST /api/bug-reports/{id}/comment deletes the bug
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
58 lines
1.7 KiB
JavaScript
58 lines
1.7 KiB
JavaScript
describe('Inventory Flow', () => {
|
|
const ADMIN_TOKEN = 'c86ae7afbe10fabe3c1d5e1a7fee74feaadfd5dc7be2ab62'
|
|
const authHeaders = { Authorization: `Bearer ${ADMIN_TOKEN}` }
|
|
const TEST_OIL = '薰衣草'
|
|
|
|
describe('API: inventory CRUD', () => {
|
|
it('adds an oil to inventory', () => {
|
|
cy.request({
|
|
method: 'POST',
|
|
url: '/api/inventory',
|
|
headers: authHeaders,
|
|
body: { oil_name: TEST_OIL }
|
|
}).then(res => {
|
|
expect(res.status).to.be.oneOf([200, 201])
|
|
})
|
|
})
|
|
|
|
it('reads inventory and sees the oil', () => {
|
|
cy.request({ url: '/api/inventory', headers: authHeaders }).then(res => {
|
|
expect(res.body).to.be.an('array')
|
|
expect(res.body).to.include(TEST_OIL)
|
|
})
|
|
})
|
|
|
|
it('gets matching recipes for inventory', () => {
|
|
cy.request({ url: '/api/inventory/recipes', headers: authHeaders }).then(res => {
|
|
expect(res.status).to.eq(200)
|
|
expect(res.body).to.be.an('array')
|
|
})
|
|
})
|
|
|
|
it('removes the oil from inventory', () => {
|
|
cy.request({
|
|
method: 'DELETE',
|
|
url: `/api/inventory/${encodeURIComponent(TEST_OIL)}`,
|
|
headers: authHeaders
|
|
}).then(res => {
|
|
expect(res.status).to.eq(200)
|
|
})
|
|
})
|
|
|
|
it('verifies oil is removed', () => {
|
|
cy.request({ url: '/api/inventory', headers: authHeaders }).then(res => {
|
|
expect(res.body).to.not.include(TEST_OIL)
|
|
})
|
|
})
|
|
})
|
|
|
|
describe('UI: inventory page', () => {
|
|
it('page loads with oil picker', () => {
|
|
cy.visit('/inventory', {
|
|
onBeforeLoad(win) { win.localStorage.setItem('oil_auth_token', ADMIN_TOKEN) }
|
|
})
|
|
cy.contains('库存', { timeout: 10000 }).should('be.visible')
|
|
})
|
|
})
|
|
})
|