X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/dc10e586102b4aad5d3c82d6b6cf799a9277a929..756da23ade34fd225e80e448fb27795d453294c6:/src/store/search-bar/search-bar-actions.test.ts diff --git a/src/store/search-bar/search-bar-actions.test.ts b/src/store/search-bar/search-bar-actions.test.ts index a579183cf0..d14f3f1475 100644 --- a/src/store/search-bar/search-bar-actions.test.ts +++ b/src/store/search-bar/search-bar-actions.test.ts @@ -2,19 +2,19 @@ // // SPDX-License-Identifier: AGPL-3.0 -import { getAdvancedDataFromQuery, getQueryFromAdvancedData } from "~/store/search-bar/search-bar-actions"; -import { ResourceKind } from "~/models/resource"; +import { getAdvancedDataFromQuery, getQueryFromAdvancedData } from "store/search-bar/search-bar-actions"; +import { ResourceKind } from "models/resource"; describe('search-bar-actions', () => { describe('getAdvancedDataFromQuery', () => { it('should correctly build advanced data record from query #1', () => { - const r = getAdvancedDataFromQuery('val0 has:"file size":"100mb" val2 has:"user":"daniel" is:starred val2 val0 is:trashed'); + const r = getAdvancedDataFromQuery('val0 has:"file size":"100mb" val2 has:"user":"daniel" is:starred val2 val0'); expect(r).toEqual({ searchValue: 'val0 val2', type: undefined, cluster: undefined, projectUuid: undefined, - inTrash: true, + inTrash: false, pastVersions: false, dateFrom: '', dateTo: '', @@ -31,14 +31,14 @@ describe('search-bar-actions', () => { }); it('should correctly build advanced data record from query #2', () => { - const r = getAdvancedDataFromQuery('document from:2017-08-01 pdf has:"filesize":"101mb" is:trashed type:arvados#collection cluster:c97qx'); + const r = getAdvancedDataFromQuery('document from:2017-08-01 pdf has:"filesize":"101mb" is:trashed type:arvados#collection cluster:c97qx is:pastVersion'); expect(r).toEqual({ searchValue: 'document pdf', type: ResourceKind.COLLECTION, cluster: 'c97qx', projectUuid: undefined, inTrash: true, - pastVersions: false, + pastVersions: true, dateFrom: '2017-08-01', dateTo: '', properties: [{ @@ -73,6 +73,27 @@ describe('search-bar-actions', () => { expect(q).toBe('document pdf type:arvados#collection cluster:c97qx is:trashed from:2017-08-01 has:"file size":"101mb" has:"Species":"Human" has:"Species":"Canine"'); }); + it('should build query from advanced data #2', () => { + const q = getQueryFromAdvancedData({ + searchValue: 'document pdf', + type: ResourceKind.COLLECTION, + cluster: 'c97qx', + projectUuid: undefined, + inTrash: false, + pastVersions: true, + dateFrom: '2017-08-01', + dateTo: '', + properties: [ + { key: 'file size', value: '101mb' }, + { key: 'Species', value: 'Human' }, + { key: 'Species', value: 'Canine' }, + ], + saveQuery: false, + queryName: '' + }); + expect(q).toBe('document pdf type:arvados#collection cluster:c97qx is:pastVersion from:2017-08-01 has:"file size":"101mb" has:"Species":"Human" has:"Species":"Canine"'); + }); + it('should add has:"key":"value" expression to query from same property key', () => { const searchValue = 'document pdf has:"file size":"101mb" has:"Species":"Canine"'; const prevData = {