Merge tag '2023.10.2' into merge-upstream
This commit is contained in:
@@ -174,6 +174,7 @@ describe('アンテナ', () => {
|
||||
users: [''],
|
||||
withFile: false,
|
||||
withReplies: false,
|
||||
localOnly: false,
|
||||
} as Antenna;
|
||||
assert.deepStrictEqual(response, expected);
|
||||
});
|
||||
|
@@ -188,6 +188,7 @@ describe('Account Move', () => {
|
||||
excludeKeywords: [],
|
||||
users: [],
|
||||
caseSensitive: false,
|
||||
localOnly: false,
|
||||
withReplies: false,
|
||||
withFile: false,
|
||||
notify: false,
|
||||
@@ -431,6 +432,7 @@ describe('Account Move', () => {
|
||||
excludeKeywords: [],
|
||||
users: [eve.id],
|
||||
caseSensitive: false,
|
||||
localOnly: false,
|
||||
withReplies: false,
|
||||
withFile: false,
|
||||
notify: false,
|
||||
|
@@ -18,7 +18,6 @@ describe('Streaming', () => {
|
||||
const follow = async (follower: any, followee: any) => {
|
||||
await Followings.save({
|
||||
id: 'a',
|
||||
createdAt: new Date(),
|
||||
followerId: follower.id,
|
||||
followeeId: followee.id,
|
||||
followerHost: follower.host,
|
||||
@@ -116,6 +115,16 @@ describe('Streaming', () => {
|
||||
assert.strictEqual(fired, true);
|
||||
});
|
||||
|
||||
test('自分の visibility: followers な投稿が流れる', async () => {
|
||||
const fired = await waitFire(
|
||||
ayano, 'homeTimeline', // ayano:Home
|
||||
() => api('notes/create', { text: 'foo', visibility: 'followers' }, ayano), // ayano posts
|
||||
msg => msg.type === 'note' && msg.body.text === 'foo',
|
||||
);
|
||||
|
||||
assert.strictEqual(fired, true);
|
||||
});
|
||||
|
||||
test('フォローしているユーザーの投稿が流れる', async () => {
|
||||
const fired = await waitFire(
|
||||
ayano, 'homeTimeline', // ayano:home
|
||||
@@ -126,6 +135,30 @@ describe('Streaming', () => {
|
||||
assert.strictEqual(fired, true);
|
||||
});
|
||||
|
||||
test('フォローしているユーザーの visibility: followers な投稿が流れる', async () => {
|
||||
const fired = await waitFire(
|
||||
ayano, 'homeTimeline', // ayano:home
|
||||
() => api('notes/create', { text: 'foo', visibility: 'followers' }, kyoko), // kyoko posts
|
||||
msg => msg.type === 'note' && msg.body.userId === kyoko.id, // wait kyoko
|
||||
);
|
||||
|
||||
assert.strictEqual(fired, true);
|
||||
});
|
||||
|
||||
/* なんか失敗する
|
||||
test('フォローしているユーザーの visibility: followers な投稿への返信が流れる', async () => {
|
||||
const note = await api('notes/create', { text: 'foo', visibility: 'followers' }, kyoko);
|
||||
|
||||
const fired = await waitFire(
|
||||
ayano, 'homeTimeline', // ayano:home
|
||||
() => api('notes/create', { text: 'bar', visibility: 'followers', replyId: note.body.id }, kyoko), // kyoko posts
|
||||
msg => msg.type === 'note' && msg.body.userId === kyoko.id && msg.body.reply.text === 'foo',
|
||||
);
|
||||
|
||||
assert.strictEqual(fired, true);
|
||||
});
|
||||
*/
|
||||
|
||||
test('フォローしていないユーザーの投稿は流れない', async () => {
|
||||
const fired = await waitFire(
|
||||
kyoko, 'homeTimeline', // kyoko:home
|
||||
@@ -242,6 +275,16 @@ describe('Streaming', () => {
|
||||
assert.strictEqual(fired, true);
|
||||
});
|
||||
|
||||
test('自分の visibility: followers な投稿が流れる', async () => {
|
||||
const fired = await waitFire(
|
||||
ayano, 'hybridTimeline',
|
||||
() => api('notes/create', { text: 'foo', visibility: 'followers' }, ayano), // ayano posts
|
||||
msg => msg.type === 'note' && msg.body.text === 'foo',
|
||||
);
|
||||
|
||||
assert.strictEqual(fired, true);
|
||||
});
|
||||
|
||||
test('フォローしていないローカルユーザーの投稿が流れる', async () => {
|
||||
const fired = await waitFire(
|
||||
ayano, 'hybridTimeline', // ayano:Hybrid
|
||||
@@ -294,6 +337,16 @@ describe('Streaming', () => {
|
||||
assert.strictEqual(fired, true);
|
||||
});
|
||||
|
||||
test('フォローしているユーザーの visibility: followers な投稿が流れる', async () => {
|
||||
const fired = await waitFire(
|
||||
ayano, 'hybridTimeline', // ayano:Hybrid
|
||||
() => api('notes/create', { text: 'foo', visibility: 'followers' }, kyoko),
|
||||
msg => msg.type === 'note' && msg.body.userId === kyoko.id, // wait kyoko
|
||||
);
|
||||
|
||||
assert.strictEqual(fired, true);
|
||||
});
|
||||
|
||||
test('フォローしていないローカルユーザーのホーム投稿は流れない', async () => {
|
||||
const fired = await waitFire(
|
||||
ayano, 'hybridTimeline', // ayano:Hybrid
|
||||
|
@@ -727,7 +727,7 @@ describe('Timelines', () => {
|
||||
|
||||
await waitForPushToTl();
|
||||
|
||||
const res = await api('/notes/hybrid-timeline', { }, alice);
|
||||
const res = await api('/notes/hybrid-timeline', { limit: 100 }, alice);
|
||||
|
||||
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
|
||||
assert.strictEqual(res.body.some((note: any) => note.id === carolNote.id), true);
|
||||
|
@@ -35,8 +35,7 @@ describe('AnnouncementService', () => {
|
||||
function createUser(data: Partial<MiUser> = {}) {
|
||||
const un = secureRndstr(16);
|
||||
return usersRepository.insert({
|
||||
id: genAidx(new Date()),
|
||||
createdAt: new Date(),
|
||||
id: genAidx(Date.now()),
|
||||
username: un,
|
||||
usernameLower: un,
|
||||
...data,
|
||||
@@ -44,10 +43,9 @@ describe('AnnouncementService', () => {
|
||||
.then(x => usersRepository.findOneByOrFail(x.identifiers[0]));
|
||||
}
|
||||
|
||||
function createAnnouncement(data: Partial<MiAnnouncement> = {}) {
|
||||
function createAnnouncement(data: Partial<MiAnnouncement & { createdAt: Date }> = {}) {
|
||||
return announcementsRepository.insert({
|
||||
id: genAidx(new Date()),
|
||||
createdAt: new Date(),
|
||||
id: genAidx(data.createdAt ?? new Date()),
|
||||
updatedAt: null,
|
||||
title: 'Title',
|
||||
text: 'Text',
|
||||
|
@@ -37,8 +37,7 @@ describe('RoleService', () => {
|
||||
function createUser(data: Partial<MiUser> = {}) {
|
||||
const un = secureRndstr(16);
|
||||
return usersRepository.insert({
|
||||
id: genAidx(new Date()),
|
||||
createdAt: new Date(),
|
||||
id: genAidx(Date.now()),
|
||||
username: un,
|
||||
usernameLower: un,
|
||||
...data,
|
||||
@@ -48,8 +47,7 @@ describe('RoleService', () => {
|
||||
|
||||
function createRole(data: Partial<MiRole> = {}) {
|
||||
return rolesRepository.insert({
|
||||
id: genAidx(new Date()),
|
||||
createdAt: new Date(),
|
||||
id: genAidx(Date.now()),
|
||||
updatedAt: new Date(),
|
||||
lastUsedAt: new Date(),
|
||||
description: '',
|
||||
@@ -198,10 +196,10 @@ describe('RoleService', () => {
|
||||
|
||||
test('conditional role', async () => {
|
||||
const user1 = await createUser({
|
||||
createdAt: new Date(Date.now() - (1000 * 60 * 60 * 24 * 365)),
|
||||
id: genAidx(Date.now() - (1000 * 60 * 60 * 24 * 365)),
|
||||
});
|
||||
const user2 = await createUser({
|
||||
createdAt: new Date(Date.now() - (1000 * 60 * 60 * 24 * 365)),
|
||||
id: genAidx(Date.now() - (1000 * 60 * 60 * 24 * 365)),
|
||||
followersCount: 10,
|
||||
});
|
||||
await createRole({
|
||||
|
@@ -23,6 +23,7 @@ import { secureRndstr } from '@/misc/secure-rndstr.js';
|
||||
import { DownloadService } from '@/core/DownloadService.js';
|
||||
import { MetaService } from '@/core/MetaService.js';
|
||||
import type { MiRemoteUser } from '@/models/User.js';
|
||||
import { genAidx } from '@/misc/id/aidx.js';
|
||||
import { MockResolver } from '../misc/mock-resolver.js';
|
||||
|
||||
const host = 'https://host1.test';
|
||||
@@ -200,7 +201,7 @@ describe('ActivityPub', () => {
|
||||
describe('Renderer', () => {
|
||||
test('Render an announce with visibility: followers', () => {
|
||||
rendererService.renderAnnounce(null, {
|
||||
createdAt: new Date(0),
|
||||
id: genAidx(Date.now()),
|
||||
visibility: 'followers',
|
||||
} as MiNote);
|
||||
});
|
||||
|
@@ -14,44 +14,44 @@ import { ulidRegExp, parseUlid } from '@/misc/id/ulid.js';
|
||||
|
||||
describe('misc:id', () => {
|
||||
test('aid', () => {
|
||||
const date = new Date();
|
||||
const date = Date.now();
|
||||
const gotAid = genAid(date);
|
||||
expect(gotAid).toMatch(aidRegExp);
|
||||
expect(parseAid(gotAid).date.getTime()).toBe(date.getTime());
|
||||
expect(parseAid(gotAid).date.getTime()).toBe(date);
|
||||
});
|
||||
|
||||
test('aidx', () => {
|
||||
const date = new Date();
|
||||
const date = Date.now();
|
||||
const gotAidx = genAidx(date);
|
||||
expect(gotAidx).toMatch(aidxRegExp);
|
||||
expect(parseAidx(gotAidx).date.getTime()).toBe(date.getTime());
|
||||
expect(parseAidx(gotAidx).date.getTime()).toBe(date);
|
||||
});
|
||||
|
||||
test('meid', () => {
|
||||
const date = new Date();
|
||||
const date = Date.now();
|
||||
const gotMeid = genMeid(date);
|
||||
expect(gotMeid).toMatch(meidRegExp);
|
||||
expect(parseMeid(gotMeid).date.getTime()).toBe(date.getTime());
|
||||
expect(parseMeid(gotMeid).date.getTime()).toBe(date);
|
||||
});
|
||||
|
||||
test('meidg', () => {
|
||||
const date = new Date();
|
||||
const date = Date.now();
|
||||
const gotMeidg = genMeidg(date);
|
||||
expect(gotMeidg).toMatch(meidgRegExp);
|
||||
expect(parseMeidg(gotMeidg).date.getTime()).toBe(date.getTime());
|
||||
expect(parseMeidg(gotMeidg).date.getTime()).toBe(date);
|
||||
});
|
||||
|
||||
test('objectid', () => {
|
||||
const date = new Date();
|
||||
const date = Date.now();
|
||||
const gotObjectId = genObjectId(date);
|
||||
expect(gotObjectId).toMatch(objectIdRegExp);
|
||||
expect(Math.floor(parseObjectId(gotObjectId).date.getTime() / 1000)).toBe(Math.floor(date.getTime() / 1000));
|
||||
expect(Math.floor(parseObjectId(gotObjectId).date.getTime() / 1000)).toBe(Math.floor(date / 1000));
|
||||
});
|
||||
|
||||
test('ulid', () => {
|
||||
const date = new Date();
|
||||
const gotUlid = ulid(date.getTime());
|
||||
const date = Date.now();
|
||||
const gotUlid = ulid(date);
|
||||
expect(gotUlid).toMatch(ulidRegExp);
|
||||
expect(parseUlid(gotUlid).date.getTime()).toBe(date.getTime());
|
||||
expect(parseUlid(gotUlid).date.getTime()).toBe(date);
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user