Skip to content

Commit

Permalink
create test-utils for Workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
itisAliRH committed Nov 9, 2023
1 parent d380f9b commit 1e4d174
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions client/src/components/Workflow/test-utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
interface Workflow {
id: string;
name: string;
owner: string;
tags: string[];
deleted: boolean;
published: boolean;
description: string;
create_time: string;
update_time: string;
annotations: string[];
show_in_tool_panel: boolean;
latest_workflow_uuid: string;
}

export function generateRandomString() {
return Math.random().toString(36).substring(7) as string;
}

export function generateRandomWorkflow(owner: string): Workflow {
return {
id: "workflow-" + Math.floor(Math.random() * 1000000),
name: generateRandomString(),
owner: owner,
tags: Array.from({ length: Math.floor(Math.random() * 10) }, () => generateRandomString()),
deleted: false,
published: Math.random() > 0.5,
description: generateRandomString(),
create_time: new Date(Date.now() + 1).toISOString(),
update_time: new Date(Date.now() + 2).toISOString(),
annotations: Array.from({ length: Math.floor(Math.random() * 2) }, () => generateRandomString()),
show_in_tool_panel: Math.random() > 0.5,
latest_workflow_uuid: generateRandomString(),
};
}

export function generateRandomWorkflowList(owner: string, count: number): Workflow[] {
return Array.from({ length: count }, () => generateRandomWorkflow(owner));
}

0 comments on commit 1e4d174

Please sign in to comment.