summaryrefslogtreecommitdiff
path: root/packages/backend/test/e2e/endpoints.ts
diff options
context:
space:
mode:
authorKagami Sascha Rosylight <saschanaz@outlook.com>2023-03-10 01:37:22 +0100
committerGitHub <noreply@github.com>2023-03-10 09:37:22 +0900
commit3f53cbd8f680c5659c53bf709fdd044c5dcb59c7 (patch)
treeb017dd7c0af0862df4e1778a87ad703bf8526e5d /packages/backend/test/e2e/endpoints.ts
parentenhance(backend): restore OpenAPI endpoints (#10281) (diff)
downloadsharkey-3f53cbd8f680c5659c53bf709fdd044c5dcb59c7.tar.gz
sharkey-3f53cbd8f680c5659c53bf709fdd044c5dcb59c7.tar.bz2
sharkey-3f53cbd8f680c5659c53bf709fdd044c5dcb59c7.zip
fix(backend/DriveService): convert WebP/AVIF to WebP (#10239)
* fix(backend/DriveService): convert transparent WebP/AVIF to PNG * webpにする その希望が複数ありましたので * Update packages/backend/src/core/DriveService.ts Co-authored-by: Acid Chicken (硫酸鶏) <root@acid-chicken.com> * update test * webpはwebpublicにできる --------- Co-authored-by: Acid Chicken (硫酸鶏) <root@acid-chicken.com> Co-authored-by: tamaina <tamaina@hotmail.co.jp>
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', () => {