Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
penginn-net committed Jan 8, 2025
1 parent be6affd commit ddc01cd
Showing 1 changed file with 10 additions and 35 deletions.
45 changes: 10 additions & 35 deletions packages/backend/test-federation/test/emoji.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import assert, { deepStrictEqual, strictEqual } from 'assert';
import * as Misskey from 'cherrypick-js';
import { addCustomEmoji, createAccount, type LoginUser, resolveRemoteUser, sleep } from './utils.js';
import { addCustomEmoji, createAccount, type LoginUser, resolveRemoteUser, sleep, createModerator, fetchAdmin } from './utils.js';

describe('Emoji', () => {
let alice: LoginUser, bob: LoginUser;
let bobInA: Misskey.entities.UserDetailedNotMe, aliceInB: Misskey.entities.UserDetailedNotMe;

let bAdmin: LoginUser;
beforeAll(async () => {
[alice, bob] = await Promise.all([
createAccount('a.test'),
Expand All @@ -16,8 +16,8 @@ describe('Emoji', () => {
resolveRemoteUser('b.test', bob.id, alice),
resolveRemoteUser('a.test', alice.id, bob),
]);

await bob.client.request('following/create', { userId: aliceInB.id });
bAdmin = await fetchAdmin('b.test');
await sleep();
});

Expand Down Expand Up @@ -195,8 +195,8 @@ describe('Emoji', () => {
assert(noteInB.emojis != null);
assert(emoji.name in noteInB.emojis);
strictEqual(noteInB.emojis[emoji.name], emoji.url);
const emojiId = (await bob.client.request('admin/emoji/list-remote')).find( x => x.name === emoji.name).id;
const res = bob.client.request('admin/emoji/copy',{ emojiId: emojiId });
const emojiId = (await bAdmin.client.request('admin/emoji/list-remote')).find( x => x.name === emoji.name).id;
const res = bAdmin.client.request('admin/emoji/copy',{ emojiId: emojiId });

Check failure on line 199 in packages/backend/test-federation/test/emoji.test.ts

View workflow job for this annotation

GitHub Actions / lint (backend)

A space is required after ','
console.log(res);
});
test('コピー拒否の絵文字をコピーできない(steal)', async () => {
Expand All @@ -220,7 +220,7 @@ describe('Emoji', () => {
assert(noteInB.emojis != null);
assert(emoji.name in noteInB.emojis);
strictEqual(noteInB.emojis[emoji.name], emoji.url);
const res = bob.client.request('admin/emoji/steal',{ name: emoji.name, host: 'a.test' });
const res = bAdmin.client.request('admin/emoji/steal',{ name: emoji.name, host: 'a.test' });

Check failure on line 223 in packages/backend/test-federation/test/emoji.test.ts

View workflow job for this annotation

GitHub Actions / lint (backend)

A space is required after ','
console.log(res);
});

Expand All @@ -245,8 +245,8 @@ describe('Emoji', () => {
assert(noteInB.emojis != null);
assert(emoji.name in noteInB.emojis);
strictEqual(noteInB.emojis[emoji.name], emoji.url);
const emojiId = (await bob.client.request('admin/emoji/list-remote')).find( x => x.name === emoji.name).id;
const res = bob.client.request('admin/emoji/copy',{ emojiId: emojiId });
const emojiId = (await bAdmin.client.request('admin/emoji/list-remote')).find( x => x.name === emoji.name).id;
const res = bAdmin.client.request('admin/emoji/copy',{ emojiId: emojiId });

Check failure on line 249 in packages/backend/test-federation/test/emoji.test.ts

View workflow job for this annotation

GitHub Actions / lint (backend)

A space is required after ','
console.log(res);
});
test('条件付きの絵文字をコピーできない', async () => {
Expand All @@ -270,33 +270,8 @@ describe('Emoji', () => {
assert(noteInB.emojis != null);
assert(emoji.name in noteInB.emojis);
strictEqual(noteInB.emojis[emoji.name], emoji.url);
const emojiId = (await bob.client.request('admin/emoji/list-remote')).find( x => x.name === emoji.name).id;
const res = bob.client.request('admin/emoji/copy',{ emojiId: emojiId });
console.log(res);
});
test('コピー拒否の絵文字をコピーできない', async () => {
const emoji = await addCustomEmoji('a.test', {
aliases: ['a', 'b', 'c'],
license: 'license',
category: 'category',
copyPermission: 'deny',
usageInfo: 'usageInfo',
author: '@[email protected]',
description: 'description',
isBasedOn: 'isBasedOn',
});
await alice.client.request('notes/create', { text: `I love :${emoji.name}:` });
await sleep();

const notes = await bob.client.request('notes/timeline', {});
const noteInB = notes[0];

strictEqual(noteInB.text, `I love \u200b:${emoji.name}:\u200b`);
assert(noteInB.emojis != null);
assert(emoji.name in noteInB.emojis);
strictEqual(noteInB.emojis[emoji.name], emoji.url);
const emojiId = (await bob.client.request('admin/emoji/list-remote')).find( x => x.name === emoji.name).id;
const res = bob.client.request('admin/emoji/copy',{ emojiId: emojiId });
const emojiId = (await bAdmin.client.request('admin/emoji/list-remote')).find( x => x.name === emoji.name).id;
const res = bAdmin.client.request('admin/emoji/copy',{ emojiId: emojiId });

Check failure on line 274 in packages/backend/test-federation/test/emoji.test.ts

View workflow job for this annotation

GitHub Actions / lint (backend)

A space is required after ','
console.log(res);
});
});

0 comments on commit ddc01cd

Please sign in to comment.