2019-04-07 15:50:36 +03:00
|
|
|
process.env.NODE_ENV = 'test';
|
|
|
|
|
|
|
|
import * as assert from 'assert';
|
2023-03-03 04:13:12 +02:00
|
|
|
import { signup, api, post, uploadUrl, startServer } from '../utils.js';
|
|
|
|
import type { INestApplicationContext } from '@nestjs/common';
|
2022-05-14 10:09:47 +03:00
|
|
|
|
2019-04-07 15:50:36 +03:00
|
|
|
describe('users/notes', () => {
|
2023-03-03 04:13:12 +02:00
|
|
|
let p: INestApplicationContext;
|
2019-04-07 15:50:36 +03:00
|
|
|
|
|
|
|
let alice: any;
|
|
|
|
let jpgNote: any;
|
|
|
|
let pngNote: any;
|
|
|
|
let jpgPngNote: any;
|
|
|
|
|
2022-09-17 21:27:08 +03:00
|
|
|
beforeAll(async () => {
|
2021-06-12 16:40:17 +03:00
|
|
|
p = await startServer();
|
2020-01-09 07:35:04 +02:00
|
|
|
alice = await signup({ username: 'alice' });
|
2022-06-26 13:16:32 +03:00
|
|
|
const jpg = await uploadUrl(alice, 'https://raw.githubusercontent.com/misskey-dev/misskey/develop/packages/backend/test/resources/Lenna.jpg');
|
|
|
|
const png = await uploadUrl(alice, 'https://raw.githubusercontent.com/misskey-dev/misskey/develop/packages/backend/test/resources/Lenna.png');
|
2020-01-09 07:35:04 +02:00
|
|
|
jpgNote = await post(alice, {
|
2022-05-21 16:21:41 +03:00
|
|
|
fileIds: [jpg.id],
|
2019-04-07 15:50:36 +03:00
|
|
|
});
|
2020-01-09 07:35:04 +02:00
|
|
|
pngNote = await post(alice, {
|
2022-05-21 16:21:41 +03:00
|
|
|
fileIds: [png.id],
|
2019-04-07 15:50:36 +03:00
|
|
|
});
|
2020-01-09 07:35:04 +02:00
|
|
|
jpgPngNote = await post(alice, {
|
2022-05-21 16:21:41 +03:00
|
|
|
fileIds: [jpg.id, png.id],
|
2020-01-09 07:35:04 +02:00
|
|
|
});
|
2023-03-03 04:13:12 +02:00
|
|
|
}, 1000 * 60 * 2);
|
2019-04-07 15:50:36 +03:00
|
|
|
|
2022-09-17 21:27:08 +03:00
|
|
|
afterAll(async() => {
|
2023-03-03 04:13:12 +02:00
|
|
|
await p.close();
|
2019-04-07 15:50:36 +03:00
|
|
|
});
|
|
|
|
|
2023-02-02 11:18:25 +02:00
|
|
|
test('ファイルタイプ指定 (jpg)', async () => {
|
2023-03-03 04:13:12 +02:00
|
|
|
const res = await api('/users/notes', {
|
2019-04-07 15:50:36 +03:00
|
|
|
userId: alice.id,
|
2022-05-21 16:21:41 +03:00
|
|
|
fileType: ['image/jpeg'],
|
2019-04-07 15:50:36 +03:00
|
|
|
}, alice);
|
|
|
|
|
|
|
|
assert.strictEqual(res.status, 200);
|
|
|
|
assert.strictEqual(Array.isArray(res.body), true);
|
|
|
|
assert.strictEqual(res.body.length, 2);
|
2020-01-09 07:35:04 +02:00
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === jpgNote.id), true);
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === jpgPngNote.id), true);
|
2022-09-17 21:27:08 +03:00
|
|
|
});
|
2019-04-07 15:50:36 +03:00
|
|
|
|
2023-02-02 11:18:25 +02:00
|
|
|
test('ファイルタイプ指定 (jpg or png)', async () => {
|
2023-03-03 04:13:12 +02:00
|
|
|
const res = await api('/users/notes', {
|
2019-04-07 15:50:36 +03:00
|
|
|
userId: alice.id,
|
2022-05-21 16:21:41 +03:00
|
|
|
fileType: ['image/jpeg', 'image/png'],
|
2019-04-07 15:50:36 +03:00
|
|
|
}, alice);
|
|
|
|
|
|
|
|
assert.strictEqual(res.status, 200);
|
|
|
|
assert.strictEqual(Array.isArray(res.body), true);
|
|
|
|
assert.strictEqual(res.body.length, 3);
|
2020-01-09 07:35:04 +02:00
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === jpgNote.id), true);
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === pngNote.id), true);
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === jpgPngNote.id), true);
|
2022-09-17 21:27:08 +03:00
|
|
|
});
|
2019-04-07 15:50:36 +03:00
|
|
|
});
|