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