mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-13 22:15:41 +02:00
* wip * update fake-timers and migrate * fix * remove jest-mock * fix * fix * fix * fix * attempt to fix unit tests * attempt to fix e2e tests * fix federation test [ci skip] * attempt to fix e2e tests * fix typecheck * fix unit tests * fix * attempt to fix e2e * fix * Revert "attempt to fix e2e" This reverts commitb7b7b05d85. * attempt to fix e2e * revert attempt to fix e2e * update deps * update vitest * migrate * attempt to fix e2e * update * fix * remove vite swc plugin as oxc parser can handle decorators * attempt to fix drive/files/create test * Revert "attempt to fix drive/files/create test" This reverts commit4715153375. * fix: エンドポイントにまつわるテストをunitからe2eに移動 * attempt to fix e2e * remove swc * attempt to fix e2e * Revert "attempt to fix e2e" This reverts commit9fb86a4076. * add logs for debug * attempt to fix e2e * Partially revert "attempt to fix e2e" This reverts commitfb0008c85a. * attempt to fix test * fix: attempt to fix test * Revert "fix: attempt to fix test" This reverts commited2f5c40e8. * Revert "attempt to fix test" This reverts commitd7329c46f1. * attempt to fix e2e * fix: surpass eventemitter warning by increasing defaultMaxListeners * attempt to fix e2e * fix * fix e2e not ending properly * exp: add hanging-process reporter for investigation * Revert "exp: add hanging-process reporter for investigation" This reverts commit26851f8282. * update changelog
109 lines
4.1 KiB
TypeScript
109 lines
4.1 KiB
TypeScript
import { describe, test, beforeAll, afterAll } from 'vitest';
|
|
import * as Misskey from 'misskey-js';
|
|
import { assertNotificationReceived, createAccount, type LoginUser, resolveRemoteNote, resolveRemoteUser, sleep } from './utils.js';
|
|
|
|
describe('Notification', () => {
|
|
let alice: LoginUser, bob: LoginUser;
|
|
let bobInA: Misskey.entities.UserDetailedNotMe, aliceInB: Misskey.entities.UserDetailedNotMe;
|
|
|
|
beforeAll(async () => {
|
|
[alice, bob] = await Promise.all([
|
|
createAccount('a.test'),
|
|
createAccount('b.test'),
|
|
]);
|
|
|
|
[bobInA, aliceInB] = await Promise.all([
|
|
resolveRemoteUser('b.test', bob.id, alice),
|
|
resolveRemoteUser('a.test', alice.id, bob),
|
|
]);
|
|
});
|
|
|
|
describe('Follow', () => {
|
|
test('Get notification when follow', async () => {
|
|
await assertNotificationReceived(
|
|
'b.test', bob,
|
|
async () => await bob.client.request('following/create', { userId: aliceInB.id }),
|
|
notification => notification.type === 'followRequestAccepted' && notification.userId === aliceInB.id,
|
|
true,
|
|
);
|
|
|
|
await bob.client.request('following/delete', { userId: aliceInB.id });
|
|
await sleep();
|
|
});
|
|
|
|
test('Get notification when get followed', async () => {
|
|
await assertNotificationReceived(
|
|
'a.test', alice,
|
|
async () => await bob.client.request('following/create', { userId: aliceInB.id }),
|
|
notification => notification.type === 'follow' && notification.userId === bobInA.id,
|
|
true,
|
|
);
|
|
});
|
|
|
|
afterAll(async () => await bob.client.request('following/delete', { userId: aliceInB.id }));
|
|
});
|
|
|
|
describe('Note', () => {
|
|
test('Get notification when get a reaction', async () => {
|
|
const note = (await alice.client.request('notes/create', { text: 'a' })).createdNote;
|
|
const noteInB = await resolveRemoteNote('a.test', note.id, bob);
|
|
const reaction = '😅';
|
|
await assertNotificationReceived(
|
|
'a.test', alice,
|
|
async () => await bob.client.request('notes/reactions/create', { noteId: noteInB.id, reaction }),
|
|
notification =>
|
|
notification.type === 'reaction' && notification.note.id === note.id && notification.userId === bobInA.id && notification.reaction === reaction,
|
|
true,
|
|
);
|
|
});
|
|
|
|
test('Get notification when replied', async () => {
|
|
const note = (await alice.client.request('notes/create', { text: 'a' })).createdNote;
|
|
const noteInB = await resolveRemoteNote('a.test', note.id, bob);
|
|
const text = crypto.randomUUID();
|
|
await assertNotificationReceived(
|
|
'a.test', alice,
|
|
async () => await bob.client.request('notes/create', { text, replyId: noteInB.id }),
|
|
notification =>
|
|
notification.type === 'reply' && notification.note.reply!.id === note.id && notification.userId === bobInA.id && notification.note.text === text,
|
|
true,
|
|
);
|
|
});
|
|
|
|
test('Get notification when renoted', async () => {
|
|
const note = (await alice.client.request('notes/create', { text: 'a' })).createdNote;
|
|
const noteInB = await resolveRemoteNote('a.test', note.id, bob);
|
|
await assertNotificationReceived(
|
|
'a.test', alice,
|
|
async () => await bob.client.request('notes/create', { renoteId: noteInB.id }),
|
|
notification =>
|
|
notification.type === 'renote' && notification.note.renote!.id === note.id && notification.userId === bobInA.id,
|
|
true,
|
|
);
|
|
});
|
|
|
|
test('Get notification when quoted', async () => {
|
|
const note = (await alice.client.request('notes/create', { text: 'a' })).createdNote;
|
|
const noteInB = await resolveRemoteNote('a.test', note.id, bob);
|
|
const text = crypto.randomUUID();
|
|
await assertNotificationReceived(
|
|
'a.test', alice,
|
|
async () => await bob.client.request('notes/create', { text, renoteId: noteInB.id }),
|
|
notification =>
|
|
notification.type === 'quote' && notification.note.renote!.id === note.id && notification.userId === bobInA.id && notification.note.text === text,
|
|
true,
|
|
);
|
|
});
|
|
|
|
test('Get notification when mentioned', async () => {
|
|
const text = `@${alice.username}@a.test`;
|
|
await assertNotificationReceived(
|
|
'a.test', alice,
|
|
async () => await bob.client.request('notes/create', { text }),
|
|
notification => notification.type === 'mention' && notification.userId === bobInA.id && notification.note.text === text,
|
|
true,
|
|
);
|
|
});
|
|
});
|
|
});
|