From 4cbbb468b5c58a649b00db93bc1e68f0dda05d36 Mon Sep 17 00:00:00 2001 From: Jason <37859597+zachowj@users.noreply.github.com> Date: Wed, 6 Sep 2023 15:30:49 -0700 Subject: [PATCH] fix(trigger-state): Fix migrations for version 3 test(trigger-state): Add test for migrations --- src/nodes/trigger-state/migrations.ts | 13 ++++++------- test/migrations/trigger-state.test.js | 27 ++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/src/nodes/trigger-state/migrations.ts b/src/nodes/trigger-state/migrations.ts index 54e2b486af..bf55904a63 100644 --- a/src/nodes/trigger-state/migrations.ts +++ b/src/nodes/trigger-state/migrations.ts @@ -56,12 +56,12 @@ export default [ const newSchema = { ...schema, version: 3, - entityId: schema.entityConfigNode, - entityIdType: schema.entityidfiltertypeentityConfigNode, - debugEnabled: schema.debugenabledentityConfigNode, - customOutputs: schema.customoutputsentityConfigNode, - outputInitially: schema.outputinitiallyentityConfigNode, - StateType: schema.state_typeentityConfigNode, + entityId: schema.entityid, + entityIdType: schema.entityidfiltertype, + debugEnabled: schema.debugenabled, + customOutputs: schema.customoutputs, + outputInitially: schema.outputinitially, + StateType: schema.state_type, exposeAsEntityConfig: '', }; @@ -71,7 +71,6 @@ export default [ newSchema.customoutputs = undefined; newSchema.outputinitially = undefined; newSchema.state_type = undefined; - newSchema.enableInput = undefined; return newSchema; }, diff --git a/test/migrations/trigger-state.test.js b/test/migrations/trigger-state.test.js index ba3dd345b8..9063c44a60 100644 --- a/test/migrations/trigger-state.test.js +++ b/test/migrations/trigger-state.test.js @@ -41,6 +41,24 @@ const VERSION_2 = { ...VERSION_1, version: 2, }; +const VERSION_3 = { + ...VERSION_2, + version: 3, + entityId: 'entity.id', + entityIdType: 'exact', + debugEnabled: false, + customOutputs: [], + outputInitially: false, + StateType: 'str', + exposeAsEntityConfig: '', + + entityid: undefined, + entityidfiltertype: undefined, + debugenabled: undefined, + customoutputs: undefined, + outputinitially: undefined, + state_type: undefined, +}; describe('Migrations - Trigger State Node', function () { describe('Version 0', function () { @@ -90,8 +108,15 @@ describe('Migrations - Trigger State Node', function () { expect(migratedSchema.entityid).to.have.lengthOf(1); }); }); + describe('Version 3', function () { + it('should update version 2 to version 3', function () { + const migrate = migrations.find((m) => m.version === 3); + const migratedSchema = migrate.up(VERSION_2); + expect(migratedSchema).to.eql(VERSION_3); + }); + }); it('should update an undefined version to current version', function () { const migratedSchema = migrate(VERSION_UNDEFINED); - expect(migratedSchema).to.eql(VERSION_2); + expect(migratedSchema).to.eql(VERSION_3); }); });