6 Commits

Author SHA1 Message Date
9492cea1a8 release: 1.0.10
All checks were successful
Tests / Backend - Tests skipped: 8, passed: 74
Backend Coverage #### Project Overview No changes detected, that affect the code coverage. * Line Coverage: 78.38% (551/703) * Lines of Code: 703 #### Quality Gates Summary No active quality gates.
Tests / Frontend - Lint, Tests et Build passed: 83
Frontend Coverage #### Project Overview No changes detected, that affect the code coverage. * Line Coverage: 80.90% (555/686) * Lines of Code: 686 #### Quality Gates Summary No active quality gates.
THE-TIP-TOP-MULTIBRANCH/pipeline/head This commit looks good
2026-09-20 01:38:42 +00:00
16bcbd731c fix: explicitly load Cloudflare Turnstile
Some checks reported errors
Tests / Backend - Tests skipped: 8, passed: 74
Backend Coverage #### Project Overview No changes detected, that affect the code coverage. * Line Coverage: 78.66% (553/703) * Lines of Code: 703 #### Quality Gates Summary No active quality gates.
Tests / Frontend - Lint, Tests et Build passed: 83
Frontend Coverage #### Project Overview No changes detected, that affect the code coverage. * Line Coverage: 80.85% (553/684) * Lines of Code: 684 #### Quality Gates Summary No active quality gates.
THE-TIP-TOP-MULTIBRANCH/pipeline/head Something is wrong with the build of this commit
2026-09-20 00:37:37 +00:00
246303139d release: 1.0.9
All checks were successful
Tests / Backend - Tests skipped: 8, passed: 74
THE-TIP-TOP-MULTIBRANCH/pipeline/head This commit looks good
Backend Coverage #### Project Overview No changes detected, that affect the code coverage. * Line Coverage: 78.38% (551/703) * Lines of Code: 703 #### Quality Gates Summary No active quality gates.
Tests / Frontend - Lint, Tests et Build passed: 83
Frontend Coverage #### Project Overview No changes detected, that affect the code coverage. * Line Coverage: 84.94% (547/644) * Lines of Code: 644 #### Quality Gates Summary No active quality gates.
2026-09-19 23:29:13 +00:00
1e09420705 release: 1.0.7
All checks were successful
Tests / Backend - Tests skipped: 8, passed: 74
Backend Coverage #### Project Overview No changes detected, that affect the code coverage. * Line Coverage: 78.38% (551/703) * Lines of Code: 703 #### Quality Gates Summary No active quality gates.
Tests / Frontend - Lint, Tests et Build passed: 83
Frontend Coverage #### Project Overview No changes detected, that affect the code coverage. * Line Coverage: 84.94% (547/644) * Lines of Code: 644 #### Quality Gates Summary No active quality gates.
THE-TIP-TOP-MULTIBRANCH/pipeline/head This commit looks good
2026-09-18 02:43:53 +00:00
cc495f3b87 release: promote 1.0.5 to production
All checks were successful
Tests / Backend - Tests skipped: 7, passed: 27
Backend Coverage #### Project Overview No changes detected, that affect the code coverage. * Line Coverage: 60.55% (333/550) * Lines of Code: 550 #### Quality Gates Summary No active quality gates.
Tests / Frontend - Lint, Tests et Build passed: 45
Frontend Coverage #### Project Overview No changes detected, that affect the code coverage. * Line Coverage: 86.14% (230/267) * Lines of Code: 267 #### Quality Gates Summary No active quality gates.
THE-TIP-TOP-MULTIBRANCH/pipeline/head This commit looks good
2026-08-28 09:10:03 +00:00
570f5d44f5 security: remove hardcoded admin credentials
All checks were successful
Tests / Backend - Tests skipped: 7, passed: 27
Backend Coverage #### Project Overview No changes detected, that affect the code coverage. * Line Coverage: 60.55% (333/550) * Lines of Code: 550 #### Quality Gates Summary No active quality gates.
Tests / Frontend - Lint, Tests et Build passed: 45
Frontend Coverage #### Project Overview No changes detected, that affect the code coverage. * Line Coverage: 86.14% (230/267) * Lines of Code: 267 #### Quality Gates Summary No active quality gates.
THE-TIP-TOP-MULTIBRANCH/pipeline/head This commit looks good
2026-08-28 09:00:51 +00:00
2 changed files with 30 additions and 170 deletions

View File

@@ -15,7 +15,6 @@ export default function Captcha({ onToken }) {
} }
let cancelled = false let cancelled = false
let localWidgetId = null
const renderWidget = () => { const renderWidget = () => {
if ( if (
@@ -26,21 +25,19 @@ export default function Captcha({ onToken }) {
return return
} }
// Nettoyage d'un éventuel widget précédent. if (widgetIdRef.current !== null) {
if (localWidgetId !== null) {
try { try {
window.turnstile.remove(localWidgetId) window.turnstile.remove(widgetIdRef.current)
} catch { } catch {
// Widget déjà supprimé. // Widget déjà supprimé
} }
localWidgetId = null
widgetIdRef.current = null widgetIdRef.current = null
} }
containerRef.current.innerHTML = '' containerRef.current.innerHTML = ''
localWidgetId = window.turnstile.render( widgetIdRef.current = window.turnstile.render(
containerRef.current, containerRef.current,
{ {
sitekey: TURNSTILE_SITE_KEY, sitekey: TURNSTILE_SITE_KEY,
@@ -61,8 +58,6 @@ export default function Captcha({ onToken }) {
}, },
} }
) )
widgetIdRef.current = localWidgetId
} }
const existingScript = document.getElementById( const existingScript = document.getElementById(
@@ -71,11 +66,19 @@ export default function Captcha({ onToken }) {
if (window.turnstile) { if (window.turnstile) {
renderWidget() renderWidget()
} else if (existingScript) { return
}
if (existingScript) {
existingScript.addEventListener('load', renderWidget, { existingScript.addEventListener('load', renderWidget, {
once: true, once: true,
}) })
} else {
return () => {
cancelled = true
}
}
const script = document.createElement('script') const script = document.createElement('script')
script.id = TURNSTILE_SCRIPT_ID script.id = TURNSTILE_SCRIPT_ID
@@ -88,25 +91,21 @@ export default function Captcha({ onToken }) {
}) })
document.head.appendChild(script) document.head.appendChild(script)
}
return () => { return () => {
cancelled = true cancelled = true
const widgetId = if (
localWidgetId !== null widgetIdRef.current !== null &&
? localWidgetId window.turnstile
: widgetIdRef.current ) {
if (widgetId !== null && window.turnstile) {
try { try {
window.turnstile.remove(widgetId) window.turnstile.remove(widgetIdRef.current)
} catch { } catch {
// Widget déjà supprimé. // Widget déjà supprimé
} }
} }
localWidgetId = null
widgetIdRef.current = null widgetIdRef.current = null
} }
}, [onToken]) }, [onToken])

View File

@@ -1,139 +0,0 @@
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'
import { render, cleanup, waitFor } from '@testing-library/react'
vi.mock('../../config/captcha', () => ({
CAPTCHA_ENABLED: true,
TURNSTILE_SITE_KEY: '0x4AAAAAAE0AF9mR2Y1luOeG',
}))
import Captcha from '../../components/Captcha'
describe('Captcha', () => {
let originalTurnstile
beforeEach(() => {
originalTurnstile = window.turnstile
document.head
.querySelectorAll('#cf-turnstile-script')
.forEach((script) => script.remove())
window.turnstile = undefined
})
afterEach(() => {
cleanup()
window.turnstile = originalTurnstile
vi.restoreAllMocks()
})
it('rend le widget lorsque Turnstile est déjà disponible', async () => {
const onToken = vi.fn()
window.turnstile = {
render: vi.fn((container, options) => {
options.callback('token-test')
return 'widget-1'
}),
remove: vi.fn(),
}
render(<Captcha onToken={onToken} />)
await waitFor(() => {
expect(window.turnstile.render).toHaveBeenCalled()
})
expect(onToken).toHaveBeenCalledWith('token-test')
})
it('gère expiration et erreur du widget', async () => {
const onToken = vi.fn()
let options
window.turnstile = {
render: vi.fn((container, opts) => {
options = opts
return 'widget-2'
}),
remove: vi.fn(),
}
render(<Captcha onToken={onToken} />)
await waitFor(() => {
expect(options).toBeDefined()
})
options['expired-callback']()
options['error-callback']()
expect(onToken).toHaveBeenNthCalledWith(1, '')
expect(onToken).toHaveBeenNthCalledWith(2, '')
})
it('charge Turnstile lorsque le script existe déjà', async () => {
const onToken = vi.fn()
const script = document.createElement('script')
script.id = 'cf-turnstile-script'
document.head.appendChild(script)
render(<Captcha onToken={onToken} />)
window.turnstile = {
render: vi.fn(() => 'widget-3'),
remove: vi.fn(),
}
script.dispatchEvent(new Event('load'))
await waitFor(() => {
expect(window.turnstile.render).toHaveBeenCalled()
})
})
it('supprime le widget au démontage', async () => {
const onToken = vi.fn()
const remove = vi.fn()
window.turnstile = {
render: vi.fn(() => 'widget-4'),
remove,
}
const { unmount } = render(<Captcha onToken={onToken} />)
await waitFor(() => {
expect(window.turnstile.render).toHaveBeenCalledTimes(1)
})
// Le widget est bien créé avant le démontage.
unmount()
expect(remove).toHaveBeenCalledWith('widget-4')
})
it('tolère une erreur lors de la suppression du widget', async () => {
const onToken = vi.fn()
const remove = vi.fn(() => {
throw new Error('widget déjà supprimé')
})
window.turnstile = {
render: vi.fn(() => 'widget-5'),
remove,
}
const { unmount } = render(<Captcha onToken={onToken} />)
await waitFor(() => {
expect(window.turnstile.render).toHaveBeenCalledTimes(1)
})
expect(() => unmount()).not.toThrow()
expect(remove).toHaveBeenCalledWith('widget-5')
})
})