Bluesky app fork with some witchin' additions 馃挮
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at theme-changes 81 lines 2.4 kB view raw
1import {type OAuthSession} from '@atproto/oauth-client-browser' 2import {describe, expect, it, jest} from '@jest/globals' 3 4jest.mock('../agent', () => ({ 5 sessionAccountToSession(account: {did: string; handle: string}) { 6 return { 7 accessJwt: '', 8 did: account.did, 9 emailAuthFactor: false, 10 emailConfirmed: false, 11 handle: account.handle, 12 refreshJwt: '', 13 active: true, 14 } 15 }, 16})) 17 18jest.mock('../moderation', () => ({ 19 configureModerationForAccount() { 20 return Promise.resolve() 21 }, 22})) 23 24jest.mock('../oauth-web-client', () => ({ 25 getWebOAuthClient() { 26 throw new Error('not used in this test') 27 }, 28})) 29 30import {OauthBskyAppAgent} from '../oauth-agent' 31 32function createOAuthSession(): OAuthSession { 33 return { 34 did: 'did:plc:alice', 35 serverMetadata: { 36 issuer: 'https://bsky.social', 37 }, 38 fetchHandler() { 39 throw new Error('not implemented in test') 40 }, 41 } as unknown as OAuthSession 42} 43 44describe('OauthBskyAppAgent', () => { 45 it('preserves service and dispatch urls when cloned and proxied', async () => { 46 const agent = new OauthBskyAppAgent(createOAuthSession()) 47 48 expect(agent.serviceUrl.toString()).toBe('https://bsky.social/') 49 expect(agent.dispatchUrl.toString()).toBe('https://bsky.social/') 50 51 await agent.prepare( 52 { 53 service: 'https://bsky.social', 54 did: 'did:plc:alice', 55 handle: 'alice.test', 56 active: true, 57 emailConfirmed: false, 58 emailAuthFactor: false, 59 pdsUrl: 'https://alice.pds.example', 60 isSelfHosted: false, 61 isOauthSession: true, 62 }, 63 Promise.resolve(), 64 Promise.resolve(), 65 ) 66 67 expect(agent.serviceUrl.toString()).toBe('https://bsky.social/') 68 expect(agent.pdsUrl?.toString()).toBe('https://alice.pds.example/') 69 expect(agent.dispatchUrl.toString()).toBe('https://alice.pds.example/') 70 71 const proxied = agent.withProxy('bsky_fg', 'did:plc:feed') 72 expect(proxied).toBeInstanceOf(OauthBskyAppAgent) 73 expect(proxied.serviceUrl.toString()).toBe('https://bsky.social/') 74 expect(proxied.dispatchUrl.toString()).toBe('https://alice.pds.example/') 75 76 const pdsAgent = agent.cloneWithoutProxy() 77 expect(pdsAgent.proxy).toBeUndefined() 78 expect(pdsAgent.serviceUrl.toString()).toBe('https://bsky.social/') 79 expect(pdsAgent.dispatchUrl.toString()).toBe('https://alice.pds.example/') 80 }) 81})