feat(integrations): добавить ручной sync с CFDM
Docker / build (push) Failing after 22s

Кнопка в настройках запрашивает полную выгрузку bindings из CFDM.

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
Denozordec
2026-07-31 23:24:04 +07:00
co-authored by Cursor
parent 5bbf0061cf
commit 033557a859
9 changed files with 215 additions and 17 deletions
+46
View File
@@ -81,3 +81,49 @@ describe('settings telegram test', () => {
expect(url).toContain('botoverride-token/')
})
})
describe('settings cfdm sync', () => {
let app: Awaited<ReturnType<typeof buildApp>>
beforeEach(async () => {
resetTestDb()
settingsRepository.upsert('settings-main', {
integrationEnabled: true,
integrationToken: 'shared-token',
cfdmApiUrl: 'http://cfdm.test',
})
app = await buildApp()
})
afterEach(async () => {
await app.close()
vi.unstubAllGlobals()
closeDb()
})
it('çàïðàøèâàåò ïîëíûé sync ó CFDM', async () => {
const fetchMock = vi.fn(async () => Response.json({ ok: true, count: 3 }))
vi.stubGlobal('fetch', fetchMock)
const res = await app.inject({ method: 'POST', url: '/api/settings/cfdm/sync' })
expect(res.statusCode).toBe(200)
expect(res.json()).toEqual({ ok: true, count: 3 })
const call = fetchMock.mock.calls[0] as [string, RequestInit] | undefined
expect(call?.[0]).toBe('http://cfdm.test/api/v1/integrations/vps-tracker/sync')
expect((call?.[1].headers as Record<string, string>).Authorization).toBe(
'Bearer shared-token',
)
})
it('âîçâðàùàåò îøèáêó åñëè ïðè¸ì âûêëþ÷åí', async () => {
settingsRepository.upsert('settings-main', {
integrationEnabled: false,
integrationToken: 'shared-token',
cfdmApiUrl: 'http://cfdm.test',
})
const res = await app.inject({ method: 'POST', url: '/api/settings/cfdm/sync' })
expect(res.statusCode).toBe(502)
expect(res.json()).toMatchObject({ ok: false })
})
})