fix test/e2e/antennas.ts

This commit is contained in:
dakkar 2025-05-13 14:36:01 +01:00
parent 2175181fa6
commit 7a2958f356
3 changed files with 22 additions and 19 deletions

View file

@ -16,6 +16,7 @@ import {
testPaginationConsistency,
uploadFile,
userList,
withNotesCount,
} from '../utils.js';
import type * as misskey from 'misskey-js';
import { DEFAULT_POLICIES } from '@/core/RoleService.js';
@ -114,6 +115,7 @@ describe('アンテナ', () => {
userBlockedByAlice = await signup({ username: 'userBlockedByAlice' });
await post(userBlockedByAlice, { text: 'test' });
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' });
await post(userMutingAlice, { text: 'test' });
await api('mute/create', { userId: alice.id }, userMutingAlice);
@ -347,7 +349,7 @@ describe('アンテナ', () => {
parameters: { antennaId: antenna.id },
user: alice,
});
const expected = [note];
const expected = withNotesCount([note], 2);
assert.deepStrictEqual(response, expected);
});
@ -666,10 +668,10 @@ describe('アンテナ', () => {
user: alice,
});
// 最後に投稿したものが先頭に来る。
const expected = [
const expected = withNotesCount([
noteInNonSensitiveChannel,
noteInLocal,
];
], 64);
assert.deepStrictEqual(response, expected);
});

View file

@ -9,7 +9,7 @@
import * as assert from 'assert';
import { setTimeout } from 'node:timers/promises';
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';
function genHost() {
@ -20,21 +20,6 @@ function waitForPushToTl() {
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;
describe('Timelines', () => {

View file

@ -691,3 +691,19 @@ export async function captureWebhook<T = SystemWebhookPayload>(postAction: () =>
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,
},
};
});
}