Merged PR 694: テスト対応
## 概要 [Task3504: テスト対応](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/3504) - ユーザー取得APIで取得するユーザーの順序をAuthor、Typist、Noneの順になるようにしました。 ## レビューポイント - 単純なorderの指定ではうまくいかないようでしたのでDBからの取得後にソートするようにしていますが処理として適切でしょうか? ## UIの変更 - なし ## 動作確認状況 - ローカルで確認
This commit is contained in:
parent
d23336a065
commit
6e931c5afb
@ -88,6 +88,16 @@ export const USER_ROLES = {
|
||||
TYPIST: 'typist',
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* ロールのソート順
|
||||
* @const {string[]}
|
||||
*/
|
||||
export const USER_ROLE_ORDERS = [
|
||||
USER_ROLES.AUTHOR,
|
||||
USER_ROLES.TYPIST,
|
||||
USER_ROLES.NONE,
|
||||
] as string[];
|
||||
|
||||
/**
|
||||
* ライセンス注文状態
|
||||
* @const {string[]}
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
import { HttpException, HttpStatus } from '@nestjs/common';
|
||||
import { AccessToken } from '../../common/token';
|
||||
import { makeErrorResponse } from '../../common/error/makeErrorResponse';
|
||||
import {
|
||||
makeDefaultAdB2cMockValue,
|
||||
@ -1389,6 +1388,16 @@ describe('UsersService.getUsers', () => {
|
||||
if (!module) fail();
|
||||
|
||||
const { id: accountId } = await makeTestSimpleAccount(source);
|
||||
const { id: typistUserId } = await makeTestUser(source, {
|
||||
account_id: accountId,
|
||||
external_id: 'external_id2',
|
||||
role: 'typist',
|
||||
author_id: undefined,
|
||||
auto_renew: true,
|
||||
encryption: false,
|
||||
encryption_password: undefined,
|
||||
prompt: false,
|
||||
});
|
||||
const { external_id: externalId_author, id: authorUserId } =
|
||||
await makeTestUser(source, {
|
||||
account_id: accountId,
|
||||
@ -1401,17 +1410,6 @@ describe('UsersService.getUsers', () => {
|
||||
prompt: false,
|
||||
});
|
||||
|
||||
const { id: typistUserId } = await makeTestUser(source, {
|
||||
account_id: accountId,
|
||||
external_id: 'external_id2',
|
||||
role: 'typist',
|
||||
author_id: undefined,
|
||||
auto_renew: true,
|
||||
encryption: false,
|
||||
encryption_password: undefined,
|
||||
prompt: false,
|
||||
});
|
||||
|
||||
await createUserGroup(source, accountId, 'group1', [typistUserId]);
|
||||
|
||||
const { id: noneUserId } = await makeTestUser(source, {
|
||||
|
||||
@ -29,6 +29,7 @@ import {
|
||||
TIERS,
|
||||
TRIAL_LICENSE_ISSUE_NUM,
|
||||
USER_ROLES,
|
||||
USER_ROLE_ORDERS,
|
||||
} from '../../constants';
|
||||
import { License } from '../licenses/entity/license.entity';
|
||||
import { NewTrialLicenseExpirationDate } from '../../features/licenses/types/types';
|
||||
@ -496,10 +497,23 @@ export class UsersRepositoryService {
|
||||
license: true,
|
||||
},
|
||||
where: { account_id: accountId },
|
||||
|
||||
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||
});
|
||||
|
||||
return dbUsers;
|
||||
// RoleのAuthor、Typist、Noneの順に並び替える
|
||||
const roleSortedUsers = dbUsers.sort((a, b) => {
|
||||
// Roleが同じ場合はIDの昇順で並び替える
|
||||
if (a.role === b.role) {
|
||||
return a.id - b.id;
|
||||
}
|
||||
|
||||
return (
|
||||
USER_ROLE_ORDERS.indexOf(a.role) - USER_ROLE_ORDERS.indexOf(b.role)
|
||||
);
|
||||
});
|
||||
|
||||
return roleSortedUsers;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user