From 06b168813088b5a12381636e0daeee683972a7ef Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sat, 15 Jul 2023 19:47:59 -0500 Subject: [PATCH 1/2] Actually, account.url is not optional --- app/soapbox/schemas/account.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/soapbox/schemas/account.ts b/app/soapbox/schemas/account.ts index 563e98e90b..a4881f4bcf 100644 --- a/app/soapbox/schemas/account.ts +++ b/app/soapbox/schemas/account.ts @@ -87,7 +87,7 @@ const baseAccountSchema = z.object({ statuses_count: z.number().catch(0), suspended: z.boolean().catch(false), uri: z.string().url().catch(''), - url: z.string().url().catch(''), + url: z.string().url(), username: z.string().catch(''), verified: z.boolean().catch(false), website: z.string().catch(''), From f456cb40864d644a81e7957a0dce87c873ee850a Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sat, 15 Jul 2023 20:25:39 -0500 Subject: [PATCH 2/2] Fix account.url tests --- .../__tests__/quoted-status.test.tsx | 1 + .../__tests__/who-to-follow-panel.test.tsx | 201 ------------------ app/soapbox/jest/factory.ts | 1 + 3 files changed, 2 insertions(+), 201 deletions(-) delete mode 100644 app/soapbox/features/ui/components/__tests__/who-to-follow-panel.test.tsx diff --git a/app/soapbox/components/__tests__/quoted-status.test.tsx b/app/soapbox/components/__tests__/quoted-status.test.tsx index d57b59b303..05c9069855 100644 --- a/app/soapbox/components/__tests__/quoted-status.test.tsx +++ b/app/soapbox/components/__tests__/quoted-status.test.tsx @@ -11,6 +11,7 @@ describe('', () => { const account = normalizeAccount({ id: '1', acct: 'alex', + url: 'https://soapbox.test/users/alex', }); const status = normalizeStatus({ diff --git a/app/soapbox/features/ui/components/__tests__/who-to-follow-panel.test.tsx b/app/soapbox/features/ui/components/__tests__/who-to-follow-panel.test.tsx deleted file mode 100644 index 01a65dc491..0000000000 --- a/app/soapbox/features/ui/components/__tests__/who-to-follow-panel.test.tsx +++ /dev/null @@ -1,201 +0,0 @@ -import React from 'react'; - -import { __stub } from 'soapbox/api'; - -import { render, rootState, screen, waitFor } from '../../../../jest/test-helpers'; -import { normalizeInstance } from '../../../../normalizers'; -import WhoToFollowPanel from '../who-to-follow-panel'; - -const buildTruthSuggestion = (id: string) => ({ - account_avatar: 'avatar', - account_id: id, - acct: 'acct', - display_name: 'my name', - note: 'hello', - verified: true, -}); - -const buildSuggestion = (id: string) => ({ - source: 'staff', - account: { - username: 'username', - verified: true, - id, - acct: 'acct', - avatar: 'avatar', - avatar_static: 'avatar', - display_name: 'my name', - }, -}); - -describe('', () => { - let store: any; - - describe('using Truth Social software', () => { - beforeEach(() => { - store = rootState - .set('me', '1234') - .set('instance', normalizeInstance({ - version: '3.4.1 (compatible; TruthSocial 1.0.0)', - })); - }); - - describe('with a single suggestion', () => { - beforeEach(() => { - __stub((mock) => { - mock.onGet('/api/v1/truth/carousels/suggestions') - .reply(200, [buildTruthSuggestion('1')], { - link: '; rel=\'prev\'', - }); - }); - }); - - it('renders suggested accounts', async () => { - render(, undefined, store); - - await waitFor(() => { - expect(screen.getByTestId('account')).toHaveTextContent(/my name/i); - }); - }); - }); - - describe('with a multiple suggestion', () => { - beforeEach(() => { - __stub((mock) => { - mock.onGet('/api/v1/truth/carousels/suggestions') - .reply(200, [buildTruthSuggestion('1'), buildTruthSuggestion('2')], { - link: '; rel=\'prev\'', - }); - }); - }); - - it('renders suggested accounts', async () => { - render(, undefined, store); - - await waitFor(() => { - expect(screen.queryAllByTestId('account')).toHaveLength(2); - }); - }); - }); - - describe('with a set limit', () => { - beforeEach(() => { - __stub((mock) => { - mock.onGet('/api/v1/truth/carousels/suggestions') - .reply(200, [buildTruthSuggestion('1'), buildTruthSuggestion('2')], { - link: '; rel=\'prev\'', - }); - }); - }); - - it('respects the limit prop', async () => { - render(, undefined, store); - - await waitFor(() => { - expect(screen.queryAllByTestId('account')).toHaveLength(1); - }); - }); - }); - - describe('when the API returns an empty list', () => { - beforeEach(() => { - __stub((mock) => { - mock.onGet('/api/v1/truth/carousels/suggestions') - .reply(200, [], { - link: '', - }); - }); - }); - - it('renders empty', async () => { - render(, undefined, store); - - await waitFor(() => { - expect(screen.queryAllByTestId('account')).toHaveLength(0); - }); - }); - }); - }); - - describe('using Pleroma software', () => { - beforeEach(() => { - store = rootState.set('me', '1234'); - }); - - describe('with a single suggestion', () => { - beforeEach(() => { - __stub((mock) => { - mock.onGet('/api/v2/suggestions') - .reply(200, [buildSuggestion('1')], { - link: '; rel=\'prev\'', - }); - }); - }); - - it('renders suggested accounts', async () => { - render(, undefined, store); - - await waitFor(() => { - expect(screen.getByTestId('account')).toHaveTextContent(/my name/i); - }); - }); - }); - - describe('with a multiple suggestion', () => { - beforeEach(() => { - __stub((mock) => { - mock.onGet('/api/v2/suggestions') - .reply(200, [buildSuggestion('1'), buildSuggestion('2')], { - link: '; rel=\'prev\'', - }); - }); - }); - - it('renders suggested accounts', async () => { - render(, undefined, store); - - await waitFor(() => { - expect(screen.queryAllByTestId('account')).toHaveLength(2); - }); - }); - }); - - describe('with a set limit', () => { - beforeEach(() => { - __stub((mock) => { - mock.onGet('/api/v2/suggestions') - .reply(200, [buildSuggestion('1'), buildSuggestion('2')], { - link: '; rel=\'prev\'', - }); - }); - }); - - it('respects the limit prop', async () => { - render(, undefined, store); - - await waitFor(() => { - expect(screen.queryAllByTestId('account')).toHaveLength(1); - }); - }); - }); - - describe('when the API returns an empty list', () => { - beforeEach(() => { - __stub((mock) => { - mock.onGet('/api/v2/suggestions') - .reply(200, [], { - link: '', - }); - }); - }); - - it('renders empty', async () => { - render(, undefined, store); - - await waitFor(() => { - expect(screen.queryAllByTestId('account')).toHaveLength(0); - }); - }); - }); - }); -}); diff --git a/app/soapbox/jest/factory.ts b/app/soapbox/jest/factory.ts index d991a2e07d..2f21df0695 100644 --- a/app/soapbox/jest/factory.ts +++ b/app/soapbox/jest/factory.ts @@ -30,6 +30,7 @@ import type { PartialDeep } from 'type-fest'; function buildAccount(props: PartialDeep = {}): Account { return accountSchema.parse(Object.assign({ id: uuidv4(), + url: `https://soapbox.test/users/${uuidv4()}`, }, props)); }