feat: implement license platform business flows and delivery tooling
Some checks failed
Check / delivery-static (push) Has been cancelled
Check / api (push) Has been cancelled
Check / web (push) Has been cancelled

Add admin and customer interfaces, orders, signed activation and leases, protected package delivery, keyring verification, migrations, security controls, tests and deployment documentation.

Co-Authored-By: Craft Agent <agents-noreply@craft.do>
This commit is contained in:
2026-10-09 15:33:22 +08:00
parent 3ab651d3a8
commit 54c318c615
142 changed files with 11105 additions and 178 deletions

View File

@@ -0,0 +1,27 @@
import { describe, expect, it, vi } from 'vitest'
import axios from 'axios'
import { checkApiHealth } from './api-health'
describe('checkApiHealth', () => {
it('returns online for the live response', async () => {
const request = vi.fn().mockResolvedValue({ data: { status: 'ok' } })
await expect(checkApiHealth(request)).resolves.toBe('online')
expect(request).toHaveBeenCalledWith('/api/v1/health/live', { timeout: 3000 })
})
it('returns offline for invalid status', async () => {
await expect(checkApiHealth(vi.fn().mockResolvedValue({ data: { status: 'degraded' } }))).resolves.toBe('offline')
await expect(checkApiHealth(vi.fn().mockResolvedValue({ data: null }))).resolves.toBe('offline')
})
it('returns offline when the request rejects', async () => {
await expect(checkApiHealth(vi.fn().mockRejectedValue(new Error('network unavailable')))).resolves.toBe('offline')
})
it('uses Axios by default', async () => {
const request = vi.spyOn(axios, 'get').mockResolvedValue({ data: { status: 'ok' } } as never)
await expect(checkApiHealth()).resolves.toBe('online')
expect(request).toHaveBeenCalledOnce()
request.mockRestore()
})
})