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: '580CCDC4A3C1B7A5BEFC7FB4EB0E7867521D9AF8BD26FBB9B491074EF20F65A1',
|
|
globalMap: 'EB0C1470AED546194B48386DD092E6D5813CA41E4C3B561838CFC5AE290677CF',
|
|
module: 'E8122ABD9476763BC36816252DBA03CDC7547A4BD36FBAB041DE01D8AF19A2F9',
|
|
moduleMap: 'A074A886F5EFE400ACD8F7A5591B7043BA2FF10500B429AFC6490BB7EEAA1430',
|
|
types: '28230A70627073D8544C0872813DDE6FDB775071A2EDC131912134F5113E2F33',
|
|
moduleTypes: '28230A70627073D8544C0872813DDE6FDB775071A2EDC131912134F5113E2F33'
|
|
})
|
|
})
|
|
})
|