From 61ebb3772a923f102c3c0e60b019fb585670b47a Mon Sep 17 00:00:00 2001 From: zyoshoka Date: Sat, 25 Nov 2023 21:17:36 +0900 Subject: [PATCH] chore: add tests --- packages/backend/test/e2e/fetch-resource.ts | 37 +++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/packages/backend/test/e2e/fetch-resource.ts b/packages/backend/test/e2e/fetch-resource.ts index 1cbfec3e5f..45e92588a4 100644 --- a/packages/backend/test/e2e/fetch-resource.ts +++ b/packages/backend/test/e2e/fetch-resource.ts @@ -84,6 +84,7 @@ describe('Webリソース', () => { aliceUploadedFile = await uploadFile(alice); alicesPost = await post(alice, { text: 'test', + fileIds: [aliceUploadedFile.body.id], }); alicePage = await page(alice, {}); alicePlay = await play(alice, {}); @@ -158,6 +159,42 @@ describe('Webリソース', () => { })); }); + describe.each([ + { ext: 'rss', type: 'application/rss+xml; charset=utf-8' }, + { ext: 'atom', type: 'application/atom+xml; charset=utf-8' }, + { ext: 'json', type: 'application/json; charset=utf-8' }, + ])('/@:username.with_replies.$ext', ({ ext, type }) => { + const path = (username: string): string => `/@${username}.with_replies.${ext}`; + + test('がGETできる。', async () => await ok({ + path: path(alice.username), + type, + })); + + test('は存在しないユーザーはGETできない。', async () => await notOk({ + path: path('nonexisting'), + status: 404, + })); + }); + + describe.each([ + { ext: 'rss', type: 'application/rss+xml; charset=utf-8' }, + { ext: 'atom', type: 'application/atom+xml; charset=utf-8' }, + { ext: 'json', type: 'application/json; charset=utf-8' }, + ])('/@:username.with_files.$ext', ({ ext, type }) => { + const path = (username: string): string => `/@${username}.with_files.${ext}`; + + test('がGETできる。', async () => await ok({ + path: path(alice.username), + type, + })); + + test('は存在しないユーザーはGETできない。', async () => await notOk({ + path: path('nonexisting'), + status: 404, + })); + }); + describe.each([{ path: '/api/foo' }])('$path', ({ path }) => { test('はGETできない。', async () => await notOk({ path,