diff --git a/dictation_server/src/features/accounts/accounts.service.spec.ts b/dictation_server/src/features/accounts/accounts.service.spec.ts index c76e4fe..6debabc 100644 --- a/dictation_server/src/features/accounts/accounts.service.spec.ts +++ b/dictation_server/src/features/accounts/accounts.service.spec.ts @@ -2645,34 +2645,34 @@ describe('getDealers', () => { ], }); }); - // TODO 本番環境デプロイのためにこのテストはスキップする - // it('非表示指定されたDealer以外のDealerを取得できる', async () => { - // if (!source) fail(); - // const module = await makeTestingModule(source); - // if (!module) fail(); - // // 100件のDealerを作成し、country,id,company_nameを取得する - // const dealers: { country: string; id: number; name: string }[] = []; - // for (let i = 0; i < 100; i++) { - // const { id, company_name, country } = ( - // await makeTestAccount(source, { - // parent_account_id: i, - // tier: TIERS.TIER4, - // country: 'JP', - // company_name: `DEALER_${i}`, - // }) - // ).account; - // dealers.push({ id, name: company_name, country }); - // } - // const service = module.get(AccountsService); - // const context = makeContext(`uuidv4`, 'requestId'); - // const result = await service.getDealers(context); - // // idが50と99のDealerを非表示にする + + it('非表示指定されたDealer以外のDealerを取得できる', async () => { + if (!source) fail(); + const module = await makeTestingModule(source); + if (!module) fail(); + // 100件のDealerを作成し、country,id,company_nameを取得する + const dealers: { country: string; id: number; name: string }[] = []; + for (let i = 0; i < 100; i++) { + const { id, company_name, country } = ( + await makeTestAccount(source, { + parent_account_id: i, + tier: TIERS.TIER4, + country: 'JP', + company_name: `DEALER_${i}`, + }) + ).account; + dealers.push({ id, name: company_name, country }); + } + const service = module.get(AccountsService); + const context = makeContext(`uuidv4`, 'requestId'); + const result = await service.getDealers(context); + // idが50と99のDealerを非表示にする - // expect(result.dealers.length).toBe(98); - // expect(result).toEqual({ - // dealers: dealers.filter((dealer) => dealer.id !== 50 && dealer.id !== 99), - // }); - // }); + expect(result.dealers.length).toBe(98); + expect(result).toEqual({ + dealers: dealers.filter((dealer) => dealer.id !== 50 && dealer.id !== 99), + }); + }); it('0件でもDealerを取得できる', async () => { if (!source) fail(); diff --git a/dictation_server/src/features/accounts/accounts.service.ts b/dictation_server/src/features/accounts/accounts.service.ts index aaefaf6..94e7e3c 100644 --- a/dictation_server/src/features/accounts/accounts.service.ts +++ b/dictation_server/src/features/accounts/accounts.service.ts @@ -76,9 +76,8 @@ import { ConfigService } from '@nestjs/config'; @Injectable() export class AccountsService { - // TODO 本番環境デプロイのためにこの変数はコメントアウトする 2024年4月22日 //プロダクト バックログ項目 4077: [保守]本番環境動作確認用のDealerアカウントを表示しないようにする の対応 - // private readonly dealerAccountIdHiddenList: number[] = []; + private readonly dealerAccountIdHiddenList: number[] = []; private readonly logger = new Logger(AccountsService.name); constructor( private readonly accountRepository: AccountsRepositoryService, @@ -94,21 +93,20 @@ export class AccountsService { const dealerAccountIdList = this.configService.get( 'DEALER_ACCOUNT_ID_HIDDEN_LIST', ); - // TODO 本番環境デプロイのためにこの変数はコメントアウトする 2024年4月22日 // ディーラーアカウントIDリストを数値配列に変換する // 変換できない場合はエラーをスローする // 存在しない場合や空文字列の場合は空の配列を返す - // if (dealerAccountIdList) { - // this.dealerAccountIdHiddenList = dealerAccountIdList - // .split(',') - // .map((x) => { - // const id = parseInt(x, 10); - // if (isNaN(id)) { - // throw new Error('DEALER_ACCOUNT_ID_HIDDEN_LIST is invalid'); - // } - // return id; - // }); - // } + if (dealerAccountIdList) { + this.dealerAccountIdHiddenList = dealerAccountIdList + .split(',') + .map((x) => { + const id = parseInt(x, 10); + if (isNaN(id)) { + throw new Error('DEALER_ACCOUNT_ID_HIDDEN_LIST is invalid'); + } + return id; + }); + } } /** @@ -1199,27 +1197,26 @@ export class AccountsService { const dealerAccounts = await this.accountRepository.findDealerAccounts( context, ); - // TODO 本番環境デプロイのためにこの変数はコメントアウトする 2024年4月22日 // プロダクト バックログ項目 4077: [保守]本番環境動作確認用のDealerアカウントを表示しないようにする の対応 // this.dealerAccountIdHiddenListに含まれるアカウント(動作確認用のアカウント)を除外する。 // 除外したアカウントをlogに出力する - // const filteredDealerAccounts = dealerAccounts.filter((dealerAccount) => { - // const isHidden = this.dealerAccountIdHiddenList.includes( - // dealerAccount.id, - // ); - // if (isHidden) { - // this.logger.log( - // `[${context.getTrackingId()}] hidden dealer account: ${ - // dealerAccount.id - // }`, - // ); - // } - // return !isHidden; - // }); + const filteredDealerAccounts = dealerAccounts.filter((dealerAccount) => { + const isHidden = this.dealerAccountIdHiddenList.includes( + dealerAccount.id, + ); + if (isHidden) { + this.logger.log( + `[${context.getTrackingId()}] hidden dealer account: ${ + dealerAccount.id + }`, + ); + } + return !isHidden; + }); // レスポンス用の型に変換 const dealers: GetDealersResponse = { - dealers: dealerAccounts.map((dealerAccount): Dealer => { + dealers: filteredDealerAccounts.map((dealerAccount): Dealer => { return { id: dealerAccount.id, name: dealerAccount.company_name,