Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
haileyok committed Aug 6, 2024
1 parent 1f5a211 commit 3e70dcd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ const noBlocks = (inputs: RulesFnInput<Context, Params, Skeleton>) => {
skeleton.dids = skeleton.dids.filter((did) => {
const actor = hydration.actors?.get(did)
if (!actor) return false
// Always display exact matches so that users can find profiles that they have blocked
const term = (params.q ?? params.term ?? '').toLowerCase()
const isExactMatch = actor.handle?.toLowerCase() === term
return isExactMatch || !ctx.views.viewerBlockExists(did, hydration)
Expand Down
22 changes: 20 additions & 2 deletions packages/bsky/tests/views/block-lists.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,21 +295,39 @@ describe('pds views with blocking from block lists', () => {
it('does not return blocked accounts in actor search typeahead', async () => {
const resCarol = await agent.api.app.bsky.actor.searchActorsTypeahead(
{
term: 'dan.test',
term: 'dan.tes',
},
{ headers: await network.serviceHeaders(carol) },
)
expect(resCarol.data.actors.some((actor) => actor.did === dan)).toBeFalsy()

const resDan = await agent.api.app.bsky.actor.searchActorsTypeahead(
{
term: 'carol.test',
term: 'carol.tes',
},
{ headers: await network.serviceHeaders(dan) },
)
expect(resDan.data.actors.some((actor) => actor.did === carol)).toBeFalsy()
})

it('does return blocked accounts in actor search typeahead when term is exact handle', async () => {
const resCarol = await agent.api.app.bsky.actor.searchActorsTypeahead(
{
term: 'dan.test',
},
{ headers: await network.serviceHeaders(carol) },
)
expect(resCarol.data.actors.some((actor) => actor.did === dan)).toBeTruthy()

const resDan = await agent.api.app.bsky.actor.searchActorsTypeahead(
{
term: 'carol.test',
},
{ headers: await network.serviceHeaders(dan) },
)
expect(resDan.data.actors.some((actor) => actor.did === carol)).toBeTruthy()
})

it('does not return blocked accounts in get suggestions', async () => {
// unfollow so they _would_ show up in suggestions if not for block
await sc.unfollow(carol, dan)
Expand Down

0 comments on commit 3e70dcd

Please sign in to comment.