fix test/e2e/antennas.ts
This commit is contained in:
parent
2175181fa6
commit
7a2958f356
3 changed files with 22 additions and 19 deletions
|
|
@ -16,6 +16,7 @@ import {
|
||||||
testPaginationConsistency,
|
testPaginationConsistency,
|
||||||
uploadFile,
|
uploadFile,
|
||||||
userList,
|
userList,
|
||||||
|
withNotesCount,
|
||||||
} from '../utils.js';
|
} from '../utils.js';
|
||||||
import type * as misskey from 'misskey-js';
|
import type * as misskey from 'misskey-js';
|
||||||
import { DEFAULT_POLICIES } from '@/core/RoleService.js';
|
import { DEFAULT_POLICIES } from '@/core/RoleService.js';
|
||||||
|
|
@ -114,6 +115,7 @@ describe('アンテナ', () => {
|
||||||
userBlockedByAlice = await signup({ username: 'userBlockedByAlice' });
|
userBlockedByAlice = await signup({ username: 'userBlockedByAlice' });
|
||||||
await post(userBlockedByAlice, { text: 'test' });
|
await post(userBlockedByAlice, { text: 'test' });
|
||||||
await api('blocking/create', { userId: userBlockedByAlice.id }, alice);
|
await api('blocking/create', { userId: userBlockedByAlice.id }, alice);
|
||||||
|
await api('mute/delete', { userId: userBlockedByAlice.id }, alice); // blocking implies muting, in Sharkey, but we want to test un-muted block
|
||||||
userMutingAlice = await signup({ username: 'userMutingAlice' });
|
userMutingAlice = await signup({ username: 'userMutingAlice' });
|
||||||
await post(userMutingAlice, { text: 'test' });
|
await post(userMutingAlice, { text: 'test' });
|
||||||
await api('mute/create', { userId: alice.id }, userMutingAlice);
|
await api('mute/create', { userId: alice.id }, userMutingAlice);
|
||||||
|
|
@ -347,7 +349,7 @@ describe('アンテナ', () => {
|
||||||
parameters: { antennaId: antenna.id },
|
parameters: { antennaId: antenna.id },
|
||||||
user: alice,
|
user: alice,
|
||||||
});
|
});
|
||||||
const expected = [note];
|
const expected = withNotesCount([note], 2);
|
||||||
assert.deepStrictEqual(response, expected);
|
assert.deepStrictEqual(response, expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -666,10 +668,10 @@ describe('アンテナ', () => {
|
||||||
user: alice,
|
user: alice,
|
||||||
});
|
});
|
||||||
// 最後に投稿したものが先頭に来る。
|
// 最後に投稿したものが先頭に来る。
|
||||||
const expected = [
|
const expected = withNotesCount([
|
||||||
noteInNonSensitiveChannel,
|
noteInNonSensitiveChannel,
|
||||||
noteInLocal,
|
noteInLocal,
|
||||||
];
|
], 64);
|
||||||
assert.deepStrictEqual(response, expected);
|
assert.deepStrictEqual(response, expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
import * as assert from 'assert';
|
import * as assert from 'assert';
|
||||||
import { setTimeout } from 'node:timers/promises';
|
import { setTimeout } from 'node:timers/promises';
|
||||||
import { Redis } from 'ioredis';
|
import { Redis } from 'ioredis';
|
||||||
import { api, post, randomString, sendEnvUpdateRequest, signup, uploadUrl } from '../utils.js';
|
import { api, post, randomString, sendEnvUpdateRequest, signup, uploadUrl, withNotesCount } from '../utils.js';
|
||||||
import { loadConfig } from '@/config.js';
|
import { loadConfig } from '@/config.js';
|
||||||
|
|
||||||
function genHost() {
|
function genHost() {
|
||||||
|
|
@ -20,21 +20,6 @@ function waitForPushToTl() {
|
||||||
return setTimeout(500);
|
return setTimeout(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
// the packed user inside each note returned by `users/notes` has the
|
|
||||||
// latest `notesCount`, not the count at the time the note was
|
|
||||||
// created, so we override it
|
|
||||||
function withNotesCount(notes, count) {
|
|
||||||
return notes.map( note => {
|
|
||||||
return {
|
|
||||||
...note,
|
|
||||||
user: {
|
|
||||||
...note.user,
|
|
||||||
notesCount: count,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
let redisForTimelines: Redis;
|
let redisForTimelines: Redis;
|
||||||
|
|
||||||
describe('Timelines', () => {
|
describe('Timelines', () => {
|
||||||
|
|
|
||||||
|
|
@ -691,3 +691,19 @@ export async function captureWebhook<T = SystemWebhookPayload>(postAction: () =>
|
||||||
|
|
||||||
return JSON.parse(result) as T;
|
return JSON.parse(result) as T;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// the packed user inside each note returned by `users/notes` has the
|
||||||
|
// latest `notesCount`, not the count at the time the note was
|
||||||
|
// created, so we override it
|
||||||
|
export function withNotesCount(notes, count) {
|
||||||
|
return notes.map( note => {
|
||||||
|
return {
|
||||||
|
...note,
|
||||||
|
user: {
|
||||||
|
...note.user,
|
||||||
|
notesCount: count,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue