diff --git a/dictation_server/src/features/workflows/workflows.service.spec.ts b/dictation_server/src/features/workflows/workflows.service.spec.ts index 177a048..4728510 100644 --- a/dictation_server/src/features/workflows/workflows.service.spec.ts +++ b/dictation_server/src/features/workflows/workflows.service.spec.ts @@ -47,22 +47,23 @@ describe('getWorkflows', () => { const { account, admin } = await makeTestAccount(source, { tier: 5 }); const { id: authorId1 } = await makeTestUser(source, { external_id: 'author1', - author_id: 'AUTHOR1', + author_id: 'BBBBB', account_id: account.id, role: USER_ROLES.AUTHOR, }); const { id: authorId2 } = await makeTestUser(source, { external_id: 'author2', - author_id: 'AUTHOR2', + author_id: 'AAAAA', account_id: account.id, role: USER_ROLES.AUTHOR, }); const { id: authorId3 } = await makeTestUser(source, { external_id: 'author3', - author_id: 'AUTHOR3', + author_id: 'CCCCC', account_id: account.id, role: USER_ROLES.AUTHOR, }); + const { id: typistId, external_id: typistExternalId } = await makeTestUser( source, { @@ -84,6 +85,12 @@ describe('getWorkflows', () => { 'worktype1', ); + const { id: worktypeId2 } = await createWorktype( + source, + account.id, + 'worktype2', + ); + const { id: templateId1 } = await createTemplateFile( source, account.id, @@ -106,6 +113,13 @@ describe('getWorkflows', () => { templateId1, ); const workflow3 = await createWorkflow( + source, + account.id, + authorId3, + worktypeId2, + undefined, + ); + const workflow4 = await createWorkflow( source, account.id, authorId3, @@ -116,6 +130,7 @@ describe('getWorkflows', () => { await createWorkflowTypist(source, workflow1.id, typistId, undefined); await createWorkflowTypist(source, workflow2.id, undefined, userGroupId); await createWorkflowTypist(source, workflow3.id, undefined, userGroupId); + await createWorkflowTypist(source, workflow4.id, undefined, userGroupId); const service = module.get(WorkflowsService); const context = makeContext(admin.external_id, 'requestId'); @@ -123,7 +138,7 @@ describe('getWorkflows', () => { //作成したデータを確認 { const workflows = await getWorkflows(source, account.id); - expect(workflows.length).toBe(3); + expect(workflows.length).toBe(4); expect(workflows[0].id).toBe(workflow1.id); expect(workflows[0].author_id).toBe(authorId1); expect(workflows[0].worktype_id).toBe(worktypeId1); @@ -136,8 +151,13 @@ describe('getWorkflows', () => { expect(workflows[2].id).toBe(workflow3.id); expect(workflows[2].author_id).toBe(authorId3); - expect(workflows[2].worktype_id).toBe(worktypeId1); + expect(workflows[2].worktype_id).toBe(worktypeId2); expect(workflows[2].template_id).toBe(null); + + expect(workflows[3].id).toBe(workflow4.id); + expect(workflows[3].author_id).toBe(authorId3); + expect(workflows[3].worktype_id).toBe(worktypeId1); + expect(workflows[3].template_id).toBe(null); } overrideAdB2cService(service, { @@ -148,37 +168,48 @@ describe('getWorkflows', () => { //実行結果を確認 { - expect(resWorkflows.length).toBe(3); - expect(resWorkflows[0].id).toBe(workflow1.id); - expect(resWorkflows[0].author.id).toBe(authorId1); - expect(resWorkflows[0].author.authorId).toBe('AUTHOR1'); - expect(resWorkflows[0].worktype?.id).toBe(worktypeId1); - expect(resWorkflows[0].worktype?.worktypeId).toBe('worktype1'); + expect(resWorkflows.length).toBe(4); + + expect(resWorkflows[0].id).toBe(workflow2.id); + expect(resWorkflows[0].author.id).toBe(authorId2); + expect(resWorkflows[0].author.authorId).toBe('AAAAA'); + expect(resWorkflows[0].worktype).toBe(undefined); expect(resWorkflows[0].template?.id).toBe(templateId1); expect(resWorkflows[0].template?.fileName).toBe('fileName1'); expect(resWorkflows[0].typists.length).toBe(1); - expect(resWorkflows[0].typists[0].typistUserId).toBe(typistId); - expect(resWorkflows[0].typists[0].typistName).toBe('typist1'); + expect(resWorkflows[0].typists[0].typistGroupId).toBe(userGroupId); + expect(resWorkflows[0].typists[0].typistName).toBe('group1'); - expect(resWorkflows[1].id).toBe(workflow2.id); - expect(resWorkflows[1].author.id).toBe(authorId2); - expect(resWorkflows[1].author.authorId).toBe('AUTHOR2'); - expect(resWorkflows[1].worktype).toBe(undefined); + expect(resWorkflows[1].id).toBe(workflow1.id); + expect(resWorkflows[1].author.id).toBe(authorId1); + expect(resWorkflows[1].author.authorId).toBe('BBBBB'); + expect(resWorkflows[1].worktype?.id).toBe(worktypeId1); + expect(resWorkflows[1].worktype?.worktypeId).toBe('worktype1'); expect(resWorkflows[1].template?.id).toBe(templateId1); expect(resWorkflows[1].template?.fileName).toBe('fileName1'); expect(resWorkflows[1].typists.length).toBe(1); - expect(resWorkflows[1].typists[0].typistGroupId).toBe(userGroupId); - expect(resWorkflows[1].typists[0].typistName).toBe('group1'); + expect(resWorkflows[1].typists[0].typistUserId).toBe(typistId); + expect(resWorkflows[1].typists[0].typistName).toBe('typist1'); - expect(resWorkflows[2].id).toBe(workflow3.id); + expect(resWorkflows[2].id).toBe(workflow4.id); expect(resWorkflows[2].author.id).toBe(authorId3); - expect(resWorkflows[2].author.authorId).toBe('AUTHOR3'); + expect(resWorkflows[2].author.authorId).toBe('CCCCC'); expect(resWorkflows[2].worktype?.id).toBe(worktypeId1); expect(resWorkflows[2].worktype?.worktypeId).toBe('worktype1'); expect(resWorkflows[2].template).toBe(undefined); expect(resWorkflows[2].typists.length).toBe(1); expect(resWorkflows[2].typists[0].typistGroupId).toBe(userGroupId); expect(resWorkflows[2].typists[0].typistName).toBe('group1'); + + expect(resWorkflows[3].id).toBe(workflow3.id); + expect(resWorkflows[3].author.id).toBe(authorId3); + expect(resWorkflows[3].author.authorId).toBe('CCCCC'); + expect(resWorkflows[3].worktype?.id).toBe(worktypeId2); + expect(resWorkflows[3].worktype?.worktypeId).toBe('worktype2'); + expect(resWorkflows[3].template).toBe(undefined); + expect(resWorkflows[3].typists.length).toBe(1); + expect(resWorkflows[3].typists[0].typistGroupId).toBe(userGroupId); + expect(resWorkflows[3].typists[0].typistName).toBe('group1'); } }); @@ -209,7 +240,7 @@ describe('getWorkflows', () => { const module = await makeTestingModule(source); if (!module) fail(); // 第五階層のアカウント作成 - const { account, admin } = await makeTestAccount(source, { tier: 5 }); + const { admin } = await makeTestAccount(source, { tier: 5 }); const service = module.get(WorkflowsService); const context = makeContext(admin.external_id, 'requestId'); diff --git a/dictation_server/src/repositories/workflows/workflows.repository.service.ts b/dictation_server/src/repositories/workflows/workflows.repository.service.ts index b945380..563daee 100644 --- a/dictation_server/src/repositories/workflows/workflows.repository.service.ts +++ b/dictation_server/src/repositories/workflows/workflows.repository.service.ts @@ -50,7 +50,10 @@ export class WorkflowsRepositoryService { }, }, order: { - id: 'ASC', + author: { + author_id: 'ASC', + }, + worktype_id: 'ASC', }, comment: `${context.getTrackingId()}_${new Date().toUTCString()}`, });