@atproto/pds 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,7 +8,8 @@ import {
8
8
  import { forSnapshot } from '../_util'
9
9
  import { NotFoundError } from '@atproto/api/src/client/types/app/bsky/feed/getPostThread'
10
10
 
11
- describe('proxies admin requests', () => {
11
+ // @TODO skipping during appview v2 buildout, as appview frontends no longer contains moderation endpoints
12
+ describe.skip('proxies admin requests', () => {
12
13
  let network: TestNetwork
13
14
  let agent: AtpAgent
14
15
  let sc: SeedClient
@@ -32,7 +33,7 @@ describe('proxies admin requests', () => {
32
33
  )
33
34
  await basicSeed(sc, {
34
35
  inviteCode: invite.code,
35
- addModLabels: true,
36
+ addModLabels: network.bsky,
36
37
  })
37
38
  await network.processAll()
38
39
  })
@@ -8,7 +8,6 @@ describe('feedgen proxy view', () => {
8
8
  let network: TestNetwork
9
9
  let agent: AtpAgent
10
10
  let sc: SeedClient
11
-
12
11
  let feedUri: AtUri
13
12
 
14
13
  beforeAll(async () => {
@@ -17,7 +16,7 @@ describe('feedgen proxy view', () => {
17
16
  })
18
17
  agent = network.pds.getClient()
19
18
  sc = network.getSeedClient()
20
- await basicSeed(sc, { addModLabels: true })
19
+ await basicSeed(sc, { addModLabels: network.bsky })
21
20
 
22
21
  feedUri = AtUri.make(sc.dids.alice, 'app.bsky.feed.generator', 'mutuals')
23
22
 
@@ -17,7 +17,7 @@ describe('proxies appview procedures', () => {
17
17
  })
18
18
  agent = network.pds.getClient()
19
19
  sc = network.getSeedClient()
20
- await basicSeed(sc, { addModLabels: true })
20
+ await basicSeed(sc, { addModLabels: network.bsky })
21
21
  await network.processAll()
22
22
  alice = sc.dids.alice
23
23
  bob = sc.dids.bob
@@ -142,7 +142,11 @@ describe('proxies appview procedures', () => {
142
142
  { headers: sc.getHeaders(alice) },
143
143
  )
144
144
  expect(result1.notifications.length).toBeGreaterThanOrEqual(5)
145
- expect(result1.notifications.every((n) => !n.isRead)).toBe(true)
145
+ expect(
146
+ result1.notifications.every((n, i) => {
147
+ return (i === 0 && !n.isRead) || (i !== 0 && n.isRead)
148
+ }),
149
+ ).toBe(true)
146
150
  // update last seen
147
151
  const { indexedAt: lastSeenAt } = result1.notifications[2]
148
152
  await agent.api.app.bsky.notification.updateSeen(
@@ -163,7 +167,7 @@ describe('proxies appview procedures', () => {
163
167
  expect(result2.notifications).toEqual(
164
168
  result1.notifications.map((n) => ({
165
169
  ...n,
166
- isRead: n.indexedAt <= lastSeenAt,
170
+ isRead: n.indexedAt < lastSeenAt,
167
171
  })),
168
172
  )
169
173
  })
@@ -22,7 +22,7 @@ describe('proxy read after write', () => {
22
22
  })
23
23
  agent = network.pds.getClient()
24
24
  sc = network.getSeedClient()
25
- await basicSeed(sc, { addModLabels: true })
25
+ await basicSeed(sc, { addModLabels: network.bsky })
26
26
  await network.processAll()
27
27
  alice = sc.dids.alice
28
28
  carol = sc.dids.carol
@@ -19,7 +19,7 @@ describe('proxies view requests', () => {
19
19
  })
20
20
  agent = network.pds.getClient()
21
21
  sc = network.getSeedClient()
22
- await basicSeed(sc, { addModLabels: true })
22
+ await basicSeed(sc, { addModLabels: network.bsky })
23
23
  alice = sc.dids.alice
24
24
  bob = sc.dids.bob
25
25
  carol = sc.dids.carol
@@ -79,9 +79,8 @@ describe('proxies view requests', () => {
79
79
  { did: sc.dids.carol, order: 2 },
80
80
  { did: sc.dids.dan, order: 3 },
81
81
  ]
82
- await network.bsky.ctx.db
83
- .getPrimary()
84
- .db.insertInto('suggested_follow')
82
+ await network.bsky.db.db
83
+ .insertInto('suggested_follow')
85
84
  .values(suggestions)
86
85
  .execute()
87
86
 
@@ -334,7 +333,8 @@ describe('proxies view requests', () => {
334
333
  expect([...pt1.data.feed, ...pt2.data.feed]).toEqual(res.data.feed)
335
334
  })
336
335
 
337
- it('unspecced.getPopularFeedGenerators', async () => {
336
+ // @TODO disabled during appview v2 buildout
337
+ it.skip('unspecced.getPopularFeedGenerators', async () => {
338
338
  const res = await agent.api.app.bsky.unspecced.getPopularFeedGenerators(
339
339
  {},
340
340
  {
@@ -1,10 +1,10 @@
1
- import { SeedClient } from '@atproto/dev-env'
1
+ import { SeedClient, TestBsky } from '@atproto/dev-env'
2
2
  import { ids } from '../../src/lexicon/lexicons'
3
3
  import usersSeed from './users'
4
4
 
5
5
  export default async (
6
6
  sc: SeedClient,
7
- opts?: { inviteCode?: string; addModLabels?: boolean },
7
+ opts?: { inviteCode?: string; addModLabels?: TestBsky },
8
8
  ) => {
9
9
  await usersSeed(sc, opts)
10
10
 
@@ -134,24 +134,7 @@ export default async (
134
134
  await sc.repost(dan, alicesReplyToBob.ref)
135
135
 
136
136
  if (opts?.addModLabels) {
137
- await sc.agent.com.atproto.admin.emitModerationEvent(
138
- {
139
- event: {
140
- createLabelVals: ['repo-action-label'],
141
- negateLabelVals: [],
142
- $type: 'com.atproto.admin.defs#modEventLabel',
143
- },
144
- subject: {
145
- $type: 'com.atproto.admin.defs#repoRef',
146
- did: dan,
147
- },
148
- createdBy: 'did:example:admin',
149
- },
150
- {
151
- encoding: 'application/json',
152
- headers: sc.adminAuthHeaders(),
153
- },
154
- )
137
+ await createLabel(opts.addModLabels, { did: dan, val: 'repo-action-label' })
155
138
  }
156
139
 
157
140
  return sc
@@ -169,3 +152,20 @@ export const replies = {
169
152
  bob: ['hear that label_me label_me_2'],
170
153
  carol: ['of course'],
171
154
  }
155
+
156
+ const createLabel = async (
157
+ bsky: TestBsky,
158
+ opts: { did: string; val: string },
159
+ ) => {
160
+ await bsky.db.db
161
+ .insertInto('label')
162
+ .values({
163
+ uri: opts.did,
164
+ cid: '',
165
+ val: opts.val,
166
+ cts: new Date().toISOString(),
167
+ neg: false,
168
+ src: 'did:example:labeler',
169
+ })
170
+ .execute()
171
+ }