From 78af4b2e9db151389acaf5f2a5d55619fa842bcf Mon Sep 17 00:00:00 2001 From: Rudy Fraser Date: Tue, 10 Nov 2026 16:54:03 -0500 Subject: [PATCH] test(merge): type the migrated test fixtures --- .../__tests__/AssemblyEmbed.test.tsx | 8 +++++-- .../PostControls/lazyMenuAnchoring.test.tsx | 1 - .../__tests__/Eyebrow.test.tsx | 2 +- .../__tests__/InputGroup.test.tsx | 2 +- src/features/events/__tests__/events.test.ts | 22 ++++++++++--------- .../streamplace/__tests__/visible.test.ts | 4 +++- .../api/__tests__/assembly-publish.test.ts | 4 ++-- .../__tests__/community-notifications.test.ts | 8 +++---- src/lib/api/feed/__tests__/utils.test.ts | 2 +- src/lib/api/feed/merge.test.ts | 2 +- .../__tests__/adult-content-labels.test.ts | 5 +++-- .../useAtmosphereExploreQuery.test.tsx | 6 ++--- src/screens/Signup/__tests__/state.test.ts | 2 +- .../cache/__tests__/post-shadow-space.test.ts | 7 ++++-- .../__tests__/fetch-page.test.ts | 2 +- .../__tests__/space-subjects.test.ts | 21 ++++++------------ .../notifications/__tests__/unread.test.tsx | 3 +-- .../provider-session-events-test.tsx | 2 +- .../session/__tests__/session-core-test.ts | 2 +- src/state/session/__tests__/session-test.ts | 6 ++--- .../state/__tests__/composer-poll.test.ts | 11 ++++++++-- .../__tests__/space-engagement.test.tsx | 4 +++- 22 files changed, 69 insertions(+), 57 deletions(-) diff --git a/src/components/Post/Embed/ExternalEmbed/__tests__/AssemblyEmbed.test.tsx b/src/components/Post/Embed/ExternalEmbed/__tests__/AssemblyEmbed.test.tsx index 1cd6822be..aee5ad04b 100644 --- a/src/components/Post/Embed/ExternalEmbed/__tests__/AssemblyEmbed.test.tsx +++ b/src/components/Post/Embed/ExternalEmbed/__tests__/AssemblyEmbed.test.tsx @@ -134,7 +134,11 @@ const PAGE_URL = `${ORIGIN}/${CONVERSATION_ID}` const TOPIC = 'Should the garden stay open late?' const VIEWER = 'did:plc:viewer' -const LINK = {uri: PAGE_URL, title: TOPIC, description: '1. Yes, until sunset'} +const LINK = { + uri: PAGE_URL, + title: TOPIC, + description: '1. Yes, until sunset', +} as app.bsky.embed.external.ViewExternal const PARAMS: EmbedPlayerParams = { type: 'assembly_conversation', source: 'assembly', @@ -852,7 +856,7 @@ describe('post text reaching the card', () => { } } - const embed = {$type: 'app.bsky.embed.external#view', external: LINK} + const embed = {$type: 'app.bsky.embed.external#view' as const, external: LINK} it('hides the topic of an embed in a post that asks the same', async () => { serve({}) diff --git a/src/components/PostControls/lazyMenuAnchoring.test.tsx b/src/components/PostControls/lazyMenuAnchoring.test.tsx index 987ee1bd3..e53d487d4 100644 --- a/src/components/PostControls/lazyMenuAnchoring.test.tsx +++ b/src/components/PostControls/lazyMenuAnchoring.test.tsx @@ -129,7 +129,6 @@ describe('lazy post menu anchoring', () => { richText={{} as never} timestamp="2026-09-27T00:00:00.000Z" logContext="Post" - forceGoogleTranslate={false} />, ) diff --git a/src/components/onboarding-chrome/__tests__/Eyebrow.test.tsx b/src/components/onboarding-chrome/__tests__/Eyebrow.test.tsx index 58b02cec1..c3e2bfa36 100644 --- a/src/components/onboarding-chrome/__tests__/Eyebrow.test.tsx +++ b/src/components/onboarding-chrome/__tests__/Eyebrow.test.tsx @@ -14,7 +14,7 @@ function renderWithI18n(ui: ReactElement) { function textTransformOf(node: {props: unknown}) { const {style} = node.props as {style?: StyleProp} - return StyleSheet.flatten(style).textTransform + return StyleSheet.flatten(style)?.textTransform } describe('Eyebrow', () => { diff --git a/src/components/onboarding-chrome/__tests__/InputGroup.test.tsx b/src/components/onboarding-chrome/__tests__/InputGroup.test.tsx index 3068ad1ad..54e04e62b 100644 --- a/src/components/onboarding-chrome/__tests__/InputGroup.test.tsx +++ b/src/components/onboarding-chrome/__tests__/InputGroup.test.tsx @@ -206,7 +206,7 @@ describe('InputGroup', () => { }) it('forwards a ref to the underlying TextInput', () => { - const ref = createRef() + const ref = createRef>() renderWithI18n( , ) diff --git a/src/features/events/__tests__/events.test.ts b/src/features/events/__tests__/events.test.ts index 86e634e8c..2d1c1f7e2 100644 --- a/src/features/events/__tests__/events.test.ts +++ b/src/features/events/__tests__/events.test.ts @@ -19,6 +19,7 @@ import { RSVP_NOTGOING, } from '../types' import {makeEventLink, parseEventUrl} from '../url' +import {type app, type com} from '#/lexicons' describe('parseEventRecord', () => { it('reads the published fields and common extensions', () => { @@ -366,7 +367,7 @@ describe('coverUrl', () => { uri: 'at://did:plc:host/community.lexicon.calendar.event/k', val, cts: '2026-09-29T00:00:00.000Z', - }) + }) as com.atproto.label.defs.Label it('hides the cover when the event carries a sensitive label', () => { expect(coverUrl({thumb: 'https://cdn/x', labels: [label('porn')]})).toBe( @@ -441,15 +442,16 @@ describe('eventPoster', () => { describe('isLiveOnStreamplace', () => { const streamer = {did: 'did:plc:host', handle: 'Host.example.com'} - const status = (uri: string, isActive = true) => ({ - status: 'app.bsky.actor.status#live', - isActive, - record: {}, - embed: { - $type: 'app.bsky.embed.external#view', - external: {uri, title: '', description: ''}, - }, - }) + const status = (uri: string, isActive = true) => + ({ + status: 'app.bsky.actor.status#live', + isActive, + record: {}, + embed: { + $type: 'app.bsky.embed.external#view', + external: {uri, title: '', description: ''}, + }, + }) as app.bsky.actor.defs.StatusView it('is live when the status points at the same channel by DID or handle', () => { expect( diff --git a/src/features/streamplace/__tests__/visible.test.ts b/src/features/streamplace/__tests__/visible.test.ts index b914321cf..b5b65f0f9 100644 --- a/src/features/streamplace/__tests__/visible.test.ts +++ b/src/features/streamplace/__tests__/visible.test.ts @@ -1,6 +1,7 @@ import {type ModerationOpts} from '@bsky/sdk/moderation' import {visibleMessages} from '../visible' +import {type app} from '#/lexicons' jest.mock('@bsky/sdk/moderation', () => ({ ...jest.requireActual('@bsky/sdk/moderation'), @@ -16,7 +17,8 @@ const m = (did: string) => ({ text: 'x', indexedAt: '', }) -const profile = (did: string) => ({did, handle: did}) +const profile = (did: string) => + ({did, handle: did}) as app.bsky.actor.defs.ProfileViewDetailed it('hides unknown, filtered and blurred authors', () => { const profiles = new Map([ diff --git a/src/lib/api/__tests__/assembly-publish.test.ts b/src/lib/api/__tests__/assembly-publish.test.ts index a2fc53266..d96ca385d 100644 --- a/src/lib/api/__tests__/assembly-publish.test.ts +++ b/src/lib/api/__tests__/assembly-publish.test.ts @@ -112,11 +112,11 @@ let warn: jest.SpyInstance function setup() { const fetchHandler = jest.fn() - const applyWrites = jest.fn(() => { + const applyWrites = jest.fn((_input: unknown) => { events.push('applyWrites') return Promise.resolve({}) }) - const getPosts = jest.fn(() => { + const getPosts = jest.fn((_input: unknown) => { events.push('getPosts') return Promise.resolve({ posts: [ diff --git a/src/lib/api/__tests__/community-notifications.test.ts b/src/lib/api/__tests__/community-notifications.test.ts index c2c4a5812..49ed53d3d 100644 --- a/src/lib/api/__tests__/community-notifications.test.ts +++ b/src/lib/api/__tests__/community-notifications.test.ts @@ -91,7 +91,7 @@ describe('community notification API', () => { const body = listBody(PUBLIC_URI) fetchHandler.mockResolvedValue(json(body)) - await expect(listNotifications(client, {})).resolves.toEqual(body) + await expect(listNotifications(client, {limit: 30})).resolves.toEqual(body) }) it('falls back only for a 501 MethodNotImplemented response', async () => { @@ -127,7 +127,7 @@ describe('community notification API', () => { const {client, fetchHandler} = mockClient() fetchHandler.mockResolvedValue(json({error, message: error}, status)) - const failure: unknown = await listNotifications(client, {}).catch( + const failure: unknown = await listNotifications(client, {limit: 30}).catch( (e: unknown) => e, ) @@ -140,7 +140,7 @@ describe('community notification API', () => { const {client, fetchHandler} = mockClient() fetchHandler.mockResolvedValue(json({}, 501)) - await expect(listNotifications(client, {})).rejects.toBeDefined() + await expect(listNotifications(client, {limit: 30})).rejects.toBeDefined() expect(fetchHandler).toHaveBeenCalledTimes(1) }) @@ -148,7 +148,7 @@ describe('community notification API', () => { const {client, fetchHandler} = mockClient() fetchHandler.mockRejectedValue(new Error('offline')) - await expect(listNotifications(client, {})).rejects.toBeDefined() + await expect(listNotifications(client, {limit: 30})).rejects.toBeDefined() expect(fetchHandler).toHaveBeenCalledTimes(1) }) diff --git a/src/lib/api/feed/__tests__/utils.test.ts b/src/lib/api/feed/__tests__/utils.test.ts index 5005a56dd..c04ea1ddf 100644 --- a/src/lib/api/feed/__tests__/utils.test.ts +++ b/src/lib/api/feed/__tests__/utils.test.ts @@ -41,7 +41,7 @@ describe('createBskyFeedHeaders', () => { regionCode: '13', city: '東京', ip: '2001:db8::1', - }) + } as never) expect( createBskyFeedHeaders(`at://${did}/app.bsky.feed.generator/test`), diff --git a/src/lib/api/feed/merge.test.ts b/src/lib/api/feed/merge.test.ts index 4fbe2ccb9..6d6477739 100644 --- a/src/lib/api/feed/merge.test.ts +++ b/src/lib/api/feed/merge.test.ts @@ -16,7 +16,7 @@ describe('MergeFeedAPI', () => { regionCode: '13', city: '東京', ip: '192.0.2.1', - }) + } as never) const call = jest.fn().mockResolvedValue({feed: []}) const thirdPartyFeed = 'at://did:example:feed/app.bsky.feed.generator/test' const api = new MergeFeedAPI({ diff --git a/src/lib/moderation/__tests__/adult-content-labels.test.ts b/src/lib/moderation/__tests__/adult-content-labels.test.ts index fb4410f27..41cb42ea5 100644 --- a/src/lib/moderation/__tests__/adult-content-labels.test.ts +++ b/src/lib/moderation/__tests__/adult-content-labels.test.ts @@ -5,6 +5,7 @@ import { configureAdultContentLabelDefs, withAdultContentBehavior, } from '../adult-content-labels' +import {type DidString} from '@atproto/syntax' const AUTHOR = 'did:plc:author' const LABELER = 'did:plc:labeler' @@ -28,7 +29,7 @@ const CONTEXTS = [ ] as const const label = (val: string, src: string): com.atproto.label.defs.Label => ({ - src, + src: src as DidString, uri: URI, cid: CID, val, @@ -63,7 +64,7 @@ const labelerView = ( $type: 'app.bsky.labeler.defs#labelerViewDetailed', uri: `at://${did}/app.bsky.labeler.service/self`, cid: 'bafyreilabeler', - creator: {did, handle: 'labeler.test'}, + creator: {did: did as DidString, handle: 'labeler.test'}, policies: { labelValues: defs.map(d => d.identifier!), labelValueDefinitions: defs.map(d => ({ diff --git a/src/screens/Atmosphere/data/__tests__/useAtmosphereExploreQuery.test.tsx b/src/screens/Atmosphere/data/__tests__/useAtmosphereExploreQuery.test.tsx index 91b11ca7f..6feb77f29 100644 --- a/src/screens/Atmosphere/data/__tests__/useAtmosphereExploreQuery.test.tsx +++ b/src/screens/Atmosphere/data/__tests__/useAtmosphereExploreQuery.test.tsx @@ -155,7 +155,7 @@ describe('useAtmosphereExploreQuery', () => { regionCode: '13', city: '東京', ip: '2001:db8::1', - }) + } as never) const {result} = renderHook(() => useAtmosphereExploreQuery(), {wrapper}) await waitFor(() => expect(result.current.isSuccess).toBe(true)) @@ -183,14 +183,14 @@ describe('useAtmosphereExploreQuery', () => { client.call.mockResolvedValue(data) jest .mocked(device.get) - .mockReturnValue({countryCode: 'JP', regionCode: '13'}) + .mockReturnValue({countryCode: 'JP', regionCode: '13'} as never) const {result} = renderHook(() => useAtmosphereExploreQuery(), {wrapper}) await waitFor(() => expect(result.current.isSuccess).toBe(true)) jest .mocked(device.get) - .mockReturnValue({countryCode: 'US', regionCode: undefined}) + .mockReturnValue({countryCode: 'US', regionCode: undefined} as never) await act(async () => { await result.current.refetch() }) diff --git a/src/screens/Signup/__tests__/state.test.ts b/src/screens/Signup/__tests__/state.test.ts index 4aa14915f..7e7d54d97 100644 --- a/src/screens/Signup/__tests__/state.test.ts +++ b/src/screens/Signup/__tests__/state.test.ts @@ -84,7 +84,7 @@ it('keeps provider metadata when reselecting the current community', () => { serviceUrl: 'https://example.com', userDomain: '.example.com', serviceDescription: { - did: 'did:web:example.com', + did: 'did:web:example.com' as const, availableUserDomains: ['.example.com'], }, } diff --git a/src/state/cache/__tests__/post-shadow-space.test.ts b/src/state/cache/__tests__/post-shadow-space.test.ts index 1340cae1c..5f9b24a16 100644 --- a/src/state/cache/__tests__/post-shadow-space.test.ts +++ b/src/state/cache/__tests__/post-shadow-space.test.ts @@ -17,6 +17,7 @@ import { updatePostShadow, } from '#/state/cache/post-shadow' import {RQKEY_ROOT as POST_FEED_QUERY_KEY_ROOT} from '#/state/queries/post-feed' +import {type AtUriString} from '@atproto/syntax' const PUBLIC_POST = 'at://did:plc:alice/app.bsky.feed.post/3kpublic' const LEGACY_POST = 'at://did:plc:alice/community.blacksky.feed.post/3klegacy' @@ -25,7 +26,7 @@ const SPACE_POST = function post(uri: string): app.bsky.feed.defs.PostView { return { - uri, + uri: uri as AtUriString, cid: 'bafyrei post', author: {did: 'did:plc:alice', handle: 'alice.test'}, record: {$type: 'app.bsky.feed.post', text: 'hello'}, @@ -52,7 +53,9 @@ describe('post shadow URI matching', () => { cachePost(queryClient, cachedPost) expect(() => - updatePostShadow(queryClient, uri, {likeUri: `${uri}/like`}), + updatePostShadow(queryClient, uri, { + likeUri: `${uri}/like` as AtUriString, + }), ).not.toThrow() expect(dangerousGetPostShadow(cachedPost)?.likeUri).toBe(`${uri}/like`) }, diff --git a/src/state/queries/notifications/__tests__/fetch-page.test.ts b/src/state/queries/notifications/__tests__/fetch-page.test.ts index d2d1db07c..bfee11f9c 100644 --- a/src/state/queries/notifications/__tests__/fetch-page.test.ts +++ b/src/state/queries/notifications/__tests__/fetch-page.test.ts @@ -14,7 +14,7 @@ const SPACE = 'at://did:plc:tenant/space/community.blacksky.feed/private' const PRIVATE_URI = `${SPACE}/did:plc:alice/app.bsky.feed.post/3kprivate` describe(fetchPage, () => { - const client = {} as AtpAgent + const client = {} as Client const queryClient = new QueryClient() beforeEach(() => { diff --git a/src/state/queries/notifications/__tests__/space-subjects.test.ts b/src/state/queries/notifications/__tests__/space-subjects.test.ts index 1a1a71c14..3babb53c4 100644 --- a/src/state/queries/notifications/__tests__/space-subjects.test.ts +++ b/src/state/queries/notifications/__tests__/space-subjects.test.ts @@ -1,10 +1,6 @@ const mockCommunityXrpc = jest.fn() -jest.mock('@atproto/api', () => ({ - ...jest.requireActual('@atproto/api'), - jsonToLex: (value: unknown) => value, -})) jest.mock('#/lib/api/community', () => ({ communityXrpc: (...args: unknown[]) => mockCommunityXrpc(...args), })) @@ -13,6 +9,7 @@ jest.mock('#/state/queries/profile', () => ({precacheProfile: jest.fn()})) import {type Client} from '@atproto/lex' import {type FeedNotification} from '../types' import {fetchSubjects} from '../util' +import {app} from '#/lexicons' const SPACE = 'at://did:plc:space/space/community.blacksky.feed/test' @@ -44,17 +41,13 @@ describe('space notification subject hydration', () => { ), ) const getPosts = jest.fn() - const getStarterPacks = jest.fn().mockResolvedValue({ - data: {starterPacks: []}, - }) + const getStarterPacks = jest.fn().mockResolvedValue({starterPacks: []}) const client = { - app: { - bsky: { - feed: {getPosts}, - graph: {getStarterPacks}, - }, - }, - } as unknown as AtpAgent + call: (method: unknown, params: unknown) => + method === app.bsky.feed.getPosts + ? getPosts(params) + : getStarterPacks(params), + } as unknown as Client const result = await fetchSubjects(client, notifications) diff --git a/src/state/queries/notifications/__tests__/unread.test.tsx b/src/state/queries/notifications/__tests__/unread.test.tsx index e4b24cee6..d468b9db2 100644 --- a/src/state/queries/notifications/__tests__/unread.test.tsx +++ b/src/state/queries/notifications/__tests__/unread.test.tsx @@ -80,7 +80,6 @@ const page: FeedPage = { cursor: undefined, seenAt: new Date('2026-09-01T00:00:00.000Z'), items: [], - priority: false, } const unreadNotification = { @@ -91,7 +90,7 @@ const unreadNotification = { record: {$type: 'app.bsky.feed.post', text: 'private'}, isRead: false, indexedAt: '2026-09-01T00:00:00.000Z', -} +} as unknown as app.bsky.notification.listNotifications.Notification const visiblePage: FeedPage = { ...page, items: [ diff --git a/src/state/session/__tests__/provider-session-events-test.tsx b/src/state/session/__tests__/provider-session-events-test.tsx index 84510e1a6..e5308287a 100644 --- a/src/state/session/__tests__/provider-session-events-test.tsx +++ b/src/state/session/__tests__/provider-session-events-test.tsx @@ -121,7 +121,7 @@ jest.mock('../create-account', () => ({ import {Provider, useSession, useSessionApi} from '#/state/session' import { type OnSessionChange, - type SessionBundle, + type PasswordSessionBundle as SessionBundle, } from '#/state/session/session-core' import {type SessionApiContext} from '#/state/session/types' diff --git a/src/state/session/__tests__/session-core-test.ts b/src/state/session/__tests__/session-core-test.ts index 4b7ea14ee..3ff329673 100644 --- a/src/state/session/__tests__/session-core-test.ts +++ b/src/state/session/__tests__/session-core-test.ts @@ -94,7 +94,7 @@ import { makeSessionHooks, registerBundleKillSwitch, sessionAccountToSessionData, - type SessionBundle, + type PasswordSessionBundle as SessionBundle, sessionDataToSessionAccount, } from '../session-core' import { diff --git a/src/state/session/__tests__/session-test.ts b/src/state/session/__tests__/session-test.ts index bf0984600..73d83de23 100644 --- a/src/state/session/__tests__/session-test.ts +++ b/src/state/session/__tests__/session-test.ts @@ -1019,7 +1019,7 @@ describe('session', () => { it('ends an active OAuth session while keeping the remembered account', () => { const account = { service: 'https://alice.com', - did: 'did:plc:alice', + did: 'did:plc:alice' as const, handle: 'alice.test', isOauthSession: true, } @@ -1043,13 +1043,13 @@ describe('session', () => { it('ignores OAuth termination for an inactive account', () => { const alice = { service: 'https://alice.com', - did: 'did:plc:alice', + did: 'did:plc:alice' as const, handle: 'alice.test', isOauthSession: true, } const bob = { service: 'https://bob.com', - did: 'did:plc:bob', + did: 'did:plc:bob' as const, handle: 'bob.test', isOauthSession: true, } diff --git a/src/view/com/composer/state/__tests__/composer-poll.test.ts b/src/view/com/composer/state/__tests__/composer-poll.test.ts index fa72dcc82..ca211fe63 100644 --- a/src/view/com/composer/state/__tests__/composer-poll.test.ts +++ b/src/view/com/composer/state/__tests__/composer-poll.test.ts @@ -17,6 +17,7 @@ import { type ThreadDraft, threadHasPoll, } from '../composer' +import {type UriString} from '@atproto/lex' jest.mock('#/lib/api/community-feed', () => ({ isSpaceBackedFeed: (config: {space?: string} | undefined) => !!config?.space, @@ -168,7 +169,10 @@ function threadWith(overrides: Partial): ThreadDraft { function threadQuoting(uri: string): ThreadDraft { const state = withPosts(threadOfTwo(), (post, index) => index === 1 - ? {...post, embed: {...post.embed, quote: {type: 'link', uri}}} + ? { + ...post, + embed: {...post.embed, quote: {type: 'link', uri: uri as UriString}}, + } : post, ) return state.thread @@ -913,7 +917,10 @@ describe('isPollPostable', () => { it('is false when the poll shares the post with another attachment', () => { const post = pollPost('Which one?', ['first']) - const link = {type: 'link' as const, uri: 'https://example.com/article'} + const link = { + type: 'link' as const, + uri: 'https://example.com/article' as UriString, + } expect(isPollPostable({...post, embed: {...post.embed, link}})).toBe(false) expect(isPollPostable({...post, embed: {...post.embed, quote: link}})).toBe( diff --git a/src/view/com/post-thread/__tests__/space-engagement.test.tsx b/src/view/com/post-thread/__tests__/space-engagement.test.tsx index 1fe406f2d..7e114b751 100644 --- a/src/view/com/post-thread/__tests__/space-engagement.test.tsx +++ b/src/view/com/post-thread/__tests__/space-engagement.test.tsx @@ -78,7 +78,9 @@ describe('permissioned-space post engagement components', () => { it('mounts quotes and requests the space quotes endpoint', async () => { expect(() => - render(, {wrapper}), + render(, { + wrapper, + }), ).not.toThrow() await waitFor(() => { -- knotmirror 0.0.1