16718: Adds unit test cases for the new is:pastVersion search term.
authorLucas Di Pentima <lucas@di-pentima.com.ar>
Tue, 6 Oct 2020 18:21:39 +0000 (15:21 -0300)
committerLucas Di Pentima <lucas@di-pentima.com.ar>
Tue, 6 Oct 2020 18:21:39 +0000 (15:21 -0300)
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas@di-pentima.com.ar>

src/store/search-bar/search-bar-actions.test.ts

index a579183cf00f2c7e1e980c641568c843eb49c17c..194ca2d71765786807859dc0dbb549012ddcb57a 100644 (file)
@@ -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 = {