Skip to content

Commit

Permalink
test(backend): goodbye, Lenna (misskey-dev#14111)
Browse files Browse the repository at this point in the history
  • Loading branch information
KisaragiEffective authored and i544c-me committed Jul 14, 2024
1 parent d3e3bd5 commit be27b6c
Show file tree
Hide file tree
Showing 13 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion packages/backend/src/models/json-schema/drive-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const packedDriveFileSchema = {
name: {
type: 'string',
optional: false, nullable: false,
example: 'lenna.jpg',
example: '192.jpg',
},
type: {
type: 'string',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const meta = {
name: {
type: 'string',
optional: false, nullable: false,
example: 'lenna.jpg',
example: '192.jpg',
},
type: {
type: 'string',
Expand Down
6 changes: 3 additions & 3 deletions packages/backend/test/e2e/drive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('Drive', () => {

const marker = Math.random().toString();

const url = 'https://raw.githubusercontent.com/misskey-dev/misskey/develop/packages/backend/test/resources/Lenna.jpg';
const url = 'https://raw.githubusercontent.com/misskey-dev/misskey/develop/packages/backend/test/resources/192.jpg';

const catcher = makeStreamCatcher(
alice,
Expand All @@ -41,14 +41,14 @@ describe('Drive', () => {
const file = await catcher;

assert.strictEqual(res.status, 204);
assert.strictEqual(file.name, 'Lenna.jpg');
assert.strictEqual(file.name, '192.jpg');
assert.strictEqual(file.type, 'image/jpeg');
});

test('ローカルからアップロードできる', async () => {
// APIレスポンスを直接使用するので utils.js uploadFile が通過することで成功とする

const res = await uploadFile(alice, { path: 'Lenna.jpg', name: 'テスト画像' });
const res = await uploadFile(alice, { path: '192.jpg', name: 'テスト画像' });

assert.strictEqual(res.body?.name, 'テスト画像.jpg');
assert.strictEqual(res.body.type, 'image/jpeg');
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/test/e2e/endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ describe('Endpoints', () => {

assert.strictEqual(res.status, 200);
assert.strictEqual(typeof res.body === 'object' && !Array.isArray(res.body), true);
assert.strictEqual(res.body!.name, 'Lenna.jpg');
assert.strictEqual(res.body!.name, '192.jpg');
});

test('ファイルに名前を付けられる', async () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/backend/test/e2e/note.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('Note', () => {
});

test('ファイルを添付できる', async () => {
const file = await uploadUrl(alice, 'https://raw.githubusercontent.com/misskey-dev/misskey/develop/packages/backend/test/resources/Lenna.jpg');
const file = await uploadUrl(alice, 'https://raw.githubusercontent.com/misskey-dev/misskey/develop/packages/backend/test/resources/192.jpg');

const res = await api('notes/create', {
fileIds: [file.id],
Expand All @@ -53,7 +53,7 @@ describe('Note', () => {
}, 1000 * 10);

test('他人のファイルで怒られる', async () => {
const file = await uploadUrl(bob, 'https://raw.githubusercontent.com/misskey-dev/misskey/develop/packages/backend/test/resources/Lenna.jpg');
const file = await uploadUrl(bob, 'https://raw.githubusercontent.com/misskey-dev/misskey/develop/packages/backend/test/resources/192.jpg');

const res = await api('notes/create', {
text: 'test',
Expand Down
4 changes: 2 additions & 2 deletions packages/backend/test/e2e/user-notes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ describe('users/notes', () => {

beforeAll(async () => {
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');
const jpg = await uploadUrl(alice, 'https://raw.githubusercontent.com/misskey-dev/misskey/develop/packages/backend/test/resources/192.jpg');
const png = await uploadUrl(alice, 'https://raw.githubusercontent.com/misskey-dev/misskey/develop/packages/backend/test/resources/192.png');
jpgNote = await post(alice, {
fileIds: [jpg.id],
});
Expand Down
Binary file added packages/backend/test/resources/192.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/backend/test/resources/192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed packages/backend/test/resources/Lenna.jpg
Binary file not shown.
Binary file removed packages/backend/test/resources/Lenna.png
Binary file not shown.
10 changes: 5 additions & 5 deletions packages/backend/test/unit/FileInfoService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,21 @@ describe('FileInfoService', () => {

describe('IMAGE', () => {
test('Generic JPEG', async () => {
const path = `${resources}/Lenna.jpg`;
const path = `${resources}/192.jpg`;
const info = await fileInfoService.getFileInfo(path, { skipSensitiveDetection: true }) as any;
delete info.warnings;
delete info.blurhash;
delete info.sensitive;
delete info.porn;
assert.deepStrictEqual(info, {
size: 25360,
md5: '091b3f259662aa31e2ffef4519951168',
size: 5131,
md5: '8c9ed0677dd2b8f9f7472c3af247e5e3',
type: {
mime: 'image/jpeg',
ext: 'jpg',
},
width: 512,
height: 512,
width: 192,
height: 192,
orientation: undefined,
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/test/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ export const uploadFile = async (user?: UserToken, { path, name, blob }: UploadO
body: misskey.entities.DriveFile | null
}> => {
const absPath = path == null
? new URL('resources/Lenna.jpg', import.meta.url)
? new URL('resources/192.jpg', import.meta.url)
: isAbsolute(path.toString())
? new URL(path)
: new URL(path, new URL('resources/', import.meta.url));
Expand Down
4 changes: 2 additions & 2 deletions packages/misskey-js/src/autogen/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4217,7 +4217,7 @@ export type components = {
id: string;
/** Format: date-time */
createdAt: string;
/** @example lenna.jpg */
/** @example 192.jpg */
name: string;
/** @example image/jpeg */
type: string;
Expand Down Expand Up @@ -6407,7 +6407,7 @@ export type operations = {
* @example 15eca7fba0480996e2245f5185bf39f2
*/
md5: string;
/** @example lenna.jpg */
/** @example 192.jpg */
name: string;
/** @example image/jpeg */
type: string;
Expand Down

0 comments on commit be27b6c

Please sign in to comment.