This commit is contained in:
ThatOneCalculator 2022-07-28 23:46:36 -07:00
parent 291649b6e7
commit e639496be2
3 changed files with 78 additions and 0 deletions

View file

@ -2,6 +2,7 @@ import main from './main.js';
import homeTimeline from './home-timeline.js';
import localTimeline from './local-timeline.js';
import hybridTimeline from './hybrid-timeline.js';
import recommendedTimeline from './recommended-timeline.js';
import globalTimeline from './global-timeline.js';
import serverStats from './server-stats.js';
import queueStats from './queue-stats.js';
@ -18,6 +19,7 @@ export default {
main,
homeTimeline,
localTimeline,
recommendedTimeline,
hybridTimeline,
globalTimeline,
serverStats,

View file

@ -223,6 +223,78 @@ describe('Streaming', () => {
});
});
describe('Recommended Timeline', () => {
it('自分の投稿が流れる', async () => {
const fired = await waitFire(
ayano, 'recommendedTimeline', // ayano:Local
() => api('notes/create', { text: 'foo' }, ayano), // ayano posts
msg => msg.type === 'note' && msg.body.text === 'foo'
);
assert.strictEqual(fired, true);
});
it('フォローしていないローカルユーザーの投稿が流れる', async () => {
const fired = await waitFire(
ayano, 'recommendedTimeline', // ayano:Local
() => api('notes/create', { text: 'foo' }, chitose), // chitose posts
msg => msg.type === 'note' && msg.body.userId === chitose.id // wait chitose
);
assert.strictEqual(fired, true);
});
it('リモートユーザーの投稿は流れない', async () => {
const fired = await waitFire(
ayano, 'recommendedTimeline', // ayano:Local
() => api('notes/create', { text: 'foo' }, chinatsu), // chinatsu posts
msg => msg.type === 'note' && msg.body.userId === chinatsu.id // wait chinatsu
);
assert.strictEqual(fired, false);
});
it('フォローしてたとしてもリモートユーザーの投稿は流れない', async () => {
const fired = await waitFire(
ayano, 'recommendedTimeline', // ayano:Local
() => api('notes/create', { text: 'foo' }, akari), // akari posts
msg => msg.type === 'note' && msg.body.userId === akari.id // wait akari
);
assert.strictEqual(fired, false);
});
it('ホーム指定の投稿は流れない', async () => {
const fired = await waitFire(
ayano, 'recommendedTimeline', // ayano:Local
() => api('notes/create', { text: 'foo', visibility: 'home' }, kyoko), // kyoko home posts
msg => msg.type === 'note' && msg.body.userId === kyoko.id // wait kyoko
);
assert.strictEqual(fired, false);
});
it('フォローしているローカルユーザーのダイレクト投稿は流れない', async () => {
const fired = await waitFire(
ayano, 'recommendedTimeline', // ayano:Local
() => api('notes/create', { text: 'foo', visibility: 'specified', visibleUserIds: [ayano.id] }, kyoko), // kyoko DM => ayano
msg => msg.type === 'note' && msg.body.userId === kyoko.id // wait kyoko
);
assert.strictEqual(fired, false);
});
it('フォローしていないローカルユーザーのフォロワー宛て投稿は流れない', async () => {
const fired = await waitFire(
ayano, 'recommendedTimeline', // ayano:Local
() => api('notes/create', { text: 'foo', visibility: 'followers' }, chitose),
msg => msg.type === 'note' && msg.body.userId === chitose.id // wait chitose
);
assert.strictEqual(fired, false);
});
});
describe('Hybrid Timeline', () => {
it('自分の投稿が流れる', async () => {
const fired = await waitFire(

View file

@ -77,6 +77,10 @@ if (props.src === 'antenna') {
endpoint = 'notes/local-timeline';
connection = stream.useChannel('localTimeline');
connection.on('note', prepend);
} else if (props.src === 'recommended') {
endpoint = 'notes/recommended-timeline';
connection = stream.useChannel('recommendedTimeline');
connection.on('note', prepend);
} else if (props.src === 'social') {
endpoint = 'notes/hybrid-timeline';
connection = stream.useChannel('hybridTimeline');