From: Lucas Di Pentima Date: Tue, 6 Oct 2020 18:21:39 +0000 (-0300) Subject: 16718: Adds unit test cases for the new is:pastVersion search term. X-Git-Tag: 2.1.1~10^2~4 X-Git-Url: https://git.arvados.org/arvados-workbench2.git/commitdiff_plain/a7812342b6c07116acda6ce154e8dc6ed9d1c1c1 16718: Adds unit test cases for the new is:pastVersion search term. Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima --- diff --git a/src/store/search-bar/search-bar-actions.test.ts b/src/store/search-bar/search-bar-actions.test.ts index a579183c..194ca2d7 100644 --- a/src/store/search-bar/search-bar-actions.test.ts +++ b/src/store/search-bar/search-bar-actions.test.ts @@ -8,13 +8,13 @@ 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 = {