diff --git a/sci-log-db/src/__tests__/unit/websocket.utils.ts b/sci-log-db/src/__tests__/unit/websocket.utils.ts index d90a98a6..bb6a2524 100644 --- a/sci-log-db/src/__tests__/unit/websocket.utils.ts +++ b/sci-log-db/src/__tests__/unit/websocket.utils.ts @@ -46,6 +46,24 @@ describe('Websocket unit tests', function (this: Suite) { ], expected: false, }, + { + input: [ + {tags: ['b', 'p'], snippetType: 'aType'}, + {filter: {snippetType: []}}, + ], + expected: true, + }, + { + input: [{tags: ['b', 'p'], snippetType: 'aType'}, {filter: {tags: []}}], + expected: true, + }, + { + input: [ + {tags: ['b', 'p'], snippetType: 'aType'}, + {filter: {tags: [], snippetType: []}}, + ], + expected: true, + }, ].forEach((t, i) => { it(`Should test matchesFilterSettings ${i}`, () => { expect( diff --git a/sci-log-db/src/utils/websocket.ts b/sci-log-db/src/utils/websocket.ts index 242b6e0a..d80fd73c 100644 --- a/sci-log-db/src/utils/websocket.ts +++ b/sci-log-db/src/utils/websocket.ts @@ -252,9 +252,11 @@ export function matchesFilterSettings( ): boolean { const tagCondition = !config.filter?.tags || - config.filter?.tags?.some(tag => snippet.tags?.includes(tag)); + config.filter.tags.length === 0 || + config.filter.tags.some(tag => snippet.tags?.includes(tag)); const snippetTypeCondition = !config.filter?.snippetType || - config.filter?.snippetType?.includes(snippet.snippetType); + config.filter.snippetType.length === 0 || + config.filter.snippetType.includes(snippet.snippetType); return tagCondition && snippetTypeCondition; }