diff --git a/server/seeders/20190227043234-scene.js b/server/seeders/20190227043234-scene.js index 79e26d5f8d..066a3fa403 100644 --- a/server/seeders/20190227043234-scene.js +++ b/server/seeders/20190227043234-scene.js @@ -21,9 +21,10 @@ module.exports = { triggers: '[]', created_at: '2019-02-12 07:49:07.556 +00:00', updated_at: '2019-02-12 07:49:07.556 +00:00', + tags: '[]', }, { - id: '88428a7d-ea9d-46a6-b0d2-46bf82d37e53 \n', + id: '88428a7d-ea9d-46a6-b0d2-46bf82d37e53', name: 'To Duplicate scene', icon: 'fe fe-bell', selector: 'to-duplicate-scene', @@ -43,6 +44,30 @@ module.exports = { ]), created_at: '2022-04-15 07:49:07.556 +00:00', updated_at: '2022-04-15 07:49:07.556 +00:00', + tags: '[]', + }, + { + id: '956794d8-a9cb-49bf-a677-57e820288b5a', + name: 'Scene with tags', + icon: 'fe fe-bell', + selector: 'scene-with-tag', + actions: JSON.stringify([ + [ + { + type: ACTIONS.LIGHT.TURN_ON, + }, + ], + ]), + triggers: JSON.stringify([ + { + type: EVENTS.TIME.CHANGED, + scheduler_type: 'every-day', + time: '12:00', + }, + ]), + created_at: '2022-04-15 07:49:07.556 +00:00', + updated_at: '2022-04-15 07:49:07.556 +00:00', + tags: '["tag 1", "tag 2"]', }, ], {}, diff --git a/server/test/lib/scene/scene.get.test.js b/server/test/lib/scene/scene.get.test.js index 897f0aca61..9ce1614d8a 100644 --- a/server/test/lib/scene/scene.get.test.js +++ b/server/test/lib/scene/scene.get.test.js @@ -39,6 +39,27 @@ describe('SceneManager.get', () => { }, ]); }); + it('should search scene by tag', async () => { + const sceneManager = new SceneManager({}, event); + const scenes = await sceneManager.get({ + search: 'tag', + }); + expect(scenes).to.be.instanceOf(Array); + expect(scenes).to.deep.equal([ + { + id: '956794d8-a9cb-49bf-a677-57e820288b5a', + name: 'Scene with tags', + icon: 'fe fe-bell', + active: true, + description: null, + selector: 'scene-with-tag', + tags: ['tag 1', 'tag 2'], + last_executed: null, + updated_at: new Date('2022-04-15T07:49:07.556Z'), + }, + ]); + }); + it('should return 0 result in search', async () => { const sceneManager = new SceneManager({}, event); const scenes = await sceneManager.get({