2023-04-07 03:56:46 +02:00
|
|
|
process.env.NODE_ENV = "test";
|
2019-04-07 14:50:36 +02:00
|
|
|
|
2023-04-07 03:56:46 +02:00
|
|
|
import * as assert from "assert";
|
|
|
|
import * as childProcess from "child_process";
|
|
|
|
import {
|
|
|
|
async,
|
2023-10-22 10:33:40 +02:00
|
|
|
post,
|
2023-11-16 21:18:19 +01:00
|
|
|
request,
|
2023-10-22 10:33:40 +02:00
|
|
|
shutdownServer,
|
2023-11-16 21:18:19 +01:00
|
|
|
signup,
|
|
|
|
startServer,
|
|
|
|
uploadUrl,
|
2023-04-07 03:56:46 +02:00
|
|
|
} from "./utils.js";
|
2022-05-14 09:09:47 +02:00
|
|
|
|
2023-04-07 03:56:46 +02:00
|
|
|
describe("users/notes", () => {
|
2019-04-07 14:50:36 +02:00
|
|
|
let p: childProcess.ChildProcess;
|
|
|
|
|
|
|
|
let alice: any;
|
|
|
|
let jpgNote: any;
|
|
|
|
let pngNote: any;
|
|
|
|
let jpgPngNote: any;
|
|
|
|
|
2021-06-12 15:40:17 +02:00
|
|
|
before(async () => {
|
|
|
|
p = await startServer();
|
2023-04-07 03:56:46 +02:00
|
|
|
alice = await signup({ username: "alice" });
|
|
|
|
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 06:35:04 +01:00
|
|
|
jpgNote = await post(alice, {
|
2022-05-21 15:21:41 +02:00
|
|
|
fileIds: [jpg.id],
|
2019-04-07 14:50:36 +02:00
|
|
|
});
|
2020-01-09 06:35:04 +01:00
|
|
|
pngNote = await post(alice, {
|
2022-05-21 15:21:41 +02:00
|
|
|
fileIds: [png.id],
|
2019-04-07 14:50:36 +02:00
|
|
|
});
|
2020-01-09 06:35:04 +01:00
|
|
|
jpgPngNote = await post(alice, {
|
2022-05-21 15:21:41 +02:00
|
|
|
fileIds: [jpg.id, png.id],
|
2020-01-09 06:35:04 +01:00
|
|
|
});
|
2021-06-12 15:40:17 +02:00
|
|
|
});
|
2019-04-07 14:50:36 +02:00
|
|
|
|
2023-04-07 03:56:46 +02:00
|
|
|
after(async () => {
|
2021-06-05 07:54:07 +02:00
|
|
|
await shutdownServer(p);
|
2019-04-07 14:50:36 +02:00
|
|
|
});
|
|
|
|
|
2023-04-07 03:56:46 +02:00
|
|
|
it("ファイルタイプ指定 (jpg)", async(async () => {
|
|
|
|
const res = await request(
|
|
|
|
"/users/notes",
|
|
|
|
{
|
|
|
|
userId: alice.id,
|
|
|
|
fileType: ["image/jpeg"],
|
|
|
|
},
|
|
|
|
alice,
|
|
|
|
);
|
2019-04-07 14:50:36 +02:00
|
|
|
|
|
|
|
assert.strictEqual(res.status, 200);
|
|
|
|
assert.strictEqual(Array.isArray(res.body), true);
|
|
|
|
assert.strictEqual(res.body.length, 2);
|
2023-04-07 03:56:46 +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,
|
|
|
|
);
|
2019-04-07 14:50:36 +02:00
|
|
|
}));
|
|
|
|
|
2023-04-07 03:56:46 +02:00
|
|
|
it("ファイルタイプ指定 (jpg or png)", async(async () => {
|
|
|
|
const res = await request(
|
|
|
|
"/users/notes",
|
|
|
|
{
|
|
|
|
userId: alice.id,
|
|
|
|
fileType: ["image/jpeg", "image/png"],
|
|
|
|
},
|
|
|
|
alice,
|
|
|
|
);
|
2019-04-07 14:50:36 +02:00
|
|
|
|
|
|
|
assert.strictEqual(res.status, 200);
|
|
|
|
assert.strictEqual(Array.isArray(res.body), true);
|
|
|
|
assert.strictEqual(res.body.length, 3);
|
2023-04-07 03:56:46 +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,
|
|
|
|
);
|
2019-04-07 14:50:36 +02:00
|
|
|
}));
|
|
|
|
});
|