2023-07-27 00:31:52 -05:00
|
|
|
/*
|
|
|
|
* SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2019-04-07 07:50:36 -05:00
|
|
|
process.env.NODE_ENV = 'test';
|
|
|
|
|
|
|
|
import * as assert from 'assert';
|
2023-03-02 20:13:12 -06:00
|
|
|
import { signup, api, post, uploadUrl, startServer } from '../utils.js';
|
|
|
|
import type { INestApplicationContext } from '@nestjs/common';
|
2023-06-24 18:34:18 -05:00
|
|
|
import type * as misskey from 'misskey-js';
|
2022-05-14 02:09:47 -05:00
|
|
|
|
2019-04-07 07:50:36 -05:00
|
|
|
describe('users/notes', () => {
|
2023-03-12 06:57:01 -05:00
|
|
|
let app: INestApplicationContext;
|
2019-04-07 07:50:36 -05:00
|
|
|
|
2023-06-24 18:34:18 -05:00
|
|
|
let alice: misskey.entities.MeSignup;
|
2019-04-07 07:50:36 -05:00
|
|
|
let jpgNote: any;
|
|
|
|
let pngNote: any;
|
|
|
|
let jpgPngNote: any;
|
|
|
|
|
2022-09-17 13:27:08 -05:00
|
|
|
beforeAll(async () => {
|
2023-03-12 06:57:01 -05:00
|
|
|
app = await startServer();
|
2020-01-08 23:35:04 -06:00
|
|
|
alice = await signup({ username: 'alice' });
|
2022-06-26 05:16:32 -05: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-08 23:35:04 -06:00
|
|
|
jpgNote = await post(alice, {
|
2022-05-21 08:21:41 -05:00
|
|
|
fileIds: [jpg.id],
|
2019-04-07 07:50:36 -05:00
|
|
|
});
|
2020-01-08 23:35:04 -06:00
|
|
|
pngNote = await post(alice, {
|
2022-05-21 08:21:41 -05:00
|
|
|
fileIds: [png.id],
|
2019-04-07 07:50:36 -05:00
|
|
|
});
|
2020-01-08 23:35:04 -06:00
|
|
|
jpgPngNote = await post(alice, {
|
2022-05-21 08:21:41 -05:00
|
|
|
fileIds: [jpg.id, png.id],
|
2020-01-08 23:35:04 -06:00
|
|
|
});
|
2023-03-02 20:13:12 -06:00
|
|
|
}, 1000 * 60 * 2);
|
2019-04-07 07:50:36 -05:00
|
|
|
|
2022-09-17 13:27:08 -05:00
|
|
|
afterAll(async() => {
|
2023-03-12 06:57:01 -05:00
|
|
|
await app.close();
|
2019-04-07 07:50:36 -05:00
|
|
|
});
|
|
|
|
|
2023-10-01 22:59:03 -05:00
|
|
|
/*
|
2023-02-02 03:18:25 -06:00
|
|
|
test('ファイルタイプ指定 (jpg)', async () => {
|
2023-03-02 20:13:12 -06:00
|
|
|
const res = await api('/users/notes', {
|
2019-04-07 07:50:36 -05:00
|
|
|
userId: alice.id,
|
2022-05-21 08:21:41 -05:00
|
|
|
fileType: ['image/jpeg'],
|
2019-04-07 07:50:36 -05:00
|
|
|
}, alice);
|
|
|
|
|
|
|
|
assert.strictEqual(res.status, 200);
|
|
|
|
assert.strictEqual(Array.isArray(res.body), true);
|
|
|
|
assert.strictEqual(res.body.length, 2);
|
2020-01-08 23:35:04 -06: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 13:27:08 -05:00
|
|
|
});
|
2019-04-07 07:50:36 -05:00
|
|
|
|
2023-02-02 03:18:25 -06:00
|
|
|
test('ファイルタイプ指定 (jpg or png)', async () => {
|
2023-03-02 20:13:12 -06:00
|
|
|
const res = await api('/users/notes', {
|
2019-04-07 07:50:36 -05:00
|
|
|
userId: alice.id,
|
2022-05-21 08:21:41 -05:00
|
|
|
fileType: ['image/jpeg', 'image/png'],
|
2019-04-07 07:50:36 -05:00
|
|
|
}, alice);
|
|
|
|
|
|
|
|
assert.strictEqual(res.status, 200);
|
|
|
|
assert.strictEqual(Array.isArray(res.body), true);
|
|
|
|
assert.strictEqual(res.body.length, 3);
|
2020-01-08 23:35:04 -06: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 13:27:08 -05:00
|
|
|
});
|
2023-10-01 22:59:03 -05:00
|
|
|
*/
|
2019-04-07 07:50:36 -05:00
|
|
|
});
|