summaryrefslogtreecommitdiff
path: root/packages/backend/test/e2e/endpoints.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/backend/test/e2e/endpoints.ts')
-rw-r--r--packages/backend/test/e2e/endpoints.ts41
1 files changed, 40 insertions, 1 deletions
diff --git a/packages/backend/test/e2e/endpoints.ts b/packages/backend/test/e2e/endpoints.ts
index c130093732..653520cf5f 100644
--- a/packages/backend/test/e2e/endpoints.ts
+++ b/packages/backend/test/e2e/endpoints.ts
@@ -4,7 +4,7 @@ import * as assert from 'assert';
// node-fetch only supports it's own Blob yet
// https://github.com/node-fetch/node-fetch/pull/1664
import { Blob } from 'node-fetch';
-import { startServer, signup, post, api, uploadFile } from '../utils.js';
+import { startServer, signup, post, api, uploadFile, simpleGet } from '../utils.js';
import type { INestApplicationContext } from '@nestjs/common';
describe('Endpoints', () => {
@@ -439,6 +439,45 @@ describe('Endpoints', () => {
assert.strictEqual(res.body.name, 'image.svg');
assert.strictEqual(res.body.type, 'image/svg+xml');
});
+
+ for (const type of ['webp', 'avif']) {
+ const mediaType = `image/${type}`;
+
+ const getWebpublicType = async (user: any, fileId: string): Promise<string> => {
+ // drive/files/create does not expose webpublicType directly, so get it by posting it
+ const res = await post(user, {
+ text: mediaType,
+ fileIds: [fileId],
+ });
+ const apRes = await simpleGet(`notes/${res.id}`, 'application/activity+json');
+ assert.strictEqual(apRes.status, 200);
+ assert.ok(Array.isArray(apRes.body.attachment));
+ return apRes.body.attachment[0].mediaType;
+ };
+
+ test(`透明な${type}ファイルを作成できる`, async () => {
+ const path = `with-alpha.${type}`;
+ const res = await uploadFile(alice, { path });
+
+ assert.strictEqual(res.status, 200);
+ assert.strictEqual(res.body.name, path);
+ assert.strictEqual(res.body.type, mediaType);
+
+ const webpublicType = await getWebpublicType(alice, res.body.id);
+ assert.strictEqual(webpublicType, 'image/webp');
+ });
+
+ test(`透明じゃない${type}ファイルを作成できる`, async () => {
+ const path = `without-alpha.${type}`;
+ const res = await uploadFile(alice, { path });
+ assert.strictEqual(res.status, 200);
+ assert.strictEqual(res.body.name, path);
+ assert.strictEqual(res.body.type, mediaType);
+
+ const webpublicType = await getWebpublicType(alice, res.body.id);
+ assert.strictEqual(webpublicType, 'image/webp');
+ });
+ }
});
describe('drive/files/update', () => {