fix: use actual local platform ID to resolve linked ROS settings
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
const { test } = require('node:test')
|
||||
const assert = require('node:assert/strict')
|
||||
const fs = require('node:fs')
|
||||
const vm = require('node:vm')
|
||||
const ts = require('typescript')
|
||||
|
||||
function setup() {
|
||||
const data = new Map()
|
||||
const exports = {}
|
||||
vm.runInNewContext(ts.transpileModule(fs.readFileSync(require.resolve('../src/renderer/src/features/workspace/sourceSettings.ts'), 'utf8'), {
|
||||
compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2022 },
|
||||
}).outputText, {
|
||||
exports,
|
||||
require: () => ({ STUDIO_SOURCE_SETTINGS_STORAGE_KEY: 'test-settings' }),
|
||||
window: { localStorage: { getItem: key => data.get(key) ?? null, setItem: (key, value) => data.set(key, value) } },
|
||||
})
|
||||
return exports
|
||||
}
|
||||
|
||||
test('remote workspace reads local domain and linked platform by actual platform ID', () => {
|
||||
const api = setup()
|
||||
api.storeStudioSourceSettings('local-platform-uuid', { ...api.defaultStudioSourceSettings, rosDomainId: '75', rosLinkedPlatformId: 'yahboom-uuid' })
|
||||
const result = api.readLocalStudioSourceSettings([
|
||||
{ id: 'yahboom-uuid', platformKey: 'yahboom', sourceSettings: { rosDomainId: '77' } },
|
||||
{ id: 'local-platform-uuid', platformKey: 'futuredrive-local-pc' },
|
||||
])
|
||||
assert.equal(result.rosDomainId, '75')
|
||||
assert.equal(result.rosLinkedPlatformId, 'yahboom-uuid')
|
||||
})
|
||||
|
||||
test('local platform defaults and unlinked selection are preserved', () => {
|
||||
const api = setup()
|
||||
const platforms = [{ id: 'local-platform-uuid', platformKey: 'futuredrive-local-pc', sourceSettings: { rosDomainId: '76' } }]
|
||||
assert.equal(api.readLocalStudioSourceSettings(platforms).rosDomainId, '76')
|
||||
api.storeStudioSourceSettings('local-platform-uuid', { ...api.defaultStudioSourceSettings, rosDomainId: '75', rosLinkedPlatformId: null })
|
||||
assert.equal(api.readLocalStudioSourceSettings(platforms).rosLinkedPlatformId, null)
|
||||
})
|
||||
Reference in New Issue
Block a user