feat(miniapp): add cycle-level billing controls

This commit is contained in:
2026-03-10 01:53:11 +04:00
parent 565ac277c1
commit 29563c24eb
11 changed files with 1772 additions and 1 deletions

View File

@@ -73,6 +73,51 @@ describe('createBotWebhookServer', () => {
}
})
},
miniAppBillingCycle: {
handler: async () =>
new Response(JSON.stringify({ ok: true, authorized: true, cycleState: {} }), {
status: 200,
headers: {
'content-type': 'application/json; charset=utf-8'
}
})
},
miniAppOpenCycle: {
handler: async () =>
new Response(JSON.stringify({ ok: true, authorized: true, cycleState: {} }), {
status: 200,
headers: {
'content-type': 'application/json; charset=utf-8'
}
})
},
miniAppCloseCycle: {
handler: async () =>
new Response(JSON.stringify({ ok: true, authorized: true, cycleState: {} }), {
status: 200,
headers: {
'content-type': 'application/json; charset=utf-8'
}
})
},
miniAppRentUpdate: {
handler: async () =>
new Response(JSON.stringify({ ok: true, authorized: true, cycleState: {} }), {
status: 200,
headers: {
'content-type': 'application/json; charset=utf-8'
}
})
},
miniAppAddUtilityBill: {
handler: async () =>
new Response(JSON.stringify({ ok: true, authorized: true, cycleState: {} }), {
status: 200,
headers: {
'content-type': 'application/json; charset=utf-8'
}
})
},
miniAppApproveMember: {
handler: async () =>
new Response(JSON.stringify({ ok: true, authorized: true, member: {} }), {
@@ -259,6 +304,86 @@ describe('createBotWebhookServer', () => {
})
})
test('accepts mini app billing cycle request', async () => {
const response = await server.fetch(
new Request('http://localhost/api/miniapp/admin/billing-cycle', {
method: 'POST',
body: JSON.stringify({ initData: 'payload' })
})
)
expect(response.status).toBe(200)
expect(await response.json()).toEqual({
ok: true,
authorized: true,
cycleState: {}
})
})
test('accepts mini app open cycle request', async () => {
const response = await server.fetch(
new Request('http://localhost/api/miniapp/admin/billing-cycle/open', {
method: 'POST',
body: JSON.stringify({ initData: 'payload' })
})
)
expect(response.status).toBe(200)
expect(await response.json()).toEqual({
ok: true,
authorized: true,
cycleState: {}
})
})
test('accepts mini app close cycle request', async () => {
const response = await server.fetch(
new Request('http://localhost/api/miniapp/admin/billing-cycle/close', {
method: 'POST',
body: JSON.stringify({ initData: 'payload' })
})
)
expect(response.status).toBe(200)
expect(await response.json()).toEqual({
ok: true,
authorized: true,
cycleState: {}
})
})
test('accepts mini app rent update request', async () => {
const response = await server.fetch(
new Request('http://localhost/api/miniapp/admin/rent/update', {
method: 'POST',
body: JSON.stringify({ initData: 'payload' })
})
)
expect(response.status).toBe(200)
expect(await response.json()).toEqual({
ok: true,
authorized: true,
cycleState: {}
})
})
test('accepts mini app utility bill add request', async () => {
const response = await server.fetch(
new Request('http://localhost/api/miniapp/admin/utility-bills/add', {
method: 'POST',
body: JSON.stringify({ initData: 'payload' })
})
)
expect(response.status).toBe(200)
expect(await response.json()).toEqual({
ok: true,
authorized: true,
cycleState: {}
})
})
test('accepts mini app approve member request', async () => {
const response = await server.fetch(
new Request('http://localhost/api/miniapp/admin/approve-member', {