Files
sky_phone/frontend/src/serverStartup.contract.test.ts
T
Leon.Schmidt e5a1c2bf40 ADD - open unique phones by item and hotkey
Register a configurable F1 phone toggle through a server-authoritative open request and retain the selected unique handset by IMEI. Verify usable-item support for every inventory adapter, fail visibly on registration errors, and document the behavior.
2026-08-17 15:57:56 +02:00

47 lines
1.5 KiB
TypeScript

import { readFileSync } from 'node:fs'
import { describe, expect, it } from 'vitest'
const manifest = readFileSync(
new URL('../../sky_phone/fxmanifest.lua', import.meta.url),
'utf8',
)
const phoneServer = readFileSync(
new URL('../../sky_phone/source/server/phone.lua', import.meta.url),
'utf8',
)
describe('server startup contracts', () => {
it('registers the production phone-open callback before the database migration runs', () => {
expect(
phoneServer.indexOf(
'Bridge.Callbacks.Register("sky_phone:device:open-request"',
),
).toBeLessThan(
phoneServer.indexOf('Bridge.Database.AfterMigration("sky_phone"'),
)
})
it('registers the development-open callback before the database migration runs', () => {
expect(manifest.indexOf("'source/server/phone.lua'")).toBeLessThan(
manifest.indexOf("'source/server/db_migrate.lua'"),
)
expect(
phoneServer.indexOf(
'Bridge.Callbacks.Register("sky_phone:device:development-open"',
),
).toBeLessThan(
phoneServer.indexOf('Bridge.Database.AfterMigration("sky_phone"'),
)
})
it('queues early opens until the resource has fully started', () => {
expect(phoneServer).toContain(
'AddEventHandler("onServerResourceStart", function(resource_name)',
)
expect(phoneServer).toContain('pending_phone_opens[source] = true')
expect(phoneServer).toContain('phone_open_handler = open_phone')
expect(phoneServer).toContain('flush_pending_phone_opens()')
})
})