From 92086353c43732cf557aa77c565e635f4da24b0b Mon Sep 17 00:00:00 2001 From: dholms Date: Fri, 22 Dec 2023 16:52:04 -0600 Subject: [PATCH] fix some pds tests --- .../proxied/__snapshots__/admin.test.ts.snap | 127 ++++++++++++------ packages/pds/tests/proxied/admin.test.ts | 6 +- 2 files changed, 90 insertions(+), 43 deletions(-) diff --git a/packages/pds/tests/proxied/__snapshots__/admin.test.ts.snap b/packages/pds/tests/proxied/__snapshots__/admin.test.ts.snap index 85e2e3b99e5..636e0dec6cf 100644 --- a/packages/pds/tests/proxied/__snapshots__/admin.test.ts.snap +++ b/packages/pds/tests/proxied/__snapshots__/admin.test.ts.snap @@ -4,7 +4,7 @@ exports[`proxies admin requests creates reports of a repo. 1`] = ` Array [ Object { "createdAt": "1970-01-01T00:00:00.000Z", - "id": 2, + "id": 4, "reasonType": "com.atproto.moderation.defs#reasonSpam", "reportedBy": "user(0)", "subject": Object { @@ -14,7 +14,7 @@ Array [ }, Object { "createdAt": "1970-01-01T00:00:00.000Z", - "id": 3, + "id": 5, "reason": "impersonation", "reasonType": "com.atproto.moderation.defs#reasonOther", "reportedBy": "user(2)", @@ -34,7 +34,7 @@ Array [ "event": Object { "$type": "com.atproto.admin.defs#modEventAcknowledge", }, - "id": 5, + "id": 7, "subject": Object { "$type": "com.atproto.admin.defs#repoRef", "did": "user(0)", @@ -51,7 +51,7 @@ Array [ "comment": "impersonation", "reportType": "com.atproto.moderation.defs#reasonOther", }, - "id": 3, + "id": 5, "subject": Object { "$type": "com.atproto.admin.defs#repoRef", "did": "user(0)", @@ -67,7 +67,7 @@ Array [ "$type": "com.atproto.admin.defs#modEventReport", "reportType": "com.atproto.moderation.defs#reasonSpam", }, - "id": 2, + "id": 4, "subject": Object { "$type": "com.atproto.admin.defs#repoRef", "did": "user(0)", @@ -81,50 +81,95 @@ Array [ exports[`proxies admin requests fetches event details. 1`] = ` Object { "createdAt": "1970-01-01T00:00:00.000Z", - "createdBy": "user(1)", + "createdBy": "did:example:labeler", "event": Object { - "$type": "com.atproto.admin.defs#modEventReport", - "reportType": "com.atproto.moderation.defs#reasonSpam", + "$type": "com.atproto.admin.defs#modEventLabel", + "comment": "[AutoModerator]: Applying labels", + "createLabelVals": Array [ + "test-label", + "test-label-2", + ], + "negateLabelVals": Array [], }, "id": 2, "subject": Object { - "$type": "com.atproto.admin.defs#repoView", - "did": "user(0)", - "handle": "bob.test", + "$type": "com.atproto.admin.defs#recordView", + "blobCids": Array [ + "cids(1)", + ], + "cid": "cids(0)", "indexedAt": "1970-01-01T00:00:00.000Z", - "moderation": Object { - "subjectStatus": Object { - "createdAt": "1970-01-01T00:00:00.000Z", - "id": 1, - "lastReportedAt": "1970-01-01T00:00:00.000Z", - "lastReviewedAt": "1970-01-01T00:00:00.000Z", - "lastReviewedBy": "did:example:admin", - "reviewState": "com.atproto.admin.defs#reviewClosed", - "subject": Object { - "$type": "com.atproto.admin.defs#repoRef", - "did": "user(0)", + "moderation": Object {}, + "repo": Object { + "did": "user(0)", + "handle": "bob.test", + "indexedAt": "1970-01-01T00:00:00.000Z", + "moderation": Object { + "subjectStatus": Object { + "createdAt": "1970-01-01T00:00:00.000Z", + "id": 1, + "lastReportedAt": "1970-01-01T00:00:00.000Z", + "lastReviewedAt": "1970-01-01T00:00:00.000Z", + "lastReviewedBy": "did:example:admin", + "reviewState": "com.atproto.admin.defs#reviewClosed", + "subject": Object { + "$type": "com.atproto.admin.defs#repoRef", + "did": "user(0)", + }, + "subjectBlobCids": Array [], + "subjectRepoHandle": "bob.test", + "takendown": false, + "updatedAt": "1970-01-01T00:00:00.000Z", }, - "subjectBlobCids": Array [], - "subjectRepoHandle": "bob.test", - "takendown": false, - "updatedAt": "1970-01-01T00:00:00.000Z", }, + "relatedRecords": Array [ + Object { + "$type": "app.bsky.actor.profile", + "avatar": Object { + "$type": "blob", + "mimeType": "image/jpeg", + "ref": Object { + "$link": "cids(3)", + }, + "size": 3976, + }, + "description": "hi im bob label_me", + "displayName": "bobby", + }, + ], }, - "relatedRecords": Array [ - Object { - "$type": "app.bsky.actor.profile", - "avatar": Object { - "$type": "blob", - "mimeType": "image/jpeg", - "ref": Object { - "$link": "cids(0)", + "uri": "record(0)", + "value": Object { + "$type": "app.bsky.feed.post", + "createdAt": "1970-01-01T00:00:00.000Z", + "embed": Object { + "$type": "app.bsky.embed.images", + "images": Array [ + Object { + "alt": "tests/sample-img/key-landscape-small.jpg", + "image": Object { + "$type": "blob", + "mimeType": "image/jpeg", + "ref": Object { + "$link": "cids(1)", + }, + "size": 4114, + }, }, - "size": 3976, + ], + }, + "reply": Object { + "parent": Object { + "cid": "cids(2)", + "uri": "record(1)", + }, + "root": Object { + "cid": "cids(2)", + "uri": "record(1)", }, - "description": "hi im bob label_me", - "displayName": "bobby", }, - ], + "text": "hear that label_me label_me_2", + }, }, "subjectBlobCids": Array [], "subjectBlobs": Array [], @@ -139,7 +184,7 @@ Array [ "event": Object { "$type": "com.atproto.admin.defs#modEventAcknowledge", }, - "id": 4, + "id": 6, "subject": Object { "$type": "com.atproto.repo.strongRef", "cid": "cids(0)", @@ -323,7 +368,7 @@ Object { "event": Object { "$type": "com.atproto.admin.defs#modEventAcknowledge", }, - "id": 4, + "id": 6, "subject": Object { "$type": "com.atproto.repo.strongRef", "cid": "cids(0)", @@ -340,7 +385,7 @@ Object { "event": Object { "$type": "com.atproto.admin.defs#modEventAcknowledge", }, - "id": 5, + "id": 7, "subject": Object { "$type": "com.atproto.admin.defs#repoRef", "did": "user(0)", diff --git a/packages/pds/tests/proxied/admin.test.ts b/packages/pds/tests/proxied/admin.test.ts index fd8538e802a..9906e4d129a 100644 --- a/packages/pds/tests/proxied/admin.test.ts +++ b/packages/pds/tests/proxied/admin.test.ts @@ -17,8 +17,6 @@ describe('proxies admin requests', () => { network = await TestNetwork.create({ dbPostgresSchema: 'proxy_admin', pds: { - // @NOTE requires admin pass be the same on pds and appview, which TestNetwork is handling for us. - bskyAppViewModeration: true, inviteRequired: true, }, }) @@ -222,6 +220,7 @@ describe('proxies admin requests', () => { encoding: 'application/json', }, ) + await network.processAll() // check profile and labels const tryGetProfileAppview = agent.api.app.bsky.actor.getProfile( { actor: sc.dids.alice }, @@ -250,6 +249,7 @@ describe('proxies admin requests', () => { encoding: 'application/json', }, ) + await network.processAll() // check profile and labels const { data: profileAppview } = await agent.api.app.bsky.actor.getProfile( { actor: sc.dids.alice }, @@ -283,6 +283,7 @@ describe('proxies admin requests', () => { encoding: 'application/json', }, ) + await network.processAll() // check thread and labels const tryGetPost = agent.api.app.bsky.feed.getPostThread( { uri: post.ref.uriStr, depth: 0 }, @@ -306,6 +307,7 @@ describe('proxies admin requests', () => { encoding: 'application/json', }, ) + await network.processAll() // check thread and labels const { data: threadAppview } = await agent.api.app.bsky.feed.getPostThread( { uri: post.ref.uriStr, depth: 0 },