Skip to content

Commit

Permalink
Add test for viewer block (#2759)
Browse files Browse the repository at this point in the history
* Add test for viewer block

* Use util
  • Loading branch information
estrattonbailey committed Aug 28, 2024
1 parent ea6cfc3 commit f1dad05
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/bsky/src/api/app/bsky/feed/getQuotes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { Views } from '../../../../views'
import { mapDefined } from '@atproto/common'
import { QueryParams } from '../../../../lexicon/types/app/bsky/feed/getQuotes'
import { parseString } from '../../../../hydration/util'
import { uriToDid } from '../../../../util/uris'

export default function (server: Server, ctx: AppContext) {
const getQuotes = createPipeline(skeleton, hydration, noBlocks, presentation)
Expand Down Expand Up @@ -74,7 +75,7 @@ const noBlocks = (inputs: {
const { ctx, skeleton, hydration } = inputs
skeleton.uris = skeleton.uris.filter((uri) => {
const embedBlock = hydration.postBlocks?.get(uri)?.embed
const authorDid = new AtUri(uri).hostname
const authorDid = uriToDid(uri)
return !ctx.views.viewerBlockExists(authorDid, hydration) && !embedBlock
})
return skeleton
Expand Down
15 changes: 15 additions & 0 deletions packages/bsky/tests/views/quotes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,21 @@ describe('pds quote views', () => {
expect(forSnapshot(alicePostQuotes.data)).toMatchSnapshot()
})

it('does not return post in list when the quote author has a block', async () => {
await sc.block(eve, carol)
await network.processAll()

const quotes = await agent.api.app.bsky.feed.getQuotes(
{ uri: sc.posts[alice][0].ref.uriStr, limit: 30 },
{
headers: await network.serviceHeaders(carol, ids.AppBskyFeedGetQuotes),
},
)

expect(quotes.data.posts.length).toBe(0)
await sc.unblock(eve, carol)
})

it('utilizes limit parameter and cursor', async () => {
const alicePostQuotes1 = await agent.api.app.bsky.feed.getQuotes(
{ uri: sc.posts[alice][1].ref.uriStr, limit: 3 },
Expand Down

0 comments on commit f1dad05

Please sign in to comment.