14841: Add link to workbench v1
[arvados-workbench2.git] / src / store / search-bar / search-bar-actions.test.ts
index d936caf528c7f66b4e7dbc4143a49396f45db9f1..ea290b4d7def5fd3bc35941f39725c1bd2341ec2 100644 (file)
@@ -2,15 +2,14 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import { getAdvancedDataFromQuery, getQueryFromAdvancedData, parseQuery } from "~/store/search-bar/search-bar-actions";
+import { getAdvancedDataFromQuery, getQueryFromAdvancedData, parseSearchQuery } from "~/store/search-bar/search-bar-actions";
 import { ResourceKind } from "~/models/resource";
-import { ClusterObjectType } from "~/models/search-bar";
 
 describe('search-bar-actions', () => {
-    describe('parseQuery', () => {
+    describe('parseSearchQuery', () => {
         it('should correctly parse query #1', () => {
             const q = 'val0 is:trashed val1';
-            const r = parseQuery(q);
+            const r = parseSearchQuery(q);
             expect(r.hasKeywords).toBeTruthy();
             expect(r.values).toEqual(['val0', 'val1']);
             expect(r.properties).toEqual({
@@ -20,7 +19,7 @@ describe('search-bar-actions', () => {
 
         it('should correctly parse query #2 (value with keyword should be ignored)', () => {
             const q = 'val0 is:from:trashed val1';
-            const r = parseQuery(q);
+            const r = parseSearchQuery(q);
             expect(r.hasKeywords).toBeTruthy();
             expect(r.values).toEqual(['val0', 'val1']);
             expect(r.properties).toEqual({
@@ -30,7 +29,7 @@ describe('search-bar-actions', () => {
 
         it('should correctly parse query #3 (many keywords)', () => {
             const q = 'val0 is:trashed val2 from:2017-04-01 val1';
-            const r = parseQuery(q);
+            const r = parseSearchQuery(q);
             expect(r.hasKeywords).toBeTruthy();
             expect(r.values).toEqual(['val0', 'val2', 'val1']);
             expect(r.properties).toEqual({
@@ -41,7 +40,7 @@ describe('search-bar-actions', () => {
 
         it('should correctly parse query #4 (no duplicated values)', () => {
             const q = 'val0 is:trashed val2 val2 val0';
-            const r = parseQuery(q);
+            const r = parseSearchQuery(q);
             expect(r.hasKeywords).toBeTruthy();
             expect(r.values).toEqual(['val0', 'val2']);
             expect(r.properties).toEqual({
@@ -51,7 +50,7 @@ describe('search-bar-actions', () => {
 
         it('should correctly parse query #5 (properties)', () => {
             const q = 'val0 has:filesize:100mb val2 val2 val0';
-            const r = parseQuery(q);
+            const r = parseSearchQuery(q);
             expect(r.hasKeywords).toBeTruthy();
             expect(r.values).toEqual(['val0', 'val2']);
             expect(r.properties).toEqual({
@@ -61,7 +60,7 @@ describe('search-bar-actions', () => {
 
         it('should correctly parse query #6 (multiple properties, multiple is)', () => {
             const q = 'val0 has:filesize:100mb val2 has:user:daniel is:starred val2 val0 is:trashed';
-            const r = parseQuery(q);
+            const r = parseSearchQuery(q);
             expect(r.hasKeywords).toBeTruthy();
             expect(r.values).toEqual(['val0', 'val2']);
             expect(r.properties).toEqual({
@@ -95,11 +94,11 @@ 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:indianapolis');
+            const r = getAdvancedDataFromQuery('document from:2017-08-01 pdf has:filesize:101mb is:trashed type:arvados#collection cluster:c97qx');
             expect(r).toEqual({
                 searchValue: 'document pdf',
                 type: ResourceKind.COLLECTION,
-                cluster: ClusterObjectType.INDIANAPOLIS,
+                cluster: 'c97qx',
                 projectUuid: undefined,
                 inTrash: true,
                 dateFrom: '2017-08-01',
@@ -119,7 +118,7 @@ describe('search-bar-actions', () => {
             const q = getQueryFromAdvancedData({
                 searchValue: 'document pdf',
                 type: ResourceKind.COLLECTION,
-                cluster: ClusterObjectType.INDIANAPOLIS,
+                cluster: 'c97qx',
                 projectUuid: undefined,
                 inTrash: true,
                 dateFrom: '2017-08-01',
@@ -131,7 +130,7 @@ describe('search-bar-actions', () => {
                 saveQuery: false,
                 queryName: ''
             });
-            expect(q).toBe('document pdf type:arvados#collection cluster:indianapolis is:trashed from:2017-08-01 has:filesize:101mb');
+            expect(q).toBe('document pdf type:arvados#collection cluster:c97qx is:trashed from:2017-08-01 has:filesize:101mb');
         });
     });
 });