Skip to content

Commit

Permalink
test(backend): catching up with misskey-dev#10516 (misskey-dev#10624)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nanashia authored and na2na-p committed May 10, 2023
1 parent 3f7947c commit eadc6f7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/backend/test/e2e/endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,8 @@ describe('Endpoints', () => {
userId: bob.id,
}, alice);

assert.strictEqual('memo' in res.body, false);
// memoには常に文字列かnullが入っている(5cac151)
assert.strictEqual(res.body.memo, null);
});

test('メモは個人ごとに独立して保存される', async () => {
Expand Down
25 changes: 23 additions & 2 deletions packages/backend/test/e2e/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('ユーザー', () => {
}, {});
};

// FIXME: 足りないキーがたくさんある
// BUG misskey-jsとjson-schemaと実際に返ってくるデータが全部違う
type UserLite = misskey.entities.UserLite & {
badgeRoles: any[],
};
Expand All @@ -55,6 +55,7 @@ describe('ユーザー', () => {
return successfulApiCall({ endpoint: 'users/show', parameters: { userId: id }, user: me }) as any;
};

// UserLiteのキーが過不足なく入っている?
const userLite = (user: User): Partial<UserLite> => {
return stripUndefined({
id: user.id,
Expand All @@ -76,6 +77,7 @@ describe('ユーザー', () => {
});
};

// UserDetailedNotMeのキーが過不足なく入っている?
const userDetailedNotMe = (user: User): Partial<UserDetailedNotMe> => {
return stripUndefined({
...userLite(user),
Expand Down Expand Up @@ -109,9 +111,11 @@ describe('ユーザー', () => {
usePasswordLessLogin: user.usePasswordLessLogin,
securityKeys: user.securityKeys,
roles: user.roles,
memo: user.memo,
});
};

// Relations関連のキーが過不足なく入っている?
const userDetailedNotMeWithRelations = (user: User): Partial<UserDetailedNotMe> => {
return stripUndefined({
...userDetailedNotMe(user),
Expand All @@ -126,6 +130,7 @@ describe('ユーザー', () => {
});
};

// MeDetailedのキーが過不足なく入っている?
const meDetailed = (user: User, security = false): Partial<MeDetailed> => {
return stripUndefined({
...userDetailedNotMe(user),
Expand Down Expand Up @@ -371,6 +376,7 @@ describe('ユーザー', () => {
assert.strictEqual(response.usePasswordLessLogin, false);
assert.strictEqual(response.securityKeys, false);
assert.deepStrictEqual(response.roles, []);
assert.strictEqual(response.memo, null);

// MeDetailedOnly
assert.strictEqual(response.avatarId, null);
Expand Down Expand Up @@ -410,7 +416,7 @@ describe('ユーザー', () => {
//#endregion
//#region 自分の情報(i)

test('を読み取ることができる。(自分)', async () => {
test('を読み取ることができること(自分)、キーが過不足なく入っていること。', async () => {
const response = await successfulApiCall({
endpoint: 'i',
parameters: {},
Expand Down Expand Up @@ -554,6 +560,21 @@ describe('ユーザー', () => {
assert.deepStrictEqual(response2, expected2);
});

//#endregion
//#region メモの更新(users/update-memo)

test.each([
{ label: '最大長', memo: 'x'.repeat(2048) },
{ label: '空文字', memo: '', expects: null },
{ label: 'null', memo: null },
])('を書き換えることができる(メモを$labelに)', async ({ memo, expects }) => {
const expected = { ...await show(bob.id), memo: expects === undefined ? memo : expects };
const parameters = { userId: bob.id, memo };
await successfulApiCall({ endpoint: 'users/update-memo', parameters, user: alice });
const response = await show(bob.id);
assert.deepStrictEqual(response, expected);
});

//#endregion
//#region ユーザー(users)

Expand Down

0 comments on commit eadc6f7

Please sign in to comment.