54 lines
2.3 KiB
TypeScript
54 lines
2.3 KiB
TypeScript
import { createHash } from 'node:crypto'
|
|
import { existsSync, readFileSync } from 'node:fs'
|
|
import { resolve } from 'node:path'
|
|
import { describe, expect, it } from 'vitest'
|
|
|
|
const sdkDirectory = resolve(process.cwd(), 'static/sgs-map-sdk')
|
|
const readSdkFile = (name: string) => readFileSync(resolve(sdkDirectory, name), 'utf8')
|
|
const sha256 = (name: string) => createHash('sha256').update(readFileSync(resolve(sdkDirectory, name))).digest('hex').toUpperCase()
|
|
|
|
describe('SGS Map SDK 2.5.0 release contract', () => {
|
|
it('keeps the local package, bridge self-report, and default Engine path aligned', () => {
|
|
const packageJson = JSON.parse(readSdkFile('package.json')) as { version: string }
|
|
const bridge = readSdkFile('index.global.js')
|
|
const dataSource = readFileSync(resolve(process.cwd(), 'src/config/dataSource.ts'), 'utf8')
|
|
|
|
expect(packageJson.version).toBe('2.5.0')
|
|
expect(bridge).toContain('"2.5.0"')
|
|
expect(bridge).toContain('/engine/index.html')
|
|
expect(dataSource).toContain("SGS_MAP_SDK_VERSION = '2.5.0'")
|
|
expect(dataSource).toContain("const defaultSgsEngineUrl = '/engine/index.html'")
|
|
})
|
|
|
|
it('ships every runtime bridge artifact required by the flattened package', () => {
|
|
[
|
|
'index.global.js',
|
|
'index.global.js.map',
|
|
'index.mjs',
|
|
'index.mjs.map',
|
|
'index.d.ts',
|
|
'index.d.mts'
|
|
].forEach((file) => {
|
|
expect(existsSync(resolve(sdkDirectory, file))).toBe(true)
|
|
})
|
|
})
|
|
|
|
it('pins the complete 2.5.0 artifact set to prevent a partial stale package', () => {
|
|
expect({
|
|
global: sha256('index.global.js'),
|
|
globalMap: sha256('index.global.js.map'),
|
|
module: sha256('index.mjs'),
|
|
moduleMap: sha256('index.mjs.map'),
|
|
types: sha256('index.d.ts'),
|
|
moduleTypes: sha256('index.d.mts')
|
|
}).toEqual({
|
|
global: '3C93DEE217615FD9454A4A8EE4282114471B36DA2B3C7A5F2B2C0FDB18BEF5D1',
|
|
globalMap: 'EB0C1470AED546194B48386DD092E6D5813CA41E4C3B561838CFC5AE290677CF',
|
|
module: 'D3C885464B887276BCB420A45BBB5AF2BECA0779482571013789EF61A0E29D59',
|
|
moduleMap: 'A074A886F5EFE400ACD8F7A5591B7043BA2FF10500B429AFC6490BB7EEAA1430',
|
|
types: '2E5875CABC6464F2A60625F7400B34B048BD706411FDEA271DBD9D3D4A9BDDD4',
|
|
moduleTypes: '2E5875CABC6464F2A60625F7400B34B048BD706411FDEA271DBD9D3D4A9BDDD4'
|
|
})
|
|
})
|
|
})
|