From 8e317f5aca4df33b6f570a5a0aed4f7b0bf99741 Mon Sep 17 00:00:00 2001 From: "saito.k" Date: Tue, 10 Oct 2023 07:22:00 +0000 Subject: [PATCH] =?UTF-8?q?Merged=20PR=20478:=20PO=E3=83=87=E3=83=A2?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 概要 [Task2821: POデモ修正対応](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/2821) - リテラル修正 - 追加Popupのタイトル - AuthorIDの初期値 - ワークフロー追加・更新の重複チェックの条件指定を修正 - undefined,nullのままだと条件指定しないという挙動になるためIsNull()を使用 - 該当ケースをテストに追加 ## レビューポイント - 特になし ## UIの変更 - タスクのなか ## 動作確認状況 - ローカルで確認、develop環境で確認など ## 補足 - 相談、参考資料などがあれば --- .../pages/WorkflowPage/addworkflowPopup.tsx | 2 +- dictation_client/src/translation/de.json | 4 +- dictation_client/src/translation/en.json | 4 +- dictation_client/src/translation/es.json | 4 +- dictation_client/src/translation/fr.json | 4 +- .../workflows/workflows.service.spec.ts | 178 ++++++++++++++++++ .../workflows/workflows.repository.service.ts | 6 +- 7 files changed, 190 insertions(+), 12 deletions(-) diff --git a/dictation_client/src/pages/WorkflowPage/addworkflowPopup.tsx b/dictation_client/src/pages/WorkflowPage/addworkflowPopup.tsx index 0192cd3..6e33f4c 100644 --- a/dictation_client/src/pages/WorkflowPage/addworkflowPopup.tsx +++ b/dictation_client/src/pages/WorkflowPage/addworkflowPopup.tsx @@ -109,7 +109,7 @@ export const AddWorkflowPopup: React.FC = (

- {t(getTranslationID("worktypeIdSetting.label.addWorktypeId"))} + {t(getTranslationID("workflowPage.label.addRoutingRule"))} {/* eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions */} { } }); + it('アカウント内にWorkflowを作成できる(WorktypeIDなし、テンプレートファイルなし、同一AuthorIDのワークフローあり)', async () => { + const module = await makeTestingModule(source); + // 第五階層のアカウント作成 + const { account, admin } = await makeTestAccount(source, { tier: 5 }); + const { id: authorId } = await makeTestUser(source, { + external_id: 'author1', + author_id: 'AUTHOR1', + account_id: account.id, + role: USER_ROLES.AUTHOR, + }); + const { id: typistId } = await makeTestUser(source, { + external_id: 'typist1', + account_id: account.id, + role: USER_ROLES.TYPIST, + }); + + const { id: worktypeId } = await createWorktype( + source, + account.id, + 'worktype1', + ); + + //作成したデータを確認 + { + const workflows = await getWorkflows(source, account.id); + const workflowTypists = await getAllWorkflowTypists(source); + expect(workflows.length).toBe(0); + expect(workflowTypists.length).toBe(0); + } + + const service = module.get(WorkflowsService); + const context = makeContext(admin.external_id); + + // 同一AuthorIDのワークフローを作成 + await service.createWorkflow( + context, + admin.external_id, + authorId, + worktypeId, + undefined, + [ + { + typistId: typistId, + }, + ], + ); + + await service.createWorkflow( + context, + admin.external_id, + authorId, + undefined, + undefined, + [ + { + typistId: typistId, + }, + ], + ); + + //実行結果を確認 + { + const workflows = await getWorkflows(source, account.id); + expect(workflows.length).toBe(2); + expect(workflows[1].account_id).toBe(account.id); + expect(workflows[1].author_id).toBe(authorId); + expect(workflows[1].worktype_id).toBe(null); + expect(workflows[1].template_id).toBe(null); + + const workflowTypists = await getWorkflowTypists(source, workflows[1].id); + expect(workflowTypists.length).toBe(1); + expect(workflowTypists[0].typist_id).toBe(typistId); + expect(workflowTypists[0].typist_group_id).toBe(null); + } + }); + it('DBにAuthorが存在しない場合、400エラーとなること', async () => { const module = await makeTestingModule(source); // 第五階層のアカウント作成 @@ -1292,6 +1368,108 @@ describe('updateWorkflow', () => { expect(workflowTypists[0].typist_id).toBe(typistId2); } }); + + it('アカウント内にWorkflowを作成できる(WorktypeIDなし、テンプレートファイルなし、同一AuthorIDのワークフローあり)', async () => { + const module = await makeTestingModule(source); + // 第五階層のアカウント作成 + const { account, admin } = await makeTestAccount(source, { tier: 5 }); + const { id: authorId1 } = await makeTestUser(source, { + external_id: 'author1', + author_id: 'AUTHOR1', + account_id: account.id, + role: USER_ROLES.AUTHOR, + }); + const { id: authorId2 } = await makeTestUser(source, { + external_id: 'author2', + author_id: 'AUTHOR2', + account_id: account.id, + role: USER_ROLES.AUTHOR, + }); + const { id: typistId1 } = await makeTestUser(source, { + external_id: 'typist1', + account_id: account.id, + role: USER_ROLES.TYPIST, + }); + const { id: typistId2 } = await makeTestUser(source, { + external_id: 'typist12', + account_id: account.id, + role: USER_ROLES.TYPIST, + }); + const { id: worktypeId } = await createWorktype( + source, + account.id, + 'worktype1', + ); + // 更新対象のワークフローを作成 + const preWorkflow1 = await createWorkflow( + source, + account.id, + authorId1, + undefined, + undefined, + ); + // 同一AuthorIDのワークフローを作成 + const preWorkflow2 = await createWorkflow( + source, + account.id, + authorId2, // 更新するAuthorIDと同じ + worktypeId, + undefined, + ); + + await createWorkflowTypist(source, preWorkflow1.id, typistId1); + await createWorkflowTypist(source, preWorkflow2.id, typistId1); + + //作成したデータを確認 + { + const workflows = await getWorkflows(source, account.id); + const workflowTypists = await getAllWorkflowTypists(source); + expect(workflows.length).toBe(2); + expect(workflows[0].id).toBe(preWorkflow1.id); + expect(workflows[0].account_id).toBe(account.id); + expect(workflows[0].author_id).toBe(authorId1); + expect(workflows[0].worktype_id).toBe(null); + expect(workflows[0].template_id).toBe(null); + expect(workflows[1].id).toBe(preWorkflow2.id); + expect(workflows[1].account_id).toBe(account.id); + expect(workflows[1].author_id).toBe(authorId2); + expect(workflows[1].worktype_id).toBe(worktypeId); + expect(workflows[1].template_id).toBe(null); + expect(workflowTypists.length).toBe(2); + } + + const service = module.get(WorkflowsService); + const context = makeContext(admin.external_id); + + await service.updateWorkflow( + context, + admin.external_id, + preWorkflow1.id, + authorId2, + undefined, + undefined, + [ + { + typistId: typistId2, + }, + ], + ); + + //実行結果を確認 + { + const workflows = await getWorkflows(source, account.id); + expect(workflows.length).toBe(2); + expect(workflows[1].account_id).toBe(account.id); + expect(workflows[1].author_id).toBe(authorId2); + expect(workflows[1].worktype_id).toBe(null); + expect(workflows[1].template_id).toBe(null); + + const workflowTypists = await getWorkflowTypists(source, workflows[1].id); + expect(workflowTypists.length).toBe(1); + expect(workflowTypists[0].typist_id).toBe(typistId2); + } + }); + it('DBにWorkflowが存在しない場合、400エラーとなること', async () => { const module = await makeTestingModule(source); // 第五階層のアカウント作成 diff --git a/dictation_server/src/repositories/workflows/workflows.repository.service.ts b/dictation_server/src/repositories/workflows/workflows.repository.service.ts index 7a06e55..0437d79 100644 --- a/dictation_server/src/repositories/workflows/workflows.repository.service.ts +++ b/dictation_server/src/repositories/workflows/workflows.repository.service.ts @@ -1,5 +1,5 @@ import { Injectable } from '@nestjs/common'; -import { DataSource, In } from 'typeorm'; +import { DataSource, In, IsNull } from 'typeorm'; import { Workflow } from './entity/workflow.entity'; import { WorkflowTypist as DbWorkflowTypist } from './entity/workflow_typists.entity'; import { User } from '../users/entity/user.entity'; @@ -131,7 +131,7 @@ export class WorkflowsRepositoryService { where: { account_id: accountId, author_id: authorId, - worktype_id: worktypeId, + worktype_id: worktypeId !== undefined ? worktypeId : IsNull(), }, }); if (workflow.length !== 0) { @@ -267,7 +267,7 @@ export class WorkflowsRepositoryService { where: { account_id: accountId, author_id: authorId, - worktype_id: worktypeId, + worktype_id: worktypeId !== undefined ? worktypeId : IsNull(), }, }); if (duplicateWorkflow.length !== 0) {