## 概要 [Task3210: 画面修正(Terms画面)](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/3210) [Task3211:API修正(バージョン取得API)](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/OMDSDictation/_sprints/taskboard/OMDSDictation%20%E3%83%81%E3%83%BC%E3%83%A0/OMDSDictation/%E3%82%B9%E3%83%97%E3%83%AA%E3%83%B3%E3%83%88%2023-1?workitem=3211) [Task3212:API修正(バージョン更新API))](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/OMDSDictation/_sprints/taskboard/OMDSDictation%20%E3%83%81%E3%83%BC%E3%83%A0/OMDSDictation/%E3%82%B9%E3%83%97%E3%83%AA%E3%83%B3%E3%83%88%2023-1?workitem=3212) - このPull Requestでの対象/対象外 Click here to read the terms of use.の文言は多言語対応の対象のため、現在一律同じ文言がでます。 第一~第四階層は 上からEULA,PrivacyNotice,DPAが表示されています 第五階層は、 上から、PrivacyNotice,DPAが表示されています - 影響範囲(他の機能にも影響があるか) ユーザアーカイブテーブルにPrivacyNoticeのバージョンを追加 ## レビューポイント 同意済みプライバシーポリシーはユーザーアーカイブの対象だと認識しているが正しいか。 termsテーブルのdocument_typeの値をPrivacyNoticeにしているが、PRIVACY_NOTICEにしたほうがよいか。 ユニットテストに不足はないか。 ## UIの変更 - Before/Afterのスクショなど - スクショ置き場 https://ndstokyo.sharepoint.com/sites/Piranha/Shared%20Documents/Forms/AllItems.aspx?csf=1&web=1&e=hzPw9b&cid=7737ed1b%2D0eb4%2D4331%2Da238%2D14dd35b27e18&FolderCTID=0x012000C0DCEE65AC2177479C3C761CD137C9C9&id=%2Fsites%2FPiranha%2FShared%20Documents%2FGeneral%2FOMDS%2F%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%BC%E3%83%B3%E3%82%B7%E3%83%A7%E3%83%83%E3%83%88%2FTask3210&viewid=786a81cf%2Dd15f%2D4dc2%2D9e55%2Dc7a729fbc72f ## 動作確認状況 - ローカルで確認 ## 補足 - 相談、参考資料などがあれば
212 lines
6.9 KiB
TypeScript
212 lines
6.9 KiB
TypeScript
import { Test, TestingModule } from '@nestjs/testing';
|
|
import { BlobstorageService } from '../../../gateways/blobstorage/blobstorage.service';
|
|
import { User } from '../../../repositories/users/entity/user.entity';
|
|
import { UsersRepositoryService } from '../../../repositories/users/users.repository.service';
|
|
import { FilesService } from '../files.service';
|
|
import { TasksRepositoryService } from '../../../repositories/tasks/tasks.repository.service';
|
|
import { Task } from '../../../repositories/tasks/entity/task.entity';
|
|
import { TemplateFilesRepositoryService } from '../../../repositories/template_files/template_files.repository.service';
|
|
import { NotificationhubService } from '../../../gateways/notificationhub/notificationhub.service';
|
|
import { UserGroupsRepositoryService } from '../../../repositories/user_groups/user_groups.repository.service';
|
|
|
|
export type BlobstorageServiceMockValue = {
|
|
createContainer: void | Error;
|
|
containerExists: boolean | Error;
|
|
fileExists: boolean | Error;
|
|
publishUploadSas: string | Error;
|
|
publishDownloadSas: string | Error;
|
|
};
|
|
|
|
export type UsersRepositoryMockValue = {
|
|
findUserByExternalId: User | Error;
|
|
isUserLicenseValid: boolean | Error;
|
|
};
|
|
|
|
export type TasksRepositoryMockValue = {
|
|
create: Task | Error;
|
|
getTasksFromAccountId: { tasks: Task[]; count: number } | Error;
|
|
};
|
|
|
|
export const makeFilesServiceMock = async (
|
|
blobStorageService: BlobstorageServiceMockValue,
|
|
usersRepositoryMockValue: UsersRepositoryMockValue,
|
|
tasksRepositoryMockValue: TasksRepositoryMockValue,
|
|
): Promise<FilesService> => {
|
|
const module: TestingModule = await Test.createTestingModule({
|
|
providers: [FilesService],
|
|
})
|
|
.useMocker((token) => {
|
|
switch (token) {
|
|
case BlobstorageService:
|
|
return makeBlobstorageServiceMock(blobStorageService);
|
|
case UsersRepositoryService:
|
|
return makeUsersRepositoryMock(usersRepositoryMockValue);
|
|
case TasksRepositoryService:
|
|
return makeTasksRepositoryMock(tasksRepositoryMockValue);
|
|
case TemplateFilesRepositoryService:
|
|
return {};
|
|
case NotificationhubService:
|
|
return {};
|
|
case UserGroupsRepositoryService:
|
|
return {};
|
|
}
|
|
})
|
|
.compile();
|
|
|
|
return module.get<FilesService>(FilesService);
|
|
};
|
|
|
|
export const makeBlobstorageServiceMock = (
|
|
value: BlobstorageServiceMockValue,
|
|
) => {
|
|
const {
|
|
containerExists,
|
|
fileExists,
|
|
createContainer,
|
|
publishUploadSas,
|
|
publishDownloadSas,
|
|
} = value;
|
|
|
|
return {
|
|
containerExists:
|
|
containerExists instanceof Error
|
|
? jest.fn<Promise<void>, []>().mockRejectedValue(containerExists)
|
|
: jest.fn<Promise<boolean>, []>().mockResolvedValue(containerExists),
|
|
fileExists:
|
|
fileExists instanceof Error
|
|
? jest.fn<Promise<void>, []>().mockRejectedValue(fileExists)
|
|
: jest.fn<Promise<boolean>, []>().mockResolvedValue(fileExists),
|
|
createContainer:
|
|
createContainer instanceof Error
|
|
? jest.fn<Promise<void>, []>().mockRejectedValue(createContainer)
|
|
: jest.fn<Promise<void>, []>().mockResolvedValue(createContainer),
|
|
publishUploadSas:
|
|
publishUploadSas instanceof Error
|
|
? jest.fn<Promise<void>, []>().mockRejectedValue(publishUploadSas)
|
|
: jest.fn<Promise<string>, []>().mockResolvedValue(publishUploadSas),
|
|
publishDownloadSas:
|
|
publishDownloadSas instanceof Error
|
|
? jest.fn<Promise<void>, []>().mockRejectedValue(publishDownloadSas)
|
|
: jest.fn<Promise<string>, []>().mockResolvedValue(publishDownloadSas),
|
|
};
|
|
};
|
|
|
|
export const makeUsersRepositoryMock = (value: UsersRepositoryMockValue) => {
|
|
const { findUserByExternalId, isUserLicenseValid } = value;
|
|
|
|
return {
|
|
findUserByExternalId:
|
|
findUserByExternalId instanceof Error
|
|
? jest.fn<Promise<void>, []>().mockRejectedValue(findUserByExternalId)
|
|
: jest.fn<Promise<User>, []>().mockResolvedValue(findUserByExternalId),
|
|
isUserLicenseValid:
|
|
isUserLicenseValid instanceof Error
|
|
? jest.fn<Promise<void>, []>().mockRejectedValue(isUserLicenseValid)
|
|
: jest.fn<Promise<boolean>, []>().mockResolvedValue(isUserLicenseValid),
|
|
};
|
|
};
|
|
|
|
export const makeBlobstorageServiceMockValue =
|
|
(): BlobstorageServiceMockValue => {
|
|
return {
|
|
containerExists: true,
|
|
fileExists: true,
|
|
publishUploadSas: 'https://blob-storage?sas-token',
|
|
publishDownloadSas: 'https://blob-storage?sas-token',
|
|
createContainer: undefined,
|
|
};
|
|
};
|
|
|
|
export const makeTasksRepositoryMock = (value: TasksRepositoryMockValue) => {
|
|
const { create } = value;
|
|
|
|
return {
|
|
create:
|
|
create instanceof Error
|
|
? jest.fn<Promise<void>, []>().mockRejectedValue(create)
|
|
: jest.fn<Promise<Task>, []>().mockResolvedValue(create),
|
|
};
|
|
};
|
|
|
|
// 個別のテストケースに対応してそれぞれのMockを用意するのは無駄が多いのでテストケース内で個別の値を設定する
|
|
export const makeDefaultUsersRepositoryMockValue =
|
|
(): UsersRepositoryMockValue => {
|
|
return {
|
|
findUserByExternalId: {
|
|
id: 2,
|
|
external_id: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx',
|
|
account_id: 1234567890123456,
|
|
role: 'none',
|
|
author_id: '',
|
|
accepted_eula_version: '1.0',
|
|
accepted_privacy_notice_version: '1.0',
|
|
accepted_dpa_version: '1.0',
|
|
email_verified: true,
|
|
deleted_at: null,
|
|
created_by: 'test',
|
|
created_at: new Date(),
|
|
updated_by: null,
|
|
updated_at: new Date(),
|
|
auto_renew: true,
|
|
license_alert: true,
|
|
notification: true,
|
|
encryption: false,
|
|
prompt: false,
|
|
encryption_password: null,
|
|
license: null,
|
|
userGroupMembers: null,
|
|
account: {
|
|
id: 2,
|
|
parent_account_id: 2,
|
|
tier: 5,
|
|
country: '',
|
|
delegation_permission: true,
|
|
locked: false,
|
|
company_name: '',
|
|
verified: true,
|
|
primary_admin_user_id: 2,
|
|
deleted_at: null,
|
|
created_by: '',
|
|
created_at: new Date(),
|
|
updated_by: '',
|
|
updated_at: new Date(),
|
|
active_worktype_id: null,
|
|
secondary_admin_user_id: null,
|
|
user: null,
|
|
},
|
|
},
|
|
isUserLicenseValid: true,
|
|
};
|
|
};
|
|
|
|
export const makeDefaultTasksRepositoryMockValue =
|
|
(): TasksRepositoryMockValue => {
|
|
return {
|
|
create: {
|
|
id: 1,
|
|
job_number: '00000001',
|
|
account_id: 1,
|
|
is_job_number_enabled: true,
|
|
audio_file_id: 1,
|
|
status: 'Uploaded',
|
|
priority: '01',
|
|
created_at: new Date(),
|
|
finished_at: null,
|
|
started_at: null,
|
|
template_file_id: null,
|
|
typist_user_id: null,
|
|
file: null,
|
|
option_items: null,
|
|
template_file: null,
|
|
typist_user: null,
|
|
created_by: null,
|
|
updated_by: null,
|
|
updated_at: new Date(),
|
|
},
|
|
getTasksFromAccountId: {
|
|
tasks: [],
|
|
count: 0,
|
|
},
|
|
};
|
|
};
|