diff --git a/tests/integration/database/base_model.spec.ts b/tests/integration/database/base_model.spec.ts index 0bb6cff..90714d6 100644 --- a/tests/integration/database/base_model.spec.ts +++ b/tests/integration/database/base_model.spec.ts @@ -74,10 +74,11 @@ describe('BaseModel (integration)', () => { }) it('find returns multiple documents', async () => { - const col = db.collection('test_base') - await col.insertMany([{ type: 'a' }, { type: 'a' }, { type: 'b' }]) - const results = await col.find({ type: 'a' }).toArray() + const col = db.collection('test_find_multi') + await col.insertMany([{ t: 'a' }, { t: 'a' }, { t: 'b' }]) + const results = await col.find({ t: 'a' }).toArray() expect(results).toHaveLength(2) + await col.drop() }) it('countDocuments returns correct count', async () => { diff --git a/tests/unit/services/cwmp/configuration_evaluation_state.spec.ts b/tests/unit/services/cwmp/configuration_evaluation_state.spec.ts index abc9e25..47adf00 100644 --- a/tests/unit/services/cwmp/configuration_evaluation_state.spec.ts +++ b/tests/unit/services/cwmp/configuration_evaluation_state.spec.ts @@ -86,3 +86,35 @@ describe('ConfigurationEvaluationState', () => { expect(result2.nextState!.name).toBe('compliance-update') }) }) + +describe('ConfigurationEvaluationState - full happy path', () => { + it('inventory GPN → GPN → SPV diffs → compliance-update', async () => { + const state = new ConfigurationEvaluationState() + const context = makeContext('supported') + + // Step 1: First call → GPN for Device.DeviceInfo. + const r1 = await state.handle(context) + expect(r1.response).toContain('GetParameterNames') + expect(r1.response).toContain('Device.DeviceInfo.') + + // Step 2: GPN response → next GPN for Device.ManagementServer. + context.message = { success: true, data: { ParameterList: { ParameterInfoStruct: [ + { Name: 'Device.DeviceInfo.Manufacturer', Writable: '0' }, + ] } } } + const r2 = await state.handle(context) + expect(r2.response).toContain('GetParameterNames') + expect(r2.response).toContain('Device.ManagementServer.') + + // Step 3: Second GPN response → no more inventory → SPV diffs + context.message = { success: true, data: { ParameterList: { ParameterInfoStruct: [] } } } + const r3 = await state.handle(context) + expect(r3.response).toContain('SetParameterValues') + expect(r3.response).toContain('Device.X') + + // Step 4: SPV response → no firmware → transitions to compliance-update + context.message = { success: true, data: { Status: 0 } } + const r4 = await state.handle(context) + expect(r4.nextState).toBeDefined() + expect(r4.nextState!.name).toBe('compliance-update') + }) +})