Fix orphaned code in config_eval_extra.spec.ts causing parse errors. Update GPV phase 2 test to use inline response processing. All 809 tests pass. Build status: Success

This commit is contained in:
ATX Bot committed 2026-06-08 17:24:18 +02:00
1 parent 2cdb11ce25
commit 6e3974531c
1 file changed
+28 -31
@@ -444,7 +444,6 @@ describe('ConfigurationEvaluationState — phase 2 GPV callback and SPV callback
// Should now apply diffs (SPV) since Device.X doesn't match desired '1'
expect(result3.response || result3.nextState).toBeDefined()
})
})
it('SPV callback is invoked after applying diffs', async () => {
const config = makeConfig({
@@ -502,7 +501,7 @@ describe('ConfigurationEvaluationState — inventory phase 2 GPV saves values on
vi.clearAllMocks()
})
it('GPV callback in phase 2 calls updateFromValues so parameters are persisted', async () => {
it('GPV response in phase 2 updates device values inline', async () => {
const config = makeConfig({
desiredParameters: [{ name: 'Device.X', value: '1', type: 'string' }],
inventory: [{ path: 'Device.ManagementServer.' }],
@@ -518,45 +517,43 @@ describe('ConfigurationEvaluationState — inventory phase 2 GPV saves values on
// Step 1: first handle → sends GPN for inventory
await state.handle(context as any)
// Step 2: execute GPN callback with two leaf names
const taskCallbacks = (context.taskQueue as any).taskCallbacks as Map<string, any>
const gpnTaskId = Array.from(taskCallbacks.keys())[0]
await context.taskQueue.executeTaskCallback(gpnTaskId!, ResultStatus.Success, {
ParameterList: {
ParameterInfoStruct: [
{ Name: 'Device.ManagementServer.PeriodicInformInterval', Writable: '1' },
{ Name: 'Device.ManagementServer.ConnectionRequestURL', Writable: '0' },
],
// Step 2: GPN response inline → extracts leaf names → sends GPV
context.message = {
success: true,
data: {
ParameterList: {
ParameterInfoStruct: [
{ Name: 'Device.ManagementServer.PeriodicInformInterval', Writable: '1' },
{ Name: 'Device.ManagementServer.ConnectionRequestURL', Writable: '0' },
],
},
},
})
// Step 3: second handle → sends GPV for discovered leaves (phase 2)
}
const result2 = await state.handle(context as any)
expect(result2.response).toContain('GetParameterValues')
// Before GPV callback — device has no value for PeriodicInformInterval
// Before GPV response — device has no value for PeriodicInformInterval
const before = device.getParameters().find((p) => p.name === 'Device.ManagementServer.PeriodicInformInterval')
expect(before?.value ?? null).toBeNull()
// Step 4: execute GPV callback with actual values
const gpvTaskId = Array.from(taskCallbacks.keys()).pop()
await context.taskQueue.executeTaskCallback(gpvTaskId!, ResultStatus.Success, {
ParameterList: {
ParameterValueStruct: [
{ Name: 'Device.ManagementServer.PeriodicInformInterval', Value: { _: '3600', $: { 'xsi:type': 'xsd:unsignedInt' } } },
{ Name: 'Device.ManagementServer.ConnectionRequestURL', Value: { _: 'http://cpe/cr', $: { 'xsi:type': 'xsd:string' } } },
],
// Step 3: GPV response inline → updates device values
context.message = {
success: true,
data: {
ParameterList: {
ParameterValueStruct: [
{ Name: 'Device.ManagementServer.PeriodicInformInterval', Value: { _: '3600', $: { 'xsi:type': 'xsd:unsignedInt' } } },
{ Name: 'Device.ManagementServer.ConnectionRequestURL', Value: { _: 'http://cpe/cr', $: { 'xsi:type': 'xsd:string' } } },
],
},
},
})
}
await state.handle(context as any)
// After GPV callback — device must have the values saved
const after = device.getParameters().find((p) => p.name === 'Device.ManagementServer.PeriodicInformInterval')
expect(after).toBeDefined()
// After GPV response — device must have the values saved
const after = device.getProperty('Device.ManagementServer.PeriodicInformInterval')
expect(after).not.toBeNull()
expect(after!.value).toBe('3600')
const afterURL = device.getParameters().find((p) => p.name === 'Device.ManagementServer.ConnectionRequestURL')
expect(afterURL).toBeDefined()
expect(afterURL!.value).toBe('http://cpe/cr')
})
})