Audit sécurité/qualité : corrections critiques, tests, CI et lint #4

Merged
cedric merged 28 commits from fix/audit-2026-07-04 into master 2026-07-04 17:01:30 +00:00
3 changed files with 37 additions and 2 deletions
Showing only changes of commit c4f45f712a - Show all commits
@@ -117,3 +117,37 @@ describe('beforeUpdate — notifications Telegram/Revolt', () => {
expect(strapiMock.log.error).toHaveBeenCalledWith(expect.stringContaining('Revolt')) expect(strapiMock.log.error).toHaveBeenCalledWith(expect.stringContaining('Revolt'))
}) })
}) })
describe('afterUpdate — historique de différence', () => {
afterEach(() => {
delete global.strapi
})
it("n'échoue pas quand updatedBy n'est pas peuplé", async () => {
const entityServiceUpdate = vi.fn(async () => {})
const strapiMock = {
entityService: {update: entityServiceUpdate}
}
const {afterUpdate} = await loadLifecycles(strapiMock)
const event = {
result: {id: 1, difference: [], updatedBy: undefined},
state: {diff: {path: 'transcription', jsonDiff: []}}
}
await afterUpdate(event)
expect(entityServiceUpdate).toHaveBeenCalledWith('api::parole.parole', 1, {
data: {
difference: [{
admin_user: null,
paroles: 'transcription',
jsonDiff: [],
date: expect.any(Date),
sources: 'transcription'
}]
}
})
})
})
@@ -256,7 +256,7 @@ module.exports = {
difference: [ difference: [
...result.difference, ...result.difference,
{ {
admin_user: result.updatedBy.id, admin_user: result.updatedBy?.id ?? null,
paroles: state.diff.path, paroles: state.diff.path,
jsonDiff: state.diff.jsonDiff, jsonDiff: state.diff.jsonDiff,
date: new Date(), date: new Date(),
@@ -8,7 +8,8 @@
"description": "" "description": ""
}, },
"options": { "options": {
"draftAndPublish": true "draftAndPublish": true,
"populateCreatorFields": true
}, },
"pluginOptions": {}, "pluginOptions": {},
"attributes": { "attributes": {