Merge branch 'develop' into feature/2024.9.0
# Conflicts: # locales/en-US.yml # locales/ja-JP.yml # packages/backend/src/core/NoteCreateService.ts # packages/backend/src/core/NoteDeleteService.ts # packages/backend/src/core/NoteEditService.ts # packages/frontend-shared/js/config.ts # packages/frontend/src/boot/common.ts # packages/frontend/src/pages/following-feed.vue # packages/misskey-js/src/autogen/endpoint.ts
This commit is contained in:
commit
8a34d8e9d2
52 changed files with 1073 additions and 268 deletions
|
|
@ -141,6 +141,7 @@ describe('ユーザー', () => {
|
|||
hasUnreadNotification: user.hasUnreadNotification,
|
||||
unreadNotificationsCount: user.unreadNotificationsCount,
|
||||
hasPendingReceivedFollowRequest: user.hasPendingReceivedFollowRequest,
|
||||
hasPendingSentFollowRequest: user.hasPendingSentFollowRequest,
|
||||
unreadAnnouncements: user.unreadAnnouncements,
|
||||
mutedWords: user.mutedWords,
|
||||
hardMutedWords: user.hardMutedWords,
|
||||
|
|
@ -381,6 +382,7 @@ describe('ユーザー', () => {
|
|||
assert.strictEqual(response.hasUnreadNotification, false);
|
||||
assert.strictEqual(response.unreadNotificationsCount, 0);
|
||||
assert.strictEqual(response.hasPendingReceivedFollowRequest, false);
|
||||
assert.strictEqual(response.hasPendingSentFollowRequest, false);
|
||||
assert.deepStrictEqual(response.unreadAnnouncements, []);
|
||||
assert.deepStrictEqual(response.mutedWords, []);
|
||||
assert.deepStrictEqual(response.mutedInstances, []);
|
||||
|
|
|
|||
13
packages/backend/test/unit/misc/from-tuple.ts
Normal file
13
packages/backend/test/unit/misc/from-tuple.ts
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import { fromTuple } from '@/misc/from-tuple.js';
|
||||
|
||||
describe(fromTuple, () => {
|
||||
it('should return value when value is not an array', () => {
|
||||
const value = fromTuple('abc');
|
||||
expect(value).toBe('abc');
|
||||
});
|
||||
|
||||
it('should return first element when value is an array', () => {
|
||||
const value = fromTuple(['abc']);
|
||||
expect(value).toBe('abc');
|
||||
});
|
||||
});
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { isQuote, isRenote } from '@/misc/is-renote.js';
|
||||
import { isPureRenote, isQuote, isRenote } from '@/misc/is-renote.js';
|
||||
import { MiNote } from '@/models/Note.js';
|
||||
|
||||
const base: MiNote = {
|
||||
|
|
@ -86,4 +86,24 @@ describe('misc:is-renote', () => {
|
|||
expect(isRenote(note)).toBe(true);
|
||||
expect(isQuote(note as any)).toBe(true);
|
||||
});
|
||||
|
||||
describe('isPureRenote', () => {
|
||||
it('should return true when note is pure renote', () => {
|
||||
const note = new MiNote({ renoteId: 'abc123', fileIds: [] });
|
||||
const result = isPureRenote(note);
|
||||
expect(result).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should return false when note is quote', () => {
|
||||
const note = new MiNote({ renoteId: 'abc123', text: 'text', fileIds: [] });
|
||||
const result = isPureRenote(note);
|
||||
expect(result).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should return false when note is not renote', () => {
|
||||
const note = new MiNote({ renoteId: null, fileIds: [] });
|
||||
const result = isPureRenote(note);
|
||||
expect(result).toBeFalsy();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
149
packages/backend/test/unit/models/LatestNote.ts
Normal file
149
packages/backend/test/unit/models/LatestNote.ts
Normal file
|
|
@ -0,0 +1,149 @@
|
|||
import { SkLatestNote } from '@/models/LatestNote.js';
|
||||
import { MiNote } from '@/models/Note.js';
|
||||
|
||||
describe(SkLatestNote, () => {
|
||||
describe('keyFor', () => {
|
||||
it('should include userId', () => {
|
||||
const note = new MiNote({ userId: 'abc123', fileIds: [] });
|
||||
const key = SkLatestNote.keyFor(note);
|
||||
expect(key.userId).toBe(note.userId);
|
||||
});
|
||||
|
||||
it('should include isPublic when is public', () => {
|
||||
const note = new MiNote({ visibility: 'public', fileIds: [] });
|
||||
const key = SkLatestNote.keyFor(note);
|
||||
expect(key.isPublic).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should include isPublic when is home-only', () => {
|
||||
const note = new MiNote({ visibility: 'home', fileIds: [] });
|
||||
const key = SkLatestNote.keyFor(note);
|
||||
expect(key.isPublic).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should include isPublic when is followers-only', () => {
|
||||
const note = new MiNote({ visibility: 'followers', fileIds: [] });
|
||||
const key = SkLatestNote.keyFor(note);
|
||||
expect(key.isPublic).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should include isPublic when is specified', () => {
|
||||
const note = new MiNote({ visibility: 'specified', fileIds: [] });
|
||||
const key = SkLatestNote.keyFor(note);
|
||||
expect(key.isPublic).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should include isReply when is reply', () => {
|
||||
const note = new MiNote({ replyId: 'abc123', fileIds: [] });
|
||||
const key = SkLatestNote.keyFor(note);
|
||||
expect(key.isReply).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should include isReply when is not reply', () => {
|
||||
const note = new MiNote({ replyId: null, fileIds: [] });
|
||||
const key = SkLatestNote.keyFor(note);
|
||||
expect(key.isReply).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should include isQuote when is quote', () => {
|
||||
const note = new MiNote({ renoteId: 'abc123', text: 'text', fileIds: [] });
|
||||
const key = SkLatestNote.keyFor(note);
|
||||
expect(key.isQuote).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should include isQuote when is reblog', () => {
|
||||
const note = new MiNote({ renoteId: 'abc123', fileIds: [] });
|
||||
const key = SkLatestNote.keyFor(note);
|
||||
expect(key.isQuote).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should include isQuote when is neither quote nor reblog', () => {
|
||||
const note = new MiNote({ renoteId: null, fileIds: [] });
|
||||
const key = SkLatestNote.keyFor(note);
|
||||
expect(key.isQuote).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('areEquivalent', () => {
|
||||
it('should return true when keys match', () => {
|
||||
const first = new MiNote({ id: '1', userId: 'abc123', visibility: 'public', replyId: null, renoteId: null, fileIds: [] });
|
||||
const second = new MiNote({ id: '2', userId: 'abc123', visibility: 'public', replyId: null, renoteId: null, fileIds: [] });
|
||||
|
||||
const result = SkLatestNote.areEquivalent(first, second);
|
||||
|
||||
expect(result).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should return true when keys match with different reply IDs', () => {
|
||||
const first = new MiNote({ id: '1', userId: 'abc123', visibility: 'public', replyId: '3', renoteId: null, fileIds: [] });
|
||||
const second = new MiNote({ id: '2', userId: 'abc123', visibility: 'public', replyId: '4', renoteId: null, fileIds: [] });
|
||||
|
||||
const result = SkLatestNote.areEquivalent(first, second);
|
||||
|
||||
expect(result).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should return true when keys match with different renote IDs', () => {
|
||||
const first = new MiNote({ id: '1', userId: 'abc123', visibility: 'public', replyId: null, renoteId: '3', fileIds: ['1'] });
|
||||
const second = new MiNote({ id: '2', userId: 'abc123', visibility: 'public', replyId: null, renoteId: '4', fileIds: ['1'] });
|
||||
|
||||
const result = SkLatestNote.areEquivalent(first, second);
|
||||
|
||||
expect(result).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should return true when keys match with different file counts', () => {
|
||||
const first = new MiNote({ id: '1', userId: 'abc123', visibility: 'public', replyId: null, renoteId: null, fileIds: ['1'] });
|
||||
const second = new MiNote({ id: '2', userId: 'abc123', visibility: 'public', replyId: null, renoteId: null, fileIds: ['1','2'] });
|
||||
|
||||
const result = SkLatestNote.areEquivalent(first, second);
|
||||
|
||||
expect(result).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should return true when keys match with different private visibilities', () => {
|
||||
const first = new MiNote({ id: '1', userId: 'abc123', visibility: 'home', replyId: null, renoteId: null, fileIds: [] });
|
||||
const second = new MiNote({ id: '2', userId: 'abc123', visibility: 'followers', replyId: null, renoteId: null, fileIds: [] });
|
||||
|
||||
const result = SkLatestNote.areEquivalent(first, second);
|
||||
|
||||
expect(result).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should return false when user ID differs', () => {
|
||||
const first = new MiNote({ id: '1', userId: 'abc123', visibility: 'public', replyId: null, renoteId: null, fileIds: [] });
|
||||
const second = new MiNote({ id: '2', userId: 'def456', visibility: 'public', replyId: null, renoteId: null, fileIds: [] });
|
||||
|
||||
const result = SkLatestNote.areEquivalent(first, second);
|
||||
|
||||
expect(result).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should return false when visibility differs', () => {
|
||||
const first = new MiNote({ id: '1', userId: 'abc123', visibility: 'public', replyId: null, renoteId: null, fileIds: [] });
|
||||
const second = new MiNote({ id: '2', userId: 'abc123', visibility: 'home', replyId: null, renoteId: null, fileIds: [] });
|
||||
|
||||
const result = SkLatestNote.areEquivalent(first, second);
|
||||
|
||||
expect(result).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should return false when reply differs', () => {
|
||||
const first = new MiNote({ id: '1', userId: 'abc123', visibility: 'public', replyId: '1', renoteId: null, fileIds: [] });
|
||||
const second = new MiNote({ id: '2', userId: 'abc123', visibility: 'public', replyId: null, renoteId: null, fileIds: [] });
|
||||
|
||||
const result = SkLatestNote.areEquivalent(first, second);
|
||||
|
||||
expect(result).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should return false when quote differs', () => {
|
||||
const first = new MiNote({ id: '1', userId: 'abc123', visibility: 'public', replyId: null, renoteId: '3', fileIds: ['1'] });
|
||||
const second = new MiNote({ id: '2', userId: 'abc123', visibility: 'public', replyId: null, renoteId: null, fileIds: [] });
|
||||
|
||||
const result = SkLatestNote.areEquivalent(first, second);
|
||||
|
||||
expect(result).toBeFalsy();
|
||||
});
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue