18975: Adds 'Main logs' filter selection. Fixes filter dynamic population.
[arvados-workbench2.git] / src / models / test-utils.ts
index aa8d96b36ae391b1a49186d055cb656e074894e6..1e1041a1d37f5ec9bc990efd87d98870dd1bc609 100644 (file)
@@ -3,21 +3,10 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import { GroupClass, GroupResource } from "./group";
-import { ResourceKind } from "./kinds";
-import { Resource } from "../common/api/common-resource-service";
+import { Resource, ResourceKind } from "./resource";
+import { ProjectResource } from "./project";
 
-type ResourceUnion = GroupResource;
-
-export const mockResource = (kind: ResourceKind, data: Partial<Exclude<ResourceUnion, "kind">>) => {
-    switch (kind) {
-        case ResourceKind.Group:
-            return mockGroupResource({ ...data, kind });
-        default:
-            return mockCommonResource({ ...data, kind });
-    }
-};
-
-export const mockGroupResource = (data: Partial<Exclude<GroupResource, "kind">>): GroupResource => ({
+export const mockGroupResource = (data: Partial<GroupResource> = {}): GroupResource => ({
     createdAt: "",
     deleteAt: "",
     description: "",
@@ -25,7 +14,7 @@ export const mockGroupResource = (data: Partial<Exclude<GroupResource, "kind">>)
     groupClass: null,
     href: "",
     isTrashed: false,
-    kind: ResourceKind.Group,
+    kind: ResourceKind.GROUP,
     modifiedAt: "",
     modifiedByClientUuid: "",
     modifiedByUserUuid: "",
@@ -34,17 +23,23 @@ export const mockGroupResource = (data: Partial<Exclude<GroupResource, "kind">>)
     properties: "",
     trashAt: "",
     uuid: "",
-    writeableBy: []
+    writableBy: [],
+    ensure_unique_name: true,
+    ...data
 });
 
-const mockCommonResource = <T extends Resource>(data: Partial<T> & { kind: ResourceKind }): Resource => ({
+export const mockProjectResource = (data: Partial<ProjectResource> = {}): ProjectResource =>
+    mockGroupResource({ ...data, groupClass: GroupClass.PROJECT }) as ProjectResource;
+
+export const mockCommonResource = (data: Partial<Resource>): Resource => ({
     createdAt: "",
     etag: "",
     href: "",
-    kind: data.kind,
+    kind: ResourceKind.NONE,
     modifiedAt: "",
     modifiedByClientUuid: "",
     modifiedByUserUuid: "",
     ownerUuid: "",
-    uuid: ""
+    uuid: "",
+    ...data
 });