From bb86a0f263b38f826cbf39036fed40458d067297 Mon Sep 17 00:00:00 2001 From: dholms Date: Tue, 19 Dec 2023 20:04:44 -0600 Subject: [PATCH] tidy test suite --- .../feed-generation.test.ts.snap | 1717 ----- .../__snapshots__/get-record.test.ts.snap | 0 .../__snapshots__/get-repo.test.ts.snap | 0 .../tests/__snapshots__/indexing.test.ts.snap | 668 -- .../moderation-events.test.ts.snap | 0 .../moderation-statuses.test.ts.snap | 0 .../__snapshots__/moderation.test.ts.snap | 0 .../ozone/tests/algos/hot-classic.test.ts | 88 - packages/ozone/tests/auth.test.ts | 64 - .../fixtures/hiveai_resp_example.json | 401 -- .../auto-moderator/fuzzy-matcher.test.ts | 165 - .../ozone/tests/auto-moderator/hive.test.ts | 16 - .../tests/auto-moderator/labeler.test.ts | 167 - .../tests/auto-moderator/takedowns.test.ts | 201 - packages/ozone/tests/blob-resolver.test.ts | 89 - packages/ozone/tests/daemon.test.ts | 191 - packages/ozone/tests/did-cache.test.ts | 144 - .../ozone/tests/duplicate-records.test.ts | 146 - packages/ozone/tests/feed-generation.test.ts | 594 -- .../tests/{admin => }/get-record.test.ts | 6 +- .../ozone/tests/{admin => }/get-repo.test.ts | 6 +- .../ozone/tests/handle-invalidation.test.ts | 127 - packages/ozone/tests/image/server.test.ts | 90 - packages/ozone/tests/image/sharp.test.ts | 185 - packages/ozone/tests/image/uri.test.ts | 87 - packages/ozone/tests/indexing.test.ts | 728 --- .../{admin => }/moderation-events.test.ts | 6 +- .../{admin => }/moderation-statuses.test.ts | 6 +- .../tests/{admin => }/moderation.test.ts | 12 +- .../ozone/tests/notification-server.test.ts | 231 - .../ozone/tests/pipeline/backpressure.test.ts | 68 - .../ozone/tests/pipeline/reingest.test.ts | 55 - .../ozone/tests/pipeline/repartition.test.ts | 86 - packages/ozone/tests/redis-cache.test.ts | 231 - .../tests/{admin => }/repo-search.test.ts | 4 +- packages/ozone/tests/reprocessing.test.ts | 71 - .../ozone/tests/subscription/repo.test.ts | 139 - .../ozone/tests/subscription/util.test.ts | 185 - .../__snapshots__/actor-search.test.ts.snap | 155 - .../__snapshots__/author-feed.test.ts.snap | 2063 ------ .../__snapshots__/block-lists.test.ts.snap | 594 -- .../views/__snapshots__/blocks.test.ts.snap | 358 -- .../views/__snapshots__/follows.test.ts.snap | 571 -- .../views/__snapshots__/likes.test.ts.snap | 95 - .../__snapshots__/list-feed.test.ts.snap | 721 --- .../__snapshots__/mute-lists.test.ts.snap | 597 -- .../views/__snapshots__/mutes.test.ts.snap | 273 - .../__snapshots__/notifications.test.ts.snap | 946 --- .../views/__snapshots__/posts.test.ts.snap | 467 -- .../views/__snapshots__/profile.test.ts.snap | 193 - .../views/__snapshots__/reposts.test.ts.snap | 75 - .../views/__snapshots__/thread.test.ts.snap | 1361 ---- .../__snapshots__/threadgating.test.ts.snap | 164 - .../views/__snapshots__/timeline.test.ts.snap | 5714 ----------------- .../ozone/tests/views/actor-likes.test.ts | 119 - .../ozone/tests/views/actor-search.test.ts | 266 - .../tests/views/admin/repo-search.test.ts | 133 - .../ozone/tests/views/author-feed.test.ts | 326 - .../ozone/tests/views/block-lists.test.ts | 434 -- packages/ozone/tests/views/blocks.test.ts | 542 -- packages/ozone/tests/views/follows.test.ts | 296 - packages/ozone/tests/views/likes.test.ts | 109 - packages/ozone/tests/views/list-feed.test.ts | 200 - packages/ozone/tests/views/mute-lists.test.ts | 383 -- packages/ozone/tests/views/mutes.test.ts | 230 - .../ozone/tests/views/notifications.test.ts | 299 - packages/ozone/tests/views/posts.test.ts | 107 - packages/ozone/tests/views/profile.test.ts | 284 - packages/ozone/tests/views/reposts.test.ts | 88 - .../tests/views/suggested-follows.test.ts | 146 - .../ozone/tests/views/suggestions.test.ts | 100 - packages/ozone/tests/views/thread.test.ts | 459 -- .../ozone/tests/views/threadgating.test.ts | 640 -- packages/ozone/tests/views/timeline.test.ts | 286 - 74 files changed, 20 insertions(+), 26748 deletions(-) delete mode 100644 packages/ozone/tests/__snapshots__/feed-generation.test.ts.snap rename packages/ozone/tests/{admin => }/__snapshots__/get-record.test.ts.snap (100%) rename packages/ozone/tests/{admin => }/__snapshots__/get-repo.test.ts.snap (100%) delete mode 100644 packages/ozone/tests/__snapshots__/indexing.test.ts.snap rename packages/ozone/tests/{admin => }/__snapshots__/moderation-events.test.ts.snap (100%) rename packages/ozone/tests/{admin => }/__snapshots__/moderation-statuses.test.ts.snap (100%) rename packages/ozone/tests/{admin => }/__snapshots__/moderation.test.ts.snap (100%) delete mode 100644 packages/ozone/tests/algos/hot-classic.test.ts delete mode 100644 packages/ozone/tests/auth.test.ts delete mode 100644 packages/ozone/tests/auto-moderator/fixtures/hiveai_resp_example.json delete mode 100644 packages/ozone/tests/auto-moderator/fuzzy-matcher.test.ts delete mode 100644 packages/ozone/tests/auto-moderator/hive.test.ts delete mode 100644 packages/ozone/tests/auto-moderator/labeler.test.ts delete mode 100644 packages/ozone/tests/auto-moderator/takedowns.test.ts delete mode 100644 packages/ozone/tests/blob-resolver.test.ts delete mode 100644 packages/ozone/tests/daemon.test.ts delete mode 100644 packages/ozone/tests/did-cache.test.ts delete mode 100644 packages/ozone/tests/duplicate-records.test.ts delete mode 100644 packages/ozone/tests/feed-generation.test.ts rename packages/ozone/tests/{admin => }/get-record.test.ts (95%) rename packages/ozone/tests/{admin => }/get-repo.test.ts (96%) delete mode 100644 packages/ozone/tests/handle-invalidation.test.ts delete mode 100644 packages/ozone/tests/image/server.test.ts delete mode 100644 packages/ozone/tests/image/sharp.test.ts delete mode 100644 packages/ozone/tests/image/uri.test.ts delete mode 100644 packages/ozone/tests/indexing.test.ts rename packages/ozone/tests/{admin => }/moderation-events.test.ts (97%) rename packages/ozone/tests/{admin => }/moderation-statuses.test.ts (96%) rename packages/ozone/tests/{admin => }/moderation.test.ts (99%) delete mode 100644 packages/ozone/tests/notification-server.test.ts delete mode 100644 packages/ozone/tests/pipeline/backpressure.test.ts delete mode 100644 packages/ozone/tests/pipeline/reingest.test.ts delete mode 100644 packages/ozone/tests/pipeline/repartition.test.ts delete mode 100644 packages/ozone/tests/redis-cache.test.ts rename packages/ozone/tests/{admin => }/repo-search.test.ts (97%) delete mode 100644 packages/ozone/tests/reprocessing.test.ts delete mode 100644 packages/ozone/tests/subscription/repo.test.ts delete mode 100644 packages/ozone/tests/subscription/util.test.ts delete mode 100644 packages/ozone/tests/views/__snapshots__/actor-search.test.ts.snap delete mode 100644 packages/ozone/tests/views/__snapshots__/author-feed.test.ts.snap delete mode 100644 packages/ozone/tests/views/__snapshots__/block-lists.test.ts.snap delete mode 100644 packages/ozone/tests/views/__snapshots__/blocks.test.ts.snap delete mode 100644 packages/ozone/tests/views/__snapshots__/follows.test.ts.snap delete mode 100644 packages/ozone/tests/views/__snapshots__/likes.test.ts.snap delete mode 100644 packages/ozone/tests/views/__snapshots__/list-feed.test.ts.snap delete mode 100644 packages/ozone/tests/views/__snapshots__/mute-lists.test.ts.snap delete mode 100644 packages/ozone/tests/views/__snapshots__/mutes.test.ts.snap delete mode 100644 packages/ozone/tests/views/__snapshots__/notifications.test.ts.snap delete mode 100644 packages/ozone/tests/views/__snapshots__/posts.test.ts.snap delete mode 100644 packages/ozone/tests/views/__snapshots__/profile.test.ts.snap delete mode 100644 packages/ozone/tests/views/__snapshots__/reposts.test.ts.snap delete mode 100644 packages/ozone/tests/views/__snapshots__/thread.test.ts.snap delete mode 100644 packages/ozone/tests/views/__snapshots__/threadgating.test.ts.snap delete mode 100644 packages/ozone/tests/views/__snapshots__/timeline.test.ts.snap delete mode 100644 packages/ozone/tests/views/actor-likes.test.ts delete mode 100644 packages/ozone/tests/views/actor-search.test.ts delete mode 100644 packages/ozone/tests/views/admin/repo-search.test.ts delete mode 100644 packages/ozone/tests/views/author-feed.test.ts delete mode 100644 packages/ozone/tests/views/block-lists.test.ts delete mode 100644 packages/ozone/tests/views/blocks.test.ts delete mode 100644 packages/ozone/tests/views/follows.test.ts delete mode 100644 packages/ozone/tests/views/likes.test.ts delete mode 100644 packages/ozone/tests/views/list-feed.test.ts delete mode 100644 packages/ozone/tests/views/mute-lists.test.ts delete mode 100644 packages/ozone/tests/views/mutes.test.ts delete mode 100644 packages/ozone/tests/views/notifications.test.ts delete mode 100644 packages/ozone/tests/views/posts.test.ts delete mode 100644 packages/ozone/tests/views/profile.test.ts delete mode 100644 packages/ozone/tests/views/reposts.test.ts delete mode 100644 packages/ozone/tests/views/suggested-follows.test.ts delete mode 100644 packages/ozone/tests/views/suggestions.test.ts delete mode 100644 packages/ozone/tests/views/thread.test.ts delete mode 100644 packages/ozone/tests/views/threadgating.test.ts delete mode 100644 packages/ozone/tests/views/timeline.test.ts diff --git a/packages/ozone/tests/__snapshots__/feed-generation.test.ts.snap b/packages/ozone/tests/__snapshots__/feed-generation.test.ts.snap deleted file mode 100644 index ac9e0eee7a0..00000000000 --- a/packages/ozone/tests/__snapshots__/feed-generation.test.ts.snap +++ /dev/null @@ -1,1717 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`feed generation does not embed taken-down feed generator records in posts 1`] = ` -Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(0)", - "embed": Object { - "$type": "app.bsky.embed.record#view", - "record": Object { - "$type": "app.bsky.embed.record#viewNotFound", - "notFound": true, - "uri": "record(1)", - }, - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.record", - "record": Object { - "cid": "cids(2)", - "uri": "record(1)", - }, - }, - "text": "weird feed", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(0)", - "viewer": Object {}, -} -`; - -exports[`feed generation embeds feed generator records in posts 1`] = ` -Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(0)", - "embed": Object { - "$type": "app.bsky.embed.record#view", - "record": Object { - "$type": "app.bsky.feed.defs#generatorView", - "cid": "cids(2)", - "creator": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(4)/cids(1)@jpeg", - "did": "user(3)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(3)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(3)", - "uri": "record(4)", - "val": "self-label-a", - }, - Object { - "cid": "cids(3)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(3)", - "uri": "record(4)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(3)", - "following": "record(2)", - "muted": false, - }, - }, - "description": "Provides all feed candidates", - "did": "user(2)", - "displayName": "All", - "indexedAt": "1970-01-01T00:00:00.000Z", - "likeCount": 2, - "uri": "record(1)", - "viewer": Object { - "like": "record(5)", - }, - }, - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.record", - "record": Object { - "cid": "cids(2)", - "uri": "record(1)", - }, - }, - "text": "cool feed!", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(0)", - "viewer": Object {}, -} -`; - -exports[`feed generation getActorFeeds fetches feed generators by actor. 1`] = ` -Array [ - Object { - "cid": "cids(0)", - "creator": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(2)/cids(1)@jpeg", - "description": "its me!", - "did": "user(1)", - "displayName": "ali", - "handle": "alice.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(3)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(3)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(2)", - "following": "record(1)", - "muted": false, - }, - }, - "description": "Provides odd-indexed feed candidates", - "did": "user(0)", - "displayName": "Odd", - "indexedAt": "1970-01-01T00:00:00.000Z", - "likeCount": 0, - "uri": "record(0)", - "viewer": Object {}, - }, - Object { - "cid": "cids(3)", - "creator": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(2)/cids(1)@jpeg", - "description": "its me!", - "did": "user(1)", - "displayName": "ali", - "handle": "alice.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(3)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(3)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(2)", - "following": "record(1)", - "muted": false, - }, - }, - "description": "Provides all feed candidates when authed", - "did": "user(0)", - "displayName": "Needs Auth", - "indexedAt": "1970-01-01T00:00:00.000Z", - "likeCount": 0, - "uri": "record(4)", - "viewer": Object {}, - }, - Object { - "cid": "cids(4)", - "creator": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(2)/cids(1)@jpeg", - "description": "its me!", - "did": "user(1)", - "displayName": "ali", - "handle": "alice.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(3)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(3)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(2)", - "following": "record(1)", - "muted": false, - }, - }, - "description": "Provides all feed candidates, blindly ignoring pagination limit", - "did": "user(0)", - "displayName": "Bad Pagination", - "indexedAt": "1970-01-01T00:00:00.000Z", - "likeCount": 0, - "uri": "record(5)", - "viewer": Object {}, - }, - Object { - "cid": "cids(5)", - "creator": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(2)/cids(1)@jpeg", - "description": "its me!", - "did": "user(1)", - "displayName": "ali", - "handle": "alice.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(3)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(3)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(2)", - "following": "record(1)", - "muted": false, - }, - }, - "description": "Provides even-indexed feed candidates", - "did": "user(0)", - "displayName": "Even", - "indexedAt": "1970-01-01T00:00:00.000Z", - "likeCount": 0, - "uri": "record(6)", - "viewer": Object {}, - }, - Object { - "cid": "cids(6)", - "creator": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(2)/cids(1)@jpeg", - "description": "its me!", - "did": "user(1)", - "displayName": "ali", - "handle": "alice.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(3)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(3)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(2)", - "following": "record(1)", - "muted": false, - }, - }, - "description": "Provides all feed candidates", - "did": "user(0)", - "displayName": "All", - "indexedAt": "1970-01-01T00:00:00.000Z", - "likeCount": 2, - "uri": "record(7)", - "viewer": Object { - "like": "record(8)", - }, - }, -] -`; - -exports[`feed generation getFeed paginates, handling replies and reposts. 1`] = ` -Array [ - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(0)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(0)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(0)", - "val": "self-label", - }, - ], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "labels": Object { - "$type": "com.atproto.label.defs#selfLabels", - "values": Array [ - Object { - "val": "self-label", - }, - ], - }, - "text": "hey there", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(0)", - "viewer": Object {}, - }, - }, - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(3)/cids(1)@jpeg", - "did": "user(2)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(4)", - "following": "record(3)", - "muted": false, - }, - }, - "cid": "cids(3)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "langs": Array [ - "en-US", - "i-klingon", - ], - "text": "bob back at it again!", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(2)", - "viewer": Object {}, - }, - }, - Object { - "post": Object { - "author": Object { - "did": "user(4)", - "handle": "carol.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(7)", - "following": "record(6)", - "muted": false, - }, - }, - "cid": "cids(4)", - "embed": Object { - "$type": "app.bsky.embed.recordWithMedia#view", - "media": Object { - "$type": "app.bsky.embed.images#view", - "images": Array [ - Object { - "alt": "tests/sample-img/key-landscape-small.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(5)/cids(5)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(5)/cids(5)@jpeg", - }, - Object { - "alt": "tests/sample-img/key-alt.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(5)/cids(6)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(5)/cids(6)@jpeg", - }, - ], - }, - "record": Object { - "record": Object { - "$type": "app.bsky.embed.record#viewRecord", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(3)/cids(1)@jpeg", - "did": "user(2)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(4)", - "following": "record(3)", - "muted": false, - }, - }, - "cid": "cids(3)", - "embeds": Array [], - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "uri": "record(2)", - "value": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "langs": Array [ - "en-US", - "i-klingon", - ], - "text": "bob back at it again!", - }, - }, - }, - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 2, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.recordWithMedia", - "media": 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(5)", - }, - "size": 4114, - }, - }, - Object { - "alt": "tests/sample-img/key-alt.jpg", - "image": Object { - "$type": "blob", - "mimeType": "image/jpeg", - "ref": Object { - "$link": "cids(6)", - }, - "size": 12736, - }, - }, - ], - }, - "record": Object { - "record": Object { - "cid": "cids(3)", - "uri": "record(2)", - }, - }, - }, - "text": "hi im carol", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(5)", - "viewer": Object { - "like": "record(8)", - }, - }, - }, - Object { - "post": Object { - "author": Object { - "did": "user(4)", - "handle": "carol.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(7)", - "following": "record(6)", - "muted": false, - }, - }, - "cid": "cids(7)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "reply": Object { - "parent": Object { - "cid": "cids(8)", - "uri": "record(10)", - }, - "root": Object { - "cid": "cids(8)", - "uri": "record(10)", - }, - }, - "text": "of course", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(9)", - "viewer": Object {}, - }, - "reply": Object { - "parent": Object { - "$type": "app.bsky.feed.defs#postView", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(8)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 2, - "repostCount": 1, - "uri": "record(10)", - "viewer": Object {}, - }, - "root": Object { - "$type": "app.bsky.feed.defs#postView", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(8)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 2, - "repostCount": 1, - "uri": "record(10)", - "viewer": Object {}, - }, - }, - }, - Object { - "post": Object { - "author": Object { - "did": "user(6)", - "handle": "dan.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "following": "record(12)", - "muted": false, - }, - }, - "cid": "cids(9)", - "embed": Object { - "$type": "app.bsky.embed.record#view", - "record": Object { - "$type": "app.bsky.embed.record#viewRecord", - "author": Object { - "did": "user(4)", - "handle": "carol.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(7)", - "following": "record(6)", - "muted": false, - }, - }, - "cid": "cids(4)", - "embeds": Array [ - Object { - "$type": "app.bsky.embed.recordWithMedia#view", - "media": Object { - "$type": "app.bsky.embed.images#view", - "images": Array [ - Object { - "alt": "tests/sample-img/key-landscape-small.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(5)/cids(5)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(5)/cids(5)@jpeg", - }, - Object { - "alt": "tests/sample-img/key-alt.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(5)/cids(6)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(5)/cids(6)@jpeg", - }, - ], - }, - "record": Object { - "record": Object { - "$type": "app.bsky.embed.record#viewRecord", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(3)/cids(1)@jpeg", - "did": "user(2)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(4)", - "following": "record(3)", - "muted": false, - }, - }, - "cid": "cids(3)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "uri": "record(2)", - "value": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "langs": Array [ - "en-US", - "i-klingon", - ], - "text": "bob back at it again!", - }, - }, - }, - }, - ], - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "uri": "record(5)", - "value": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.recordWithMedia", - "media": 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(5)", - }, - "size": 4114, - }, - }, - Object { - "alt": "tests/sample-img/key-alt.jpg", - "image": Object { - "$type": "blob", - "mimeType": "image/jpeg", - "ref": Object { - "$link": "cids(6)", - }, - "size": 12736, - }, - }, - ], - }, - "record": Object { - "record": Object { - "cid": "cids(3)", - "uri": "record(2)", - }, - }, - }, - "text": "hi im carol", - }, - }, - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.record", - "record": Object { - "cid": "cids(4)", - "uri": "record(5)", - }, - }, - "facets": Array [ - Object { - "features": Array [ - Object { - "$type": "app.bsky.richtext.facet#mention", - "did": "user(0)", - }, - ], - "index": Object { - "byteEnd": 18, - "byteStart": 0, - }, - }, - ], - "text": "@alice.bluesky.xyz is the best", - }, - "replyCount": 0, - "repostCount": 1, - "uri": "record(11)", - "viewer": Object {}, - }, - "reason": Object { - "$type": "app.bsky.feed.defs#reasonRepost", - "by": Object { - "did": "user(4)", - "handle": "carol.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(7)", - "following": "record(6)", - "muted": false, - }, - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - }, - }, -] -`; - -exports[`feed generation getFeed resolves basic feed contents without auth. 1`] = ` -Array [ - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-b", - }, - ], - }, - "cid": "cids(0)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(0)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(0)", - "val": "self-label", - }, - ], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "labels": Object { - "$type": "com.atproto.label.defs#selfLabels", - "values": Array [ - Object { - "val": "self-label", - }, - ], - }, - "text": "hey there", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(0)", - }, - }, - Object { - "post": Object { - "author": Object { - "did": "user(2)", - "handle": "carol.test", - "labels": Array [], - }, - "cid": "cids(3)", - "embed": Object { - "$type": "app.bsky.embed.recordWithMedia#view", - "media": Object { - "$type": "app.bsky.embed.images#view", - "images": Array [ - Object { - "alt": "tests/sample-img/key-landscape-small.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(5)/cids(4)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(5)/cids(4)@jpeg", - }, - Object { - "alt": "tests/sample-img/key-alt.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(5)/cids(5)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(5)/cids(5)@jpeg", - }, - ], - }, - "record": Object { - "record": Object { - "$type": "app.bsky.embed.record#viewRecord", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(4)/cids(1)@jpeg", - "did": "user(3)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - }, - "cid": "cids(6)", - "embeds": Array [], - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "uri": "record(3)", - "value": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "langs": Array [ - "en-US", - "i-klingon", - ], - "text": "bob back at it again!", - }, - }, - }, - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 2, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.recordWithMedia", - "media": 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(4)", - }, - "size": 4114, - }, - }, - Object { - "alt": "tests/sample-img/key-alt.jpg", - "image": Object { - "$type": "blob", - "mimeType": "image/jpeg", - "ref": Object { - "$link": "cids(5)", - }, - "size": 12736, - }, - }, - ], - }, - "record": Object { - "record": Object { - "cid": "cids(6)", - "uri": "record(3)", - }, - }, - }, - "text": "hi im carol", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(2)", - }, - }, - Object { - "post": Object { - "author": Object { - "did": "user(2)", - "handle": "carol.test", - "labels": Array [], - }, - "cid": "cids(7)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "reply": Object { - "parent": Object { - "cid": "cids(8)", - "uri": "record(5)", - }, - "root": Object { - "cid": "cids(8)", - "uri": "record(5)", - }, - }, - "text": "of course", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(4)", - }, - "reply": Object { - "parent": Object { - "$type": "app.bsky.feed.defs#postView", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-b", - }, - ], - }, - "cid": "cids(8)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 2, - "repostCount": 1, - "uri": "record(5)", - }, - "root": Object { - "$type": "app.bsky.feed.defs#postView", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-b", - }, - ], - }, - "cid": "cids(8)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 2, - "repostCount": 1, - "uri": "record(5)", - }, - }, - }, -] -`; - -exports[`feed generation getFeed resolves basic feed contents. 1`] = ` -Array [ - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(0)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(0)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(0)", - "val": "self-label", - }, - ], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "labels": Object { - "$type": "com.atproto.label.defs#selfLabels", - "values": Array [ - Object { - "val": "self-label", - }, - ], - }, - "text": "hey there", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(0)", - "viewer": Object {}, - }, - }, - Object { - "post": Object { - "author": Object { - "did": "user(2)", - "handle": "carol.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(4)", - "following": "record(3)", - "muted": false, - }, - }, - "cid": "cids(3)", - "embed": Object { - "$type": "app.bsky.embed.recordWithMedia#view", - "media": Object { - "$type": "app.bsky.embed.images#view", - "images": Array [ - Object { - "alt": "tests/sample-img/key-landscape-small.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(5)/cids(4)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(5)/cids(4)@jpeg", - }, - Object { - "alt": "tests/sample-img/key-alt.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(5)/cids(5)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(5)/cids(5)@jpeg", - }, - ], - }, - "record": Object { - "record": Object { - "$type": "app.bsky.embed.record#viewRecord", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(4)/cids(1)@jpeg", - "did": "user(3)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(7)", - "following": "record(6)", - "muted": false, - }, - }, - "cid": "cids(6)", - "embeds": Array [], - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "uri": "record(5)", - "value": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "langs": Array [ - "en-US", - "i-klingon", - ], - "text": "bob back at it again!", - }, - }, - }, - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 2, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.recordWithMedia", - "media": 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(4)", - }, - "size": 4114, - }, - }, - Object { - "alt": "tests/sample-img/key-alt.jpg", - "image": Object { - "$type": "blob", - "mimeType": "image/jpeg", - "ref": Object { - "$link": "cids(5)", - }, - "size": 12736, - }, - }, - ], - }, - "record": Object { - "record": Object { - "cid": "cids(6)", - "uri": "record(5)", - }, - }, - }, - "text": "hi im carol", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(2)", - "viewer": Object { - "like": "record(8)", - }, - }, - }, - Object { - "post": Object { - "author": Object { - "did": "user(2)", - "handle": "carol.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(4)", - "following": "record(3)", - "muted": false, - }, - }, - "cid": "cids(7)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "reply": Object { - "parent": Object { - "cid": "cids(8)", - "uri": "record(10)", - }, - "root": Object { - "cid": "cids(8)", - "uri": "record(10)", - }, - }, - "text": "of course", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(9)", - "viewer": Object {}, - }, - "reply": Object { - "parent": Object { - "$type": "app.bsky.feed.defs#postView", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(8)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 2, - "repostCount": 1, - "uri": "record(10)", - "viewer": Object {}, - }, - "root": Object { - "$type": "app.bsky.feed.defs#postView", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(8)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 2, - "repostCount": 1, - "uri": "record(10)", - "viewer": Object {}, - }, - }, - }, -] -`; - -exports[`feed generation getFeedGenerator describes a feed gen & returns online status 1`] = ` -Object { - "isOnline": true, - "isValid": true, - "view": Object { - "cid": "cids(0)", - "creator": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(2)/cids(1)@jpeg", - "did": "user(1)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(3)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(3)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(2)", - "following": "record(1)", - "muted": false, - }, - }, - "description": "Provides all feed candidates", - "did": "user(0)", - "displayName": "All", - "indexedAt": "1970-01-01T00:00:00.000Z", - "likeCount": 2, - "uri": "record(0)", - "viewer": Object { - "like": "record(4)", - }, - }, -} -`; - -exports[`feed generation getFeedGenerators describes multiple feed gens 1`] = ` -Object { - "feeds": Array [ - Object { - "cid": "cids(0)", - "creator": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(2)/cids(1)@jpeg", - "did": "user(1)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(3)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(3)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(2)", - "following": "record(1)", - "muted": false, - }, - }, - "description": "Provides all feed candidates", - "did": "user(0)", - "displayName": "All", - "indexedAt": "1970-01-01T00:00:00.000Z", - "likeCount": 2, - "uri": "record(0)", - "viewer": Object { - "like": "record(4)", - }, - }, - Object { - "cid": "cids(3)", - "creator": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(2)/cids(1)@jpeg", - "did": "user(1)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(3)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(3)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(2)", - "following": "record(1)", - "muted": false, - }, - }, - "description": "Provides even-indexed feed candidates", - "did": "user(0)", - "displayName": "Even", - "indexedAt": "1970-01-01T00:00:00.000Z", - "likeCount": 0, - "uri": "record(5)", - "viewer": Object {}, - }, - ], -} -`; - -exports[`feed generation getSuggestedFeeds returns list of suggested feed generators 1`] = ` -Object { - "feeds": Array [ - Object { - "cid": "cids(0)", - "creator": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(2)/cids(1)@jpeg", - "did": "user(1)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(3)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(3)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(2)", - "following": "record(1)", - "muted": false, - }, - }, - "description": "Provides all feed candidates", - "did": "user(0)", - "displayName": "All", - "indexedAt": "1970-01-01T00:00:00.000Z", - "likeCount": 2, - "uri": "record(0)", - "viewer": Object { - "like": "record(4)", - }, - }, - Object { - "cid": "cids(3)", - "creator": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(2)/cids(1)@jpeg", - "did": "user(1)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(3)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(3)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(2)", - "following": "record(1)", - "muted": false, - }, - }, - "description": "Provides even-indexed feed candidates", - "did": "user(0)", - "displayName": "Even", - "indexedAt": "1970-01-01T00:00:00.000Z", - "likeCount": 0, - "uri": "record(5)", - "viewer": Object {}, - }, - Object { - "cid": "cids(4)", - "creator": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(2)/cids(1)@jpeg", - "did": "user(1)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(3)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(3)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(2)", - "following": "record(1)", - "muted": false, - }, - }, - "description": "Provides all feed candidates, blindly ignoring pagination limit", - "did": "user(0)", - "displayName": "Bad Pagination", - "indexedAt": "1970-01-01T00:00:00.000Z", - "likeCount": 0, - "uri": "record(6)", - "viewer": Object {}, - }, - ], -} -`; diff --git a/packages/ozone/tests/admin/__snapshots__/get-record.test.ts.snap b/packages/ozone/tests/__snapshots__/get-record.test.ts.snap similarity index 100% rename from packages/ozone/tests/admin/__snapshots__/get-record.test.ts.snap rename to packages/ozone/tests/__snapshots__/get-record.test.ts.snap diff --git a/packages/ozone/tests/admin/__snapshots__/get-repo.test.ts.snap b/packages/ozone/tests/__snapshots__/get-repo.test.ts.snap similarity index 100% rename from packages/ozone/tests/admin/__snapshots__/get-repo.test.ts.snap rename to packages/ozone/tests/__snapshots__/get-repo.test.ts.snap diff --git a/packages/ozone/tests/__snapshots__/indexing.test.ts.snap b/packages/ozone/tests/__snapshots__/indexing.test.ts.snap deleted file mode 100644 index 88c02c6e3e0..00000000000 --- a/packages/ozone/tests/__snapshots__/indexing.test.ts.snap +++ /dev/null @@ -1,668 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`indexing indexRepo updates indexes when records change. 1`] = ` -Array [ - Object { - "description": "freshening things up", - "did": "user(0)", - "followersCount": 2, - "followsCount": 2, - "handle": "alice.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "postsCount": 5, - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - Object { - "cursor": "0000000000000::bafycid", - "feed": Array [ - Object { - "post": Object { - "author": Object { - "did": "user(0)", - "handle": "alice.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(0)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "text": "fresh post!", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(0)", - "viewer": Object {}, - }, - }, - Object { - "post": Object { - "author": Object { - "did": "user(0)", - "handle": "alice.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(1)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "reply": Object { - "parent": Object { - "cid": "cids(3)", - "uri": "record(3)", - }, - "root": Object { - "cid": "cids(2)", - "uri": "record(2)", - }, - }, - "text": "thanks bob", - }, - "replyCount": 0, - "repostCount": 1, - "uri": "record(1)", - "viewer": Object {}, - }, - "reply": Object { - "parent": Object { - "$type": "app.bsky.feed.defs#postView", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(2)/cids(4)@jpeg", - "did": "user(1)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(5)", - "following": "record(4)", - "muted": false, - }, - }, - "cid": "cids(3)", - "embed": Object { - "$type": "app.bsky.embed.images#view", - "images": Array [ - Object { - "alt": "tests/sample-img/key-landscape-small.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(2)/cids(5)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(2)/cids(5)@jpeg", - }, - ], - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(3)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(3)", - "val": "test-label", - }, - Object { - "cid": "cids(3)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(3)", - "val": "test-label-2", - }, - ], - "likeCount": 0, - "record": 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(5)", - }, - "size": 4114, - }, - }, - ], - }, - "reply": Object { - "parent": Object { - "cid": "cids(2)", - "uri": "record(2)", - }, - "root": Object { - "cid": "cids(2)", - "uri": "record(2)", - }, - }, - "text": "hear that label_me label_me_2", - }, - "replyCount": 1, - "repostCount": 0, - "uri": "record(3)", - "viewer": Object {}, - }, - "root": Object { - "$type": "app.bsky.feed.defs#postView", - "author": Object { - "did": "user(0)", - "handle": "alice.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(2)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 2, - "repostCount": 1, - "uri": "record(2)", - "viewer": Object {}, - }, - }, - }, - Object { - "post": Object { - "author": Object { - "did": "user(0)", - "handle": "alice.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(6)", - "embed": Object { - "$type": "app.bsky.embed.record#view", - "record": Object { - "$type": "app.bsky.embed.record#viewRecord", - "author": Object { - "did": "user(3)", - "handle": "dan.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "following": "record(8)", - "muted": false, - }, - }, - "cid": "cids(7)", - "embeds": Array [ - Object { - "$type": "app.bsky.embed.record#view", - "record": Object { - "$type": "app.bsky.embed.record#viewRecord", - "author": Object { - "did": "user(4)", - "handle": "carol.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(10)", - "muted": false, - }, - }, - "cid": "cids(8)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "uri": "record(9)", - "value": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.recordWithMedia", - "media": 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(5)", - }, - "size": 4114, - }, - }, - Object { - "alt": "tests/sample-img/key-alt.jpg", - "image": Object { - "$type": "blob", - "mimeType": "image/jpeg", - "ref": Object { - "$link": "cids(9)", - }, - "size": 12736, - }, - }, - ], - }, - "record": Object { - "record": Object { - "cid": "cids(10)", - "uri": "record(11)", - }, - }, - }, - "text": "hi im carol", - }, - }, - }, - ], - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "uri": "record(7)", - "value": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.record", - "record": Object { - "cid": "cids(8)", - "uri": "record(9)", - }, - }, - "facets": Array [ - Object { - "features": Array [ - Object { - "$type": "app.bsky.richtext.facet#mention", - "did": "user(0)", - }, - ], - "index": Object { - "byteEnd": 18, - "byteStart": 0, - }, - }, - ], - "text": "@alice.bluesky.xyz is the best", - }, - }, - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(6)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(6)", - "val": "test-label", - }, - ], - "likeCount": 2, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.record", - "record": Object { - "cid": "cids(7)", - "uri": "record(7)", - }, - }, - "text": "yoohoo label_me", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(6)", - "viewer": Object {}, - }, - }, - Object { - "post": Object { - "author": Object { - "did": "user(0)", - "handle": "alice.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(2)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 2, - "repostCount": 1, - "uri": "record(2)", - "viewer": Object {}, - }, - }, - Object { - "post": Object { - "author": Object { - "did": "user(0)", - "handle": "alice.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(11)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(11)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(12)", - "val": "self-label", - }, - ], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "labels": Object { - "$type": "com.atproto.label.defs#selfLabels", - "values": Array [ - Object { - "val": "self-label", - }, - ], - }, - "text": "hey there", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(12)", - "viewer": Object {}, - }, - }, - ], - }, - Object { - "cursor": "0000000000000::bafycid", - "follows": Array [ - Object { - "did": "user(3)", - "handle": "dan.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "following": "record(8)", - "muted": false, - }, - }, - Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(2)/cids(4)@jpeg", - "description": "hi im bob label_me", - "did": "user(1)", - "displayName": "bobby", - "handle": "bob.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(5)", - "following": "record(4)", - "muted": false, - }, - }, - ], - "subject": Object { - "description": "freshening things up", - "did": "user(0)", - "handle": "alice.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - }, -] -`; - -exports[`indexing indexes posts. 1`] = ` -Object { - "thread": Object { - "$type": "app.bsky.feed.defs#threadViewPost", - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(0)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "facets": Array [ - Object { - "features": Array [ - Object { - "$type": "app.bsky.richtext.facet#mention", - "did": "user(2)", - }, - ], - "index": Object { - "byteEnd": 9, - "byteStart": 0, - }, - }, - ], - "text": "@bob.test how are you?", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(0)", - "viewer": Object {}, - }, - "replies": Array [], - }, -} -`; - -exports[`indexing indexes posts. 2`] = ` -Object { - "thread": Object { - "$type": "app.bsky.feed.defs#threadViewPost", - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(0)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "facets": Array [ - Object { - "features": Array [ - Object { - "$type": "app.bsky.richtext.facet#mention", - "did": "user(2)", - }, - ], - "index": Object { - "byteEnd": 11, - "byteStart": 0, - }, - }, - ], - "text": "@carol.test how are you?", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(0)", - "viewer": Object {}, - }, - "replies": Array [], - }, -} -`; - -exports[`indexing indexes posts. 3`] = ` -Object { - "createNotifications": Array [ - Object { - "author": "user(1)", - "did": "user(0)", - "id": 0, - "reason": "mention", - "reasonSubject": null, - "recordCid": "cids(0)", - "recordUri": "record(0)", - "sortAt": "1970-01-01T00:00:00.000Z", - }, - ], - "deleteNotifications": Array [], - "updateNotifications": Array [ - Object { - "author": "user(1)", - "did": "user(2)", - "id": 0, - "reason": "mention", - "reasonSubject": null, - "recordCid": "cids(1)", - "recordUri": "record(0)", - "sortAt": "1970-01-01T00:00:00.000Z", - }, - ], -} -`; - -exports[`indexing indexes profiles. 1`] = ` -Object { - "did": "user(0)", - "displayName": "dan", - "followersCount": 0, - "followsCount": 0, - "handle": "dan.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "postsCount": 0, - "viewer": Object { - "blockedBy": false, - "muted": false, - }, -} -`; - -exports[`indexing indexes profiles. 2`] = ` -Object { - "did": "user(0)", - "displayName": "danny", - "followersCount": 0, - "followsCount": 0, - "handle": "dan.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "postsCount": 0, - "viewer": Object { - "blockedBy": false, - "muted": false, - }, -} -`; - -exports[`indexing indexes profiles. 3`] = ` -Object { - "did": "user(0)", - "followersCount": 0, - "followsCount": 0, - "handle": "dan.test", - "labels": Array [], - "postsCount": 0, - "viewer": Object { - "blockedBy": false, - "muted": false, - }, -} -`; diff --git a/packages/ozone/tests/admin/__snapshots__/moderation-events.test.ts.snap b/packages/ozone/tests/__snapshots__/moderation-events.test.ts.snap similarity index 100% rename from packages/ozone/tests/admin/__snapshots__/moderation-events.test.ts.snap rename to packages/ozone/tests/__snapshots__/moderation-events.test.ts.snap diff --git a/packages/ozone/tests/admin/__snapshots__/moderation-statuses.test.ts.snap b/packages/ozone/tests/__snapshots__/moderation-statuses.test.ts.snap similarity index 100% rename from packages/ozone/tests/admin/__snapshots__/moderation-statuses.test.ts.snap rename to packages/ozone/tests/__snapshots__/moderation-statuses.test.ts.snap diff --git a/packages/ozone/tests/admin/__snapshots__/moderation.test.ts.snap b/packages/ozone/tests/__snapshots__/moderation.test.ts.snap similarity index 100% rename from packages/ozone/tests/admin/__snapshots__/moderation.test.ts.snap rename to packages/ozone/tests/__snapshots__/moderation.test.ts.snap diff --git a/packages/ozone/tests/algos/hot-classic.test.ts b/packages/ozone/tests/algos/hot-classic.test.ts deleted file mode 100644 index bb44ca5c0e8..00000000000 --- a/packages/ozone/tests/algos/hot-classic.test.ts +++ /dev/null @@ -1,88 +0,0 @@ -import AtpAgent, { AtUri } from '@atproto/api' -import { TestNetwork, SeedClient } from '@atproto/dev-env' -import basicSeed from '../seeds/basic' -import { makeAlgos } from '../../src' - -describe('algo hot-classic', () => { - let network: TestNetwork - let agent: AtpAgent - let sc: SeedClient - - // account dids, for convenience - let alice: string - let bob: string - - const feedPublisherDid = 'did:example:feed-publisher' - const feedUri = AtUri.make( - feedPublisherDid, - 'app.bsky.feed.generator', - 'hot-classic', - ).toString() - - beforeAll(async () => { - network = await TestNetwork.create({ - dbPostgresSchema: 'bsky_algo_hot_classic', - bsky: { algos: makeAlgos(feedPublisherDid) }, - }) - agent = new AtpAgent({ service: network.bsky.url }) - sc = network.getSeedClient() - await basicSeed(sc) - - alice = sc.dids.alice - bob = sc.dids.bob - await network.processAll() - }) - - afterAll(async () => { - await network.close() - }) - - it('returns well liked posts', async () => { - const img = await sc.uploadFile( - alice, - 'tests/sample-img/key-landscape-small.jpg', - 'image/jpeg', - ) - const one = await sc.post(alice, 'first post', undefined, [img]) - const two = await sc.post(bob, 'bobby boi') - const three = await sc.reply(bob, one.ref, one.ref, 'reply') - - for (let i = 0; i < 12; i++) { - const name = `user${i}` - await sc.createAccount(name, { - handle: `user${i}.test`, - email: `user${i}@test.com`, - password: 'password', - }) - await sc.like(sc.dids[name], one.ref) - await sc.like(sc.dids[name], two.ref) - await sc.like(sc.dids[name], three.ref) - } - await network.processAll() - - const res = await agent.api.app.bsky.feed.getFeed( - { feed: feedUri }, - { headers: await network.serviceHeaders(alice) }, - ) - const feedUris = res.data.feed.map((i) => i.post.uri).sort() - const expected = [one.ref.uriStr, two.ref.uriStr].sort() - expect(feedUris).toEqual(expected) - }) - - it('paginates', async () => { - const res = await agent.api.app.bsky.feed.getFeed( - { feed: feedUri }, - { headers: await network.serviceHeaders(alice) }, - ) - const first = await agent.api.app.bsky.feed.getFeed( - { feed: feedUri, limit: 1 }, - { headers: await network.serviceHeaders(alice) }, - ) - const second = await agent.api.app.bsky.feed.getFeed( - { feed: feedUri, cursor: first.data.cursor }, - { headers: await network.serviceHeaders(alice) }, - ) - - expect([...first.data.feed, ...second.data.feed]).toEqual(res.data.feed) - }) -}) diff --git a/packages/ozone/tests/auth.test.ts b/packages/ozone/tests/auth.test.ts deleted file mode 100644 index 6b3fbd6b73d..00000000000 --- a/packages/ozone/tests/auth.test.ts +++ /dev/null @@ -1,64 +0,0 @@ -import AtpAgent from '@atproto/api' -import { SeedClient, TestNetwork } from '@atproto/dev-env' -import usersSeed from './seeds/users' -import { createServiceJwt } from '@atproto/xrpc-server' -import { Keypair, Secp256k1Keypair } from '@atproto/crypto' - -describe('auth', () => { - let network: TestNetwork - let agent: AtpAgent - let sc: SeedClient - - beforeAll(async () => { - network = await TestNetwork.create({ - dbPostgresSchema: 'bsky_auth', - }) - agent = network.bsky.getClient() - sc = network.getSeedClient() - await usersSeed(sc) - await network.processAll() - }) - - afterAll(async () => { - await network.close() - }) - - it('handles signing key change for service auth.', async () => { - const issuer = sc.dids.alice - const attemptWithKey = async (keypair: Keypair) => { - const jwt = await createServiceJwt({ - iss: issuer, - aud: network.bsky.ctx.cfg.serverDid, - keypair, - }) - return agent.api.app.bsky.actor.getProfile( - { actor: sc.dids.carol }, - { headers: { authorization: `Bearer ${jwt}` } }, - ) - } - const origSigningKey = await network.pds.ctx.actorStore.keypair(issuer) - const newSigningKey = await Secp256k1Keypair.create({ exportable: true }) - // confirm original signing key works - await expect(attemptWithKey(origSigningKey)).resolves.toBeDefined() - // confirm next signing key doesn't work yet - await expect(attemptWithKey(newSigningKey)).rejects.toThrow( - 'jwt signature does not match jwt issuer', - ) - // update to new signing key - await network.plc - .getClient() - .updateAtprotoKey( - issuer, - network.pds.ctx.plcRotationKey, - newSigningKey.did(), - ) - // old signing key still works due to did doc cache - await expect(attemptWithKey(origSigningKey)).resolves.toBeDefined() - // new signing key works - await expect(attemptWithKey(newSigningKey)).resolves.toBeDefined() - // old signing key no longer works after cache is updated - await expect(attemptWithKey(origSigningKey)).rejects.toThrow( - 'jwt signature does not match jwt issuer', - ) - }) -}) diff --git a/packages/ozone/tests/auto-moderator/fixtures/hiveai_resp_example.json b/packages/ozone/tests/auto-moderator/fixtures/hiveai_resp_example.json deleted file mode 100644 index 2315fa9d0c0..00000000000 --- a/packages/ozone/tests/auto-moderator/fixtures/hiveai_resp_example.json +++ /dev/null @@ -1,401 +0,0 @@ -{ - "id": "02122580-c37f-11ed-81d2-000000000000", - "code": 200, - "project_id": 12345, - "user_id": 12345, - "created_on": "2023-03-15T22:16:18.408Z", - "status": [ - { - "status": { - "code": "0", - "message": "SUCCESS" - }, - "response": { - "input": { - "id": "02122580-c37f-11ed-81d2-000000000000", - "charge": 0.003, - "model": "mod55_dense", - "model_version": 1, - "model_type": "CATEGORIZATION", - "created_on": "2023-03-15T22:16:18.136Z", - "media": { - "url": null, - "filename": "bafkreiam7k6mvkyuoybq4ynhljvj5xa75sdbhjbolzjf5j2udx7vj5gnsy", - "type": "PHOTO", - "mime_type": "jpeg", - "mimetype": "image/jpeg", - "width": 800, - "height": 800, - "num_frames": 1, - "duration": 0 - }, - "user_id": 12345, - "project_id": 12345, - "config_version": 1, - "config_tag": "default" - }, - "output": [ - { - "time": 0, - "classes": [ - { - "class": "general_not_nsfw_not_suggestive", - "score": 0.9998097218132356 - }, - { - "class": "general_nsfw", - "score": 8.857344804177162e-5 - }, - { - "class": "general_suggestive", - "score": 0.00010170473872266839 - }, - { - "class": "no_female_underwear", - "score": 0.9999923079040384 - }, - { - "class": "yes_female_underwear", - "score": 7.692095961599136e-6 - }, - { - "class": "no_male_underwear", - "score": 0.9999984904867634 - }, - { - "class": "yes_male_underwear", - "score": 1.5095132367094679e-6 - }, - { - "class": "no_sex_toy", - "score": 0.9999970970762551 - }, - { - "class": "yes_sex_toy", - "score": 2.9029237450490604e-6 - }, - { - "class": "no_female_nudity", - "score": 0.9999739028909301 - }, - { - "class": "yes_female_nudity", - "score": 2.60971090699536e-5 - }, - { - "class": "no_male_nudity", - "score": 0.9999711373083747 - }, - { - "class": "yes_male_nudity", - "score": 2.8862691625255323e-5 - }, - { - "class": "no_female_swimwear", - "score": 0.9999917609899659 - }, - { - "class": "yes_female_swimwear", - "score": 8.239010034025379e-6 - }, - { - "class": "no_male_shirtless", - "score": 0.9999583350744331 - }, - { - "class": "yes_male_shirtless", - "score": 4.166492556688088e-5 - }, - { - "class": "no_text", - "score": 0.9958378716447616 - }, - { - "class": "text", - "score": 0.0041621283552384265 - }, - { - "class": "animated", - "score": 0.46755478950048235 - }, - { - "class": "hybrid", - "score": 0.0011440363434524984 - }, - { - "class": "natural", - "score": 0.5313011741560651 - }, - { - "class": "animated_gun", - "score": 2.0713000782979496e-5 - }, - { - "class": "gun_in_hand", - "score": 1.5844730446534659e-6 - }, - { - "class": "gun_not_in_hand", - "score": 1.0338973818006654e-6 - }, - { - "class": "no_gun", - "score": 0.9999766686287906 - }, - { - "class": "culinary_knife_in_hand", - "score": 3.8063500083369785e-6 - }, - { - "class": "culinary_knife_not_in_hand", - "score": 7.94057948996249e-7 - }, - { - "class": "knife_in_hand", - "score": 4.5578955723278505e-7 - }, - { - "class": "knife_not_in_hand", - "score": 3.842124714748908e-7 - }, - { - "class": "no_knife", - "score": 0.999994559590014 - }, - { - "class": "a_little_bloody", - "score": 2.1317745626539786e-7 - }, - { - "class": "no_blood", - "score": 0.9999793341236429 - }, - { - "class": "other_blood", - "score": 2.0322054269591763e-5 - }, - { - "class": "very_bloody", - "score": 1.306446309561673e-7 - }, - { - "class": "no_pills", - "score": 0.9999989592376954 - }, - { - "class": "yes_pills", - "score": 1.0407623044588633e-6 - }, - { - "class": "no_smoking", - "score": 0.9999939101969173 - }, - { - "class": "yes_smoking", - "score": 6.089803082758281e-6 - }, - { - "class": "illicit_injectables", - "score": 6.925695592003094e-7 - }, - { - "class": "medical_injectables", - "score": 8.587808234452378e-7 - }, - { - "class": "no_injectables", - "score": 0.9999984486496174 - }, - { - "class": "no_nazi", - "score": 0.9999987449628097 - }, - { - "class": "yes_nazi", - "score": 1.2550371902234279e-6 - }, - { - "class": "no_kkk", - "score": 0.999999762417549 - }, - { - "class": "yes_kkk", - "score": 2.3758245111050425e-7 - }, - { - "class": "no_middle_finger", - "score": 0.9999881515231847 - }, - { - "class": "yes_middle_finger", - "score": 1.184847681536747e-5 - }, - { - "class": "no_terrorist", - "score": 0.9999998870793229 - }, - { - "class": "yes_terrorist", - "score": 1.1292067715380635e-7 - }, - { - "class": "no_overlay_text", - "score": 0.9996453363440359 - }, - { - "class": "yes_overlay_text", - "score": 0.0003546636559640924 - }, - { - "class": "no_sexual_activity", - "score": 0.9999563580374798 - }, - { - "class": "yes_sexual_activity", - "score": 0.99, - "realScore": 4.364196252012032e-5 - }, - { - "class": "hanging", - "score": 3.6435135762510905e-7 - }, - { - "class": "no_hanging_no_noose", - "score": 0.9999980779196416 - }, - { - "class": "noose", - "score": 1.5577290007796094e-6 - }, - { - "class": "no_realistic_nsfw", - "score": 0.9999944341007805 - }, - { - "class": "yes_realistic_nsfw", - "score": 5.565899219571182e-6 - }, - { - "class": "animated_corpse", - "score": 5.276802046755426e-7 - }, - { - "class": "human_corpse", - "score": 2.5449360984211012e-8 - }, - { - "class": "no_corpse", - "score": 0.9999994468704343 - }, - { - "class": "no_self_harm", - "score": 0.9999994515625507 - }, - { - "class": "yes_self_harm", - "score": 5.484374493605692e-7 - }, - { - "class": "no_drawing", - "score": 0.9978276028816608 - }, - { - "class": "yes_drawing", - "score": 0.0021723971183392485 - }, - { - "class": "no_emaciated_body", - "score": 0.9999998146500432 - }, - { - "class": "yes_emaciated_body", - "score": 1.853499568724518e-7 - }, - { - "class": "no_child_present", - "score": 0.9999970498515446 - }, - { - "class": "yes_child_present", - "score": 2.950148455380443e-6 - }, - { - "class": "no_sexual_intent", - "score": 0.9999963861546292 - }, - { - "class": "yes_sexual_intent", - "score": 3.613845370766111e-6 - }, - { - "class": "animal_genitalia_and_human", - "score": 2.255472023465222e-8 - }, - { - "class": "animal_genitalia_only", - "score": 4.6783185199931176e-7 - }, - { - "class": "animated_animal_genitalia", - "score": 6.707857419436447e-7 - }, - { - "class": "no_animal_genitalia", - "score": 0.9999988388276858 - }, - { - "class": "no_gambling", - "score": 0.9999960939687145 - }, - { - "class": "yes_gambling", - "score": 3.906031285604864e-6 - }, - { - "class": "no_undressed", - "score": 0.99999923356218 - }, - { - "class": "yes_undressed", - "score": 7.664378199789045e-7 - }, - { - "class": "no_confederate", - "score": 0.9999925456900376 - }, - { - "class": "yes_confederate", - "score": 7.454309962453175e-6 - }, - { - "class": "animated_alcohol", - "score": 1.8109949948066074e-6 - }, - { - "class": "no_alcohol", - "score": 0.9999916620957963 - }, - { - "class": "yes_alcohol", - "score": 5.88781463445443e-6 - }, - { - "class": "yes_drinking_alcohol", - "score": 6.390945746578106e-7 - }, - { - "class": "no_religious_icon", - "score": 0.9999862158580689 - }, - { - "class": "yes_religious_icon", - "score": 1.3784141931119298e-5 - } - ] - } - ] - } - } - ], - "from_cache": false -} diff --git a/packages/ozone/tests/auto-moderator/fuzzy-matcher.test.ts b/packages/ozone/tests/auto-moderator/fuzzy-matcher.test.ts deleted file mode 100644 index 60fe50d582d..00000000000 --- a/packages/ozone/tests/auto-moderator/fuzzy-matcher.test.ts +++ /dev/null @@ -1,165 +0,0 @@ -import { TestNetwork, SeedClient } from '@atproto/dev-env' -import { FuzzyMatcher, encode } from '../../src/auto-moderator/fuzzy-matcher' -import basicSeed from '../seeds/basic' -import { AtpAgent } from '@atproto/api' -import { ImageInvalidator } from '../../src/image/invalidator' - -describe('fuzzy matcher', () => { - let network: TestNetwork - let agent: AtpAgent - let sc: SeedClient - let fuzzyMatcher: FuzzyMatcher - - let alice: string - - beforeAll(async () => { - network = await TestNetwork.create({ - dbPostgresSchema: 'fuzzy_matcher', - bsky: { - imgInvalidator: new NoopInvalidator(), - indexer: { - fuzzyMatchB64: encode(['evil']), - }, - }, - }) - fuzzyMatcher = new FuzzyMatcher(['evil', 'mean', 'bad'], ['baddie']) - agent = network.pds.getClient() - sc = network.getSeedClient() - await basicSeed(sc) - await network.processAll() - alice = sc.dids.alice - }) - - afterAll(async () => { - await network.close() - }) - - const getAllReports = () => { - return network.bsky.ctx.db - .getPrimary() - .db.selectFrom('moderation_event') - .where('action', '=', 'com.atproto.admin.defs#modEventReport') - .selectAll() - .orderBy('id', 'asc') - .execute() - } - - it('identifies fuzzy matches', () => { - expect(fuzzyMatcher.getMatches('evil.john.test')).toMatchObject(['evil']) - expect(fuzzyMatcher.getMatches('john.evil.test')).toMatchObject(['evil']) - expect(fuzzyMatcher.getMatches('john.test.evil')).toMatchObject(['evil']) - expect(fuzzyMatcher.getMatches('ev1l.test.john')).toMatchObject(['evil']) - expect(fuzzyMatcher.getMatches('ev-1l.test.john')).toMatchObject(['evil']) - expect(fuzzyMatcher.getMatches('ev-11.test.john')).toMatchObject(['evil']) - expect(fuzzyMatcher.getMatches('ev.-1.l-test.john')).toMatchObject(['evil']) - }) - - it('identifies fuzzy false positivies', () => { - expect(fuzzyMatcher.getMatches('john.test')).toHaveLength(0) - expect(fuzzyMatcher.getMatches('good.john.test')).toHaveLength(0) - expect(fuzzyMatcher.getMatches('john.baddie.test')).toHaveLength(0) - }) - - it('doesnt label any of the content in the seed', async () => { - const reports = await getAllReports() - expect(reports.length).toBe(0) - }) - - it('flags a handle with an unacceptable word', async () => { - await sc.updateHandle(alice, 'evil.test') - await network.processAll() - const reports = await getAllReports() - expect(reports.length).toBe(1) - expect(reports.at(-1)?.subjectDid).toEqual(alice) - }) - - it('flags a profile with an unacceptable displayName', async () => { - const res = await agent.api.com.atproto.repo.putRecord( - { - repo: alice, - collection: 'app.bsky.actor.profile', - rkey: 'self', - record: { - displayName: 'evil alice', - }, - }, - { headers: sc.getHeaders(alice), encoding: 'application/json' }, - ) - await network.processAll() - - const reports = await getAllReports() - expect(reports.length).toBe(2) - expect(reports.at(-1)?.subjectUri).toEqual(res.data.uri) - expect(reports.at(-1)?.subjectCid).toEqual(res.data.cid) - }) - - it('flags a list with an unacceptable name', async () => { - const res = await agent.api.com.atproto.repo.createRecord( - { - repo: alice, - collection: 'app.bsky.graph.list', - rkey: 'list', - record: { - name: 'myevillist', - purpose: 'app.bsky.graph.defs#modList', - createdAt: new Date().toISOString(), - }, - }, - { headers: sc.getHeaders(alice), encoding: 'application/json' }, - ) - await network.processAll() - - const reports = await getAllReports() - expect(reports.length).toBe(3) - expect(reports.at(-1)?.subjectUri).toEqual(res.data.uri) - expect(reports.at(-1)?.subjectCid).toEqual(res.data.cid) - }) - - it('flags a feed generator with an unacceptable displayName', async () => { - const res = await agent.api.com.atproto.repo.createRecord( - { - repo: alice, - collection: 'app.bsky.feed.generator', - rkey: 'generator', - record: { - did: alice, - displayName: 'myevilfeed', - createdAt: new Date().toISOString(), - }, - }, - { headers: sc.getHeaders(alice), encoding: 'application/json' }, - ) - await network.processAll() - - const reports = await getAllReports() - expect(reports.length).toBe(4) - expect(reports.at(-1)?.subjectUri).toEqual(res.data.uri) - expect(reports.at(-1)?.subjectCid).toEqual(res.data.cid) - }) - - it('flags a record with an unacceptable rkey', async () => { - const res = await agent.api.com.atproto.repo.createRecord( - { - repo: alice, - collection: 'app.bsky.feed.generator', - rkey: 'evilrkey', - record: { - did: alice, - displayName: 'totally fine feed', - createdAt: new Date().toISOString(), - }, - }, - { headers: sc.getHeaders(alice), encoding: 'application/json' }, - ) - await network.processAll() - - const reports = await getAllReports() - expect(reports.length).toBe(5) - expect(reports.at(-1)?.subjectUri).toEqual(res.data.uri) - expect(reports.at(-1)?.subjectCid).toEqual(res.data.cid) - }) -}) - -class NoopInvalidator implements ImageInvalidator { - async invalidate() {} -} diff --git a/packages/ozone/tests/auto-moderator/hive.test.ts b/packages/ozone/tests/auto-moderator/hive.test.ts deleted file mode 100644 index 3a5cef45a37..00000000000 --- a/packages/ozone/tests/auto-moderator/hive.test.ts +++ /dev/null @@ -1,16 +0,0 @@ -import fs from 'fs/promises' -import * as hive from '../../src/auto-moderator/hive' - -describe('labeling', () => { - it('correctly parses hive responses', async () => { - const exampleRespBytes = await fs.readFile( - 'tests/auto-moderator/fixtures/hiveai_resp_example.json', - ) - const exampleResp = JSON.parse(exampleRespBytes.toString()) - const classes = hive.respToClasses(exampleResp) - expect(classes.length).toBeGreaterThan(10) - - const labels = hive.summarizeLabels(classes) - expect(labels).toEqual(['porn']) - }) -}) diff --git a/packages/ozone/tests/auto-moderator/labeler.test.ts b/packages/ozone/tests/auto-moderator/labeler.test.ts deleted file mode 100644 index 3687a360980..00000000000 --- a/packages/ozone/tests/auto-moderator/labeler.test.ts +++ /dev/null @@ -1,167 +0,0 @@ -import { TestNetwork } from '@atproto/dev-env' -import { AtUri, BlobRef } from '@atproto/api' -import { Readable } from 'stream' -import { AutoModerator } from '../../src/auto-moderator' -import IndexerContext from '../../src/indexer/context' -import { cidForRecord } from '@atproto/repo' -import { TID } from '@atproto/common' -import { LabelService } from '../../src/services/label' -import usersSeed from '../seeds/users' -import { CID } from 'multiformats/cid' -import { ImgLabeler } from '../../src/auto-moderator/hive' - -// outside of test suite so that TestLabeler can access them -let badCid1: CID | undefined = undefined -let badCid2: CID | undefined = undefined - -describe('labeler', () => { - let network: TestNetwork - let autoMod: AutoModerator - let labelSrvc: LabelService - let ctx: IndexerContext - let labelerDid: string - let badBlob1: BlobRef - let badBlob2: BlobRef - let goodBlob: BlobRef - let alice: string - const postUri = () => AtUri.make(alice, 'app.bsky.feed.post', TID.nextStr()) - - beforeAll(async () => { - network = await TestNetwork.create({ - dbPostgresSchema: 'bsky_labeler', - }) - ctx = network.bsky.indexer.ctx - const pdsCtx = network.pds.ctx - labelerDid = ctx.cfg.labelerDid - autoMod = ctx.autoMod - autoMod.imgLabeler = new TestImgLabeler() - labelSrvc = ctx.services.label(ctx.db) - const sc = network.getSeedClient() - await usersSeed(sc) - await network.processAll() - alice = sc.dids.alice - const storeBlob = (bytes: Uint8Array) => { - return pdsCtx.actorStore.transact(alice, async (store) => { - const blobRef = await store.repo.blob.addUntetheredBlob( - 'image/jpeg', - Readable.from([bytes], { objectMode: false }), - ) - const preparedBlobRef = { - cid: blobRef.ref, - mimeType: 'image/jpeg', - constraints: {}, - } - await store.repo.blob.verifyBlobAndMakePermanent(preparedBlobRef) - await store.repo.blob.associateBlob( - preparedBlobRef, - postUri(), - TID.nextStr(), - ) - return blobRef - }) - } - const bytes1 = new Uint8Array([1, 2, 3, 4]) - const bytes2 = new Uint8Array([5, 6, 7, 8]) - const bytes3 = new Uint8Array([4, 3, 2, 1]) - badBlob1 = await storeBlob(bytes1) - badBlob2 = await storeBlob(bytes2) - goodBlob = await storeBlob(bytes3) - badCid1 = badBlob1.ref - badCid2 = badBlob2.ref - }) - - afterAll(async () => { - await network.close() - }) - - it('labels text in posts', async () => { - const post = { - $type: 'app.bsky.feed.post', - text: 'blah blah label_me', - createdAt: new Date().toISOString(), - } - const cid = await cidForRecord(post) - const uri = postUri() - autoMod.processRecord(uri, cid, post) - await autoMod.processAll() - const labels = await labelSrvc.getLabels(uri.toString()) - expect(labels.length).toBe(1) - expect(labels[0]).toMatchObject({ - src: labelerDid, - uri: uri.toString(), - cid: cid.toString(), - val: 'test-label', - neg: false, - }) - }) - - it('labels embeds in posts', async () => { - const post = { - $type: 'app.bsky.feed.post', - text: 'blah blah', - embed: { - $type: 'app.bsky.embed.images', - images: [ - { - image: badBlob1, - alt: 'img', - }, - { - image: badBlob2, - alt: 'label_me_2', - }, - { - image: goodBlob, - alt: 'img', - }, - ], - }, - createdAt: new Date().toISOString(), - } - const uri = postUri() - const cid = await cidForRecord(post) - autoMod.processRecord(uri, cid, post) - await autoMod.processAll() - const dbLabels = await labelSrvc.getLabels(uri.toString()) - const labels = dbLabels.map((row) => row.val).sort() - expect(labels).toEqual( - ['test-label', 'test-label-2', 'img-label', 'other-img-label'].sort(), - ) - }) - - it('retrieves repo labels on profile views', async () => { - await ctx.db.db - .insertInto('label') - .values({ - src: labelerDid, - uri: alice, - cid: '', - val: 'repo-label', - neg: false, - cts: new Date().toISOString(), - }) - .execute() - - const labels = await labelSrvc.getLabelsForProfile(alice) - - expect(labels.length).toBe(1) - expect(labels[0]).toMatchObject({ - src: labelerDid, - uri: alice, - val: 'repo-label', - neg: false, - }) - }) -}) - -class TestImgLabeler implements ImgLabeler { - async labelImg(_did: string, cid: CID): Promise { - if (cid.equals(badCid1)) { - return ['img-label'] - } - if (cid.equals(badCid2)) { - return ['other-img-label'] - } - return [] - } -} diff --git a/packages/ozone/tests/auto-moderator/takedowns.test.ts b/packages/ozone/tests/auto-moderator/takedowns.test.ts deleted file mode 100644 index 8c1f1a21cdd..00000000000 --- a/packages/ozone/tests/auto-moderator/takedowns.test.ts +++ /dev/null @@ -1,201 +0,0 @@ -import fs from 'fs/promises' -import { TestNetwork, SeedClient, ImageRef } from '@atproto/dev-env' -import { AtpAgent } from '@atproto/api' -import { AutoModerator } from '../../src/auto-moderator' -import IndexerContext from '../../src/indexer/context' -import { sha256RawToCid } from '@atproto/common' -import usersSeed from '../seeds/users' -import { CID } from 'multiformats/cid' -import { AtUri } from '@atproto/syntax' -import { ImageFlagger } from '../../src/auto-moderator/abyss' -import { ImageInvalidator } from '../../src/image/invalidator' -import { sha256 } from '@atproto/crypto' -import { ids } from '../../src/lexicon/lexicons' - -// outside of test suite so that TestLabeler can access them -let badCid1: CID | undefined = undefined -let badCid2: CID | undefined = undefined - -describe('takedowner', () => { - let network: TestNetwork - let autoMod: AutoModerator - let testInvalidator: TestInvalidator - let ctx: IndexerContext - let pdsAgent: AtpAgent - let sc: SeedClient - let alice: string - let badBlob1: ImageRef - let badBlob2: ImageRef - let goodBlob: ImageRef - - beforeAll(async () => { - testInvalidator = new TestInvalidator() - network = await TestNetwork.create({ - dbPostgresSchema: 'bsky_automod_takedown', - bsky: { - imgInvalidator: testInvalidator, - }, - }) - ctx = network.bsky.indexer.ctx - autoMod = ctx.autoMod - autoMod.imageFlagger = new TestFlagger() - pdsAgent = new AtpAgent({ service: network.pds.url }) - sc = network.getSeedClient() - await usersSeed(sc) - await network.processAll() - alice = sc.dids.alice - const fileBytes1 = await fs.readFile( - 'tests/sample-img/key-portrait-small.jpg', - ) - const fileBytes2 = await fs.readFile( - 'tests/sample-img/key-portrait-large.jpg', - ) - badCid1 = sha256RawToCid(await sha256(fileBytes1)) - badCid2 = sha256RawToCid(await sha256(fileBytes2)) - goodBlob = await sc.uploadFile( - alice, - 'tests/sample-img/key-landscape-small.jpg', - 'image/jpeg', - ) - badBlob1 = await sc.uploadFile( - alice, - 'tests/sample-img/key-portrait-small.jpg', - 'image/jpeg', - ) - badBlob2 = await sc.uploadFile( - alice, - 'tests/sample-img/key-portrait-large.jpg', - 'image/jpeg', - ) - }) - - afterAll(async () => { - await network.close() - }) - - it('takes down flagged content in posts', async () => { - const post = await sc.post(alice, 'blah', undefined, [goodBlob, badBlob1]) - await network.processAll() - await autoMod.processAll() - const [modStatus, takedownEvent] = await Promise.all([ - ctx.db.db - .selectFrom('moderation_subject_status') - .where('did', '=', alice) - .where( - 'recordPath', - '=', - `${post.ref.uri.collection}/${post.ref.uri.rkey}`, - ) - .select(['takendown', 'id']) - .executeTakeFirst(), - ctx.db.db - .selectFrom('moderation_event') - .where('subjectDid', '=', alice) - .where('action', '=', 'com.atproto.admin.defs#modEventTakedown') - .selectAll() - .executeTakeFirst(), - ]) - if (!modStatus || !takedownEvent) { - throw new Error('expected mod action') - } - expect(modStatus.takendown).toEqual(true) - const record = await ctx.db.db - .selectFrom('record') - .where('uri', '=', post.ref.uriStr) - .select('takedownId') - .executeTakeFirst() - expect(record?.takedownId).toBeGreaterThan(0) - - const recordPds = await network.pds.ctx.actorStore.read( - post.ref.uri.hostname, - (store) => - store.db.db - .selectFrom('record') - .where('uri', '=', post.ref.uriStr) - .select('takedownRef') - .executeTakeFirst(), - ) - expect(recordPds?.takedownRef).toEqual(takedownEvent.id.toString()) - - expect(testInvalidator.invalidated.length).toBe(1) - expect(testInvalidator.invalidated[0].subject).toBe( - badBlob1.image.ref.toString(), - ) - }) - - it('takes down flagged content in profiles', async () => { - const res = await pdsAgent.api.com.atproto.repo.putRecord( - { - repo: alice, - collection: ids.AppBskyActorProfile, - rkey: 'self', - record: { - avatar: badBlob2.image, - }, - }, - { headers: sc.getHeaders(alice), encoding: 'application/json' }, - ) - await network.processAll() - const [modStatus, takedownEvent] = await Promise.all([ - ctx.db.db - .selectFrom('moderation_subject_status') - .where('did', '=', alice) - .where('recordPath', '=', `${ids.AppBskyActorProfile}/self`) - .select(['takendown', 'id']) - .executeTakeFirst(), - ctx.db.db - .selectFrom('moderation_event') - .where('subjectDid', '=', alice) - .where( - 'subjectUri', - '=', - AtUri.make(alice, ids.AppBskyActorProfile, 'self').toString(), - ) - .where('action', '=', 'com.atproto.admin.defs#modEventTakedown') - .selectAll() - .executeTakeFirst(), - ]) - if (!modStatus || !takedownEvent) { - throw new Error('expected mod action') - } - expect(modStatus.takendown).toEqual(true) - const record = await ctx.db.db - .selectFrom('record') - .where('uri', '=', res.data.uri) - .select('takedownId') - .executeTakeFirst() - expect(record?.takedownId).toBeGreaterThan(0) - - const recordPds = await network.pds.ctx.actorStore.read(alice, (store) => - store.db.db - .selectFrom('record') - .where('uri', '=', res.data.uri) - .select('takedownRef') - .executeTakeFirst(), - ) - expect(recordPds?.takedownRef).toEqual(takedownEvent.id.toString()) - - expect(testInvalidator.invalidated.length).toBe(2) - expect(testInvalidator.invalidated[1].subject).toBe( - badBlob2.image.ref.toString(), - ) - }) -}) - -class TestInvalidator implements ImageInvalidator { - public invalidated: { subject: string; paths: string[] }[] = [] - async invalidate(subject: string, paths: string[]) { - this.invalidated.push({ subject, paths }) - } -} - -class TestFlagger implements ImageFlagger { - async scanImage(_did: string, cid: CID, _uri: AtUri): Promise { - if (cid.equals(badCid1)) { - return ['kill-it'] - } else if (cid.equals(badCid2)) { - return ['with-fire'] - } - return [] - } -} diff --git a/packages/ozone/tests/blob-resolver.test.ts b/packages/ozone/tests/blob-resolver.test.ts deleted file mode 100644 index 79491c5601e..00000000000 --- a/packages/ozone/tests/blob-resolver.test.ts +++ /dev/null @@ -1,89 +0,0 @@ -import axios, { AxiosInstance } from 'axios' -import { CID } from 'multiformats/cid' -import { verifyCidForBytes } from '@atproto/common' -import { TestNetwork } from '@atproto/dev-env' -import basicSeed from './seeds/basic' -import { randomBytes } from '@atproto/crypto' - -describe('blob resolver', () => { - let network: TestNetwork - let client: AxiosInstance - let fileDid: string - let fileCid: CID - - beforeAll(async () => { - network = await TestNetwork.create({ - dbPostgresSchema: 'bsky_blob_resolver', - }) - const sc = network.getSeedClient() - await basicSeed(sc) - await network.processAll() - await network.bsky.processAll() - fileDid = sc.dids.carol - fileCid = sc.posts[fileDid][0].images[0].image.ref - client = axios.create({ - baseURL: network.bsky.url, - validateStatus: () => true, - }) - }) - - afterAll(async () => { - await network.close() - }) - - it('resolves blob with good signature check.', async () => { - const { data, status, headers } = await client.get( - `/blob/${fileDid}/${fileCid.toString()}`, - { responseType: 'arraybuffer' }, - ) - expect(status).toEqual(200) - expect(headers['content-type']).toEqual('image/jpeg') - expect(headers['content-security-policy']).toEqual( - `default-src 'none'; sandbox`, - ) - expect(headers['x-content-type-options']).toEqual('nosniff') - await expect(verifyCidForBytes(fileCid, data)).resolves.toBeUndefined() - }) - - it('404s on missing blob.', async () => { - const { data, status } = await client.get( - `/blob/did:plc:unknown/${fileCid.toString()}`, - ) - expect(status).toEqual(404) - expect(data).toEqual({ - error: 'NotFoundError', - message: 'Blob not found', - }) - }) - - it('400s on invalid did.', async () => { - const { data, status } = await client.get( - `/blob/did::/${fileCid.toString()}`, - ) - expect(status).toEqual(400) - expect(data).toEqual({ - error: 'BadRequestError', - message: 'Invalid did', - }) - }) - - it('400s on invalid cid.', async () => { - const { data, status } = await client.get(`/blob/${fileDid}/barfy`) - expect(status).toEqual(400) - expect(data).toEqual({ - error: 'BadRequestError', - message: 'Invalid cid', - }) - }) - - it('fails on blob with bad signature check.', async () => { - await network.pds.ctx.blobstore(fileDid).delete(fileCid) - await network.pds.ctx - .blobstore(fileDid) - .putPermanent(fileCid, randomBytes(100)) - const tryGetBlob = client.get(`/blob/${fileDid}/${fileCid.toString()}`) - await expect(tryGetBlob).rejects.toThrow( - 'maxContentLength size of -1 exceeded', - ) - }) -}) diff --git a/packages/ozone/tests/daemon.test.ts b/packages/ozone/tests/daemon.test.ts deleted file mode 100644 index 32f0d6617ab..00000000000 --- a/packages/ozone/tests/daemon.test.ts +++ /dev/null @@ -1,191 +0,0 @@ -import assert from 'assert' -import { AtUri } from '@atproto/api' -import { TestNetwork } from '@atproto/dev-env' -import { BskyDaemon, DaemonConfig, PrimaryDatabase } from '../src' -import usersSeed from './seeds/users' -import { countAll, excluded } from '../src/db/util' -import { NotificationsDaemon } from '../src/daemon/notifications' -import { - BEFORE_LAST_SEEN_DAYS, - BEFORE_LATEST_UNREAD_DAYS, - UNREAD_KEPT_COUNT, -} from '../src/services/util/notification' - -describe('daemon', () => { - let network: TestNetwork - let daemon: BskyDaemon - let db: PrimaryDatabase - let actors: { did: string }[] = [] - - beforeAll(async () => { - network = await TestNetwork.create({ - dbPostgresSchema: 'bsky_daemon', - }) - db = network.bsky.ctx.db.getPrimary() - daemon = BskyDaemon.create({ - db, - cfg: new DaemonConfig({ - version: network.bsky.ctx.cfg.version, - dbPostgresUrl: network.bsky.ctx.cfg.dbPrimaryPostgresUrl, - dbPostgresSchema: network.bsky.ctx.cfg.dbPostgresSchema, - }), - }) - const sc = network.getSeedClient() - await usersSeed(sc) - await network.processAll() - actors = await db.db.selectFrom('actor').selectAll().execute() - }) - - afterAll(async () => { - await network.close() - }) - - describe('notifications daemon', () => { - it('processes all dids', async () => { - for (const { did } of actors) { - await Promise.all([ - setLastSeen(daemon.ctx.db, { did }), - createNotifications(daemon.ctx.db, { - did, - daysAgo: 2 * BEFORE_LAST_SEEN_DAYS, - count: 1, - }), - ]) - } - await expect(countNotifications(db)).resolves.toBe(actors.length) - await runNotifsOnce(daemon.notifications) - await expect(countNotifications(db)).resolves.toBe(0) - }) - - it('removes read notifications older than threshold.', async () => { - const { did } = actors[0] - const lastSeenDaysAgo = 10 - await Promise.all([ - setLastSeen(daemon.ctx.db, { did, daysAgo: lastSeenDaysAgo }), - // read, delete - createNotifications(daemon.ctx.db, { - did, - daysAgo: lastSeenDaysAgo + BEFORE_LAST_SEEN_DAYS + 1, - count: 2, - }), - // read, keep - createNotifications(daemon.ctx.db, { - did, - daysAgo: lastSeenDaysAgo + BEFORE_LAST_SEEN_DAYS - 1, - count: 3, - }), - // unread, keep - createNotifications(daemon.ctx.db, { - did, - daysAgo: lastSeenDaysAgo - 1, - count: 4, - }), - ]) - await expect(countNotifications(db)).resolves.toBe(9) - await runNotifsOnce(daemon.notifications) - await expect(countNotifications(db)).resolves.toBe(7) - await clearNotifications(db) - }) - - it('removes unread notifications older than threshold.', async () => { - const { did } = actors[0] - await Promise.all([ - setLastSeen(daemon.ctx.db, { - did, - daysAgo: 2 * BEFORE_LATEST_UNREAD_DAYS, // all are unread - }), - createNotifications(daemon.ctx.db, { - did, - daysAgo: 0, - count: 1, - }), - createNotifications(daemon.ctx.db, { - did, - daysAgo: BEFORE_LATEST_UNREAD_DAYS - 1, - count: 99, - }), - createNotifications(daemon.ctx.db, { - did, - daysAgo: BEFORE_LATEST_UNREAD_DAYS + 1, - count: 400, - }), - ]) - await expect(countNotifications(db)).resolves.toBe(UNREAD_KEPT_COUNT) - await runNotifsOnce(daemon.notifications) - // none removed when within UNREAD_KEPT_COUNT - await expect(countNotifications(db)).resolves.toBe(UNREAD_KEPT_COUNT) - // add one more, tip over UNREAD_KEPT_COUNT - await createNotifications(daemon.ctx.db, { - did, - daysAgo: BEFORE_LATEST_UNREAD_DAYS + 1, - count: 1, - }) - await runNotifsOnce(daemon.notifications) - // removed all older than BEFORE_LATEST_UNREAD_DAYS - await expect(countNotifications(db)).resolves.toBe(100) - await clearNotifications(db) - }) - }) - - const runNotifsOnce = async (notifsDaemon: NotificationsDaemon) => { - assert(!notifsDaemon.running, 'notifications daemon is already running') - notifsDaemon.run({ forever: false, batchSize: 2 }) - await notifsDaemon.running - } - - const setLastSeen = async ( - db: PrimaryDatabase, - opts: { did: string; daysAgo?: number }, - ) => { - const { did, daysAgo = 0 } = opts - const lastSeenAt = new Date() - lastSeenAt.setDate(lastSeenAt.getDate() - daysAgo) - await db.db - .insertInto('actor_state') - .values({ did, lastSeenNotifs: lastSeenAt.toISOString() }) - .onConflict((oc) => - oc.column('did').doUpdateSet({ - lastSeenNotifs: excluded(db.db, 'lastSeenNotifs'), - }), - ) - .execute() - } - - const createNotifications = async ( - db: PrimaryDatabase, - opts: { - did: string - count: number - daysAgo: number - }, - ) => { - const { did, count, daysAgo } = opts - const sortAt = new Date() - sortAt.setDate(sortAt.getDate() - daysAgo) - await db.db - .insertInto('notification') - .values( - [...Array(count)].map(() => ({ - did, - author: did, - reason: 'none', - recordCid: 'bafycid', - recordUri: AtUri.make(did, 'invalid.collection', 'self').toString(), - sortAt: sortAt.toISOString(), - })), - ) - .execute() - } - - const clearNotifications = async (db: PrimaryDatabase) => { - await db.db.deleteFrom('notification').execute() - } - - const countNotifications = async (db: PrimaryDatabase) => { - const { count } = await db.db - .selectFrom('notification') - .select(countAll.as('count')) - .executeTakeFirstOrThrow() - return count - } -}) diff --git a/packages/ozone/tests/did-cache.test.ts b/packages/ozone/tests/did-cache.test.ts deleted file mode 100644 index 8314981102e..00000000000 --- a/packages/ozone/tests/did-cache.test.ts +++ /dev/null @@ -1,144 +0,0 @@ -import { TestNetwork, SeedClient } from '@atproto/dev-env' -import userSeed from './seeds/users' -import { IdResolver } from '@atproto/identity' -import DidRedisCache from '../src/did-cache' -import { wait } from '@atproto/common' -import { Redis } from '../src' - -describe('did cache', () => { - let network: TestNetwork - let sc: SeedClient - let idResolver: IdResolver - let redis: Redis - let didCache: DidRedisCache - - let alice: string - let bob: string - let carol: string - let dan: string - - beforeAll(async () => { - network = await TestNetwork.create({ - dbPostgresSchema: 'bsky_did_cache', - }) - idResolver = network.bsky.indexer.ctx.idResolver - redis = network.bsky.indexer.ctx.redis - didCache = network.bsky.indexer.ctx.didCache - sc = network.getSeedClient() - await userSeed(sc) - await network.processAll() - alice = sc.dids.alice - bob = sc.dids.bob - carol = sc.dids.carol - dan = sc.dids.dan - }) - - afterAll(async () => { - await network.close() - }) - - it('caches dids on lookup', async () => { - await didCache.processAll() - const docs = await Promise.all([ - idResolver.did.cache?.checkCache(alice), - idResolver.did.cache?.checkCache(bob), - idResolver.did.cache?.checkCache(carol), - idResolver.did.cache?.checkCache(dan), - ]) - expect(docs.length).toBe(4) - expect(docs[0]?.doc.id).toEqual(alice) - expect(docs[1]?.doc.id).toEqual(bob) - expect(docs[2]?.doc.id).toEqual(carol) - expect(docs[3]?.doc.id).toEqual(dan) - }) - - it('clears cache and repopulates', async () => { - await Promise.all([ - idResolver.did.cache?.clearEntry(alice), - idResolver.did.cache?.clearEntry(bob), - idResolver.did.cache?.clearEntry(carol), - idResolver.did.cache?.clearEntry(dan), - ]) - const docsCleared = await Promise.all([ - idResolver.did.cache?.checkCache(alice), - idResolver.did.cache?.checkCache(bob), - idResolver.did.cache?.checkCache(carol), - idResolver.did.cache?.checkCache(dan), - ]) - expect(docsCleared).toEqual([null, null, null, null]) - - await Promise.all([ - idResolver.did.resolve(alice), - idResolver.did.resolve(bob), - idResolver.did.resolve(carol), - idResolver.did.resolve(dan), - ]) - await didCache.processAll() - - const docs = await Promise.all([ - idResolver.did.cache?.checkCache(alice), - idResolver.did.cache?.checkCache(bob), - idResolver.did.cache?.checkCache(carol), - idResolver.did.cache?.checkCache(dan), - ]) - expect(docs.length).toBe(4) - expect(docs[0]?.doc.id).toEqual(alice) - expect(docs[1]?.doc.id).toEqual(bob) - expect(docs[2]?.doc.id).toEqual(carol) - expect(docs[3]?.doc.id).toEqual(dan) - }) - - it('accurately reports expired dids & refreshes the cache', async () => { - const didCache = new DidRedisCache(redis.withNamespace('did-doc'), { - staleTTL: 1, - maxTTL: 60000, - }) - const shortCacheResolver = new IdResolver({ - plcUrl: network.bsky.ctx.cfg.didPlcUrl, - didCache, - }) - const doc = await shortCacheResolver.did.resolve(alice) - await didCache.processAll() - // let's mess with alice's doc so we know what we're getting - await didCache.cacheDid(alice, { ...doc, id: 'did:example:alice' }) - await wait(5) - - // first check the cache & see that we have the stale value - const cached = await shortCacheResolver.did.cache?.checkCache(alice) - expect(cached?.stale).toBe(true) - expect(cached?.doc.id).toEqual('did:example:alice') - // see that the resolver gives us the stale value while it revalidates - const staleGet = await shortCacheResolver.did.resolve(alice) - expect(staleGet?.id).toEqual('did:example:alice') - await didCache.processAll() - - // since it revalidated, ensure we have the new value - const updatedCache = await shortCacheResolver.did.cache?.checkCache(alice) - expect(updatedCache?.doc.id).toEqual(alice) - const updatedGet = await shortCacheResolver.did.resolve(alice) - expect(updatedGet?.id).toEqual(alice) - await didCache.destroy() - }) - - it('does not return expired dids & refreshes the cache', async () => { - const didCache = new DidRedisCache(redis.withNamespace('did-doc'), { - staleTTL: 0, - maxTTL: 1, - }) - const shortExpireResolver = new IdResolver({ - plcUrl: network.bsky.ctx.cfg.didPlcUrl, - didCache, - }) - const doc = await shortExpireResolver.did.resolve(alice) - await didCache.processAll() - - // again, we mess with the cached doc so we get something different - await didCache.cacheDid(alice, { ...doc, id: 'did:example:alice' }) - await wait(5) - - // see that the resolver does not return expired value & instead force refreshes - const staleGet = await shortExpireResolver.did.resolve(alice) - expect(staleGet?.id).toEqual(alice) - await didCache.destroy() - }) -}) diff --git a/packages/ozone/tests/duplicate-records.test.ts b/packages/ozone/tests/duplicate-records.test.ts deleted file mode 100644 index 9c7617bd668..00000000000 --- a/packages/ozone/tests/duplicate-records.test.ts +++ /dev/null @@ -1,146 +0,0 @@ -import { AtUri } from '@atproto/syntax' -import { cidForCbor, TID } from '@atproto/common' -import { WriteOpAction } from '@atproto/repo' -import { TestNetwork } from '@atproto/dev-env' -import { Database } from '../src' -import { PrimaryDatabase } from '../src/db' -import * as lex from '../src/lexicon/lexicons' -import { Services } from '../src/indexer/services' - -describe('duplicate record', () => { - let network: TestNetwork - let did: string - let db: PrimaryDatabase - let services: Services - - beforeAll(async () => { - network = await TestNetwork.create({ - dbPostgresSchema: 'bsky_duplicates', - }) - db = network.bsky.indexer.ctx.db - services = network.bsky.indexer.ctx.services - did = 'did:example:alice' - }) - - afterAll(async () => { - await network.close() - }) - - const countRecords = async (db: Database, table: string) => { - const got = await db.db - .selectFrom(table as any) - .selectAll() - .where('creator', '=', did) - .execute() - return got.length - } - - it('dedupes reposts', async () => { - const subject = AtUri.make(did, lex.ids.AppBskyFeedPost, TID.nextStr()) - const subjectCid = await cidForCbor({ test: 'blah' }) - const coll = lex.ids.AppBskyFeedRepost - const uris: AtUri[] = [] - for (let i = 0; i < 5; i++) { - const repost = { - $type: coll, - subject: { - uri: subject.toString(), - cid: subjectCid.toString(), - }, - createdAt: new Date().toISOString(), - } - const uri = AtUri.make(did, coll, TID.nextStr()) - const cid = await cidForCbor(repost) - await services - .indexing(db) - .indexRecord(uri, cid, repost, WriteOpAction.Create, repost.createdAt) - uris.push(uri) - } - - let count = await countRecords(db, 'repost') - expect(count).toBe(1) - - await services.indexing(db).deleteRecord(uris[0], false) - - count = await countRecords(db, 'repost') - expect(count).toBe(1) - - await services.indexing(db).deleteRecord(uris[1], true) - - count = await countRecords(db, 'repost') - expect(count).toBe(0) - }) - - it('dedupes like', async () => { - const subject = AtUri.make(did, lex.ids.AppBskyFeedPost, TID.nextStr()) - const subjectCid = await cidForCbor({ test: 'blah' }) - const coll = lex.ids.AppBskyFeedLike - const uris: AtUri[] = [] - for (let i = 0; i < 5; i++) { - const like = { - $type: coll, - subject: { - uri: subject.toString(), - cid: subjectCid.toString(), - }, - createdAt: new Date().toISOString(), - } - const uri = AtUri.make(did, coll, TID.nextStr()) - const cid = await cidForCbor(like) - await services - .indexing(db) - .indexRecord(uri, cid, like, WriteOpAction.Create, like.createdAt) - uris.push(uri) - } - - let count = await countRecords(db, 'like') - expect(count).toBe(1) - - await services.indexing(db).deleteRecord(uris[0], false) - - count = await countRecords(db, 'like') - expect(count).toBe(1) - const got = await db.db - .selectFrom('like') - .where('creator', '=', did) - .selectAll() - .executeTakeFirst() - expect(got?.uri).toEqual(uris[1].toString()) - - await services.indexing(db).deleteRecord(uris[1], true) - - count = await countRecords(db, 'like') - expect(count).toBe(0) - }) - - it('dedupes follows', async () => { - const coll = lex.ids.AppBskyGraphFollow - const uris: AtUri[] = [] - for (let i = 0; i < 5; i++) { - const follow = { - $type: coll, - subject: 'did:example:bob', - createdAt: new Date().toISOString(), - } - const uri = AtUri.make(did, coll, TID.nextStr()) - const cid = await cidForCbor(follow) - await services - .indexing(db) - .indexRecord(uri, cid, follow, WriteOpAction.Create, follow.createdAt) - uris.push(uri) - } - - let count = await countRecords(db, 'follow') - expect(count).toBe(1) - - await services.indexing(db).deleteRecord(uris[0], false) - - count = await countRecords(db, 'follow') - expect(count).toBe(1) - - await services.indexing(db).deleteRecord(uris[1], true) - - count = await countRecords(db, 'follow') - expect(count).toBe(0) - }) -}) diff --git a/packages/ozone/tests/feed-generation.test.ts b/packages/ozone/tests/feed-generation.test.ts deleted file mode 100644 index aceecec3204..00000000000 --- a/packages/ozone/tests/feed-generation.test.ts +++ /dev/null @@ -1,594 +0,0 @@ -import { TID } from '@atproto/common' -import { AtUri, AtpAgent } from '@atproto/api' -import { - TestNetwork, - TestFeedGen, - SeedClient, - RecordRef, -} from '@atproto/dev-env' -import { Handler as SkeletonHandler } from '../src/lexicon/types/app/bsky/feed/getFeedSkeleton' -import { GeneratorView } from '@atproto/api/src/client/types/app/bsky/feed/defs' -import { UnknownFeedError } from '@atproto/api/src/client/types/app/bsky/feed/getFeed' -import { ids } from '../src/lexicon/lexicons' -import { - FeedViewPost, - SkeletonFeedPost, -} from '../src/lexicon/types/app/bsky/feed/defs' -import basicSeed from './seeds/basic' -import { forSnapshot, paginateAll } from './_util' -import { AuthRequiredError } from '@atproto/xrpc-server' -import assert from 'assert' -import { XRPCError } from '@atproto/xrpc' - -describe('feed generation', () => { - let network: TestNetwork - let agent: AtpAgent - let pdsAgent: AtpAgent - let sc: SeedClient - let gen: TestFeedGen - - let alice: string - let feedUriAll: string - let feedUriAllRef: RecordRef - let feedUriEven: string - let feedUriOdd: string // Unsupported by feed gen - let feedUriBadPagination: string - let feedUriPrime: string // Taken-down - let feedUriPrimeRef: RecordRef - let feedUriNeedsAuth: string - - beforeAll(async () => { - network = await TestNetwork.create({ - dbPostgresSchema: 'bsky_feed_generation', - }) - agent = network.bsky.getClient() - pdsAgent = network.pds.getClient() - sc = network.getSeedClient() - await basicSeed(sc) - await network.processAll() - alice = sc.dids.alice - const allUri = AtUri.make(alice, 'app.bsky.feed.generator', 'all') - const feedUriBadPagination = AtUri.make( - alice, - 'app.bsky.feed.generator', - 'bad-pagination', - ) - const evenUri = AtUri.make(alice, 'app.bsky.feed.generator', 'even') - const primeUri = AtUri.make(alice, 'app.bsky.feed.generator', 'prime') - const needsAuthUri = AtUri.make( - alice, - 'app.bsky.feed.generator', - 'needs-auth', - ) - gen = await network.createFeedGen({ - [allUri.toString()]: feedGenHandler('all'), - [evenUri.toString()]: feedGenHandler('even'), - [feedUriBadPagination.toString()]: feedGenHandler('bad-pagination'), - [primeUri.toString()]: feedGenHandler('prime'), - [needsAuthUri.toString()]: feedGenHandler('needs-auth'), - }) - - const feedSuggestions = [ - { uri: allUri.toString(), order: 1 }, - { uri: evenUri.toString(), order: 2 }, - { uri: feedUriBadPagination.toString(), order: 3 }, - { uri: primeUri.toString(), order: 4 }, - ] - await network.bsky.ctx.db - .getPrimary() - .db.insertInto('suggested_feed') - .values(feedSuggestions) - .execute() - }) - - afterAll(async () => { - await gen.close() - await network.close() - }) - - // @TODO enable once getFeed is implemented - it('describes the feed generator', async () => { - const res = await agent.api.app.bsky.feed.describeFeedGenerator() - expect(res.data.did).toBe(network.bsky.ctx.cfg.feedGenDid) - }) - - it('feed gen records can be created.', async () => { - const all = await pdsAgent.api.app.bsky.feed.generator.create( - { repo: alice, rkey: 'all' }, - { - did: gen.did, - displayName: 'All', - description: 'Provides all feed candidates', - createdAt: new Date().toISOString(), - }, - sc.getHeaders(alice), - ) - const even = await pdsAgent.api.app.bsky.feed.generator.create( - { repo: alice, rkey: 'even' }, - { - did: gen.did, - displayName: 'Even', - description: 'Provides even-indexed feed candidates', - createdAt: new Date().toISOString(), - }, - sc.getHeaders(alice), - ) - // Unsupported by feed gen - const odd = await pdsAgent.api.app.bsky.feed.generator.create( - { repo: alice, rkey: 'odd' }, - { - did: gen.did, - displayName: 'Temp', // updated in next test - description: 'Temp', // updated in next test - createdAt: new Date().toISOString(), - }, - sc.getHeaders(alice), - ) - const badPagination = await pdsAgent.api.app.bsky.feed.generator.create( - { repo: alice, rkey: 'bad-pagination' }, - { - did: gen.did, - displayName: 'Bad Pagination', - description: - 'Provides all feed candidates, blindly ignoring pagination limit', - createdAt: new Date().toISOString(), - }, - sc.getHeaders(alice), - ) - // Taken-down - const prime = await pdsAgent.api.app.bsky.feed.generator.create( - { repo: alice, rkey: 'prime' }, - { - did: gen.did, - displayName: 'Prime', - description: 'Provides prime-indexed feed candidates', - createdAt: new Date().toISOString(), - }, - sc.getHeaders(alice), - ) - const needsAuth = await pdsAgent.api.app.bsky.feed.generator.create( - { repo: alice, rkey: 'needs-auth' }, - { - did: gen.did, - displayName: 'Needs Auth', - description: 'Provides all feed candidates when authed', - createdAt: new Date().toISOString(), - }, - sc.getHeaders(alice), - ) - await network.processAll() - await agent.api.com.atproto.admin.emitModerationEvent( - { - event: { $type: 'com.atproto.admin.defs#modEventTakedown' }, - subject: { - $type: 'com.atproto.repo.strongRef', - uri: prime.uri, - cid: prime.cid, - }, - createdBy: 'did:example:admin', - reason: 'Y', - }, - { - encoding: 'application/json', - headers: network.pds.adminAuthHeaders(), - }, - ) - feedUriAll = all.uri - feedUriAllRef = new RecordRef(all.uri, all.cid) - feedUriEven = even.uri - feedUriOdd = odd.uri - feedUriBadPagination = badPagination.uri - feedUriPrime = prime.uri - feedUriPrimeRef = new RecordRef(prime.uri, prime.cid) - feedUriNeedsAuth = needsAuth.uri - }) - - it('feed gen records can be updated', async () => { - await pdsAgent.api.com.atproto.repo.putRecord( - { - repo: alice, - collection: ids.AppBskyFeedGenerator, - rkey: 'odd', - record: { - did: gen.did, - displayName: 'Odd', - description: 'Provides odd-indexed feed candidates', - createdAt: new Date().toISOString(), - }, - }, - { headers: sc.getHeaders(alice), encoding: 'application/json' }, - ) - await network.processAll() - }) - - it('getActorFeeds fetches feed generators by actor.', async () => { - // add some likes - await sc.like(sc.dids.bob, feedUriAllRef) - await sc.like(sc.dids.carol, feedUriAllRef) - await network.processAll() - - const results = (results) => results.flatMap((res) => res.feeds) - const paginator = async (cursor?: string) => { - const res = await agent.api.app.bsky.feed.getActorFeeds( - { actor: alice, cursor, limit: 2 }, - { headers: await network.serviceHeaders(sc.dids.bob) }, - ) - return res.data - } - - const paginatedAll: GeneratorView[] = results(await paginateAll(paginator)) - - expect(paginatedAll.length).toEqual(5) - expect(paginatedAll[0].uri).toEqual(feedUriOdd) - expect(paginatedAll[1].uri).toEqual(feedUriNeedsAuth) - expect(paginatedAll[2].uri).toEqual(feedUriBadPagination) - expect(paginatedAll[3].uri).toEqual(feedUriEven) - expect(paginatedAll[4].uri).toEqual(feedUriAll) - expect(paginatedAll.map((fg) => fg.uri)).not.toContain(feedUriPrime) // taken-down - expect(forSnapshot(paginatedAll)).toMatchSnapshot() - }) - - it('embeds feed generator records in posts', async () => { - const res = await pdsAgent.api.app.bsky.feed.post.create( - { repo: sc.dids.bob }, - { - text: 'cool feed!', - embed: { - $type: 'app.bsky.embed.record', - record: feedUriAllRef.raw, - }, - createdAt: new Date().toISOString(), - }, - sc.getHeaders(sc.dids.bob), - ) - await network.processAll() - const view = await agent.api.app.bsky.feed.getPosts( - { uris: [res.uri] }, - { headers: await network.serviceHeaders(sc.dids.bob) }, - ) - expect(view.data.posts.length).toBe(1) - expect(forSnapshot(view.data.posts[0])).toMatchSnapshot() - }) - - it('does not embed taken-down feed generator records in posts', async () => { - const res = await pdsAgent.api.app.bsky.feed.post.create( - { repo: sc.dids.bob }, - { - text: 'weird feed', - embed: { - $type: 'app.bsky.embed.record', - record: feedUriPrimeRef.raw, - }, - createdAt: new Date().toISOString(), - }, - sc.getHeaders(sc.dids.bob), - ) - await network.processAll() - const view = await agent.api.app.bsky.feed.getPosts( - { uris: [res.uri] }, - { headers: await network.serviceHeaders(sc.dids.bob) }, - ) - expect(view.data.posts.length).toBe(1) - expect(forSnapshot(view.data.posts[0])).toMatchSnapshot() - }) - - describe('getFeedGenerator', () => { - it('describes a feed gen & returns online status', async () => { - const resEven = await agent.api.app.bsky.feed.getFeedGenerator( - { feed: feedUriAll }, - { headers: await network.serviceHeaders(sc.dids.bob) }, - ) - expect(forSnapshot(resEven.data)).toMatchSnapshot() - expect(resEven.data.isOnline).toBe(true) - expect(resEven.data.isValid).toBe(true) - }) - - it('does not describe taken-down feed', async () => { - const tryGetFeed = agent.api.app.bsky.feed.getFeedGenerator( - { feed: feedUriPrime }, - { headers: await network.serviceHeaders(sc.dids.bob) }, - ) - await expect(tryGetFeed).rejects.toThrow('could not find feed') - }) - - // @TODO temporarily skipping while external feedgens catch-up on describeFeedGenerator - it.skip('handles an unsupported algo', async () => { - const resOdd = await agent.api.app.bsky.feed.getFeedGenerator( - { feed: feedUriOdd }, - { headers: await network.serviceHeaders(sc.dids.bob) }, - ) - expect(resOdd.data.isOnline).toBe(true) - expect(resOdd.data.isValid).toBe(false) - }) - - // @TODO temporarily skipping while external feedgens catch-up on describeFeedGenerator - it.skip('handles an offline feed', async () => { - // make an invalid feed gen in bob's repo - const allUriBob = AtUri.make( - sc.dids.bob, - 'app.bsky.feed.generator', - 'all', - ) - const bobFg = await network.createFeedGen({ - [allUriBob.toString()]: feedGenHandler('all'), - }) - - await pdsAgent.api.app.bsky.feed.generator.create( - { repo: sc.dids.bob, rkey: 'all' }, - { - did: bobFg.did, - displayName: 'All by bob', - description: 'Provides all feed candidates - by bob', - createdAt: new Date().toISOString(), - }, - sc.getHeaders(sc.dids.bob), - ) - await network.processAll() - await network.bsky.processAll() - - // now take it offline - await bobFg.close() - - const res = await agent.api.app.bsky.feed.getFeedGenerator( - { - feed: allUriBob.toString(), - }, - { headers: await network.serviceHeaders(sc.dids.alice) }, - ) - expect(res.data.isOnline).toBe(false) - expect(res.data.isValid).toBe(false) - }) - }) - - describe('getFeedGenerators', () => { - it('describes multiple feed gens', async () => { - const resEven = await agent.api.app.bsky.feed.getFeedGenerators( - { feeds: [feedUriEven, feedUriAll, feedUriPrime] }, - { headers: await network.serviceHeaders(sc.dids.bob) }, - ) - expect(forSnapshot(resEven.data)).toMatchSnapshot() - expect(resEven.data.feeds.map((fg) => fg.uri)).not.toContain(feedUriPrime) // taken-down - }) - }) - - describe('getSuggestedFeeds', () => { - it('returns list of suggested feed generators', async () => { - const resEven = await agent.api.app.bsky.feed.getSuggestedFeeds( - {}, - { headers: await network.serviceHeaders(sc.dids.bob) }, - ) - expect(forSnapshot(resEven.data)).toMatchSnapshot() - expect(resEven.data.feeds.map((fg) => fg.uri)).not.toContain(feedUriPrime) // taken-down - }) - }) - - describe('getPopularFeedGenerators', () => { - it('gets popular feed generators', async () => { - const resEven = - await agent.api.app.bsky.unspecced.getPopularFeedGenerators( - {}, - { headers: await network.serviceHeaders(sc.dids.bob) }, - ) - expect(resEven.data.feeds.map((f) => f.likeCount)).toEqual([ - 2, 0, 0, 0, 0, - ]) - expect(resEven.data.feeds.map((f) => f.uri)).not.toContain(feedUriPrime) // taken-down - }) - - it('paginates', async () => { - const resFull = - await agent.api.app.bsky.unspecced.getPopularFeedGenerators( - {}, - { headers: await network.serviceHeaders(sc.dids.bob) }, - ) - - const resOne = - await agent.api.app.bsky.unspecced.getPopularFeedGenerators( - { limit: 2 }, - { headers: await network.serviceHeaders(sc.dids.bob) }, - ) - const resTwo = - await agent.api.app.bsky.unspecced.getPopularFeedGenerators( - { cursor: resOne.data.cursor }, - { headers: await network.serviceHeaders(sc.dids.bob) }, - ) - expect([...resOne.data.feeds, ...resTwo.data.feeds]).toEqual( - resFull.data.feeds, - ) - }) - }) - - describe('getFeed', () => { - it('resolves basic feed contents.', async () => { - const feed = await agent.api.app.bsky.feed.getFeed( - { feed: feedUriEven }, - { headers: await network.serviceHeaders(alice, gen.did) }, - ) - expect(feed.data.feed.map((item) => item.post.uri)).toEqual([ - sc.posts[sc.dids.alice][0].ref.uriStr, - sc.posts[sc.dids.carol][0].ref.uriStr, - sc.replies[sc.dids.carol][0].ref.uriStr, - ]) - expect(forSnapshot(feed.data.feed)).toMatchSnapshot() - }) - - it('resolves basic feed contents without auth.', async () => { - const feed = await agent.api.app.bsky.feed.getFeed({ feed: feedUriEven }) - expect(feed.data.feed.map((item) => item.post.uri)).toEqual([ - sc.posts[sc.dids.alice][0].ref.uriStr, - sc.posts[sc.dids.carol][0].ref.uriStr, - sc.replies[sc.dids.carol][0].ref.uriStr, - ]) - expect(forSnapshot(feed.data.feed)).toMatchSnapshot() - }) - - it('paginates, handling replies and reposts.', async () => { - const results = (results) => results.flatMap((res) => res.feed) - const paginator = async (cursor?: string) => { - const res = await agent.api.app.bsky.feed.getFeed( - { feed: feedUriAll, cursor, limit: 2 }, - { headers: await network.serviceHeaders(alice, gen.did) }, - ) - return res.data - } - - const paginatedAll: FeedViewPost[] = results(await paginateAll(paginator)) - - // Unknown post uri is omitted - expect(paginatedAll.map((item) => item.post.uri)).toEqual([ - sc.posts[sc.dids.alice][0].ref.uriStr, - sc.posts[sc.dids.bob][0].ref.uriStr, - sc.posts[sc.dids.carol][0].ref.uriStr, - sc.replies[sc.dids.carol][0].ref.uriStr, - sc.posts[sc.dids.dan][1].ref.uriStr, - ]) - expect(forSnapshot(paginatedAll)).toMatchSnapshot() - }) - - it('paginates, handling feed not respecting limit.', async () => { - const res = await agent.api.app.bsky.feed.getFeed( - { feed: feedUriBadPagination, limit: 3 }, - { headers: await network.serviceHeaders(alice, gen.did) }, - ) - // refused to respect pagination limit, so it got cut short by appview but the cursor remains. - expect(res.data.feed.length).toBeLessThanOrEqual(3) - expect(parseInt(res.data.cursor || '', 10)).toBeGreaterThanOrEqual(3) - expect(res.data.feed.map((item) => item.post.uri)).toEqual([ - sc.posts[sc.dids.alice][0].ref.uriStr, - sc.posts[sc.dids.bob][0].ref.uriStr, - sc.posts[sc.dids.carol][0].ref.uriStr, - ]) - }) - - it('fails on unknown feed.', async () => { - const tryGetFeed = agent.api.app.bsky.feed.getFeed( - { feed: feedUriOdd }, - { headers: await network.serviceHeaders(alice, gen.did) }, - ) - await expect(tryGetFeed).rejects.toThrow(UnknownFeedError) - }) - - it('resolves contents of taken-down feed.', async () => { - const tryGetFeed = agent.api.app.bsky.feed.getFeed( - { feed: feedUriPrime }, - { headers: await network.serviceHeaders(alice) }, - ) - await expect(tryGetFeed).resolves.toBeDefined() - }) - - it('receives proper auth details.', async () => { - const feed = await agent.api.app.bsky.feed.getFeed( - { feed: feedUriEven }, - { headers: await network.serviceHeaders(alice, gen.did) }, - ) - expect(feed.data['$auth']?.['aud']).toEqual(gen.did) - expect(feed.data['$auth']?.['iss']).toEqual(alice) - }) - - it('receives proper auth details.', async () => { - const feed = await agent.api.app.bsky.feed.getFeed( - { feed: feedUriEven }, - { headers: await network.serviceHeaders(alice, gen.did) }, - ) - expect(feed.data['$auth']?.['aud']).toEqual(gen.did) - expect(feed.data['$auth']?.['iss']).toEqual(alice) - }) - - it('passes through auth error from feed.', async () => { - const tryGetFeed = agent.api.app.bsky.feed.getFeed({ - feed: feedUriNeedsAuth, - }) - const err = await tryGetFeed.catch((err) => err) - assert(err instanceof XRPCError) - expect(err.status).toBe(401) - expect(err.message).toBe('This feed requires auth') - }) - - it('provides timing info in server-timing header.', async () => { - const result = await agent.api.app.bsky.feed.getFeed( - { feed: feedUriEven }, - { headers: await network.serviceHeaders(alice, gen.did) }, - ) - expect(result.headers['server-timing']).toMatch( - /^skele;dur=\d+, hydr;dur=\d+$/, - ) - }) - - it('returns an upstream failure error when the feed is down.', async () => { - await gen.close() // @NOTE must be last test - const tryGetFeed = agent.api.app.bsky.feed.getFeed( - { feed: feedUriEven }, - { headers: await network.serviceHeaders(alice, gen.did) }, - ) - await expect(tryGetFeed).rejects.toThrow('feed unavailable') - }) - }) - - const feedGenHandler = - ( - feedName: 'even' | 'all' | 'prime' | 'bad-pagination' | 'needs-auth', - ): SkeletonHandler => - async ({ req, params }) => { - if (feedName === 'needs-auth' && !req.headers.authorization) { - throw new AuthRequiredError('This feed requires auth') - } - const { limit, cursor } = params - const candidates: SkeletonFeedPost[] = [ - { post: sc.posts[sc.dids.alice][0].ref.uriStr }, - { post: sc.posts[sc.dids.bob][0].ref.uriStr }, - { post: sc.posts[sc.dids.carol][0].ref.uriStr }, - { post: `at://did:plc:unknown/app.bsky.feed.post/${TID.nextStr()}` }, // Doesn't exist - { post: sc.replies[sc.dids.carol][0].ref.uriStr }, // Reply - // Repost (accurate) - { - post: sc.posts[sc.dids.dan][1].ref.uriStr, - reason: { - $type: 'app.bsky.feed.defs#skeletonReasonRepost', - repost: sc.reposts[sc.dids.carol][0].uriStr, - }, - }, - // Repost (inaccurate) - { - post: sc.posts[alice][1].ref.uriStr, - reason: { - $type: 'app.bsky.feed.defs#skeletonReasonRepost', - repost: sc.reposts[sc.dids.carol][0].uriStr, - }, - }, - ] - const offset = cursor ? parseInt(cursor, 10) : 0 - const fullFeed = candidates.filter((_, i) => { - if (feedName === 'even') { - return i % 2 === 0 - } - if (feedName === 'prime') { - return [2, 3, 5, 7, 11, 13].includes(i) - } - return true - }) - const feedResults = - feedName === 'bad-pagination' - ? fullFeed.slice(offset) // does not respect limit - : fullFeed.slice(offset, offset + limit) - const lastResult = feedResults.at(-1) - return { - encoding: 'application/json', - body: { - feed: feedResults, - cursor: lastResult - ? (fullFeed.indexOf(lastResult) + 1).toString() - : undefined, - $auth: jwtBody(req.headers.authorization), // for testing purposes - }, - } - } -}) - -const jwtBody = (authHeader?: string): Record | undefined => { - if (!authHeader?.startsWith('Bearer')) return undefined - const jwt = authHeader.replace('Bearer ', '') - const [, bodyb64] = jwt.split('.') - const body = JSON.parse(Buffer.from(bodyb64, 'base64').toString()) - if (!body || typeof body !== 'object') return undefined - return body -} diff --git a/packages/ozone/tests/admin/get-record.test.ts b/packages/ozone/tests/get-record.test.ts similarity index 95% rename from packages/ozone/tests/admin/get-record.test.ts rename to packages/ozone/tests/get-record.test.ts index 8a303886966..512f5388114 100644 --- a/packages/ozone/tests/admin/get-record.test.ts +++ b/packages/ozone/tests/get-record.test.ts @@ -4,9 +4,9 @@ import { AtUri } from '@atproto/syntax' import { REASONOTHER, REASONSPAM, -} from '../../src/lexicon/types/com/atproto/moderation/defs' -import { forSnapshot } from '../_util' -import basicSeed from '../seeds/basic' +} from '../src/lexicon/types/com/atproto/moderation/defs' +import { forSnapshot } from './_util' +import basicSeed from './seeds/basic' describe('admin get record view', () => { let network: TestNetwork diff --git a/packages/ozone/tests/admin/get-repo.test.ts b/packages/ozone/tests/get-repo.test.ts similarity index 96% rename from packages/ozone/tests/admin/get-repo.test.ts rename to packages/ozone/tests/get-repo.test.ts index 74969b87adf..f1b298780f6 100644 --- a/packages/ozone/tests/admin/get-repo.test.ts +++ b/packages/ozone/tests/get-repo.test.ts @@ -3,9 +3,9 @@ import AtpAgent from '@atproto/api' import { REASONOTHER, REASONSPAM, -} from '../../src/lexicon/types/com/atproto/moderation/defs' -import { forSnapshot } from '../_util' -import basicSeed from '../seeds/basic' +} from '../src/lexicon/types/com/atproto/moderation/defs' +import { forSnapshot } from './_util' +import basicSeed from './seeds/basic' describe('admin get repo view', () => { let network: TestNetwork diff --git a/packages/ozone/tests/handle-invalidation.test.ts b/packages/ozone/tests/handle-invalidation.test.ts deleted file mode 100644 index cee9cfb61df..00000000000 --- a/packages/ozone/tests/handle-invalidation.test.ts +++ /dev/null @@ -1,127 +0,0 @@ -import { DAY } from '@atproto/common' -import { TestNetwork, SeedClient } from '@atproto/dev-env' -import { AtpAgent } from '@atproto/api' -import userSeed from './seeds/users' - -describe('handle invalidation', () => { - let network: TestNetwork - let agent: AtpAgent - let pdsAgent: AtpAgent - let sc: SeedClient - let alice: string - let bob: string - - const mockHandles = {} - - beforeAll(async () => { - network = await TestNetwork.create({ - dbPostgresSchema: 'bsky_handle_invalidation', - }) - agent = network.bsky.getClient() - pdsAgent = network.pds.getClient() - sc = network.getSeedClient() - await userSeed(sc) - await network.processAll() - - alice = sc.dids.alice - bob = sc.dids.bob - - const origResolve = network.bsky.indexer.ctx.idResolver.handle.resolve - network.bsky.indexer.ctx.idResolver.handle.resolve = async ( - handle: string, - ) => { - if (mockHandles[handle] === null) { - return undefined - } else if (mockHandles[handle]) { - return mockHandles[handle] - } - return origResolve(handle) - } - }) - - afterAll(async () => { - await network.close() - }) - - const backdateIndexedAt = async (did: string) => { - const TWO_DAYS_AGO = new Date(Date.now() - 2 * DAY).toISOString() - await network.bsky.ctx.db - .getPrimary() - .db.updateTable('actor') - .set({ indexedAt: TWO_DAYS_AGO }) - .where('did', '=', did) - .execute() - } - - it('indexes an account with no proper handle', async () => { - mockHandles['eve.test'] = null - const eveAccnt = await sc.createAccount('eve', { - handle: 'eve.test', - email: 'eve@test.com', - password: 'eve-pass', - }) - await network.processAll() - - const res = await agent.api.app.bsky.actor.getProfile( - { actor: eveAccnt.did }, - { headers: await network.serviceHeaders(alice) }, - ) - expect(res.data.handle).toEqual('handle.invalid') - }) - - it('invalidates out of date handles', async () => { - await backdateIndexedAt(alice) - - const aliceHandle = sc.accounts[alice].handle - // alice's handle no longer resolves - mockHandles[aliceHandle] = null - await sc.post(alice, 'blah') - await network.processAll() - const res = await agent.api.app.bsky.actor.getProfile( - { actor: alice }, - { headers: await network.serviceHeaders(alice) }, - ) - expect(res.data.handle).toEqual('handle.invalid') - }) - - it('revalidates an out of date handle', async () => { - await backdateIndexedAt(alice) - const aliceHandle = sc.accounts[alice].handle - // alice's handle no longer resolves - delete mockHandles[aliceHandle] - - await sc.post(alice, 'blah') - await network.processAll() - const res = await agent.api.app.bsky.actor.getProfile( - { actor: alice }, - { headers: await network.serviceHeaders(alice) }, - ) - expect(res.data.handle).toEqual(sc.accounts[alice].handle) - }) - - it('deals with handle contention', async () => { - await backdateIndexedAt(bob) - // update alices handle so that the pds will let bob take her old handle - await network.pds.ctx.accountManager.updateHandle(alice, 'not-alice.test') - - await pdsAgent.api.com.atproto.identity.updateHandle( - { - handle: sc.accounts[alice].handle, - }, - { headers: sc.getHeaders(bob), encoding: 'application/json' }, - ) - await network.processAll() - - const aliceRes = await agent.api.app.bsky.actor.getProfile( - { actor: alice }, - { headers: await network.serviceHeaders(alice) }, - ) - expect(aliceRes.data.handle).toEqual('handle.invalid') - - const bobRes = await agent.api.app.bsky.actor.getProfile( - { actor: bob }, - { headers: await network.serviceHeaders(alice) }, - ) - expect(bobRes.data.handle).toEqual(sc.accounts[alice].handle) - }) -}) diff --git a/packages/ozone/tests/image/server.test.ts b/packages/ozone/tests/image/server.test.ts deleted file mode 100644 index 3bce638ce45..00000000000 --- a/packages/ozone/tests/image/server.test.ts +++ /dev/null @@ -1,90 +0,0 @@ -import axios, { AxiosInstance } from 'axios' -import { CID } from 'multiformats/cid' -import { cidForCbor } from '@atproto/common' -import { TestNetwork } from '@atproto/dev-env' -import { getInfo } from '../../src/image/sharp' -import basicSeed from '../seeds/basic' -import { ImageUriBuilder } from '../../src/image/uri' - -describe('image processing server', () => { - let network: TestNetwork - let client: AxiosInstance - let fileDid: string - let fileCid: CID - - beforeAll(async () => { - network = await TestNetwork.create({ - dbPostgresSchema: 'bsky_image_processing_server', - }) - const sc = network.getSeedClient() - await basicSeed(sc) - await network.processAll() - await network.bsky.processAll() - fileDid = sc.dids.carol - fileCid = sc.posts[fileDid][0].images[0].image.ref - client = axios.create({ - baseURL: `${network.bsky.url}/img`, - validateStatus: () => true, - }) - }) - - afterAll(async () => { - await network.close() - }) - - it('processes image from blob resolver.', async () => { - const res = await client.get( - ImageUriBuilder.getPath({ - preset: 'feed_fullsize', - did: fileDid, - cid: fileCid, - }), - { responseType: 'stream' }, - ) - - const info = await getInfo(res.data) - - expect(info).toEqual({ - height: 580, - width: 1000, - size: 127578, - mime: 'image/jpeg', - }) - expect(res.headers).toEqual( - expect.objectContaining({ - 'content-type': 'image/jpeg', - 'cache-control': 'public, max-age=31536000', - 'content-length': '127578', - }), - ) - }) - - it('caches results.', async () => { - const path = ImageUriBuilder.getPath({ - preset: 'avatar', - did: fileDid, - cid: fileCid, - }) - const res1 = await client.get(path, { responseType: 'arraybuffer' }) - expect(res1.headers['x-cache']).toEqual('miss') - const res2 = await client.get(path, { responseType: 'arraybuffer' }) - expect(res2.headers['x-cache']).toEqual('hit') - const res3 = await client.get(path, { responseType: 'arraybuffer' }) - expect(res3.headers['x-cache']).toEqual('hit') - expect(Buffer.compare(res1.data, res2.data)).toEqual(0) - expect(Buffer.compare(res1.data, res3.data)).toEqual(0) - }) - - it('errors on missing file.', async () => { - const missingCid = await cidForCbor('missing-file') - const res = await client.get( - ImageUriBuilder.getPath({ - preset: 'feed_fullsize', - did: fileDid, - cid: missingCid, - }), - ) - expect(res.status).toEqual(404) - expect(res.data).toEqual({ message: 'Image not found' }) - }) -}) diff --git a/packages/ozone/tests/image/sharp.test.ts b/packages/ozone/tests/image/sharp.test.ts deleted file mode 100644 index 17b3b7f3964..00000000000 --- a/packages/ozone/tests/image/sharp.test.ts +++ /dev/null @@ -1,185 +0,0 @@ -import { createReadStream } from 'fs' -import { Options, getInfo, resize } from '../../src/image/sharp' - -describe('sharp image processor', () => { - it('scales up to cover.', async () => { - const result = await processFixture('key-landscape-small.jpg', { - format: 'jpeg', - fit: 'cover', - width: 500, - height: 500, - min: true, - }) - expect(result).toEqual( - expect.objectContaining({ - height: 500, - width: 500, - }), - ) - }) - - it('scales up to inside (landscape).', async () => { - const result = await processFixture('key-landscape-small.jpg', { - format: 'jpeg', - fit: 'inside', - width: 500, - height: 500, - min: true, - }) - expect(result).toEqual( - expect.objectContaining({ - height: 290, - width: 500, - }), - ) - }) - - it('scales up to inside (portrait).', async () => { - const result = await processFixture('key-portrait-small.jpg', { - format: 'jpeg', - fit: 'inside', - width: 500, - height: 500, - min: true, - }) - expect(result).toEqual( - expect.objectContaining({ - height: 500, - width: 290, - }), - ) - }) - - it('scales up to min.', async () => { - const result = await processFixture('key-landscape-small.jpg', { - format: 'jpeg', - width: 500, - height: 500, - min: { height: 200, width: 200 }, - }) - expect(result).toEqual( - expect.objectContaining({ - height: 200, - width: 345, - }), - ) - }) - - it('does not scale image up when min is false.', async () => { - const result = await processFixture('key-landscape-small.jpg', { - format: 'jpeg', - width: 500, - height: 500, - min: false, - }) - expect(result).toEqual( - expect.objectContaining({ - height: 87, - width: 150, - mime: 'image/jpeg', - }), - ) - }) - - it('scales down to cover.', async () => { - const result = await processFixture('key-landscape-large.jpg', { - format: 'jpeg', - fit: 'cover', - width: 500, - height: 500, - }) - expect(result).toEqual( - expect.objectContaining({ - height: 500, - width: 500, - }), - ) - }) - - it('scales down to inside (landscape).', async () => { - const result = await processFixture('key-landscape-large.jpg', { - format: 'jpeg', - fit: 'inside', - width: 500, - height: 500, - }) - expect(result).toEqual( - expect.objectContaining({ - height: 290, - width: 500, - }), - ) - }) - - it('scales down to inside (portrait).', async () => { - const result = await processFixture('key-portrait-large.jpg', { - format: 'jpeg', - fit: 'inside', - width: 500, - height: 500, - }) - expect(result).toEqual( - expect.objectContaining({ - height: 500, - width: 290, - }), - ) - }) - - it('converts jpeg to png.', async () => { - const result = await processFixture('key-landscape-small.jpg', { - format: 'png', - width: 500, - height: 500, - min: false, - }) - expect(result).toEqual( - expect.objectContaining({ - height: 87, - width: 150, - size: expect.any(Number), - mime: 'image/png', - }), - ) - }) - - it('controls quality (jpeg).', async () => { - const high = await processFixture('key-portrait-small.jpg', { - format: 'jpeg', - width: 500, - height: 500, - quality: 90, - }) - const low = await processFixture('key-portrait-small.jpg', { - format: 'jpeg', - width: 500, - height: 500, - quality: 10, - }) - expect(high.size).toBeGreaterThan(1000) - expect(low.size).toBeLessThan(1000) - }) - - it('controls quality (png).', async () => { - const high = await processFixture('key-portrait-small.jpg', { - format: 'png', - width: 500, - height: 500, - quality: 80, - }) - const low = await processFixture('key-portrait-small.jpg', { - format: 'png', - width: 500, - height: 500, - quality: 10, - }) - expect(high.size).toBeGreaterThan(3000) - expect(low.size).toBeLessThan(3000) - }) - - async function processFixture(fixture: string, options: Options) { - const image = createReadStream(`tests/sample-img/${fixture}`) - const resized = await resize(image, options) - return await getInfo(resized) - } -}) diff --git a/packages/ozone/tests/image/uri.test.ts b/packages/ozone/tests/image/uri.test.ts deleted file mode 100644 index 60586d23f6b..00000000000 --- a/packages/ozone/tests/image/uri.test.ts +++ /dev/null @@ -1,87 +0,0 @@ -import { cidForCbor } from '@atproto/common' -import { CID } from 'multiformats/cid' -import { ImageUriBuilder, BadPathError } from '../../src/image/uri' - -describe('image uri builder', () => { - let uriBuilder: ImageUriBuilder - let cid: CID - const did = 'did:plc:xyz' - - beforeAll(async () => { - const endpoint = 'https://example.com/img' - uriBuilder = new ImageUriBuilder(endpoint) - cid = await cidForCbor('test cid') - }) - - it('generates paths.', () => { - expect(ImageUriBuilder.getPath({ preset: 'banner', did, cid })).toEqual( - `/banner/plain/${did}/${cid.toString()}@jpeg`, - ) - expect( - ImageUriBuilder.getPath({ preset: 'feed_thumbnail', did, cid }), - ).toEqual(`/feed_thumbnail/plain/${did}/${cid.toString()}@jpeg`) - }) - - it('generates uris.', () => { - expect(uriBuilder.getPresetUri('banner', did, cid)).toEqual( - `https://example.com/img/banner/plain/${did}/${cid.toString()}@jpeg`, - ) - expect( - uriBuilder.getPresetUri('feed_thumbnail', did, cid.toString()), - ).toEqual( - `https://example.com/img/feed_thumbnail/plain/${did}/${cid.toString()}@jpeg`, - ) - }) - - it('parses options.', () => { - expect( - ImageUriBuilder.getOptions(`/banner/plain/${did}/${cid.toString()}@png`), - ).toEqual({ - did: 'did:plc:xyz', - cid, - fit: 'cover', - format: 'png', - height: 1000, - min: true, - preset: 'banner', - width: 3000, - }) - expect( - ImageUriBuilder.getOptions( - `/feed_thumbnail/plain/${did}/${cid.toString()}@jpeg`, - ), - ).toEqual({ - did: 'did:plc:xyz', - cid, - fit: 'inside', - format: 'jpeg', - height: 2000, - min: true, - preset: 'feed_thumbnail', - width: 2000, - }) - }) - - it('errors on bad url pattern.', () => { - expect(tryGetOptions(`/a`)).toThrow(new BadPathError('Invalid path')) - expect(tryGetOptions(`/banner/plain/${did}@jpeg`)).toThrow( - new BadPathError('Invalid path'), - ) - }) - - it('errors on bad preset.', () => { - expect( - tryGetOptions(`/bad_banner/plain/${did}/${cid.toString()}@jpeg`), - ).toThrow(new BadPathError('Invalid path: bad preset')) - }) - - it('errors on bad format.', () => { - expect( - tryGetOptions(`/banner/plain/${did}/${cid.toString()}@webp`), - ).toThrow(new BadPathError('Invalid path: bad format')) - }) - - function tryGetOptions(path: string) { - return () => ImageUriBuilder.getOptions(path) - } -}) diff --git a/packages/ozone/tests/indexing.test.ts b/packages/ozone/tests/indexing.test.ts deleted file mode 100644 index f874a084567..00000000000 --- a/packages/ozone/tests/indexing.test.ts +++ /dev/null @@ -1,728 +0,0 @@ -import { sql } from 'kysely' -import { CID } from 'multiformats/cid' -import { cidForCbor, TID } from '@atproto/common' -import * as pdsRepo from '@atproto/pds/src/repo/prepare' -import { WriteOpAction } from '@atproto/repo' -import { AtUri } from '@atproto/syntax' -import AtpAgent, { - AppBskyActorProfile, - AppBskyFeedPost, - AppBskyFeedLike, - AppBskyFeedRepost, - AppBskyGraphFollow, -} from '@atproto/api' -import { TestNetwork, SeedClient } from '@atproto/dev-env' -import { forSnapshot } from './_util' -import usersSeed from './seeds/users' -import basicSeed from './seeds/basic' -import { ids } from '../src/lexicon/lexicons' -import { Database } from '../src/db' - -describe('indexing', () => { - let network: TestNetwork - let agent: AtpAgent - let pdsAgent: AtpAgent - let sc: SeedClient - - beforeAll(async () => { - network = await TestNetwork.create({ - dbPostgresSchema: 'bsky_indexing', - }) - agent = network.bsky.getClient() - pdsAgent = network.pds.getClient() - sc = network.getSeedClient() - await usersSeed(sc) - // Data in tests is not processed from subscription - await network.processAll() - await network.bsky.ingester.sub.destroy() - await network.bsky.indexer.sub.destroy() - await network.bsky.processAll() - }) - - afterAll(async () => { - await network.close() - }) - - it('indexes posts.', async () => { - const { db, services } = network.bsky.indexer.ctx - const createdAt = new Date().toISOString() - const createRecord = await prepareCreate({ - did: sc.dids.alice, - collection: ids.AppBskyFeedPost, - record: { - $type: ids.AppBskyFeedPost, - text: '@bob.test how are you?', - facets: [ - { - index: { byteStart: 0, byteEnd: 9 }, - features: [ - { - $type: `${ids.AppBskyRichtextFacet}#mention`, - did: sc.dids.bob, - }, - ], - }, - ], - createdAt, - } as AppBskyFeedPost.Record, - }) - const [uri] = createRecord - const updateRecord = await prepareUpdate({ - did: sc.dids.alice, - collection: ids.AppBskyFeedPost, - rkey: uri.rkey, - record: { - $type: ids.AppBskyFeedPost, - text: '@carol.test how are you?', - facets: [ - { - index: { byteStart: 0, byteEnd: 11 }, - features: [ - { - $type: `${ids.AppBskyRichtextFacet}#mention`, - did: sc.dids.carol, - }, - ], - }, - ], - createdAt, - } as AppBskyFeedPost.Record, - }) - const deleteRecord = prepareDelete({ - did: sc.dids.alice, - collection: ids.AppBskyFeedPost, - rkey: uri.rkey, - }) - - // Create - await services.indexing(db).indexRecord(...createRecord) - - const getAfterCreate = await agent.api.app.bsky.feed.getPostThread( - { uri: uri.toString() }, - { headers: await network.serviceHeaders(sc.dids.alice) }, - ) - expect(forSnapshot(getAfterCreate.data)).toMatchSnapshot() - const createNotifications = await getNotifications(db, uri) - - // Update - await services.indexing(db).indexRecord(...updateRecord) - - const getAfterUpdate = await agent.api.app.bsky.feed.getPostThread( - { uri: uri.toString() }, - { headers: await network.serviceHeaders(sc.dids.alice) }, - ) - expect(forSnapshot(getAfterUpdate.data)).toMatchSnapshot() - const updateNotifications = await getNotifications(db, uri) - - // Delete - await services.indexing(db).deleteRecord(...deleteRecord) - - const getAfterDelete = agent.api.app.bsky.feed.getPostThread( - { uri: uri.toString() }, - { headers: await network.serviceHeaders(sc.dids.alice) }, - ) - await expect(getAfterDelete).rejects.toThrow(/Post not found:/) - const deleteNotifications = await getNotifications(db, uri) - - expect( - forSnapshot({ - createNotifications, - updateNotifications, - deleteNotifications, - }), - ).toMatchSnapshot() - }) - - it('indexes profiles.', async () => { - const { db, services } = network.bsky.indexer.ctx - const createRecord = await prepareCreate({ - did: sc.dids.dan, - collection: ids.AppBskyActorProfile, - rkey: 'self', - record: { - $type: ids.AppBskyActorProfile, - displayName: 'dan', - } as AppBskyActorProfile.Record, - }) - const [uri] = createRecord - const updateRecord = await prepareUpdate({ - did: sc.dids.dan, - collection: ids.AppBskyActorProfile, - rkey: uri.rkey, - record: { - $type: ids.AppBskyActorProfile, - displayName: 'danny', - } as AppBskyActorProfile.Record, - }) - const deleteRecord = prepareDelete({ - did: sc.dids.dan, - collection: ids.AppBskyActorProfile, - rkey: uri.rkey, - }) - - // Create - await services.indexing(db).indexRecord(...createRecord) - - const getAfterCreate = await agent.api.app.bsky.actor.getProfile( - { actor: sc.dids.dan }, - { headers: await network.serviceHeaders(sc.dids.alice) }, - ) - expect(forSnapshot(getAfterCreate.data)).toMatchSnapshot() - - // Update - await services.indexing(db).indexRecord(...updateRecord) - - const getAfterUpdate = await agent.api.app.bsky.actor.getProfile( - { actor: sc.dids.dan }, - { headers: await network.serviceHeaders(sc.dids.alice) }, - ) - expect(forSnapshot(getAfterUpdate.data)).toMatchSnapshot() - - // Delete - await services.indexing(db).deleteRecord(...deleteRecord) - - const getAfterDelete = await agent.api.app.bsky.actor.getProfile( - { actor: sc.dids.dan }, - { headers: await network.serviceHeaders(sc.dids.alice) }, - ) - expect(forSnapshot(getAfterDelete.data)).toMatchSnapshot() - }) - - it('handles post aggregations out of order.', async () => { - const { db, services } = network.bsky.indexer.ctx - const createdAt = new Date().toISOString() - const originalPost = await prepareCreate({ - did: sc.dids.alice, - collection: ids.AppBskyFeedPost, - record: { - $type: ids.AppBskyFeedPost, - text: 'original post', - createdAt, - } as AppBskyFeedPost.Record, - }) - const originalPostRef = { - uri: originalPost[0].toString(), - cid: originalPost[1].toString(), - } - const reply = await prepareCreate({ - did: sc.dids.bob, - collection: ids.AppBskyFeedPost, - record: { - $type: ids.AppBskyFeedPost, - text: 'reply post', - reply: { - root: originalPostRef, - parent: originalPostRef, - }, - createdAt, - } as AppBskyFeedPost.Record, - }) - const like = await prepareCreate({ - did: sc.dids.bob, - collection: ids.AppBskyFeedLike, - record: { - $type: ids.AppBskyFeedLike, - subject: originalPostRef, - createdAt, - } as AppBskyFeedLike.Record, - }) - const repost = await prepareCreate({ - did: sc.dids.bob, - collection: ids.AppBskyFeedRepost, - record: { - $type: ids.AppBskyFeedRepost, - subject: originalPostRef, - createdAt, - } as AppBskyFeedRepost.Record, - }) - // reply, like, and repost indexed orior to the original post - await services.indexing(db).indexRecord(...reply) - await services.indexing(db).indexRecord(...like) - await services.indexing(db).indexRecord(...repost) - await services.indexing(db).indexRecord(...originalPost) - await network.bsky.processAll() - const agg = await db.db - .selectFrom('post_agg') - .selectAll() - .where('uri', '=', originalPostRef.uri) - .executeTakeFirst() - expect(agg).toEqual({ - uri: originalPostRef.uri, - replyCount: 1, - repostCount: 1, - likeCount: 1, - }) - // Cleanup - const del = (uri: AtUri) => { - return prepareDelete({ - did: uri.host, - collection: uri.collection, - rkey: uri.rkey, - }) - } - await services.indexing(db).deleteRecord(...del(reply[0])) - await services.indexing(db).deleteRecord(...del(like[0])) - await services.indexing(db).deleteRecord(...del(repost[0])) - await services.indexing(db).deleteRecord(...del(originalPost[0])) - }) - - it('does not notify user of own like or repost', async () => { - const { db, services } = network.bsky.indexer.ctx - const createdAt = new Date().toISOString() - - const originalPost = await prepareCreate({ - did: sc.dids.bob, - collection: ids.AppBskyFeedPost, - record: { - $type: ids.AppBskyFeedPost, - text: 'original post', - createdAt, - } as AppBskyFeedPost.Record, - }) - - const originalPostRef = { - uri: originalPost[0].toString(), - cid: originalPost[1].toString(), - } - - // own actions - const ownLike = await prepareCreate({ - did: sc.dids.bob, - collection: ids.AppBskyFeedLike, - record: { - $type: ids.AppBskyFeedLike, - subject: originalPostRef, - createdAt, - } as AppBskyFeedLike.Record, - }) - const ownRepost = await prepareCreate({ - did: sc.dids.bob, - collection: ids.AppBskyFeedRepost, - record: { - $type: ids.AppBskyFeedRepost, - subject: originalPostRef, - createdAt, - } as AppBskyFeedRepost.Record, - }) - - // other actions - const aliceLike = await prepareCreate({ - did: sc.dids.alice, - collection: ids.AppBskyFeedLike, - record: { - $type: ids.AppBskyFeedLike, - subject: originalPostRef, - createdAt, - } as AppBskyFeedLike.Record, - }) - const aliceRepost = await prepareCreate({ - did: sc.dids.alice, - collection: ids.AppBskyFeedRepost, - record: { - $type: ids.AppBskyFeedRepost, - subject: originalPostRef, - createdAt, - } as AppBskyFeedRepost.Record, - }) - - await services.indexing(db).indexRecord(...originalPost) - await services.indexing(db).indexRecord(...ownLike) - await services.indexing(db).indexRecord(...ownRepost) - await services.indexing(db).indexRecord(...aliceLike) - await services.indexing(db).indexRecord(...aliceRepost) - - await network.bsky.processAll() - - const { - data: { notifications }, - } = await agent.api.app.bsky.notification.listNotifications( - {}, - { headers: await network.serviceHeaders(sc.dids.bob) }, - ) - - expect(notifications).toHaveLength(2) - expect( - notifications.every((n) => { - return n.author.did !== sc.dids.bob - }), - ).toBeTruthy() - - // Cleanup - const del = (uri: AtUri) => { - return prepareDelete({ - did: uri.host, - collection: uri.collection, - rkey: uri.rkey, - }) - } - - await services.indexing(db).deleteRecord(...del(ownLike[0])) - await services.indexing(db).deleteRecord(...del(ownRepost[0])) - await services.indexing(db).deleteRecord(...del(aliceLike[0])) - await services.indexing(db).deleteRecord(...del(aliceRepost[0])) - await services.indexing(db).deleteRecord(...del(originalPost[0])) - }) - - it('handles profile aggregations out of order.', async () => { - const { db, services } = network.bsky.indexer.ctx - const createdAt = new Date().toISOString() - const unknownDid = 'did:example:unknown' - const follow = await prepareCreate({ - did: sc.dids.bob, - collection: ids.AppBskyGraphFollow, - record: { - $type: ids.AppBskyGraphFollow, - subject: unknownDid, - createdAt, - } as AppBskyGraphFollow.Record, - }) - await services.indexing(db).indexRecord(...follow) - await network.bsky.processAll() - const agg = await db.db - .selectFrom('profile_agg') - .select(['did', 'followersCount']) - .where('did', '=', unknownDid) - .executeTakeFirst() - expect(agg).toEqual({ - did: unknownDid, - followersCount: 1, - }) - // Cleanup - const del = (uri: AtUri) => { - return prepareDelete({ - did: uri.host, - collection: uri.collection, - rkey: uri.rkey, - }) - } - await services.indexing(db).deleteRecord(...del(follow[0])) - }) - - describe('indexRepo', () => { - beforeAll(async () => { - network.bsky.indexer.sub.resume() - network.bsky.ingester.sub.resume() - await basicSeed(sc, false) - await network.processAll() - await network.bsky.ingester.sub.destroy() - await network.bsky.indexer.sub.destroy() - await network.bsky.processAll() - }) - - it('preserves indexes when no record changes.', async () => { - const { db, services } = network.bsky.indexer.ctx - // Mark originals - const { data: origProfile } = await agent.api.app.bsky.actor.getProfile( - { actor: sc.dids.alice }, - { headers: await network.serviceHeaders(sc.dids.alice) }, - ) - const { data: origFeed } = await agent.api.app.bsky.feed.getAuthorFeed( - { actor: sc.dids.alice }, - { headers: await network.serviceHeaders(sc.dids.alice) }, - ) - const { data: origFollows } = await agent.api.app.bsky.graph.getFollows( - { actor: sc.dids.alice }, - { headers: await network.serviceHeaders(sc.dids.alice) }, - ) - // Index - const { data: commit } = - await pdsAgent.api.com.atproto.sync.getLatestCommit({ - did: sc.dids.alice, - }) - await services.indexing(db).indexRepo(sc.dids.alice, commit.cid) - await network.bsky.processAll() - // Check - const { data: profile } = await agent.api.app.bsky.actor.getProfile( - { actor: sc.dids.alice }, - { headers: await network.serviceHeaders(sc.dids.alice) }, - ) - const { data: feed } = await agent.api.app.bsky.feed.getAuthorFeed( - { actor: sc.dids.alice }, - { headers: await network.serviceHeaders(sc.dids.alice) }, - ) - const { data: follows } = await agent.api.app.bsky.graph.getFollows( - { actor: sc.dids.alice }, - { headers: await network.serviceHeaders(sc.dids.alice) }, - ) - expect(forSnapshot([origProfile, origFeed, origFollows])).toEqual( - forSnapshot([profile, feed, follows]), - ) - }) - - it('updates indexes when records change.', async () => { - const { db, services } = network.bsky.indexer.ctx - // Update profile - await pdsAgent.api.com.atproto.repo.putRecord( - { - repo: sc.dids.alice, - collection: ids.AppBskyActorProfile, - rkey: 'self', - record: { description: 'freshening things up' }, - }, - { headers: sc.getHeaders(sc.dids.alice), encoding: 'application/json' }, - ) - // Add post - const newPost = await sc.post(sc.dids.alice, 'fresh post!') - // Remove a follow - const removedFollow = sc.follows[sc.dids.alice][sc.dids.carol] - await pdsAgent.api.app.bsky.graph.follow.delete( - { repo: sc.dids.alice, rkey: removedFollow.uri.rkey }, - sc.getHeaders(sc.dids.alice), - ) - // Index - const { data: commit } = - await pdsAgent.api.com.atproto.sync.getLatestCommit({ - did: sc.dids.alice, - }) - await services.indexing(db).indexRepo(sc.dids.alice, commit.cid) - await network.bsky.processAll() - // Check - const { data: profile } = await agent.api.app.bsky.actor.getProfile( - { actor: sc.dids.alice }, - { headers: await network.serviceHeaders(sc.dids.alice) }, - ) - const { data: feed } = await agent.api.app.bsky.feed.getAuthorFeed( - { actor: sc.dids.alice }, - { headers: await network.serviceHeaders(sc.dids.alice) }, - ) - const { data: follows } = await agent.api.app.bsky.graph.getFollows( - { actor: sc.dids.alice }, - { headers: await network.serviceHeaders(sc.dids.alice) }, - ) - expect(profile.description).toEqual('freshening things up') - expect(feed.feed[0].post.uri).toEqual(newPost.ref.uriStr) - expect(feed.feed[0].post.cid).toEqual(newPost.ref.cidStr) - expect(follows.follows.map(({ did }) => did)).not.toContain(sc.dids.carol) - expect(forSnapshot([profile, feed, follows])).toMatchSnapshot() - }) - - it('skips invalid records.', async () => { - const { db, services } = network.bsky.indexer.ctx - const { accountManager } = network.pds.ctx - // const { db: pdsDb, services: pdsServices } = network.pds.ctx - // Create a good and a bad post record - const writes = await Promise.all([ - pdsRepo.prepareCreate({ - did: sc.dids.alice, - collection: ids.AppBskyFeedPost, - record: { text: 'valid', createdAt: new Date().toISOString() }, - }), - pdsRepo.prepareCreate({ - did: sc.dids.alice, - collection: ids.AppBskyFeedPost, - record: { text: 0 }, - validate: false, - }), - ]) - const writeCommit = await network.pds.ctx.actorStore.transact( - sc.dids.alice, - (store) => store.repo.processWrites(writes), - ) - await accountManager.updateRepoRoot( - sc.dids.alice, - writeCommit.cid, - writeCommit.rev, - ) - await network.pds.ctx.sequencer.sequenceCommit( - sc.dids.alice, - writeCommit, - writes, - ) - // Index - const { data: commit } = - await pdsAgent.api.com.atproto.sync.getLatestCommit({ - did: sc.dids.alice, - }) - await services.indexing(db).indexRepo(sc.dids.alice, commit.cid) - // Check - const getGoodPost = agent.api.app.bsky.feed.getPostThread( - { uri: writes[0].uri.toString(), depth: 0 }, - { headers: await network.serviceHeaders(sc.dids.alice) }, - ) - await expect(getGoodPost).resolves.toBeDefined() - const getBadPost = agent.api.app.bsky.feed.getPostThread( - { uri: writes[1].uri.toString(), depth: 0 }, - { headers: await network.serviceHeaders(sc.dids.alice) }, - ) - await expect(getBadPost).rejects.toThrow('Post not found') - }) - }) - - describe('indexHandle', () => { - const getIndexedHandle = async (did) => { - const res = await agent.api.app.bsky.actor.getProfile( - { actor: did }, - { headers: await network.serviceHeaders(sc.dids.alice) }, - ) - return res.data.handle - } - - it('indexes handle for a fresh did', async () => { - const { db, services } = network.bsky.indexer.ctx - const now = new Date().toISOString() - const sessionAgent = new AtpAgent({ service: network.pds.url }) - const { - data: { did }, - } = await sessionAgent.createAccount({ - email: 'did1@test.com', - handle: 'did1.test', - password: 'password', - }) - await expect(getIndexedHandle(did)).rejects.toThrow('Profile not found') - await services.indexing(db).indexHandle(did, now) - await expect(getIndexedHandle(did)).resolves.toEqual('did1.test') - }) - - it('reindexes handle for existing did when forced', async () => { - const { db, services } = network.bsky.indexer.ctx - const now = new Date().toISOString() - const sessionAgent = new AtpAgent({ service: network.pds.url }) - const { - data: { did }, - } = await sessionAgent.createAccount({ - email: 'did2@test.com', - handle: 'did2.test', - password: 'password', - }) - await services.indexing(db).indexHandle(did, now) - await expect(getIndexedHandle(did)).resolves.toEqual('did2.test') - await sessionAgent.com.atproto.identity.updateHandle({ - handle: 'did2-updated.test', - }) - await services.indexing(db).indexHandle(did, now) - await expect(getIndexedHandle(did)).resolves.toEqual('did2.test') // Didn't update, not forced - await services.indexing(db).indexHandle(did, now, true) - await expect(getIndexedHandle(did)).resolves.toEqual('did2-updated.test') - }) - - it('handles profile aggregations out of order', async () => { - const { db, services } = network.bsky.indexer.ctx - const now = new Date().toISOString() - const sessionAgent = new AtpAgent({ service: network.pds.url }) - const { - data: { did }, - } = await sessionAgent.createAccount({ - email: 'did3@test.com', - handle: 'did3.test', - password: 'password', - }) - const follow = await prepareCreate({ - did: sc.dids.bob, - collection: ids.AppBskyGraphFollow, - record: { - $type: ids.AppBskyGraphFollow, - subject: did, - createdAt: now, - } as AppBskyGraphFollow.Record, - }) - await services.indexing(db).indexRecord(...follow) - await services.indexing(db).indexHandle(did, now) - await network.bsky.processAll() - const agg = await db.db - .selectFrom('profile_agg') - .select(['did', 'followersCount']) - .where('did', '=', did) - .executeTakeFirst() - expect(agg).toEqual({ - did, - followersCount: 1, - }) - }) - }) - - describe('tombstoneActor', () => { - it('does not unindex actor when they are still being hosted by their pds', async () => { - const { db, services } = network.bsky.indexer.ctx - const { data: profileBefore } = await agent.api.app.bsky.actor.getProfile( - { actor: sc.dids.alice }, - { headers: await network.serviceHeaders(sc.dids.bob) }, - ) - // Attempt indexing tombstone - await services.indexing(db).tombstoneActor(sc.dids.alice) - const { data: profileAfter } = await agent.api.app.bsky.actor.getProfile( - { actor: sc.dids.alice }, - { headers: await network.serviceHeaders(sc.dids.bob) }, - ) - expect(profileAfter).toEqual(profileBefore) - }) - - it('unindexes actor when they are no longer hosted by their pds', async () => { - const { db, services } = network.bsky.indexer.ctx - const { alice } = sc.dids - const getProfileBefore = agent.api.app.bsky.actor.getProfile( - { actor: alice }, - { headers: await network.serviceHeaders(sc.dids.bob) }, - ) - await expect(getProfileBefore).resolves.toBeDefined() - // Delete account on pds - const token = await network.pds.ctx.accountManager.createEmailToken( - alice, - 'delete_account', - ) - await pdsAgent.api.com.atproto.server.deleteAccount({ - token, - did: alice, - password: sc.accounts[alice].password, - }) - await network.pds.ctx.backgroundQueue.processAll() - // Index tombstone - await services.indexing(db).tombstoneActor(alice) - const getProfileAfter = agent.api.app.bsky.actor.getProfile( - { actor: alice }, - { headers: await network.serviceHeaders(sc.dids.bob) }, - ) - await expect(getProfileAfter).rejects.toThrow('Profile not found') - }) - }) - - async function getNotifications(db: Database, uri: AtUri) { - return await db.db - .selectFrom('notification') - .selectAll() - .select(sql`0`.as('id')) // Ignore notification ids in comparisons - .where('recordUri', '=', uri.toString()) - .orderBy('sortAt') - .execute() - } -}) - -async function prepareCreate(opts: { - did: string - collection: string - rkey?: string - record: unknown - timestamp?: string -}): Promise<[AtUri, CID, unknown, WriteOpAction.Create, string]> { - const rkey = opts.rkey ?? TID.nextStr() - return [ - AtUri.make(opts.did, opts.collection, rkey), - await cidForCbor(opts.record), - opts.record, - WriteOpAction.Create, - opts.timestamp ?? new Date().toISOString(), - ] -} - -async function prepareUpdate(opts: { - did: string - collection: string - rkey: string - record: unknown - timestamp?: string -}): Promise<[AtUri, CID, unknown, WriteOpAction.Update, string]> { - return [ - AtUri.make(opts.did, opts.collection, opts.rkey), - await cidForCbor(opts.record), - opts.record, - WriteOpAction.Update, - opts.timestamp ?? new Date().toISOString(), - ] -} - -function prepareDelete(opts: { - did: string - collection: string - rkey: string -}): [AtUri] { - return [AtUri.make(opts.did, opts.collection, opts.rkey)] -} diff --git a/packages/ozone/tests/admin/moderation-events.test.ts b/packages/ozone/tests/moderation-events.test.ts similarity index 97% rename from packages/ozone/tests/admin/moderation-events.test.ts rename to packages/ozone/tests/moderation-events.test.ts index 6a49d8fb572..6cc266f2405 100644 --- a/packages/ozone/tests/admin/moderation-events.test.ts +++ b/packages/ozone/tests/moderation-events.test.ts @@ -1,11 +1,11 @@ import { TestNetwork, SeedClient } from '@atproto/dev-env' import AtpAgent, { ComAtprotoAdminDefs } from '@atproto/api' -import { forSnapshot } from '../_util' -import basicSeed from '../seeds/basic' +import { forSnapshot } from './_util' +import basicSeed from './seeds/basic' import { REASONMISLEADING, REASONSPAM, -} from '../../src/lexicon/types/com/atproto/moderation/defs' +} from '../src/lexicon/types/com/atproto/moderation/defs' describe('moderation-events', () => { let network: TestNetwork diff --git a/packages/ozone/tests/admin/moderation-statuses.test.ts b/packages/ozone/tests/moderation-statuses.test.ts similarity index 96% rename from packages/ozone/tests/admin/moderation-statuses.test.ts rename to packages/ozone/tests/moderation-statuses.test.ts index fa010160048..1e80422e5d6 100644 --- a/packages/ozone/tests/admin/moderation-statuses.test.ts +++ b/packages/ozone/tests/moderation-statuses.test.ts @@ -3,12 +3,12 @@ import AtpAgent, { ComAtprotoAdminDefs, ComAtprotoAdminQueryModerationStatuses, } from '@atproto/api' -import { forSnapshot } from '../_util' -import basicSeed from '../seeds/basic' +import { forSnapshot } from './_util' +import basicSeed from './seeds/basic' import { REASONMISLEADING, REASONSPAM, -} from '../../src/lexicon/types/com/atproto/moderation/defs' +} from '../src/lexicon/types/com/atproto/moderation/defs' describe('moderation-statuses', () => { let network: TestNetwork diff --git a/packages/ozone/tests/admin/moderation.test.ts b/packages/ozone/tests/moderation.test.ts similarity index 99% rename from packages/ozone/tests/admin/moderation.test.ts rename to packages/ozone/tests/moderation.test.ts index 93e0998f2d3..ac83fe01261 100644 --- a/packages/ozone/tests/admin/moderation.test.ts +++ b/packages/ozone/tests/moderation.test.ts @@ -5,20 +5,20 @@ import AtpAgent, { ComAtprotoModerationCreateReport, } from '@atproto/api' import { AtUri } from '@atproto/syntax' -import { forSnapshot } from '../_util' -import basicSeed from '../seeds/basic' +import { forSnapshot } from './_util' +import basicSeed from './seeds/basic' import { REASONMISLEADING, REASONOTHER, REASONSPAM, -} from '../../src/lexicon/types/com/atproto/moderation/defs' +} from '../src/lexicon/types/com/atproto/moderation/defs' import { ModEventLabel, ModEventTakedown, REVIEWCLOSED, REVIEWESCALATED, -} from '../../src/lexicon/types/com/atproto/admin/defs' -import { PeriodicModerationEventReversal } from '../../src' +} from '../src/lexicon/types/com/atproto/admin/defs' +import { PeriodicModerationEventReversal } from '../src' type BaseCreateReportParams = | { account: string } @@ -741,7 +741,7 @@ describe('moderation', () => { // In the actual app, this will be instantiated and run on server startup const periodicReversal = new PeriodicModerationEventReversal( - network.bsky.ctx, + network.ozone.ctx, ) await periodicReversal.findAndRevertDueActions() diff --git a/packages/ozone/tests/notification-server.test.ts b/packages/ozone/tests/notification-server.test.ts deleted file mode 100644 index 6f9c8b00224..00000000000 --- a/packages/ozone/tests/notification-server.test.ts +++ /dev/null @@ -1,231 +0,0 @@ -import AtpAgent, { AtUri } from '@atproto/api' -import { TestNetwork, SeedClient } from '@atproto/dev-env' -import basicSeed from './seeds/basic' -import { NotificationServer } from '../src/notifications' -import { Database } from '../src' - -describe('notification server', () => { - let network: TestNetwork - let agent: AtpAgent - let pdsAgent: AtpAgent - let sc: SeedClient - let notifServer: NotificationServer - - // account dids, for convenience - let alice: string - - beforeAll(async () => { - network = await TestNetwork.create({ - dbPostgresSchema: 'bsky_notification_server', - }) - agent = network.bsky.getClient() - pdsAgent = network.pds.getClient() - sc = network.getSeedClient() - await basicSeed(sc) - await network.processAll() - await network.bsky.processAll() - alice = sc.dids.alice - notifServer = network.bsky.ctx.notifServer - }) - - afterAll(async () => { - await network.close() - }) - - describe('registerPushNotification', () => { - it('registers push notification token and device.', async () => { - const res = await agent.api.app.bsky.notification.registerPush( - { - serviceDid: network.bsky.ctx.cfg.serverDid, - platform: 'ios', - token: '123', - appId: 'xyz.blueskyweb.app', - }, - { - encoding: 'application/json', - headers: await network.serviceHeaders(alice), - }, - ) - expect(res.success).toEqual(true) - }) - - it('allows reregistering push notification token.', async () => { - const res1 = await agent.api.app.bsky.notification.registerPush( - { - serviceDid: network.bsky.ctx.cfg.serverDid, - platform: 'web', - token: '234', - appId: 'xyz.blueskyweb.app', - }, - { - encoding: 'application/json', - headers: await network.serviceHeaders(alice), - }, - ) - const res2 = await agent.api.app.bsky.notification.registerPush( - { - serviceDid: network.bsky.ctx.cfg.serverDid, - platform: 'web', - token: '234', - appId: 'xyz.blueskyweb.app', - }, - { - encoding: 'application/json', - headers: await network.serviceHeaders(alice), - }, - ) - expect(res1.success).toEqual(true) - expect(res2.success).toEqual(true) - }) - - it('does not allows registering push notification at mismatching service.', async () => { - const tryRegister = agent.api.app.bsky.notification.registerPush( - { - serviceDid: 'did:web:notifservice.com', - platform: 'ios', - token: '123', - appId: 'xyz.blueskyweb.app', - }, - { - encoding: 'application/json', - headers: await network.serviceHeaders(alice), - }, - ) - await expect(tryRegister).rejects.toThrow('Invalid serviceDid.') - }) - }) - - describe('NotificationServer', () => { - it('gets user tokens from db', async () => { - const tokens = await notifServer.getTokensByDid([alice]) - expect(tokens[alice][0].token).toEqual('123') - }) - - it('gets notification display attributes: title and body', async () => { - const db = network.bsky.ctx.db.getPrimary() - const notif = await getLikeNotification(db, alice) - if (!notif) throw new Error('no notification found') - const attrs = await notifServer.getNotificationDisplayAttributes([notif]) - if (!attrs.length) - throw new Error('no notification display attributes found') - expect(attrs[0].title).toEqual('bobby liked your post') - }) - - it('filters notifications that violate blocks', async () => { - const db = network.bsky.ctx.db.getPrimary() - const notif = await getLikeNotification(db, alice) - if (!notif) throw new Error('no notification found') - const blockRef = await pdsAgent.api.app.bsky.graph.block.create( - { repo: alice }, - { subject: notif.author, createdAt: new Date().toISOString() }, - sc.getHeaders(alice), - ) - await network.processAll() - // verify inverse of block - const flippedNotif = { - ...notif, - did: notif.author, - author: notif.did, - } - const attrs = await notifServer.getNotificationDisplayAttributes([ - notif, - flippedNotif, - ]) - expect(attrs.length).toBe(0) - const uri = new AtUri(blockRef.uri) - await pdsAgent.api.app.bsky.graph.block.delete( - { repo: alice, rkey: uri.rkey }, - sc.getHeaders(alice), - ) - await network.processAll() - }) - - it('filters notifications that violate mutes', async () => { - const db = network.bsky.ctx.db.getPrimary() - const notif = await getLikeNotification(db, alice) - if (!notif) throw new Error('no notification found') - await pdsAgent.api.app.bsky.graph.muteActor( - { actor: notif.author }, - { headers: sc.getHeaders(alice), encoding: 'application/json' }, - ) - const attrs = await notifServer.getNotificationDisplayAttributes([notif]) - expect(attrs.length).toBe(0) - await pdsAgent.api.app.bsky.graph.unmuteActor( - { actor: notif.author }, - { headers: sc.getHeaders(alice), encoding: 'application/json' }, - ) - }) - - it('filters notifications that violate mutelists', async () => { - const db = network.bsky.ctx.db.getPrimary() - const notif = await getLikeNotification(db, alice) - if (!notif) throw new Error('no notification found') - const listRef = await pdsAgent.api.app.bsky.graph.list.create( - { repo: alice }, - { - name: 'mute', - purpose: 'app.bsky.graph.defs#modlist', - createdAt: new Date().toISOString(), - }, - sc.getHeaders(alice), - ) - await pdsAgent.api.app.bsky.graph.listitem.create( - { repo: alice }, - { - subject: notif.author, - list: listRef.uri, - createdAt: new Date().toISOString(), - }, - sc.getHeaders(alice), - ) - await network.processAll() - await pdsAgent.api.app.bsky.graph.muteActorList( - { list: listRef.uri }, - { headers: sc.getHeaders(alice), encoding: 'application/json' }, - ) - const attrs = await notifServer.getNotificationDisplayAttributes([notif]) - expect(attrs.length).toBe(0) - await pdsAgent.api.app.bsky.graph.unmuteActorList( - { list: listRef.uri }, - { headers: sc.getHeaders(alice), encoding: 'application/json' }, - ) - }) - - it('prepares notification to be sent', async () => { - const db = network.bsky.ctx.db.getPrimary() - const notif = await getLikeNotification(db, alice) - if (!notif) throw new Error('no notification found') - const notifAsArray = [ - notif, - notif /* second one will get dropped by rate limit */, - ] - const prepared = await notifServer.prepareNotifsToSend(notifAsArray) - expect(prepared).toEqual([ - { - collapse_id: 'like', - collapse_key: 'like', - data: { - reason: notif.reason, - recordCid: notif.recordCid, - recordUri: notif.recordUri, - }, - message: 'again', - platform: 1, - title: 'bobby liked your post', - tokens: ['123'], - topic: 'xyz.blueskyweb.app', - }, - ]) - }) - }) - - async function getLikeNotification(db: Database, did: string) { - return await db.db - .selectFrom('notification') - .selectAll() - .where('did', '=', did) - .where('reason', '=', 'like') - .orderBy('sortAt') - .executeTakeFirst() - } -}) diff --git a/packages/ozone/tests/pipeline/backpressure.test.ts b/packages/ozone/tests/pipeline/backpressure.test.ts deleted file mode 100644 index 583d749100e..00000000000 --- a/packages/ozone/tests/pipeline/backpressure.test.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { wait } from '@atproto/common' -import { - BskyIndexers, - TestNetworkNoAppView, - getIndexers, - getIngester, - processAll, - SeedClient, -} from '@atproto/dev-env' -import basicSeed from '../seeds/basic' -import { BskyIngester } from '../../src' - -const TEST_NAME = 'pipeline_backpressure' - -describe('pipeline backpressure', () => { - let network: TestNetworkNoAppView - let ingester: BskyIngester - let indexers: BskyIndexers - - let sc: SeedClient - - beforeAll(async () => { - network = await TestNetworkNoAppView.create({ - dbPostgresSchema: TEST_NAME, - }) - ingester = await getIngester(network, { - name: TEST_NAME, - ingesterPartitionCount: 2, - ingesterMaxItems: 10, - ingesterCheckItemsEveryN: 5, - }) - indexers = await getIndexers(network, { - name: TEST_NAME, - partitionIdsByIndexer: [[0], [1]], - }) - sc = network.getSeedClient() - await basicSeed(sc) - }) - - afterAll(async () => { - await network.close() - }) - - it('ingester issues backpressure based on total of partition lengths.', async () => { - // ingest until first 10 are seen - await ingester.start() - while ((ingester.sub.lastSeq ?? 0) < 10) { - await wait(50) - } - // allow additional time to pass to ensure no additional events are being consumed - await wait(200) - // check that max items has been respected (i.e. backpressure was applied) - const lengths = await ingester.ctx.redis.streamLengths(['repo:0', 'repo:1']) - expect(lengths).toHaveLength(2) - expect(lengths[0] + lengths[1]).toBeLessThanOrEqual(10 + 5) // not exact due to batching, may catch on following check backpressure - // drain all items using indexers, releasing backpressure - await indexers.start() - await processAll(network, ingester) - const lengthsFinal = await ingester.ctx.redis.streamLengths([ - 'repo:0', - 'repo:1', - ]) - expect(lengthsFinal).toHaveLength(2) - expect(lengthsFinal[0] + lengthsFinal[1]).toEqual(0) - await indexers.destroy() - await ingester.destroy() - }) -}) diff --git a/packages/ozone/tests/pipeline/reingest.test.ts b/packages/ozone/tests/pipeline/reingest.test.ts deleted file mode 100644 index 3c860bcf680..00000000000 --- a/packages/ozone/tests/pipeline/reingest.test.ts +++ /dev/null @@ -1,55 +0,0 @@ -import { - TestNetworkNoAppView, - SeedClient, - getIngester, - ingestAll, -} from '@atproto/dev-env' -import basicSeed from '../seeds/basic' -import { BskyIngester } from '../../src' - -const TEST_NAME = 'pipeline_reingest' - -describe('pipeline reingestion', () => { - let network: TestNetworkNoAppView - let ingester: BskyIngester - let sc: SeedClient - - beforeAll(async () => { - network = await TestNetworkNoAppView.create({ - dbPostgresSchema: TEST_NAME, - }) - ingester = await getIngester(network, { - name: TEST_NAME, - ingesterPartitionCount: 1, - }) - sc = network.getSeedClient() - await basicSeed(sc) - }) - - afterAll(async () => { - await network.close() - await ingester.destroy() - }) - - it('allows events to be reingested multiple times.', async () => { - // ingest all events once - await ingester.start() - await ingestAll(network, ingester) - const initialCursor = await ingester.sub.getCursor() - const [initialLen] = await ingester.ctx.redis.streamLengths(['repo:0']) - expect(initialCursor).toBeGreaterThan(10) - expect(initialLen).toBeGreaterThan(10) - // stop ingesting and reset ingester state - await ingester.sub.destroy() - await ingester.sub.resetCursor() - // add one new event and reingest - await sc.post(sc.dids.alice, 'one more event!') // add one event to firehose - ingester.sub.resume() - await ingestAll(network, ingester) - // confirm the newest event was ingested - const finalCursor = await ingester.sub.getCursor() - const [finalLen] = await ingester.ctx.redis.streamLengths(['repo:0']) - expect(finalCursor).toEqual(initialCursor + 1) - expect(finalLen).toEqual(initialLen + 1) - }) -}) diff --git a/packages/ozone/tests/pipeline/repartition.test.ts b/packages/ozone/tests/pipeline/repartition.test.ts deleted file mode 100644 index f228b954fb6..00000000000 --- a/packages/ozone/tests/pipeline/repartition.test.ts +++ /dev/null @@ -1,86 +0,0 @@ -import { - BskyIndexers, - TestNetworkNoAppView, - SeedClient, - getIndexers, - getIngester, - ingestAll, - processAll, -} from '@atproto/dev-env' -import usersSeed from '../seeds/users' -import { BskyIngester } from '../../src' -import { countAll } from '../../src/db/util' - -const TEST_NAME = 'pipeline_repartition' - -describe('pipeline indexer repartitioning', () => { - let network: TestNetworkNoAppView - let ingester: BskyIngester - let indexers1: BskyIndexers - let indexers2: BskyIndexers - let sc: SeedClient - - beforeAll(async () => { - network = await TestNetworkNoAppView.create({ - dbPostgresSchema: TEST_NAME, - }) - ingester = await getIngester(network, { - name: TEST_NAME, - ingesterPartitionCount: 2, - }) - indexers1 = await getIndexers(network, { - name: TEST_NAME, - partitionIdsByIndexer: [[0, 1]], // one indexer consuming two partitions - }) - indexers2 = await getIndexers(network, { - name: TEST_NAME, - partitionIdsByIndexer: [[0], [1]], // two indexers, each consuming one partition - }) - sc = network.getSeedClient() - await usersSeed(sc) - }) - - afterAll(async () => { - await network.close() - }) - - it('indexers repartition without missing events.', async () => { - const poster = createPoster(sc) - await Promise.all([poster.post(4), indexers1.start(), ingester.start()]) - await poster.post(1) - await processAll(network, ingester) - const { count: indexedPosts } = await indexers1.db.db - .selectFrom('post') - .select(countAll.as('count')) - .executeTakeFirstOrThrow() - expect(indexedPosts).toEqual(5) - await Promise.all([poster.post(3), indexers1.destroy()]) - await poster.post(3) // miss some events - await ingestAll(network, ingester) - await Promise.all([poster.post(3), indexers2.start()]) // handle some events on indexers2 - await processAll(network, ingester) - const { count: allIndexedPosts } = await indexers2.db.db - .selectFrom('post') - .select(countAll.as('count')) - .executeTakeFirstOrThrow() - expect(allIndexedPosts).toBeGreaterThan(indexedPosts) - expect(allIndexedPosts).toEqual(poster.postCount) - await indexers2.destroy() - await ingester.destroy() - }) -}) - -function createPoster(sc: SeedClient) { - return { - postCount: 0, - destroyed: false, - async post(n = 1) { - const dids = Object.values(sc.dids) - for (let i = 0; i < n; ++i) { - const did = dids[this.postCount % dids.length] - await sc.post(did, `post ${this.postCount}`) - this.postCount++ - } - }, - } -} diff --git a/packages/ozone/tests/redis-cache.test.ts b/packages/ozone/tests/redis-cache.test.ts deleted file mode 100644 index dc975a66161..00000000000 --- a/packages/ozone/tests/redis-cache.test.ts +++ /dev/null @@ -1,231 +0,0 @@ -import { wait } from '@atproto/common' -import { Redis } from '../src/' -import { ReadThroughCache } from '../src/cache/read-through' - -describe('redis cache', () => { - let redis: Redis - - beforeAll(async () => { - redis = new Redis({ host: process.env.REDIS_HOST || '' }) - }) - - afterAll(async () => { - await redis.destroy() - }) - - it('caches according to namespace', async () => { - const ns1 = redis.withNamespace('ns1') - const ns2 = redis.withNamespace('ns2') - await Promise.all([ - ns1.set('key', 'a'), - ns2.set('key', 'b'), - redis.set('key', 'c'), - ]) - const got = await Promise.all([ - ns1.get('key'), - ns2.get('key'), - redis.get('key'), - ]) - expect(got[0]).toEqual('a') - expect(got[1]).toEqual('b') - expect(got[2]).toEqual('c') - - await Promise.all([ - ns1.setMulti({ key1: 'a', key2: 'b' }), - ns2.setMulti({ key1: 'c', key2: 'd' }), - redis.setMulti({ key1: 'e', key2: 'f' }), - ]) - const gotMany = await Promise.all([ - ns1.getMulti(['key1', 'key2']), - ns2.getMulti(['key1', 'key2']), - redis.getMulti(['key1', 'key2']), - ]) - expect(gotMany[0]['key1']).toEqual('a') - expect(gotMany[0]['key2']).toEqual('b') - expect(gotMany[1]['key1']).toEqual('c') - expect(gotMany[1]['key2']).toEqual('d') - expect(gotMany[2]['key1']).toEqual('e') - expect(gotMany[2]['key2']).toEqual('f') - }) - - it('caches values when empty', async () => { - const vals = { - '1': 'a', - '2': 'b', - '3': 'c', - } - let hits = 0 - const cache = new ReadThroughCache(redis.withNamespace('test1'), { - staleTTL: 60000, - maxTTL: 60000, - fetchMethod: async (key) => { - hits++ - return vals[key] - }, - }) - const got = await Promise.all([ - cache.get('1'), - cache.get('2'), - cache.get('3'), - ]) - expect(got[0]).toEqual('a') - expect(got[1]).toEqual('b') - expect(got[2]).toEqual('c') - expect(hits).toBe(3) - - const refetched = await Promise.all([ - cache.get('1'), - cache.get('2'), - cache.get('3'), - ]) - expect(refetched[0]).toEqual('a') - expect(refetched[1]).toEqual('b') - expect(refetched[2]).toEqual('c') - expect(hits).toBe(3) - }) - - it('skips and refreshes cache when requested', async () => { - let val = 'a' - let hits = 0 - const cache = new ReadThroughCache(redis.withNamespace('test2'), { - staleTTL: 60000, - maxTTL: 60000, - fetchMethod: async () => { - hits++ - return val - }, - }) - - const try1 = await cache.get('1') - expect(try1).toEqual('a') - expect(hits).toBe(1) - - val = 'b' - - const try2 = await cache.get('1') - expect(try2).toEqual('a') - expect(hits).toBe(1) - - const try3 = await cache.get('1', { revalidate: true }) - expect(try3).toEqual('b') - expect(hits).toBe(2) - - const try4 = await cache.get('1') - expect(try4).toEqual('b') - expect(hits).toBe(2) - }) - - it('accurately reports stale entries & refreshes the cache', async () => { - let val = 'a' - let hits = 0 - const cache = new ReadThroughCache(redis.withNamespace('test3'), { - staleTTL: 1, - maxTTL: 60000, - fetchMethod: async () => { - hits++ - return val - }, - }) - - const try1 = await cache.get('1') - expect(try1).toEqual('a') - - await wait(5) - - val = 'b' - - const try2 = await cache.get('1') - // cache gives us stale value while it revalidates - expect(try2).toEqual('a') - - await wait(5) - - const try3 = await cache.get('1') - expect(try3).toEqual('b') - expect(hits).toEqual(3) - }) - - it('does not return expired dids & refreshes the cache', async () => { - let val = 'a' - let hits = 0 - const cache = new ReadThroughCache(redis.withNamespace('test4'), { - staleTTL: 0, - maxTTL: 1, - fetchMethod: async () => { - hits++ - return val - }, - }) - - const try1 = await cache.get('1') - expect(try1).toEqual('a') - - await wait(5) - - val = 'b' - - const try2 = await cache.get('1') - expect(try2).toEqual('b') - expect(hits).toBe(2) - }) - - it('caches negative values', async () => { - let val: string | null = null - let hits = 0 - const cache = new ReadThroughCache(redis.withNamespace('test5'), { - staleTTL: 60000, - maxTTL: 60000, - fetchMethod: async () => { - hits++ - return val - }, - }) - - const try1 = await cache.get('1') - expect(try1).toEqual(null) - expect(hits).toBe(1) - - val = 'b' - - const try2 = await cache.get('1') - // returns cached negative value - expect(try2).toEqual(null) - expect(hits).toBe(1) - - const try3 = await cache.get('1', { revalidate: true }) - expect(try3).toEqual('b') - expect(hits).toEqual(2) - - const try4 = await cache.get('1') - expect(try4).toEqual('b') - expect(hits).toEqual(2) - }) - - it('times out and fails open', async () => { - let val = 'a' - let hits = 0 - const cache = new ReadThroughCache(redis.withNamespace('test6'), { - staleTTL: 60000, - maxTTL: 60000, - fetchMethod: async () => { - hits++ - return val - }, - }) - - const try1 = await cache.get('1') - expect(try1).toEqual('a') - - const orig = cache.redis.driver.get - cache.redis.driver.get = async (key) => { - await wait(600) - return orig(key) - } - - val = 'b' - - const try2 = await cache.get('1') - expect(try2).toEqual('b') - expect(hits).toBe(2) - }) -}) diff --git a/packages/ozone/tests/admin/repo-search.test.ts b/packages/ozone/tests/repo-search.test.ts similarity index 97% rename from packages/ozone/tests/admin/repo-search.test.ts rename to packages/ozone/tests/repo-search.test.ts index 9e643ba12e0..57da070fa49 100644 --- a/packages/ozone/tests/admin/repo-search.test.ts +++ b/packages/ozone/tests/repo-search.test.ts @@ -1,7 +1,7 @@ import { SeedClient, TestNetwork } from '@atproto/dev-env' import AtpAgent from '@atproto/api' -import { paginateAll } from '../_util' -import usersBulkSeed from '../seeds/users-bulk' +import { paginateAll } from './_util' +import usersBulkSeed from './seeds/users-bulk' describe('admin repo search view', () => { let network: TestNetwork diff --git a/packages/ozone/tests/reprocessing.test.ts b/packages/ozone/tests/reprocessing.test.ts deleted file mode 100644 index 046bc58076b..00000000000 --- a/packages/ozone/tests/reprocessing.test.ts +++ /dev/null @@ -1,71 +0,0 @@ -import axios from 'axios' -import { AtUri } from '@atproto/syntax' -import { TestNetwork, SeedClient } from '@atproto/dev-env' -import basicSeed from './seeds/basic' -import { Database } from '../src/db' - -describe('reprocessing', () => { - let network: TestNetwork - let sc: SeedClient - let alice: string - - beforeAll(async () => { - network = await TestNetwork.create({ - dbPostgresSchema: 'bsky_reprocessing', - }) - sc = network.getSeedClient() - await basicSeed(sc) - alice = sc.dids.alice - await network.processAll() - }) - - afterAll(async () => { - await network.close() - }) - - const getRecordUris = async (db: Database, did: string) => { - const res = await db.db - .selectFrom('record') - .select('uri') - .where('did', '=', did) - .execute() - return res.map((row) => row.uri) - } - it('reprocesses repo data', async () => { - const db = network.bsky.ctx.db.getPrimary() - const urisBefore = await getRecordUris(db, alice) - await db.db.deleteFrom('record').where('did', '=', alice).execute() - const indexerPort = network.bsky.indexer.ctx.cfg.indexerPort - await axios.post(`http://localhost:${indexerPort}/reprocess/${alice}`) - await network.processAll() - const urisAfter = await getRecordUris(db, alice) - expect(urisAfter.sort()).toEqual(urisBefore.sort()) - }) - - it('buffers commits while reprocessing repo data', async () => { - const db = network.bsky.ctx.db.getPrimary() - const urisBefore = await getRecordUris(db, alice) - await db.db.deleteFrom('record').where('did', '=', alice).execute() - const indexerPort = network.bsky.indexer.ctx.cfg.indexerPort - const toDeleteIndex = urisBefore.findIndex((uri) => - uri.includes('app.bsky.feed.post'), - ) - if (toDeleteIndex < 0) { - throw new Error('could not find post to delete') - } - // request reprocess while buffering a new post & delete - const [newPost] = await Promise.all([ - sc.post(alice, 'blah blah'), - axios.post(`http://localhost:${indexerPort}/reprocess/${alice}`), - sc.deletePost(alice, new AtUri(urisBefore[toDeleteIndex])), - ]) - await network.processAll() - const urisAfter = await getRecordUris(db, alice) - const expected = [ - ...urisBefore.slice(0, toDeleteIndex), - ...urisBefore.slice(toDeleteIndex + 1), - newPost.ref.uriStr, - ] - expect(urisAfter.sort()).toEqual(expected.sort()) - }) -}) diff --git a/packages/ozone/tests/subscription/repo.test.ts b/packages/ozone/tests/subscription/repo.test.ts deleted file mode 100644 index 1c83e4c0cca..00000000000 --- a/packages/ozone/tests/subscription/repo.test.ts +++ /dev/null @@ -1,139 +0,0 @@ -import AtpAgent from '@atproto/api' -import { TestNetwork, SeedClient } from '@atproto/dev-env' -import { CommitData } from '@atproto/repo' -import { PreparedWrite } from '@atproto/pds/src/repo' -import * as sequencer from '@atproto/pds/src/sequencer' -import { cborDecode, cborEncode } from '@atproto/common' -import { DatabaseSchemaType } from '../../src/db/database-schema' -import { ids } from '../../src/lexicon/lexicons' -import { forSnapshot } from '../_util' -import { AppContext, Database } from '../../src' -import basicSeed from '../seeds/basic' - -describe('sync', () => { - let network: TestNetwork - let ctx: AppContext - let pdsAgent: AtpAgent - let sc: SeedClient - - beforeAll(async () => { - network = await TestNetwork.create({ - dbPostgresSchema: 'bsky_subscription_repo', - }) - ctx = network.bsky.ctx - pdsAgent = network.pds.getClient() - sc = network.getSeedClient() - await basicSeed(sc) - }) - - afterAll(async () => { - await network.close() - }) - - it('indexes permit history being replayed.', async () => { - const db = ctx.db.getPrimary() - - // Generate some modifications and dupes - const { alice, bob, carol, dan } = sc.dids - await sc.follow(alice, bob) - await sc.follow(carol, alice) - await sc.follow(bob, alice) - await sc.follow(dan, bob) - await sc.like(dan, sc.posts[alice][1].ref) // Identical - await sc.like(alice, sc.posts[carol][0].ref) // Identical - await updateProfile(pdsAgent, alice, { displayName: 'ali!' }) - await updateProfile(pdsAgent, bob, { displayName: 'robert!' }) - - await network.processAll() - - // Table comparator - const getTableDump = async () => { - const [actor, post, profile, like, follow, dupes] = await Promise.all([ - dumpTable(db, 'actor', ['did']), - dumpTable(db, 'post', ['uri']), - dumpTable(db, 'profile', ['uri']), - dumpTable(db, 'like', ['creator', 'subject']), - dumpTable(db, 'follow', ['creator', 'subjectDid']), - dumpTable(db, 'duplicate_record', ['uri']), - ]) - return { actor, post, profile, like, follow, dupes } - } - - // Mark originals - const originalTableDump = await getTableDump() - - // Reprocess repos via sync subscription, on top of existing indices - await network.bsky.ingester.sub.destroy() - await network.bsky.indexer.sub.destroy() - // Hard reset of state in redis - await network.bsky.ingester.sub.resetCursor() - const indexerSub = network.bsky.indexer.sub - const partition = indexerSub.partitions.get(0) - await network.bsky.indexer.ctx.redis.del(partition.key) - // Boot streams back up - network.bsky.indexer.sub.resume() - network.bsky.ingester.sub.resume() - await network.processAll() - - // Permissive of indexedAt times changing - expect(forSnapshot(await getTableDump())).toEqual( - forSnapshot(originalTableDump), - ) - }) - - it('indexes actor when commit is unprocessable.', async () => { - // mock sequencing to create an unprocessable commit event - const sequenceCommitOrig = network.pds.ctx.sequencer.sequenceCommit - network.pds.ctx.sequencer.sequenceCommit = async function ( - did: string, - commitData: CommitData, - writes: PreparedWrite[], - ) { - const seqEvt = await sequencer.formatSeqCommit(did, commitData, writes) - const evt = cborDecode(seqEvt.event) as sequencer.CommitEvt - evt.blocks = new Uint8Array() // bad blocks - seqEvt.event = cborEncode(evt) - await network.pds.ctx.sequencer.sequenceEvt(seqEvt) - } - // create account and index the initial commit event - await sc.createAccount('jack', { - handle: 'jack.test', - email: 'jack@test.com', - password: 'password', - }) - await network.processAll() - // confirm jack was indexed as an actor despite the bad event - const actors = await dumpTable(ctx.db.getPrimary(), 'actor', ['did']) - expect(actors.map((a) => a.handle)).toContain('jack.test') - network.pds.ctx.sequencer.sequenceCommit = sequenceCommitOrig - }) - - async function updateProfile( - agent: AtpAgent, - did: string, - record: Record, - ) { - return await agent.api.com.atproto.repo.putRecord( - { - repo: did, - collection: ids.AppBskyActorProfile, - rkey: 'self', - record, - }, - { headers: sc.getHeaders(did), encoding: 'application/json' }, - ) - } -}) - -async function dumpTable( - db: Database, - tableName: T, - pkeys: (keyof DatabaseSchemaType[T] & string)[], -) { - const { ref } = db.db.dynamic - let builder = db.db.selectFrom(tableName).selectAll() - pkeys.forEach((key) => { - builder = builder.orderBy(ref(key)) - }) - return await builder.execute() -} diff --git a/packages/ozone/tests/subscription/util.test.ts b/packages/ozone/tests/subscription/util.test.ts deleted file mode 100644 index 497532f643b..00000000000 --- a/packages/ozone/tests/subscription/util.test.ts +++ /dev/null @@ -1,185 +0,0 @@ -import { wait } from '@atproto/common' -import { - ConsecutiveList, - LatestQueue, - PartitionedQueue, -} from '../../src/subscription/util' -import { randomStr } from '../../../crypto/src' - -describe('subscription utils', () => { - describe('ConsecutiveList', () => { - it('tracks consecutive complete items.', () => { - const consecutive = new ConsecutiveList() - // add items - const item1 = consecutive.push(1) - const item2 = consecutive.push(2) - const item3 = consecutive.push(3) - expect(item1.isComplete).toEqual(false) - expect(item2.isComplete).toEqual(false) - expect(item3.isComplete).toEqual(false) - // complete items out of order - expect(consecutive.list.length).toBe(3) - expect(item2.complete()).toEqual([]) - expect(item2.isComplete).toEqual(true) - expect(consecutive.list.length).toBe(3) - expect(item1.complete()).toEqual([1, 2]) - expect(item1.isComplete).toEqual(true) - expect(consecutive.list.length).toBe(1) - expect(item3.complete()).toEqual([3]) - expect(consecutive.list.length).toBe(0) - expect(item3.isComplete).toEqual(true) - }) - }) - - describe('LatestQueue', () => { - it('only performs most recently queued item.', async () => { - const latest = new LatestQueue() - const complete: number[] = [] - latest.add(async () => { - await wait(1) - complete.push(1) - }) - latest.add(async () => { - await wait(1) - complete.push(2) - }) - latest.add(async () => { - await wait(1) - complete.push(3) - }) - latest.add(async () => { - await wait(1) - complete.push(4) - }) - await latest.queue.onIdle() - expect(complete).toEqual([1, 4]) // skip 2, 3 - latest.add(async () => { - await wait(1) - complete.push(5) - }) - latest.add(async () => { - await wait(1) - complete.push(6) - }) - await latest.queue.onIdle() - expect(complete).toEqual([1, 4, 5, 6]) - }) - - it('stops processing queued messages on destroy.', async () => { - const latest = new LatestQueue() - const complete: number[] = [] - latest.add(async () => { - await wait(1) - complete.push(1) - }) - latest.add(async () => { - await wait(1) - complete.push(2) - }) - const destroyed = latest.destroy() - latest.add(async () => { - await wait(1) - complete.push(3) - }) - await destroyed - expect(complete).toEqual([1]) // 2 was cleared, 3 was after destroy - // show that waiting on destroyed above was already enough to reflect all complete items - await latest.queue.onIdle() - expect(complete).toEqual([1]) - }) - }) - - describe('PartitionedQueue', () => { - it('performs work in parallel across partitions, serial within a partition.', async () => { - const partitioned = new PartitionedQueue({ concurrency: Infinity }) - const complete: number[] = [] - // partition 1 items start slow but get faster: slow should still complete first. - partitioned.add('1', async () => { - await wait(30) - complete.push(11) - }) - partitioned.add('1', async () => { - await wait(20) - complete.push(12) - }) - partitioned.add('1', async () => { - await wait(1) - complete.push(13) - }) - expect(partitioned.partitions.size).toEqual(1) - // partition 2 items complete quickly except the last, which is slowest of all events. - partitioned.add('2', async () => { - await wait(1) - complete.push(21) - }) - partitioned.add('2', async () => { - await wait(1) - complete.push(22) - }) - partitioned.add('2', async () => { - await wait(1) - complete.push(23) - }) - partitioned.add('2', async () => { - await wait(60) - complete.push(24) - }) - expect(partitioned.partitions.size).toEqual(2) - await partitioned.main.onIdle() - expect(complete).toEqual([21, 22, 23, 11, 12, 13, 24]) - expect(partitioned.partitions.size).toEqual(0) - }) - - it('limits overall concurrency.', async () => { - const partitioned = new PartitionedQueue({ concurrency: 1 }) - const complete: number[] = [] - // if concurrency were not constrained, partition 1 would complete all items - // before any items from partition 2. since it is constrained, the work is complete in the order added. - partitioned.add('1', async () => { - await wait(1) - complete.push(11) - }) - partitioned.add('2', async () => { - await wait(10) - complete.push(21) - }) - partitioned.add('1', async () => { - await wait(1) - complete.push(12) - }) - partitioned.add('2', async () => { - await wait(10) - complete.push(22) - }) - // only partition 1 exists so far due to the concurrency - expect(partitioned.partitions.size).toEqual(1) - await partitioned.main.onIdle() - expect(complete).toEqual([11, 21, 12, 22]) - expect(partitioned.partitions.size).toEqual(0) - }) - - it('settles with many items.', async () => { - const partitioned = new PartitionedQueue({ concurrency: 100 }) - const complete: { partition: string; id: number }[] = [] - const partitions = new Set() - for (let i = 0; i < 500; ++i) { - const partition = randomStr(1, 'base16').slice(0, 1) - partitions.add(partition) - partitioned.add(partition, async () => { - await wait((i % 2) * 2) - complete.push({ partition, id: i }) - }) - } - expect(partitioned.partitions.size).toEqual(partitions.size) - await partitioned.main.onIdle() - expect(complete.length).toEqual(500) - for (const partition of partitions) { - const ids = complete - .filter((item) => item.partition === partition) - .map((item) => item.id) - expect(ids).toEqual([...ids].sort((a, b) => a - b)) - } - expect(partitioned.partitions.size).toEqual(0) - }) - }) -}) diff --git a/packages/ozone/tests/views/__snapshots__/actor-search.test.ts.snap b/packages/ozone/tests/views/__snapshots__/actor-search.test.ts.snap deleted file mode 100644 index a6990b60ed3..00000000000 --- a/packages/ozone/tests/views/__snapshots__/actor-search.test.ts.snap +++ /dev/null @@ -1,155 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`pds actor search views search gives relevant results 1`] = ` -Array [ - Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(0)@jpeg", - "did": "user(0)", - "displayName": "Carlton Abernathy IV", - "handle": "aliya-hodkiewicz.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - Object { - "did": "user(2)", - "handle": "cara-wiegand69.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - Object { - "did": "user(3)", - "handle": "carlos6.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(5)/cids(0)@jpeg", - "did": "user(4)", - "displayName": "Latoya Windler", - "handle": "carolina-mcdermott77.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(7)/cids(0)@jpeg", - "did": "user(6)", - "displayName": "Rachel Kshlerin", - "handle": "cayla-marquardt39.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(9)/cids(0)@jpeg", - "did": "user(8)", - "displayName": "Carol Littel", - "handle": "eudora-dietrich4.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(11)/cids(0)@jpeg", - "did": "user(10)", - "displayName": "Sadie Carter", - "handle": "shane-torphy52.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, -] -`; - -exports[`pds actor search views typeahead gives relevant results 1`] = ` -Array [ - Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(0)@jpeg", - "did": "user(0)", - "displayName": "Carlton Abernathy IV", - "handle": "aliya-hodkiewicz.test", - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - Object { - "did": "user(2)", - "handle": "cara-wiegand69.test", - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - Object { - "did": "user(3)", - "handle": "carlos6.test", - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(5)/cids(0)@jpeg", - "did": "user(4)", - "displayName": "Latoya Windler", - "handle": "carolina-mcdermott77.test", - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(7)/cids(0)@jpeg", - "did": "user(6)", - "displayName": "Rachel Kshlerin", - "handle": "cayla-marquardt39.test", - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(9)/cids(0)@jpeg", - "did": "user(8)", - "displayName": "Carol Littel", - "handle": "eudora-dietrich4.test", - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(11)/cids(0)@jpeg", - "did": "user(10)", - "displayName": "Sadie Carter", - "handle": "shane-torphy52.test", - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, -] -`; diff --git a/packages/ozone/tests/views/__snapshots__/author-feed.test.ts.snap b/packages/ozone/tests/views/__snapshots__/author-feed.test.ts.snap deleted file mode 100644 index 9d1d41bd3db..00000000000 --- a/packages/ozone/tests/views/__snapshots__/author-feed.test.ts.snap +++ /dev/null @@ -1,2063 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`pds author feed views fetches full author feeds for self (sorted, minimal viewer state). 1`] = ` -Array [ - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(0)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "reply": Object { - "parent": Object { - "cid": "cids(4)", - "uri": "record(3)", - }, - "root": Object { - "cid": "cids(3)", - "uri": "record(2)", - }, - }, - "text": "thanks bob", - }, - "replyCount": 0, - "repostCount": 1, - "uri": "record(0)", - "viewer": Object {}, - }, - "reply": Object { - "parent": Object { - "$type": "app.bsky.feed.defs#postView", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(3)/cids(1)@jpeg", - "did": "user(2)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(5)", - "following": "record(4)", - "muted": false, - }, - }, - "cid": "cids(4)", - "embed": Object { - "$type": "app.bsky.embed.images#view", - "images": Array [ - Object { - "alt": "tests/sample-img/key-landscape-small.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(3)/cids(5)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(3)/cids(5)@jpeg", - }, - ], - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(4)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(3)", - "val": "test-label", - }, - Object { - "cid": "cids(4)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(3)", - "val": "test-label-2", - }, - ], - "likeCount": 0, - "record": 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(5)", - }, - "size": 4114, - }, - }, - ], - }, - "reply": Object { - "parent": Object { - "cid": "cids(3)", - "uri": "record(2)", - }, - "root": Object { - "cid": "cids(3)", - "uri": "record(2)", - }, - }, - "text": "hear that label_me label_me_2", - }, - "replyCount": 1, - "repostCount": 0, - "uri": "record(3)", - "viewer": Object {}, - }, - "root": Object { - "$type": "app.bsky.feed.defs#postView", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(3)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 3, - "repostCount": 1, - "uri": "record(2)", - "viewer": Object {}, - }, - }, - }, - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(6)", - "embed": Object { - "$type": "app.bsky.embed.record#view", - "record": Object { - "$type": "app.bsky.embed.record#viewRecord", - "author": Object { - "did": "user(4)", - "handle": "dan.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "following": "record(8)", - "muted": false, - }, - }, - "cid": "cids(7)", - "embeds": Array [ - Object { - "$type": "app.bsky.embed.record#view", - "record": Object { - "$type": "app.bsky.embed.record#viewRecord", - "author": Object { - "did": "user(5)", - "handle": "carol.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(11)", - "following": "record(10)", - "muted": false, - }, - }, - "cid": "cids(8)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "uri": "record(9)", - "value": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.recordWithMedia", - "media": 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(5)", - }, - "size": 4114, - }, - }, - Object { - "alt": "tests/sample-img/key-alt.jpg", - "image": Object { - "$type": "blob", - "mimeType": "image/jpeg", - "ref": Object { - "$link": "cids(9)", - }, - "size": 12736, - }, - }, - ], - }, - "record": Object { - "record": Object { - "cid": "cids(10)", - "uri": "record(12)", - }, - }, - }, - "text": "hi im carol", - }, - }, - }, - ], - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "uri": "record(7)", - "value": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.record", - "record": Object { - "cid": "cids(8)", - "uri": "record(9)", - }, - }, - "facets": Array [ - Object { - "features": Array [ - Object { - "$type": "app.bsky.richtext.facet#mention", - "did": "user(0)", - }, - ], - "index": Object { - "byteEnd": 18, - "byteStart": 0, - }, - }, - ], - "text": "@alice.bluesky.xyz is the best", - }, - }, - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(6)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(6)", - "val": "test-label", - }, - ], - "likeCount": 2, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.record", - "record": Object { - "cid": "cids(7)", - "uri": "record(7)", - }, - }, - "text": "yoohoo label_me", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(6)", - "viewer": Object {}, - }, - }, - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(3)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 3, - "repostCount": 1, - "uri": "record(2)", - "viewer": Object {}, - }, - }, - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(11)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(11)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(13)", - "val": "self-label", - }, - ], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "labels": Object { - "$type": "com.atproto.label.defs#selfLabels", - "values": Array [ - Object { - "val": "self-label", - }, - ], - }, - "text": "hey there", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(13)", - "viewer": Object {}, - }, - }, -] -`; - -exports[`pds author feed views fetches full author feeds for self (sorted, minimal viewer state). 2`] = ` -Array [ - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(0)", - "embed": Object { - "$type": "app.bsky.embed.images#view", - "images": Array [ - Object { - "alt": "tests/sample-img/key-landscape-small.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(1)/cids(2)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(1)/cids(2)@jpeg", - }, - ], - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(0)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(0)", - "val": "test-label", - }, - Object { - "cid": "cids(0)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(0)", - "val": "test-label-2", - }, - ], - "likeCount": 0, - "record": 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(2)", - }, - "size": 4114, - }, - }, - ], - }, - "reply": Object { - "parent": Object { - "cid": "cids(3)", - "uri": "record(1)", - }, - "root": Object { - "cid": "cids(3)", - "uri": "record(1)", - }, - }, - "text": "hear that label_me label_me_2", - }, - "replyCount": 1, - "repostCount": 0, - "uri": "record(0)", - "viewer": Object {}, - }, - "reply": Object { - "parent": Object { - "$type": "app.bsky.feed.defs#postView", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(3)/cids(1)@jpeg", - "did": "user(2)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(4)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(2)", - "uri": "record(4)", - "val": "self-label-a", - }, - Object { - "cid": "cids(4)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(2)", - "uri": "record(4)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(3)", - "following": "record(2)", - "muted": false, - }, - }, - "cid": "cids(3)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 3, - "repostCount": 1, - "uri": "record(1)", - "viewer": Object { - "like": "record(5)", - }, - }, - "root": Object { - "$type": "app.bsky.feed.defs#postView", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(3)/cids(1)@jpeg", - "did": "user(2)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(4)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(2)", - "uri": "record(4)", - "val": "self-label-a", - }, - Object { - "cid": "cids(4)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(2)", - "uri": "record(4)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(3)", - "following": "record(2)", - "muted": false, - }, - }, - "cid": "cids(3)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 3, - "repostCount": 1, - "uri": "record(1)", - "viewer": Object { - "like": "record(5)", - }, - }, - }, - }, - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(5)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000+00:00", - "text": "bobby boy here", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(6)", - "viewer": Object {}, - }, - }, - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(6)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "langs": Array [ - "en-US", - "i-klingon", - ], - "text": "bob back at it again!", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(7)", - "viewer": Object {}, - }, - }, -] -`; - -exports[`pds author feed views fetches full author feeds for self (sorted, minimal viewer state). 3`] = ` -Array [ - Object { - "post": Object { - "author": Object { - "did": "user(0)", - "handle": "dan.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(0)", - "embed": Object { - "$type": "app.bsky.embed.record#view", - "record": Object { - "$type": "app.bsky.embed.record#viewRecord", - "author": Object { - "did": "user(2)", - "handle": "carol.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(1)", - "embeds": Array [ - Object { - "$type": "app.bsky.embed.recordWithMedia#view", - "media": Object { - "$type": "app.bsky.embed.images#view", - "images": Array [ - Object { - "alt": "tests/sample-img/key-landscape-small.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(5)/cids(2)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(5)/cids(2)@jpeg", - }, - Object { - "alt": "tests/sample-img/key-alt.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(5)/cids(3)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(5)/cids(3)@jpeg", - }, - ], - }, - "record": Object { - "record": Object { - "$type": "app.bsky.embed.record#viewRecord", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(4)/cids(5)@jpeg", - "did": "user(3)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(3)", - "muted": false, - }, - }, - "cid": "cids(4)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "uri": "record(2)", - "value": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "langs": Array [ - "en-US", - "i-klingon", - ], - "text": "bob back at it again!", - }, - }, - }, - }, - ], - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "uri": "record(1)", - "value": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.recordWithMedia", - "media": 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(2)", - }, - "size": 4114, - }, - }, - Object { - "alt": "tests/sample-img/key-alt.jpg", - "image": Object { - "$type": "blob", - "mimeType": "image/jpeg", - "ref": Object { - "$link": "cids(3)", - }, - "size": 12736, - }, - }, - ], - }, - "record": Object { - "record": Object { - "cid": "cids(4)", - "uri": "record(2)", - }, - }, - }, - "text": "hi im carol", - }, - }, - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.record", - "record": Object { - "cid": "cids(1)", - "uri": "record(1)", - }, - }, - "facets": Array [ - Object { - "features": Array [ - Object { - "$type": "app.bsky.richtext.facet#mention", - "did": "user(1)", - }, - ], - "index": Object { - "byteEnd": 18, - "byteStart": 0, - }, - }, - ], - "text": "@alice.bluesky.xyz is the best", - }, - "replyCount": 0, - "repostCount": 1, - "uri": "record(0)", - "viewer": Object { - "repost": "record(4)", - }, - }, - "reason": Object { - "$type": "app.bsky.feed.defs#reasonRepost", - "by": Object { - "did": "user(2)", - "handle": "carol.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - }, - }, - Object { - "post": Object { - "author": Object { - "did": "user(2)", - "handle": "carol.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(6)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "reply": Object { - "parent": Object { - "cid": "cids(7)", - "uri": "record(6)", - }, - "root": Object { - "cid": "cids(7)", - "uri": "record(6)", - }, - }, - "text": "of course", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(5)", - "viewer": Object {}, - }, - "reply": Object { - "parent": Object { - "$type": "app.bsky.feed.defs#postView", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(6)/cids(5)@jpeg", - "did": "user(1)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(8)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(9)", - "val": "self-label-a", - }, - Object { - "cid": "cids(8)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(9)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(8)", - "following": "record(7)", - "muted": false, - }, - }, - "cid": "cids(7)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 3, - "repostCount": 1, - "uri": "record(6)", - "viewer": Object { - "like": "record(10)", - }, - }, - "root": Object { - "$type": "app.bsky.feed.defs#postView", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(6)/cids(5)@jpeg", - "did": "user(1)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(8)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(9)", - "val": "self-label-a", - }, - Object { - "cid": "cids(8)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(9)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(8)", - "following": "record(7)", - "muted": false, - }, - }, - "cid": "cids(7)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 3, - "repostCount": 1, - "uri": "record(6)", - "viewer": Object { - "like": "record(10)", - }, - }, - }, - }, - Object { - "post": Object { - "author": Object { - "did": "user(2)", - "handle": "carol.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(1)", - "embed": Object { - "$type": "app.bsky.embed.recordWithMedia#view", - "media": Object { - "$type": "app.bsky.embed.images#view", - "images": Array [ - Object { - "alt": "tests/sample-img/key-landscape-small.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(5)/cids(2)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(5)/cids(2)@jpeg", - }, - Object { - "alt": "tests/sample-img/key-alt.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(5)/cids(3)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(5)/cids(3)@jpeg", - }, - ], - }, - "record": Object { - "record": Object { - "$type": "app.bsky.embed.record#viewRecord", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(4)/cids(5)@jpeg", - "did": "user(3)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(3)", - "muted": false, - }, - }, - "cid": "cids(4)", - "embeds": Array [], - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "uri": "record(2)", - "value": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "langs": Array [ - "en-US", - "i-klingon", - ], - "text": "bob back at it again!", - }, - }, - }, - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 2, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.recordWithMedia", - "media": 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(2)", - }, - "size": 4114, - }, - }, - Object { - "alt": "tests/sample-img/key-alt.jpg", - "image": Object { - "$type": "blob", - "mimeType": "image/jpeg", - "ref": Object { - "$link": "cids(3)", - }, - "size": 12736, - }, - }, - ], - }, - "record": Object { - "record": Object { - "cid": "cids(4)", - "uri": "record(2)", - }, - }, - }, - "text": "hi im carol", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(1)", - "viewer": Object {}, - }, - }, -] -`; - -exports[`pds author feed views fetches full author feeds for self (sorted, minimal viewer state). 4`] = ` -Array [ - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(2)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(2)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(1)", - "muted": false, - }, - }, - "cid": "cids(0)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "reply": Object { - "parent": Object { - "cid": "cids(4)", - "uri": "record(4)", - }, - "root": Object { - "cid": "cids(3)", - "uri": "record(3)", - }, - }, - "text": "thanks bob", - }, - "replyCount": 0, - "repostCount": 1, - "uri": "record(0)", - "viewer": Object { - "repost": "record(5)", - }, - }, - "reason": Object { - "$type": "app.bsky.feed.defs#reasonRepost", - "by": Object { - "did": "user(2)", - "handle": "dan.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - }, - "reply": Object { - "parent": Object { - "$type": "app.bsky.feed.defs#postView", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(4)/cids(1)@jpeg", - "did": "user(3)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "following": "record(8)", - "muted": false, - }, - }, - "cid": "cids(4)", - "embed": Object { - "$type": "app.bsky.embed.images#view", - "images": Array [ - Object { - "alt": "tests/sample-img/key-landscape-small.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(4)/cids(5)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(4)/cids(5)@jpeg", - }, - ], - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(4)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(4)", - "val": "test-label", - }, - Object { - "cid": "cids(4)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(4)", - "val": "test-label-2", - }, - ], - "likeCount": 0, - "record": 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(5)", - }, - "size": 4114, - }, - }, - ], - }, - "reply": Object { - "parent": Object { - "cid": "cids(3)", - "uri": "record(3)", - }, - "root": Object { - "cid": "cids(3)", - "uri": "record(3)", - }, - }, - "text": "hear that label_me label_me_2", - }, - "replyCount": 1, - "repostCount": 0, - "uri": "record(4)", - "viewer": Object {}, - }, - "root": Object { - "$type": "app.bsky.feed.defs#postView", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(2)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(2)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(1)", - "muted": false, - }, - }, - "cid": "cids(3)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 3, - "repostCount": 1, - "uri": "record(3)", - "viewer": Object { - "like": "record(7)", - "repost": "record(6)", - }, - }, - }, - }, - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(2)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(2)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(1)", - "muted": false, - }, - }, - "cid": "cids(3)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 3, - "repostCount": 1, - "uri": "record(3)", - "viewer": Object { - "like": "record(7)", - "repost": "record(6)", - }, - }, - "reason": Object { - "$type": "app.bsky.feed.defs#reasonRepost", - "by": Object { - "did": "user(2)", - "handle": "dan.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - }, - }, - Object { - "post": Object { - "author": Object { - "did": "user(2)", - "handle": "dan.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(6)", - "embed": Object { - "$type": "app.bsky.embed.record#view", - "record": Object { - "$type": "app.bsky.embed.record#viewRecord", - "author": Object { - "did": "user(5)", - "handle": "carol.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(7)", - "embeds": Array [ - Object { - "$type": "app.bsky.embed.recordWithMedia#view", - "media": Object { - "$type": "app.bsky.embed.images#view", - "images": Array [ - Object { - "alt": "tests/sample-img/key-landscape-small.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(6)/cids(5)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(6)/cids(5)@jpeg", - }, - Object { - "alt": "tests/sample-img/key-alt.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(6)/cids(8)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(6)/cids(8)@jpeg", - }, - ], - }, - "record": Object { - "record": Object { - "$type": "app.bsky.embed.record#viewRecord", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(4)/cids(1)@jpeg", - "did": "user(3)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "following": "record(8)", - "muted": false, - }, - }, - "cid": "cids(9)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "uri": "record(11)", - "value": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "langs": Array [ - "en-US", - "i-klingon", - ], - "text": "bob back at it again!", - }, - }, - }, - }, - ], - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "uri": "record(10)", - "value": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.recordWithMedia", - "media": 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(5)", - }, - "size": 4114, - }, - }, - Object { - "alt": "tests/sample-img/key-alt.jpg", - "image": Object { - "$type": "blob", - "mimeType": "image/jpeg", - "ref": Object { - "$link": "cids(8)", - }, - "size": 12736, - }, - }, - ], - }, - "record": Object { - "record": Object { - "cid": "cids(9)", - "uri": "record(11)", - }, - }, - }, - "text": "hi im carol", - }, - }, - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.record", - "record": Object { - "cid": "cids(7)", - "uri": "record(10)", - }, - }, - "facets": Array [ - Object { - "features": Array [ - Object { - "$type": "app.bsky.richtext.facet#mention", - "did": "user(0)", - }, - ], - "index": Object { - "byteEnd": 18, - "byteStart": 0, - }, - }, - ], - "text": "@alice.bluesky.xyz is the best", - }, - "replyCount": 0, - "repostCount": 1, - "uri": "record(9)", - "viewer": Object {}, - }, - }, - Object { - "post": Object { - "author": Object { - "did": "user(2)", - "handle": "dan.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(10)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "text": "dan here!", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(12)", - "viewer": Object {}, - }, - }, -] -`; - -exports[`pds author feed views reflects fetching user's state in the feed. 1`] = ` -Array [ - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(2)", - "following": "record(1)", - "muted": false, - }, - }, - "cid": "cids(0)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "reply": Object { - "parent": Object { - "cid": "cids(4)", - "uri": "record(5)", - }, - "root": Object { - "cid": "cids(3)", - "uri": "record(4)", - }, - }, - "text": "thanks bob", - }, - "replyCount": 0, - "repostCount": 1, - "uri": "record(0)", - "viewer": Object {}, - }, - "reply": Object { - "parent": Object { - "$type": "app.bsky.feed.defs#postView", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(3)/cids(1)@jpeg", - "did": "user(2)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(7)", - "muted": false, - }, - }, - "cid": "cids(4)", - "embed": Object { - "$type": "app.bsky.embed.images#view", - "images": Array [ - Object { - "alt": "tests/sample-img/key-landscape-small.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(3)/cids(5)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(3)/cids(5)@jpeg", - }, - ], - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(4)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(5)", - "val": "test-label", - }, - Object { - "cid": "cids(4)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(5)", - "val": "test-label-2", - }, - ], - "likeCount": 0, - "record": 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(5)", - }, - "size": 4114, - }, - }, - ], - }, - "reply": Object { - "parent": Object { - "cid": "cids(3)", - "uri": "record(4)", - }, - "root": Object { - "cid": "cids(3)", - "uri": "record(4)", - }, - }, - "text": "hear that label_me label_me_2", - }, - "replyCount": 1, - "repostCount": 0, - "uri": "record(5)", - "viewer": Object {}, - }, - "root": Object { - "$type": "app.bsky.feed.defs#postView", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(2)", - "following": "record(1)", - "muted": false, - }, - }, - "cid": "cids(3)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 3, - "repostCount": 1, - "uri": "record(4)", - "viewer": Object { - "like": "record(6)", - }, - }, - }, - }, - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(2)", - "following": "record(1)", - "muted": false, - }, - }, - "cid": "cids(6)", - "embed": Object { - "$type": "app.bsky.embed.record#view", - "record": Object { - "$type": "app.bsky.embed.record#viewRecord", - "author": Object { - "did": "user(4)", - "handle": "dan.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(7)", - "embeds": Array [ - Object { - "$type": "app.bsky.embed.record#view", - "record": Object { - "$type": "app.bsky.embed.record#viewRecord", - "author": Object { - "did": "user(5)", - "handle": "carol.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(8)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "uri": "record(10)", - "value": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.recordWithMedia", - "media": 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(5)", - }, - "size": 4114, - }, - }, - Object { - "alt": "tests/sample-img/key-alt.jpg", - "image": Object { - "$type": "blob", - "mimeType": "image/jpeg", - "ref": Object { - "$link": "cids(9)", - }, - "size": 12736, - }, - }, - ], - }, - "record": Object { - "record": Object { - "cid": "cids(10)", - "uri": "record(11)", - }, - }, - }, - "text": "hi im carol", - }, - }, - }, - ], - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "uri": "record(9)", - "value": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.record", - "record": Object { - "cid": "cids(8)", - "uri": "record(10)", - }, - }, - "facets": Array [ - Object { - "features": Array [ - Object { - "$type": "app.bsky.richtext.facet#mention", - "did": "user(0)", - }, - ], - "index": Object { - "byteEnd": 18, - "byteStart": 0, - }, - }, - ], - "text": "@alice.bluesky.xyz is the best", - }, - }, - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(6)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(8)", - "val": "test-label", - }, - ], - "likeCount": 2, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.record", - "record": Object { - "cid": "cids(7)", - "uri": "record(9)", - }, - }, - "text": "yoohoo label_me", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(8)", - "viewer": Object { - "like": "record(12)", - }, - }, - }, - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(2)", - "following": "record(1)", - "muted": false, - }, - }, - "cid": "cids(3)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 3, - "repostCount": 1, - "uri": "record(4)", - "viewer": Object { - "like": "record(6)", - }, - }, - }, - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(2)", - "following": "record(1)", - "muted": false, - }, - }, - "cid": "cids(11)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(11)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(13)", - "val": "self-label", - }, - ], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "labels": Object { - "$type": "com.atproto.label.defs#selfLabels", - "values": Array [ - Object { - "val": "self-label", - }, - ], - }, - "text": "hey there", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(13)", - "viewer": Object {}, - }, - }, -] -`; diff --git a/packages/ozone/tests/views/__snapshots__/block-lists.test.ts.snap b/packages/ozone/tests/views/__snapshots__/block-lists.test.ts.snap deleted file mode 100644 index 7f0989a5975..00000000000 --- a/packages/ozone/tests/views/__snapshots__/block-lists.test.ts.snap +++ /dev/null @@ -1,594 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`pds views with blocking from block lists blocks record embeds 1`] = ` -Object { - "thread": Object { - "$type": "app.bsky.feed.defs#threadViewPost", - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(2)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(2)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(1)", - "muted": false, - }, - }, - "cid": "cids(0)", - "embed": Object { - "$type": "app.bsky.embed.record#view", - "record": Object { - "$type": "app.bsky.embed.record#viewRecord", - "author": Object { - "did": "user(2)", - "handle": "dan.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(3)", - "embeds": Array [ - Object { - "$type": "app.bsky.embed.record#view", - "record": Object { - "$type": "app.bsky.embed.record#viewBlocked", - "author": Object { - "did": "user(3)", - "viewer": Object { - "blockedBy": false, - "blocking": "record(5)", - }, - }, - "blocked": true, - "uri": "record(4)", - }, - }, - ], - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "uri": "record(3)", - "value": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.record", - "record": Object { - "cid": "cids(4)", - "uri": "record(4)", - }, - }, - "facets": Array [ - Object { - "features": Array [ - Object { - "$type": "app.bsky.richtext.facet#mention", - "did": "user(0)", - }, - ], - "index": Object { - "byteEnd": 18, - "byteStart": 0, - }, - }, - ], - "text": "@alice.bluesky.xyz is the best", - }, - }, - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(0)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(0)", - "val": "test-label", - }, - ], - "likeCount": 2, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.record", - "record": Object { - "cid": "cids(3)", - "uri": "record(3)", - }, - }, - "text": "yoohoo label_me", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(0)", - "viewer": Object {}, - }, - }, -} -`; - -exports[`pds views with blocking from block lists blocks thread parent 1`] = ` -Object { - "thread": Object { - "$type": "app.bsky.feed.defs#threadViewPost", - "parent": Object { - "$type": "app.bsky.feed.defs#blockedPost", - "author": Object { - "did": "user(2)", - "viewer": Object { - "blockedBy": true, - }, - }, - "blocked": true, - "uri": "record(4)", - }, - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(2)", - "following": "record(1)", - "muted": false, - }, - }, - "cid": "cids(0)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "reply": Object { - "parent": Object { - "cid": "cids(3)", - "uri": "record(4)", - }, - "root": Object { - "cid": "cids(3)", - "uri": "record(4)", - }, - }, - "text": "alice replies to dan", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(0)", - "viewer": Object {}, - }, - "replies": Array [], - }, -} -`; - -exports[`pds views with blocking from block lists blocks thread reply 1`] = ` -Object { - "thread": Object { - "$type": "app.bsky.feed.defs#threadViewPost", - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(2)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(2)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(1)", - "muted": false, - }, - }, - "cid": "cids(0)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 2, - "repostCount": 1, - "uri": "record(0)", - "viewer": Object { - "like": "record(4)", - "repost": "record(3)", - }, - }, - "replies": Array [ - Object { - "$type": "app.bsky.feed.defs#blockedPost", - "author": Object { - "did": "user(2)", - "viewer": Object { - "blockedBy": false, - "blocking": "record(6)", - }, - }, - "blocked": true, - "uri": "record(5)", - }, - Object { - "$type": "app.bsky.feed.defs#blockedPost", - "author": Object { - "did": "user(3)", - "viewer": Object { - "blockedBy": false, - "blocking": "record(6)", - }, - }, - "blocked": true, - "uri": "record(7)", - }, - ], - }, -} -`; - -exports[`pds views with blocking from block lists returns a users own list blocks 1`] = ` -Object { - "cursor": "0000000000000::bafycid", - "lists": Array [ - Object { - "cid": "cids(0)", - "creator": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "description": "its me!", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(2)", - "muted": false, - }, - }, - "description": "blah blah", - "indexedAt": "1970-01-01T00:00:00.000Z", - "name": "new list", - "purpose": "app.bsky.graph.defs#modlist", - "uri": "record(0)", - "viewer": Object { - "blocked": "record(1)", - "muted": false, - }, - }, - Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "cid": "cids(3)", - "creator": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "description": "its me!", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(2)", - "muted": false, - }, - }, - "description": "big list of blocks", - "indexedAt": "1970-01-01T00:00:00.000Z", - "name": "alice blocks", - "purpose": "app.bsky.graph.defs#modlist", - "uri": "record(4)", - "viewer": Object { - "blocked": "record(5)", - "muted": false, - }, - }, - ], -} -`; - -exports[`pds views with blocking from block lists returns lists associated with a user 1`] = ` -Object { - "cursor": "0000000000000::bafycid", - "lists": Array [ - Object { - "cid": "cids(0)", - "creator": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "description": "its me!", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(2)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(2)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(1)", - "muted": false, - }, - }, - "description": "blah blah", - "indexedAt": "1970-01-01T00:00:00.000Z", - "name": "new list", - "purpose": "app.bsky.graph.defs#modlist", - "uri": "record(0)", - "viewer": Object { - "muted": false, - }, - }, - Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "cid": "cids(3)", - "creator": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "description": "its me!", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(2)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(2)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(1)", - "muted": false, - }, - }, - "description": "big list of blocks", - "indexedAt": "1970-01-01T00:00:00.000Z", - "name": "alice blocks", - "purpose": "app.bsky.graph.defs#modlist", - "uri": "record(3)", - "viewer": Object { - "blocked": "record(4)", - "muted": false, - }, - }, - ], -} -`; - -exports[`pds views with blocking from block lists returns the contents of a list 1`] = ` -Object { - "cursor": "0000000000000::bafycid", - "items": Array [ - Object { - "subject": Object { - "did": "user(2)", - "handle": "dan.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "uri": "record(4)", - }, - Object { - "subject": Object { - "did": "user(3)", - "handle": "carol.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "blocking": "record(0)", - "blockingByList": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(0)/cids(1)@jpeg", - "cid": "cids(0)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "name": "alice blocks", - "purpose": "app.bsky.graph.defs#modlist", - "uri": "record(0)", - "viewer": Object { - "blocked": "record(1)", - "muted": false, - }, - }, - "muted": false, - }, - }, - "uri": "record(5)", - }, - Object { - "subject": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(5)/cids(1)@jpeg", - "description": "hi im bob label_me", - "did": "user(4)", - "displayName": "bobby", - "handle": "bob.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "blocking": "record(0)", - "blockingByList": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(0)/cids(1)@jpeg", - "cid": "cids(0)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "name": "alice blocks", - "purpose": "app.bsky.graph.defs#modlist", - "uri": "record(0)", - "viewer": Object { - "blocked": "record(1)", - "muted": false, - }, - }, - "muted": false, - }, - }, - "uri": "record(6)", - }, - ], - "list": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(0)/cids(1)@jpeg", - "cid": "cids(0)", - "creator": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(0)/cids(1)@jpeg", - "description": "its me!", - "did": "user(1)", - "displayName": "ali", - "handle": "alice.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(3)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(3)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(2)", - "muted": false, - }, - }, - "description": "big list of blocks", - "indexedAt": "1970-01-01T00:00:00.000Z", - "name": "alice blocks", - "purpose": "app.bsky.graph.defs#modlist", - "uri": "record(0)", - "viewer": Object { - "blocked": "record(1)", - "muted": false, - }, - }, -} -`; diff --git a/packages/ozone/tests/views/__snapshots__/blocks.test.ts.snap b/packages/ozone/tests/views/__snapshots__/blocks.test.ts.snap deleted file mode 100644 index 2a27fcf4955..00000000000 --- a/packages/ozone/tests/views/__snapshots__/blocks.test.ts.snap +++ /dev/null @@ -1,358 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`pds views with blocking blocks record embeds 1`] = ` -Object { - "thread": Object { - "$type": "app.bsky.feed.defs#threadViewPost", - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(2)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(2)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(1)", - "muted": false, - }, - }, - "cid": "cids(0)", - "embed": Object { - "$type": "app.bsky.embed.record#view", - "record": Object { - "$type": "app.bsky.embed.record#viewRecord", - "author": Object { - "did": "user(2)", - "handle": "dan.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(3)", - "embeds": Array [ - Object { - "$type": "app.bsky.embed.record#view", - "record": Object { - "$type": "app.bsky.embed.record#viewBlocked", - "author": Object { - "did": "user(3)", - "viewer": Object { - "blockedBy": false, - "blocking": "record(5)", - }, - }, - "blocked": true, - "uri": "record(4)", - }, - }, - ], - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "uri": "record(3)", - "value": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.record", - "record": Object { - "cid": "cids(4)", - "uri": "record(4)", - }, - }, - "facets": Array [ - Object { - "features": Array [ - Object { - "$type": "app.bsky.richtext.facet#mention", - "did": "user(0)", - }, - ], - "index": Object { - "byteEnd": 18, - "byteStart": 0, - }, - }, - ], - "text": "@alice.bluesky.xyz is the best", - }, - }, - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(0)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(0)", - "val": "test-label", - }, - ], - "likeCount": 2, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.record", - "record": Object { - "cid": "cids(3)", - "uri": "record(3)", - }, - }, - "text": "yoohoo label_me", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(0)", - "viewer": Object {}, - }, - }, -} -`; - -exports[`pds views with blocking blocks thread parent 1`] = ` -Object { - "thread": Object { - "$type": "app.bsky.feed.defs#threadViewPost", - "parent": Object { - "$type": "app.bsky.feed.defs#blockedPost", - "author": Object { - "did": "user(2)", - "viewer": Object { - "blockedBy": true, - }, - }, - "blocked": true, - "uri": "record(4)", - }, - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(2)", - "following": "record(1)", - "muted": false, - }, - }, - "cid": "cids(0)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "reply": Object { - "parent": Object { - "cid": "cids(3)", - "uri": "record(4)", - }, - "root": Object { - "cid": "cids(3)", - "uri": "record(4)", - }, - }, - "text": "alice replies to dan", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(0)", - "viewer": Object {}, - }, - "replies": Array [], - }, -} -`; - -exports[`pds views with blocking blocks thread reply 1`] = ` -Object { - "thread": Object { - "$type": "app.bsky.feed.defs#threadViewPost", - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(2)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(2)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(1)", - "muted": false, - }, - }, - "cid": "cids(0)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 2, - "repostCount": 1, - "uri": "record(0)", - "viewer": Object { - "like": "record(4)", - "repost": "record(3)", - }, - }, - "replies": Array [ - Object { - "$type": "app.bsky.feed.defs#blockedPost", - "author": Object { - "did": "user(2)", - "viewer": Object { - "blockedBy": false, - "blocking": "record(6)", - }, - }, - "blocked": true, - "uri": "record(5)", - }, - Object { - "$type": "app.bsky.feed.defs#threadViewPost", - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(4)/cids(1)@jpeg", - "did": "user(3)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "following": "record(8)", - "muted": false, - }, - }, - "cid": "cids(3)", - "embed": Object { - "$type": "app.bsky.embed.images#view", - "images": Array [ - Object { - "alt": "tests/sample-img/key-landscape-small.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(4)/cids(4)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(4)/cids(4)@jpeg", - }, - ], - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(3)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(7)", - "val": "test-label", - }, - Object { - "cid": "cids(3)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(7)", - "val": "test-label-2", - }, - ], - "likeCount": 0, - "record": 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(4)", - }, - "size": 4114, - }, - }, - ], - }, - "reply": Object { - "parent": Object { - "cid": "cids(0)", - "uri": "record(0)", - }, - "root": Object { - "cid": "cids(0)", - "uri": "record(0)", - }, - }, - "text": "hear that label_me label_me_2", - }, - "replyCount": 1, - "repostCount": 0, - "uri": "record(7)", - "viewer": Object {}, - }, - }, - ], - }, -} -`; diff --git a/packages/ozone/tests/views/__snapshots__/follows.test.ts.snap b/packages/ozone/tests/views/__snapshots__/follows.test.ts.snap deleted file mode 100644 index c85b0549de7..00000000000 --- a/packages/ozone/tests/views/__snapshots__/follows.test.ts.snap +++ /dev/null @@ -1,571 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`pds follow views fetches followers 1`] = ` -Object { - "cursor": "0000000000000::bafycid", - "followers": Array [ - Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(0)@jpeg", - "description": "descript-eve", - "did": "user(0)", - "displayName": "display-eve", - "handle": "eve.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(1)", - "following": "record(0)", - "muted": false, - }, - }, - Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(3)/cids(0)@jpeg", - "description": "descript-dan", - "did": "user(2)", - "displayName": "display-dan", - "handle": "dan.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(3)", - "following": "record(2)", - "muted": false, - }, - }, - Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(5)/cids(0)@jpeg", - "description": "descript-bob", - "did": "user(4)", - "displayName": "display-bob", - "handle": "bob.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(5)", - "following": "record(4)", - "muted": false, - }, - }, - Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(7)/cids(0)@jpeg", - "description": "descript-carol", - "did": "user(6)", - "displayName": "display-carol", - "handle": "carol.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(7)", - "following": "record(6)", - "muted": false, - }, - }, - ], - "subject": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(9)/cids(0)@jpeg", - "description": "descript-alice", - "did": "user(8)", - "displayName": "display-alice", - "handle": "alice.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, -} -`; - -exports[`pds follow views fetches followers 2`] = ` -Object { - "cursor": "0000000000000::bafycid", - "followers": Array [ - Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(0)@jpeg", - "description": "descript-dan", - "did": "user(0)", - "displayName": "display-dan", - "handle": "dan.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(1)", - "following": "record(0)", - "muted": false, - }, - }, - Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(3)/cids(0)@jpeg", - "description": "descript-alice", - "did": "user(2)", - "displayName": "display-alice", - "handle": "alice.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - ], - "subject": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(5)/cids(0)@jpeg", - "description": "descript-bob", - "did": "user(4)", - "displayName": "display-bob", - "handle": "bob.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(3)", - "following": "record(2)", - "muted": false, - }, - }, -} -`; - -exports[`pds follow views fetches followers 3`] = ` -Object { - "cursor": "0000000000000::bafycid", - "followers": Array [ - Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(0)@jpeg", - "description": "descript-eve", - "did": "user(0)", - "displayName": "display-eve", - "handle": "eve.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(1)", - "following": "record(0)", - "muted": false, - }, - }, - Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(3)/cids(0)@jpeg", - "description": "descript-bob", - "did": "user(2)", - "displayName": "display-bob", - "handle": "bob.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(3)", - "following": "record(2)", - "muted": false, - }, - }, - Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(5)/cids(0)@jpeg", - "description": "descript-alice", - "did": "user(4)", - "displayName": "display-alice", - "handle": "alice.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - ], - "subject": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(7)/cids(0)@jpeg", - "description": "descript-carol", - "did": "user(6)", - "displayName": "display-carol", - "handle": "carol.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(5)", - "following": "record(4)", - "muted": false, - }, - }, -} -`; - -exports[`pds follow views fetches followers 4`] = ` -Object { - "cursor": "0000000000000::bafycid", - "followers": Array [ - Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(0)@jpeg", - "description": "descript-alice", - "did": "user(0)", - "displayName": "display-alice", - "handle": "alice.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - ], - "subject": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(3)/cids(0)@jpeg", - "description": "descript-dan", - "did": "user(2)", - "displayName": "display-dan", - "handle": "dan.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(1)", - "following": "record(0)", - "muted": false, - }, - }, -} -`; - -exports[`pds follow views fetches followers 5`] = ` -Object { - "cursor": "0000000000000::bafycid", - "followers": Array [ - Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(0)@jpeg", - "description": "descript-dan", - "did": "user(0)", - "displayName": "display-dan", - "handle": "dan.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(1)", - "following": "record(0)", - "muted": false, - }, - }, - Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(3)/cids(0)@jpeg", - "description": "descript-alice", - "did": "user(2)", - "displayName": "display-alice", - "handle": "alice.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - ], - "subject": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(5)/cids(0)@jpeg", - "description": "descript-eve", - "did": "user(4)", - "displayName": "display-eve", - "handle": "eve.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(3)", - "following": "record(2)", - "muted": false, - }, - }, -} -`; - -exports[`pds follow views fetches follows 1`] = ` -Object { - "cursor": "0000000000000::bafycid", - "follows": Array [ - Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(0)@jpeg", - "description": "descript-eve", - "did": "user(0)", - "displayName": "display-eve", - "handle": "eve.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(1)", - "following": "record(0)", - "muted": false, - }, - }, - Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(3)/cids(0)@jpeg", - "description": "descript-dan", - "did": "user(2)", - "displayName": "display-dan", - "handle": "dan.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(3)", - "following": "record(2)", - "muted": false, - }, - }, - Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(5)/cids(0)@jpeg", - "description": "descript-carol", - "did": "user(4)", - "displayName": "display-carol", - "handle": "carol.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(5)", - "following": "record(4)", - "muted": false, - }, - }, - Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(7)/cids(0)@jpeg", - "description": "descript-bob", - "did": "user(6)", - "displayName": "display-bob", - "handle": "bob.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(7)", - "following": "record(6)", - "muted": false, - }, - }, - ], - "subject": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(9)/cids(0)@jpeg", - "description": "descript-alice", - "did": "user(8)", - "displayName": "display-alice", - "handle": "alice.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, -} -`; - -exports[`pds follow views fetches follows 2`] = ` -Object { - "cursor": "0000000000000::bafycid", - "follows": Array [ - Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(0)@jpeg", - "description": "descript-carol", - "did": "user(0)", - "displayName": "display-carol", - "handle": "carol.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(1)", - "following": "record(0)", - "muted": false, - }, - }, - Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(3)/cids(0)@jpeg", - "description": "descript-alice", - "did": "user(2)", - "displayName": "display-alice", - "handle": "alice.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - ], - "subject": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(5)/cids(0)@jpeg", - "description": "descript-bob", - "did": "user(4)", - "displayName": "display-bob", - "handle": "bob.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(3)", - "following": "record(2)", - "muted": false, - }, - }, -} -`; - -exports[`pds follow views fetches follows 3`] = ` -Object { - "cursor": "0000000000000::bafycid", - "follows": Array [ - Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(0)@jpeg", - "description": "descript-alice", - "did": "user(0)", - "displayName": "display-alice", - "handle": "alice.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - ], - "subject": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(3)/cids(0)@jpeg", - "description": "descript-carol", - "did": "user(2)", - "displayName": "display-carol", - "handle": "carol.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(1)", - "following": "record(0)", - "muted": false, - }, - }, -} -`; - -exports[`pds follow views fetches follows 4`] = ` -Object { - "cursor": "0000000000000::bafycid", - "follows": Array [ - Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(0)@jpeg", - "description": "descript-eve", - "did": "user(0)", - "displayName": "display-eve", - "handle": "eve.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(1)", - "following": "record(0)", - "muted": false, - }, - }, - Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(3)/cids(0)@jpeg", - "description": "descript-bob", - "did": "user(2)", - "displayName": "display-bob", - "handle": "bob.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(3)", - "following": "record(2)", - "muted": false, - }, - }, - Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(5)/cids(0)@jpeg", - "description": "descript-alice", - "did": "user(4)", - "displayName": "display-alice", - "handle": "alice.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - ], - "subject": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(7)/cids(0)@jpeg", - "description": "descript-dan", - "did": "user(6)", - "displayName": "display-dan", - "handle": "dan.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(5)", - "following": "record(4)", - "muted": false, - }, - }, -} -`; - -exports[`pds follow views fetches follows 5`] = ` -Object { - "cursor": "0000000000000::bafycid", - "follows": Array [ - Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(0)@jpeg", - "description": "descript-carol", - "did": "user(0)", - "displayName": "display-carol", - "handle": "carol.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(1)", - "following": "record(0)", - "muted": false, - }, - }, - Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(3)/cids(0)@jpeg", - "description": "descript-alice", - "did": "user(2)", - "displayName": "display-alice", - "handle": "alice.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - ], - "subject": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(5)/cids(0)@jpeg", - "description": "descript-eve", - "did": "user(4)", - "displayName": "display-eve", - "handle": "eve.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(3)", - "following": "record(2)", - "muted": false, - }, - }, -} -`; diff --git a/packages/ozone/tests/views/__snapshots__/likes.test.ts.snap b/packages/ozone/tests/views/__snapshots__/likes.test.ts.snap deleted file mode 100644 index 426467a3fa7..00000000000 --- a/packages/ozone/tests/views/__snapshots__/likes.test.ts.snap +++ /dev/null @@ -1,95 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`pds like views fetches post likes 1`] = ` -Object { - "cursor": "0000000000000::bafycid", - "likes": Array [ - Object { - "actor": Object { - "did": "user(0)", - "handle": "eve.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "createdAt": "1970-01-01T00:00:00.000Z", - "indexedAt": "1970-01-01T00:00:00.000Z", - }, - Object { - "actor": Object { - "did": "user(1)", - "handle": "dan.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "following": "record(0)", - "muted": false, - }, - }, - "createdAt": "1970-01-01T00:00:00.000Z", - "indexedAt": "1970-01-01T00:00:00.000Z", - }, - Object { - "actor": Object { - "did": "user(2)", - "handle": "carol.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(2)", - "following": "record(1)", - "muted": false, - }, - }, - "createdAt": "1970-01-01T00:00:00.000Z", - "indexedAt": "1970-01-01T00:00:00.000Z", - }, - Object { - "actor": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(4)/cids(0)@jpeg", - "description": "hi im bob label_me", - "did": "user(3)", - "displayName": "bobby", - "handle": "bob.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(4)", - "following": "record(3)", - "muted": false, - }, - }, - "createdAt": "1970-01-01T00:00:00.000Z", - "indexedAt": "1970-01-01T00:00:00.000Z", - }, - ], - "uri": "record(5)", -} -`; - -exports[`pds like views fetches reply likes 1`] = ` -Object { - "cursor": "0000000000000::bafycid", - "likes": Array [ - Object { - "actor": Object { - "did": "user(0)", - "handle": "carol.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(1)", - "following": "record(0)", - "muted": false, - }, - }, - "createdAt": "1970-01-01T00:00:00.000Z", - "indexedAt": "1970-01-01T00:00:00.000Z", - }, - ], - "uri": "record(2)", -} -`; diff --git a/packages/ozone/tests/views/__snapshots__/list-feed.test.ts.snap b/packages/ozone/tests/views/__snapshots__/list-feed.test.ts.snap deleted file mode 100644 index d6712c89c56..00000000000 --- a/packages/ozone/tests/views/__snapshots__/list-feed.test.ts.snap +++ /dev/null @@ -1,721 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`list feed views fetches list feed 1`] = ` -Array [ - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(2)", - "following": "record(1)", - "muted": false, - }, - }, - "cid": "cids(0)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "reply": Object { - "parent": Object { - "cid": "cids(4)", - "uri": "record(5)", - }, - "root": Object { - "cid": "cids(3)", - "uri": "record(4)", - }, - }, - "text": "thanks bob", - }, - "replyCount": 0, - "repostCount": 1, - "uri": "record(0)", - "viewer": Object {}, - }, - "reply": Object { - "parent": Object { - "$type": "app.bsky.feed.defs#postView", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(3)/cids(1)@jpeg", - "did": "user(2)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(7)", - "muted": false, - }, - }, - "cid": "cids(4)", - "embed": Object { - "$type": "app.bsky.embed.images#view", - "images": Array [ - Object { - "alt": "tests/sample-img/key-landscape-small.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(3)/cids(5)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(3)/cids(5)@jpeg", - }, - ], - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(4)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(5)", - "val": "test-label", - }, - Object { - "cid": "cids(4)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(5)", - "val": "test-label-2", - }, - ], - "likeCount": 0, - "record": 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(5)", - }, - "size": 4114, - }, - }, - ], - }, - "reply": Object { - "parent": Object { - "cid": "cids(3)", - "uri": "record(4)", - }, - "root": Object { - "cid": "cids(3)", - "uri": "record(4)", - }, - }, - "text": "hear that label_me label_me_2", - }, - "replyCount": 1, - "repostCount": 0, - "uri": "record(5)", - "viewer": Object {}, - }, - "root": Object { - "$type": "app.bsky.feed.defs#postView", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(2)", - "following": "record(1)", - "muted": false, - }, - }, - "cid": "cids(3)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 2, - "repostCount": 1, - "uri": "record(4)", - "viewer": Object { - "like": "record(6)", - }, - }, - }, - }, - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(3)/cids(1)@jpeg", - "did": "user(2)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(7)", - "muted": false, - }, - }, - "cid": "cids(4)", - "embed": Object { - "$type": "app.bsky.embed.images#view", - "images": Array [ - Object { - "alt": "tests/sample-img/key-landscape-small.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(3)/cids(5)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(3)/cids(5)@jpeg", - }, - ], - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(4)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(5)", - "val": "test-label", - }, - Object { - "cid": "cids(4)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(5)", - "val": "test-label-2", - }, - ], - "likeCount": 0, - "record": 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(5)", - }, - "size": 4114, - }, - }, - ], - }, - "reply": Object { - "parent": Object { - "cid": "cids(3)", - "uri": "record(4)", - }, - "root": Object { - "cid": "cids(3)", - "uri": "record(4)", - }, - }, - "text": "hear that label_me label_me_2", - }, - "replyCount": 1, - "repostCount": 0, - "uri": "record(5)", - "viewer": Object {}, - }, - "reply": Object { - "parent": Object { - "$type": "app.bsky.feed.defs#postView", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(2)", - "following": "record(1)", - "muted": false, - }, - }, - "cid": "cids(3)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 2, - "repostCount": 1, - "uri": "record(4)", - "viewer": Object { - "like": "record(6)", - }, - }, - "root": Object { - "$type": "app.bsky.feed.defs#postView", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(2)", - "following": "record(1)", - "muted": false, - }, - }, - "cid": "cids(3)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 2, - "repostCount": 1, - "uri": "record(4)", - "viewer": Object { - "like": "record(6)", - }, - }, - }, - }, - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(2)", - "following": "record(1)", - "muted": false, - }, - }, - "cid": "cids(6)", - "embed": Object { - "$type": "app.bsky.embed.record#view", - "record": Object { - "$type": "app.bsky.embed.record#viewRecord", - "author": Object { - "did": "user(4)", - "handle": "dan.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(7)", - "embeds": Array [ - Object { - "$type": "app.bsky.embed.record#view", - "record": Object { - "$type": "app.bsky.embed.record#viewRecord", - "author": Object { - "did": "user(5)", - "handle": "carol.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(8)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "uri": "record(10)", - "value": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.recordWithMedia", - "media": 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(5)", - }, - "size": 4114, - }, - }, - Object { - "alt": "tests/sample-img/key-alt.jpg", - "image": Object { - "$type": "blob", - "mimeType": "image/jpeg", - "ref": Object { - "$link": "cids(9)", - }, - "size": 12736, - }, - }, - ], - }, - "record": Object { - "record": Object { - "cid": "cids(10)", - "uri": "record(11)", - }, - }, - }, - "text": "hi im carol", - }, - }, - }, - ], - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "uri": "record(9)", - "value": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.record", - "record": Object { - "cid": "cids(8)", - "uri": "record(10)", - }, - }, - "facets": Array [ - Object { - "features": Array [ - Object { - "$type": "app.bsky.richtext.facet#mention", - "did": "user(0)", - }, - ], - "index": Object { - "byteEnd": 18, - "byteStart": 0, - }, - }, - ], - "text": "@alice.bluesky.xyz is the best", - }, - }, - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(6)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(8)", - "val": "test-label", - }, - ], - "likeCount": 2, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.record", - "record": Object { - "cid": "cids(7)", - "uri": "record(9)", - }, - }, - "text": "yoohoo label_me", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(8)", - "viewer": Object { - "like": "record(12)", - }, - }, - }, - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(3)/cids(1)@jpeg", - "did": "user(2)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(7)", - "muted": false, - }, - }, - "cid": "cids(11)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000+00:00", - "text": "bobby boy here", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(13)", - "viewer": Object {}, - }, - }, - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(2)", - "following": "record(1)", - "muted": false, - }, - }, - "cid": "cids(3)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 2, - "repostCount": 1, - "uri": "record(4)", - "viewer": Object { - "like": "record(6)", - }, - }, - }, - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(3)/cids(1)@jpeg", - "did": "user(2)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(7)", - "muted": false, - }, - }, - "cid": "cids(10)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "langs": Array [ - "en-US", - "i-klingon", - ], - "text": "bob back at it again!", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(11)", - "viewer": Object {}, - }, - }, - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(2)", - "following": "record(1)", - "muted": false, - }, - }, - "cid": "cids(12)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(12)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(14)", - "val": "self-label", - }, - ], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "labels": Object { - "$type": "com.atproto.label.defs#selfLabels", - "values": Array [ - Object { - "val": "self-label", - }, - ], - }, - "text": "hey there", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(14)", - "viewer": Object {}, - }, - }, -] -`; diff --git a/packages/ozone/tests/views/__snapshots__/mute-lists.test.ts.snap b/packages/ozone/tests/views/__snapshots__/mute-lists.test.ts.snap deleted file mode 100644 index d4b11f0d235..00000000000 --- a/packages/ozone/tests/views/__snapshots__/mute-lists.test.ts.snap +++ /dev/null @@ -1,597 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`bsky views with mutes from mute lists embeds lists in posts 1`] = ` -Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(0)", - "embed": Object { - "$type": "app.bsky.embed.record#view", - "record": Object { - "$type": "app.bsky.graph.defs#listView", - "cid": "cids(4)", - "creator": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "description": "new descript", - "indexedAt": "1970-01-01T00:00:00.000Z", - "name": "updated alice mutes", - "purpose": "app.bsky.graph.defs#modlist", - "uri": "record(2)", - "viewer": Object { - "muted": false, - }, - }, - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.record", - "record": Object { - "cid": "cids(3)", - "uri": "record(2)", - }, - }, - "text": "list embed!", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(0)", - "viewer": Object {}, -} -`; - -exports[`bsky views with mutes from mute lists flags mutes in threads 1`] = ` -Object { - "$type": "app.bsky.feed.defs#threadViewPost", - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(2)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(2)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(1)", - "muted": false, - }, - }, - "cid": "cids(0)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 2, - "repostCount": 1, - "uri": "record(0)", - "viewer": Object { - "like": "record(4)", - "repost": "record(3)", - }, - }, - "replies": Array [ - Object { - "$type": "app.bsky.feed.defs#threadViewPost", - "post": Object { - "author": Object { - "did": "user(2)", - "handle": "carol.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(8)", - "following": "record(7)", - "muted": true, - "mutedByList": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "cid": "cids(4)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "name": "alice mutes", - "purpose": "app.bsky.graph.defs#modlist", - "uri": "record(6)", - "viewer": Object { - "muted": true, - }, - }, - }, - }, - "cid": "cids(3)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "reply": Object { - "parent": Object { - "cid": "cids(0)", - "uri": "record(0)", - }, - "root": Object { - "cid": "cids(0)", - "uri": "record(0)", - }, - }, - "text": "of course", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(5)", - "viewer": Object {}, - }, - }, - Object { - "$type": "app.bsky.feed.defs#threadViewPost", - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(4)/cids(1)@jpeg", - "did": "user(3)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "following": "record(10)", - "muted": true, - "mutedByList": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "cid": "cids(4)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "name": "alice mutes", - "purpose": "app.bsky.graph.defs#modlist", - "uri": "record(6)", - "viewer": Object { - "muted": true, - }, - }, - }, - }, - "cid": "cids(5)", - "embed": Object { - "$type": "app.bsky.embed.images#view", - "images": Array [ - Object { - "alt": "tests/sample-img/key-landscape-small.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(4)/cids(6)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(4)/cids(6)@jpeg", - }, - ], - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(5)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(9)", - "val": "test-label", - }, - Object { - "cid": "cids(5)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(9)", - "val": "test-label-2", - }, - ], - "likeCount": 0, - "record": 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(6)", - }, - "size": 4114, - }, - }, - ], - }, - "reply": Object { - "parent": Object { - "cid": "cids(0)", - "uri": "record(0)", - }, - "root": Object { - "cid": "cids(0)", - "uri": "record(0)", - }, - }, - "text": "hear that label_me label_me_2", - }, - "replyCount": 1, - "repostCount": 0, - "uri": "record(9)", - "viewer": Object {}, - }, - }, - ], -} -`; - -exports[`bsky views with mutes from mute lists returns a users own list mutes 1`] = ` -Object { - "cursor": "0000000000000::bafycid", - "lists": Array [ - Object { - "cid": "cids(0)", - "creator": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "description": "its me!", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(2)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(2)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(1)", - "muted": false, - }, - }, - "description": "blah blah", - "indexedAt": "1970-01-01T00:00:00.000Z", - "name": "new list", - "purpose": "app.bsky.graph.defs#modlist", - "uri": "record(0)", - "viewer": Object { - "muted": true, - }, - }, - Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "cid": "cids(3)", - "creator": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "description": "its me!", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(2)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(2)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(1)", - "muted": false, - }, - }, - "description": "big list of mutes", - "indexedAt": "1970-01-01T00:00:00.000Z", - "name": "alice mutes", - "purpose": "app.bsky.graph.defs#modlist", - "uri": "record(3)", - "viewer": Object { - "muted": true, - }, - }, - ], -} -`; - -exports[`bsky views with mutes from mute lists returns lists associated with a user 1`] = ` -Object { - "cursor": "0000000000000::bafycid", - "lists": Array [ - Object { - "cid": "cids(0)", - "creator": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "description": "its me!", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(2)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(2)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(1)", - "muted": false, - }, - }, - "description": "blah blah", - "indexedAt": "1970-01-01T00:00:00.000Z", - "name": "new list", - "purpose": "app.bsky.graph.defs#modlist", - "uri": "record(0)", - "viewer": Object { - "muted": false, - }, - }, - Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "cid": "cids(3)", - "creator": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "description": "its me!", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(2)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(2)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(1)", - "muted": false, - }, - }, - "description": "big list of mutes", - "indexedAt": "1970-01-01T00:00:00.000Z", - "name": "alice mutes", - "purpose": "app.bsky.graph.defs#modlist", - "uri": "record(3)", - "viewer": Object { - "muted": true, - }, - }, - ], -} -`; - -exports[`bsky views with mutes from mute lists returns the contents of a list 1`] = ` -Object { - "cursor": "0000000000000::bafycid", - "items": Array [ - Object { - "subject": Object { - "did": "user(2)", - "handle": "dan.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "uri": "record(3)", - }, - Object { - "subject": Object { - "did": "user(3)", - "handle": "carol.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(5)", - "muted": true, - "mutedByList": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(0)/cids(1)@jpeg", - "cid": "cids(0)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "name": "alice mutes", - "purpose": "app.bsky.graph.defs#modlist", - "uri": "record(0)", - "viewer": Object { - "muted": true, - }, - }, - }, - }, - "uri": "record(4)", - }, - Object { - "subject": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(5)/cids(1)@jpeg", - "description": "hi im bob label_me", - "did": "user(4)", - "displayName": "bobby", - "handle": "bob.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "following": "record(7)", - "muted": true, - "mutedByList": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(0)/cids(1)@jpeg", - "cid": "cids(0)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "name": "alice mutes", - "purpose": "app.bsky.graph.defs#modlist", - "uri": "record(0)", - "viewer": Object { - "muted": true, - }, - }, - }, - }, - "uri": "record(6)", - }, - ], - "list": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(0)/cids(1)@jpeg", - "cid": "cids(0)", - "creator": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(0)/cids(1)@jpeg", - "description": "its me!", - "did": "user(1)", - "displayName": "ali", - "handle": "alice.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(2)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(2)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(1)", - "muted": false, - }, - }, - "description": "big list of mutes", - "indexedAt": "1970-01-01T00:00:00.000Z", - "name": "alice mutes", - "purpose": "app.bsky.graph.defs#modlist", - "uri": "record(0)", - "viewer": Object { - "muted": true, - }, - }, -} -`; diff --git a/packages/ozone/tests/views/__snapshots__/mutes.test.ts.snap b/packages/ozone/tests/views/__snapshots__/mutes.test.ts.snap deleted file mode 100644 index 0e1c14c2696..00000000000 --- a/packages/ozone/tests/views/__snapshots__/mutes.test.ts.snap +++ /dev/null @@ -1,273 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`mute views fetches mutes for the logged-in user. 1`] = ` -Array [ - Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(0)@jpeg", - "did": "user(0)", - "displayName": "Dr. Lowell DuBuque", - "handle": "elta48.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": true, - }, - }, - Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(3)/cids(0)@jpeg", - "did": "user(2)", - "displayName": "Sally Funk", - "handle": "magnus53.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": true, - }, - }, - Object { - "did": "user(4)", - "handle": "nicolas-krajcik10.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": true, - }, - }, - Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(6)/cids(0)@jpeg", - "did": "user(5)", - "displayName": "Patrick Sawayn", - "handle": "jeffrey-sawayn87.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": true, - }, - }, - Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(8)/cids(0)@jpeg", - "did": "user(7)", - "displayName": "Kim Streich", - "handle": "adrienne49.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": true, - }, - }, - Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(10)/cids(0)@jpeg", - "did": "user(9)", - "displayName": "Carlton Abernathy IV", - "handle": "aliya-hodkiewicz.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": true, - }, - }, - Object { - "did": "user(11)", - "handle": "carol.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(0)", - "muted": true, - }, - }, - Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(13)/cids(0)@jpeg", - "description": "hi im bob label_me", - "did": "user(12)", - "displayName": "bobby", - "handle": "bob.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(1)", - "muted": true, - }, - }, -] -`; - -exports[`mute views flags mutes in threads 1`] = ` -Object { - "$type": "app.bsky.feed.defs#threadViewPost", - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(0)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 2, - "repostCount": 1, - "uri": "record(0)", - "viewer": Object {}, - }, - "replies": Array [ - Object { - "$type": "app.bsky.feed.defs#threadViewPost", - "post": Object { - "author": Object { - "did": "user(2)", - "handle": "carol.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(4)", - "following": "record(3)", - "muted": true, - }, - }, - "cid": "cids(3)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "reply": Object { - "parent": Object { - "cid": "cids(0)", - "uri": "record(0)", - }, - "root": Object { - "cid": "cids(0)", - "uri": "record(0)", - }, - }, - "text": "of course", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(2)", - "viewer": Object {}, - }, - }, - Object { - "$type": "app.bsky.feed.defs#threadViewPost", - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(4)/cids(1)@jpeg", - "did": "user(3)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(7)", - "following": "record(6)", - "muted": true, - }, - }, - "cid": "cids(4)", - "embed": Object { - "$type": "app.bsky.embed.images#view", - "images": Array [ - Object { - "alt": "tests/sample-img/key-landscape-small.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(4)/cids(5)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(4)/cids(5)@jpeg", - }, - ], - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(4)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(5)", - "val": "test-label", - }, - Object { - "cid": "cids(4)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(5)", - "val": "test-label-2", - }, - ], - "likeCount": 0, - "record": 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(5)", - }, - "size": 4114, - }, - }, - ], - }, - "reply": Object { - "parent": Object { - "cid": "cids(0)", - "uri": "record(0)", - }, - "root": Object { - "cid": "cids(0)", - "uri": "record(0)", - }, - }, - "text": "hear that label_me label_me_2", - }, - "replyCount": 1, - "repostCount": 0, - "uri": "record(5)", - "viewer": Object {}, - }, - }, - ], -} -`; diff --git a/packages/ozone/tests/views/__snapshots__/notifications.test.ts.snap b/packages/ozone/tests/views/__snapshots__/notifications.test.ts.snap deleted file mode 100644 index bce3d4e5139..00000000000 --- a/packages/ozone/tests/views/__snapshots__/notifications.test.ts.snap +++ /dev/null @@ -1,946 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`notification views fetches notifications omitting mentions and replies for taken-down posts 1`] = ` -Array [ - Object { - "author": Object { - "did": "user(0)", - "handle": "dan.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "following": "record(1)", - "muted": false, - }, - }, - "cid": "cids(0)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "isRead": false, - "labels": Array [], - "reason": "repost", - "reasonSubject": "record(2)", - "record": Object { - "$type": "app.bsky.feed.repost", - "createdAt": "1970-01-01T00:00:00.000Z", - "subject": Object { - "cid": "cids(1)", - "uri": "record(2)", - }, - }, - "uri": "record(0)", - }, - Object { - "author": Object { - "did": "user(0)", - "handle": "dan.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "following": "record(1)", - "muted": false, - }, - }, - "cid": "cids(2)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "isRead": false, - "labels": Array [], - "reason": "repost", - "reasonSubject": "record(4)", - "record": Object { - "$type": "app.bsky.feed.repost", - "createdAt": "1970-01-01T00:00:00.000Z", - "subject": Object { - "cid": "cids(3)", - "uri": "record(4)", - }, - }, - "uri": "record(3)", - }, - Object { - "author": Object { - "did": "user(0)", - "handle": "dan.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "following": "record(1)", - "muted": false, - }, - }, - "cid": "cids(4)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "isRead": false, - "labels": Array [], - "reason": "like", - "reasonSubject": "record(4)", - "record": Object { - "$type": "app.bsky.feed.like", - "createdAt": "1970-01-01T00:00:00.000Z", - "subject": Object { - "cid": "cids(3)", - "uri": "record(4)", - }, - }, - "uri": "record(5)", - }, - Object { - "author": Object { - "did": "user(1)", - "handle": "carol.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(6)", - "following": "record(7)", - "muted": false, - }, - }, - "cid": "cids(5)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "isRead": false, - "labels": Array [], - "reason": "follow", - "record": Object { - "$type": "app.bsky.graph.follow", - "createdAt": "1970-01-01T00:00:00.000Z", - "subject": "user(2)", - }, - "uri": "record(6)", - }, - Object { - "author": Object { - "did": "user(1)", - "handle": "carol.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(6)", - "following": "record(7)", - "muted": false, - }, - }, - "cid": "cids(6)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "isRead": false, - "labels": Array [], - "reason": "reply", - "reasonSubject": "record(2)", - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "reply": Object { - "parent": Object { - "cid": "cids(1)", - "uri": "record(2)", - }, - "root": Object { - "cid": "cids(3)", - "uri": "record(4)", - }, - }, - "text": "indeed", - }, - "uri": "record(8)", - }, - Object { - "author": Object { - "did": "user(1)", - "handle": "carol.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(6)", - "following": "record(7)", - "muted": false, - }, - }, - "cid": "cids(7)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "isRead": false, - "labels": Array [], - "reason": "like", - "reasonSubject": "record(10)", - "record": Object { - "$type": "app.bsky.feed.like", - "createdAt": "1970-01-01T00:00:00.000Z", - "subject": Object { - "cid": "cids(8)", - "uri": "record(10)", - }, - }, - "uri": "record(9)", - }, - Object { - "author": Object { - "did": "user(1)", - "handle": "carol.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(6)", - "following": "record(7)", - "muted": false, - }, - }, - "cid": "cids(9)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "isRead": false, - "labels": Array [], - "reason": "like", - "reasonSubject": "record(4)", - "record": Object { - "$type": "app.bsky.feed.like", - "createdAt": "1970-01-01T00:00:00.000Z", - "subject": Object { - "cid": "cids(3)", - "uri": "record(4)", - }, - }, - "uri": "record(11)", - }, - Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(4)/cids(11)@jpeg", - "description": "hi im bob label_me", - "did": "user(3)", - "displayName": "bobby", - "handle": "bob.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(12)", - "following": "record(13)", - "muted": false, - }, - }, - "cid": "cids(10)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "isRead": false, - "labels": Array [], - "reason": "follow", - "record": Object { - "$type": "app.bsky.graph.follow", - "createdAt": "1970-01-01T00:00:00.000Z", - "subject": "user(2)", - }, - "uri": "record(12)", - }, - Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(4)/cids(11)@jpeg", - "description": "hi im bob label_me", - "did": "user(3)", - "displayName": "bobby", - "handle": "bob.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(12)", - "following": "record(13)", - "muted": false, - }, - }, - "cid": "cids(12)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "isRead": false, - "labels": Array [ - Object { - "cid": "cids(12)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(14)", - "val": "test-label", - }, - Object { - "cid": "cids(12)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(14)", - "val": "test-label-2", - }, - ], - "reason": "reply", - "reasonSubject": "record(4)", - "record": 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(13)", - }, - "size": 4114, - }, - }, - ], - }, - "reply": Object { - "parent": Object { - "cid": "cids(3)", - "uri": "record(4)", - }, - "root": Object { - "cid": "cids(3)", - "uri": "record(4)", - }, - }, - "text": "hear that label_me label_me_2", - }, - "uri": "record(14)", - }, - Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(4)/cids(11)@jpeg", - "description": "hi im bob label_me", - "did": "user(3)", - "displayName": "bobby", - "handle": "bob.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(12)", - "following": "record(13)", - "muted": false, - }, - }, - "cid": "cids(14)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "isRead": false, - "labels": Array [], - "reason": "like", - "reasonSubject": "record(10)", - "record": Object { - "$type": "app.bsky.feed.like", - "createdAt": "1970-01-01T00:00:00.000Z", - "subject": Object { - "cid": "cids(8)", - "uri": "record(10)", - }, - }, - "uri": "record(15)", - }, - Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(4)/cids(11)@jpeg", - "description": "hi im bob label_me", - "did": "user(3)", - "displayName": "bobby", - "handle": "bob.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(12)", - "following": "record(13)", - "muted": false, - }, - }, - "cid": "cids(15)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "isRead": false, - "labels": Array [], - "reason": "like", - "reasonSubject": "record(4)", - "record": Object { - "$type": "app.bsky.feed.like", - "createdAt": "1970-01-01T00:00:00.000Z", - "subject": Object { - "cid": "cids(3)", - "uri": "record(4)", - }, - }, - "uri": "record(16)", - }, -] -`; - -exports[`notification views fetches notifications without a last-seen 1`] = ` -Array [ - Object { - "author": Object { - "did": "user(0)", - "handle": "dan.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "following": "record(1)", - "muted": false, - }, - }, - "cid": "cids(0)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "isRead": false, - "labels": Array [], - "reason": "repost", - "reasonSubject": "record(2)", - "record": Object { - "$type": "app.bsky.feed.repost", - "createdAt": "1970-01-01T00:00:00.000Z", - "subject": Object { - "cid": "cids(1)", - "uri": "record(2)", - }, - }, - "uri": "record(0)", - }, - Object { - "author": Object { - "did": "user(0)", - "handle": "dan.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "following": "record(1)", - "muted": false, - }, - }, - "cid": "cids(2)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "isRead": false, - "labels": Array [], - "reason": "repost", - "reasonSubject": "record(4)", - "record": Object { - "$type": "app.bsky.feed.repost", - "createdAt": "1970-01-01T00:00:00.000Z", - "subject": Object { - "cid": "cids(3)", - "uri": "record(4)", - }, - }, - "uri": "record(3)", - }, - Object { - "author": Object { - "did": "user(0)", - "handle": "dan.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "following": "record(1)", - "muted": false, - }, - }, - "cid": "cids(4)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "isRead": false, - "labels": Array [], - "reason": "mention", - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.record", - "record": Object { - "cid": "cids(5)", - "uri": "record(6)", - }, - }, - "facets": Array [ - Object { - "features": Array [ - Object { - "$type": "app.bsky.richtext.facet#mention", - "did": "user(1)", - }, - ], - "index": Object { - "byteEnd": 18, - "byteStart": 0, - }, - }, - ], - "text": "@alice.bluesky.xyz is the best", - }, - "uri": "record(5)", - }, - Object { - "author": Object { - "did": "user(0)", - "handle": "dan.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "following": "record(1)", - "muted": false, - }, - }, - "cid": "cids(6)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "isRead": false, - "labels": Array [], - "reason": "like", - "reasonSubject": "record(4)", - "record": Object { - "$type": "app.bsky.feed.like", - "createdAt": "1970-01-01T00:00:00.000Z", - "subject": Object { - "cid": "cids(3)", - "uri": "record(4)", - }, - }, - "uri": "record(7)", - }, - Object { - "author": Object { - "did": "user(2)", - "handle": "carol.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(8)", - "following": "record(9)", - "muted": false, - }, - }, - "cid": "cids(7)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "isRead": false, - "labels": Array [], - "reason": "follow", - "record": Object { - "$type": "app.bsky.graph.follow", - "createdAt": "1970-01-01T00:00:00.000Z", - "subject": "user(1)", - }, - "uri": "record(8)", - }, - Object { - "author": Object { - "did": "user(2)", - "handle": "carol.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(8)", - "following": "record(9)", - "muted": false, - }, - }, - "cid": "cids(8)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "isRead": false, - "labels": Array [], - "reason": "reply", - "reasonSubject": "record(2)", - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "reply": Object { - "parent": Object { - "cid": "cids(1)", - "uri": "record(2)", - }, - "root": Object { - "cid": "cids(3)", - "uri": "record(4)", - }, - }, - "text": "indeed", - }, - "uri": "record(10)", - }, - Object { - "author": Object { - "did": "user(2)", - "handle": "carol.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(8)", - "following": "record(9)", - "muted": false, - }, - }, - "cid": "cids(9)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "isRead": false, - "labels": Array [], - "reason": "reply", - "reasonSubject": "record(4)", - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "reply": Object { - "parent": Object { - "cid": "cids(3)", - "uri": "record(4)", - }, - "root": Object { - "cid": "cids(3)", - "uri": "record(4)", - }, - }, - "text": "of course", - }, - "uri": "record(11)", - }, - Object { - "author": Object { - "did": "user(2)", - "handle": "carol.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(8)", - "following": "record(9)", - "muted": false, - }, - }, - "cid": "cids(10)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "isRead": false, - "labels": Array [], - "reason": "like", - "reasonSubject": "record(13)", - "record": Object { - "$type": "app.bsky.feed.like", - "createdAt": "1970-01-01T00:00:00.000Z", - "subject": Object { - "cid": "cids(11)", - "uri": "record(13)", - }, - }, - "uri": "record(12)", - }, - Object { - "author": Object { - "did": "user(2)", - "handle": "carol.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(8)", - "following": "record(9)", - "muted": false, - }, - }, - "cid": "cids(12)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "isRead": false, - "labels": Array [], - "reason": "like", - "reasonSubject": "record(4)", - "record": Object { - "$type": "app.bsky.feed.like", - "createdAt": "1970-01-01T00:00:00.000Z", - "subject": Object { - "cid": "cids(3)", - "uri": "record(4)", - }, - }, - "uri": "record(14)", - }, - Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(4)/cids(14)@jpeg", - "description": "hi im bob label_me", - "did": "user(3)", - "displayName": "bobby", - "handle": "bob.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(15)", - "following": "record(16)", - "muted": false, - }, - }, - "cid": "cids(13)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "isRead": false, - "labels": Array [], - "reason": "follow", - "record": Object { - "$type": "app.bsky.graph.follow", - "createdAt": "1970-01-01T00:00:00.000Z", - "subject": "user(1)", - }, - "uri": "record(15)", - }, - Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(4)/cids(14)@jpeg", - "description": "hi im bob label_me", - "did": "user(3)", - "displayName": "bobby", - "handle": "bob.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(15)", - "following": "record(16)", - "muted": false, - }, - }, - "cid": "cids(15)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "isRead": false, - "labels": Array [ - Object { - "cid": "cids(15)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(17)", - "val": "test-label", - }, - Object { - "cid": "cids(15)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(17)", - "val": "test-label-2", - }, - ], - "reason": "reply", - "reasonSubject": "record(4)", - "record": 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(16)", - }, - "size": 4114, - }, - }, - ], - }, - "reply": Object { - "parent": Object { - "cid": "cids(3)", - "uri": "record(4)", - }, - "root": Object { - "cid": "cids(3)", - "uri": "record(4)", - }, - }, - "text": "hear that label_me label_me_2", - }, - "uri": "record(17)", - }, - Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(4)/cids(14)@jpeg", - "description": "hi im bob label_me", - "did": "user(3)", - "displayName": "bobby", - "handle": "bob.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(15)", - "following": "record(16)", - "muted": false, - }, - }, - "cid": "cids(17)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "isRead": false, - "labels": Array [], - "reason": "like", - "reasonSubject": "record(13)", - "record": Object { - "$type": "app.bsky.feed.like", - "createdAt": "1970-01-01T00:00:00.000Z", - "subject": Object { - "cid": "cids(11)", - "uri": "record(13)", - }, - }, - "uri": "record(18)", - }, - Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(4)/cids(14)@jpeg", - "description": "hi im bob label_me", - "did": "user(3)", - "displayName": "bobby", - "handle": "bob.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(15)", - "following": "record(16)", - "muted": false, - }, - }, - "cid": "cids(18)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "isRead": false, - "labels": Array [], - "reason": "like", - "reasonSubject": "record(4)", - "record": Object { - "$type": "app.bsky.feed.like", - "createdAt": "1970-01-01T00:00:00.000Z", - "subject": Object { - "cid": "cids(3)", - "uri": "record(4)", - }, - }, - "uri": "record(19)", - }, -] -`; - -exports[`notification views generates notifications for quotes 1`] = ` -Array [ - Object { - "author": Object { - "did": "user(0)", - "handle": "carol.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(0)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "isRead": false, - "labels": Array [], - "reason": "repost", - "reasonSubject": "record(1)", - "record": Object { - "$type": "app.bsky.feed.repost", - "createdAt": "1970-01-01T00:00:00.000Z", - "subject": Object { - "cid": "cids(1)", - "uri": "record(1)", - }, - }, - "uri": "record(0)", - }, - Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(2)/cids(3)@jpeg", - "description": "its me!", - "did": "user(1)", - "displayName": "ali", - "handle": "alice.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(4)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(3)", - "val": "self-label-a", - }, - Object { - "cid": "cids(4)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(3)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(2)", - "muted": false, - }, - }, - "cid": "cids(2)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "isRead": false, - "labels": Array [], - "reason": "follow", - "record": Object { - "$type": "app.bsky.graph.follow", - "createdAt": "1970-01-01T00:00:00.000Z", - "subject": "user(3)", - }, - "uri": "record(2)", - }, - Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(2)/cids(3)@jpeg", - "description": "its me!", - "did": "user(1)", - "displayName": "ali", - "handle": "alice.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(4)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(3)", - "val": "self-label-a", - }, - Object { - "cid": "cids(4)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(3)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(2)", - "muted": false, - }, - }, - "cid": "cids(5)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "isRead": false, - "labels": Array [ - Object { - "cid": "cids(5)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(4)", - "val": "test-label", - }, - ], - "reason": "quote", - "reasonSubject": "record(1)", - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.record", - "record": Object { - "cid": "cids(1)", - "uri": "record(1)", - }, - }, - "text": "yoohoo label_me", - }, - "uri": "record(4)", - }, -] -`; diff --git a/packages/ozone/tests/views/__snapshots__/posts.test.ts.snap b/packages/ozone/tests/views/__snapshots__/posts.test.ts.snap deleted file mode 100644 index 3b14a184dc1..00000000000 --- a/packages/ozone/tests/views/__snapshots__/posts.test.ts.snap +++ /dev/null @@ -1,467 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`pds posts views fetches posts 1`] = ` -Array [ - Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(0)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(0)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(0)", - "val": "self-label", - }, - ], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "labels": Object { - "$type": "com.atproto.label.defs#selfLabels", - "values": Array [ - Object { - "val": "self-label", - }, - ], - }, - "text": "hey there", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(0)", - "viewer": Object {}, - }, - Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(3)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 2, - "repostCount": 1, - "uri": "record(2)", - "viewer": Object {}, - }, - Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(3)/cids(1)@jpeg", - "did": "user(2)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(5)", - "following": "record(4)", - "muted": false, - }, - }, - "cid": "cids(4)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "langs": Array [ - "en-US", - "i-klingon", - ], - "text": "bob back at it again!", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(3)", - "viewer": Object {}, - }, - Object { - "author": Object { - "did": "user(4)", - "handle": "carol.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(8)", - "following": "record(7)", - "muted": false, - }, - }, - "cid": "cids(5)", - "embed": Object { - "$type": "app.bsky.embed.recordWithMedia#view", - "media": Object { - "$type": "app.bsky.embed.images#view", - "images": Array [ - Object { - "alt": "tests/sample-img/key-landscape-small.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(5)/cids(6)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(5)/cids(6)@jpeg", - }, - Object { - "alt": "tests/sample-img/key-alt.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(5)/cids(7)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(5)/cids(7)@jpeg", - }, - ], - }, - "record": Object { - "record": Object { - "$type": "app.bsky.embed.record#viewRecord", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(3)/cids(1)@jpeg", - "did": "user(2)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(5)", - "following": "record(4)", - "muted": false, - }, - }, - "cid": "cids(4)", - "embeds": Array [], - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "uri": "record(3)", - "value": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "langs": Array [ - "en-US", - "i-klingon", - ], - "text": "bob back at it again!", - }, - }, - }, - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 2, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.recordWithMedia", - "media": 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(6)", - }, - "size": 4114, - }, - }, - Object { - "alt": "tests/sample-img/key-alt.jpg", - "image": Object { - "$type": "blob", - "mimeType": "image/jpeg", - "ref": Object { - "$link": "cids(7)", - }, - "size": 12736, - }, - }, - ], - }, - "record": Object { - "record": Object { - "cid": "cids(4)", - "uri": "record(3)", - }, - }, - }, - "text": "hi im carol", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(6)", - "viewer": Object { - "like": "record(9)", - }, - }, - Object { - "author": Object { - "did": "user(6)", - "handle": "dan.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "following": "record(11)", - "muted": false, - }, - }, - "cid": "cids(8)", - "embed": Object { - "$type": "app.bsky.embed.record#view", - "record": Object { - "$type": "app.bsky.embed.record#viewRecord", - "author": Object { - "did": "user(4)", - "handle": "carol.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(8)", - "following": "record(7)", - "muted": false, - }, - }, - "cid": "cids(5)", - "embeds": Array [ - Object { - "$type": "app.bsky.embed.recordWithMedia#view", - "media": Object { - "$type": "app.bsky.embed.images#view", - "images": Array [ - Object { - "alt": "tests/sample-img/key-landscape-small.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(5)/cids(6)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(5)/cids(6)@jpeg", - }, - Object { - "alt": "tests/sample-img/key-alt.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(5)/cids(7)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(5)/cids(7)@jpeg", - }, - ], - }, - "record": Object { - "record": Object { - "$type": "app.bsky.embed.record#viewRecord", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(3)/cids(1)@jpeg", - "did": "user(2)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(5)", - "following": "record(4)", - "muted": false, - }, - }, - "cid": "cids(4)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "uri": "record(3)", - "value": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "langs": Array [ - "en-US", - "i-klingon", - ], - "text": "bob back at it again!", - }, - }, - }, - }, - ], - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "uri": "record(6)", - "value": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.recordWithMedia", - "media": 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(6)", - }, - "size": 4114, - }, - }, - Object { - "alt": "tests/sample-img/key-alt.jpg", - "image": Object { - "$type": "blob", - "mimeType": "image/jpeg", - "ref": Object { - "$link": "cids(7)", - }, - "size": 12736, - }, - }, - ], - }, - "record": Object { - "record": Object { - "cid": "cids(4)", - "uri": "record(3)", - }, - }, - }, - "text": "hi im carol", - }, - }, - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.record", - "record": Object { - "cid": "cids(5)", - "uri": "record(6)", - }, - }, - "facets": Array [ - Object { - "features": Array [ - Object { - "$type": "app.bsky.richtext.facet#mention", - "did": "user(0)", - }, - ], - "index": Object { - "byteEnd": 18, - "byteStart": 0, - }, - }, - ], - "text": "@alice.bluesky.xyz is the best", - }, - "replyCount": 0, - "repostCount": 1, - "uri": "record(10)", - "viewer": Object {}, - }, - Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(9)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "reply": Object { - "parent": Object { - "cid": "cids(10)", - "uri": "record(13)", - }, - "root": Object { - "cid": "cids(3)", - "uri": "record(2)", - }, - }, - "text": "thanks bob", - }, - "replyCount": 0, - "repostCount": 1, - "uri": "record(12)", - "viewer": Object {}, - }, -] -`; diff --git a/packages/ozone/tests/views/__snapshots__/profile.test.ts.snap b/packages/ozone/tests/views/__snapshots__/profile.test.ts.snap deleted file mode 100644 index 62b88f825e0..00000000000 --- a/packages/ozone/tests/views/__snapshots__/profile.test.ts.snap +++ /dev/null @@ -1,193 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`pds profile views fetches multiple profiles 1`] = ` -Array [ - Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(0)@jpeg", - "description": "its me!", - "did": "user(0)", - "displayName": "ali", - "followersCount": 2, - "followsCount": 3, - "handle": "alice.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(1)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(2)", - "val": "self-label-a", - }, - Object { - "cid": "cids(1)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(2)", - "val": "self-label-b", - }, - ], - "postsCount": 4, - "viewer": Object { - "blockedBy": false, - "followedBy": "record(1)", - "following": "record(0)", - "muted": false, - }, - }, - Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(3)/cids(0)@jpeg", - "description": "hi im bob label_me", - "did": "user(2)", - "displayName": "bobby", - "followersCount": 2, - "followsCount": 2, - "handle": "bob.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "postsCount": 3, - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - Object { - "did": "user(4)", - "followersCount": 2, - "followsCount": 1, - "handle": "carol.test", - "labels": Array [], - "postsCount": 2, - "viewer": Object { - "blockedBy": false, - "following": "record(3)", - "muted": false, - }, - }, - Object { - "did": "user(5)", - "followersCount": 1, - "followsCount": 1, - "handle": "dan.test", - "labels": Array [], - "postsCount": 2, - "viewer": Object { - "blockedBy": false, - "followedBy": "record(4)", - "muted": false, - }, - }, -] -`; - -exports[`pds profile views fetches other's profile, with a follow 1`] = ` -Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(0)@jpeg", - "description": "its me!", - "did": "user(0)", - "displayName": "ali", - "followersCount": 2, - "followsCount": 3, - "handle": "alice.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(1)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(2)", - "val": "self-label-a", - }, - Object { - "cid": "cids(1)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(2)", - "val": "self-label-b", - }, - ], - "postsCount": 4, - "viewer": Object { - "blockedBy": false, - "followedBy": "record(1)", - "following": "record(0)", - "muted": false, - }, -} -`; - -exports[`pds profile views fetches other's profile, without a follow 1`] = ` -Object { - "did": "user(0)", - "followersCount": 1, - "followsCount": 1, - "handle": "dan.test", - "labels": Array [], - "postsCount": 2, - "viewer": Object { - "blockedBy": false, - "followedBy": "record(0)", - "muted": false, - }, -} -`; - -exports[`pds profile views fetches own profile 1`] = ` -Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(0)@jpeg", - "description": "its me!", - "did": "user(0)", - "displayName": "ali", - "followersCount": 2, - "followsCount": 3, - "handle": "alice.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(1)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(0)", - "val": "self-label-a", - }, - Object { - "cid": "cids(1)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(0)", - "val": "self-label-b", - }, - ], - "postsCount": 4, - "viewer": Object { - "blockedBy": false, - "muted": false, - }, -} -`; - -exports[`pds profile views presents avatars & banners 1`] = ` -Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(0)@jpeg", - "banner": "https://bsky.public.url/img/banner/plain/user(1)/cids(1)@jpeg", - "description": "new descript", - "did": "user(0)", - "displayName": "ali", - "followersCount": 2, - "followsCount": 3, - "handle": "alice.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "postsCount": 4, - "viewer": Object { - "blockedBy": false, - "muted": false, - }, -} -`; diff --git a/packages/ozone/tests/views/__snapshots__/reposts.test.ts.snap b/packages/ozone/tests/views/__snapshots__/reposts.test.ts.snap deleted file mode 100644 index e927d73dfac..00000000000 --- a/packages/ozone/tests/views/__snapshots__/reposts.test.ts.snap +++ /dev/null @@ -1,75 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`pds repost views fetches reposted-by for a post 1`] = ` -Array [ - Object { - "did": "user(0)", - "handle": "eve.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - Object { - "did": "user(1)", - "handle": "dan.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "following": "record(0)", - "muted": false, - }, - }, - Object { - "did": "user(2)", - "handle": "carol.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(2)", - "following": "record(1)", - "muted": false, - }, - }, - Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(4)/cids(0)@jpeg", - "description": "hi im bob label_me", - "did": "user(3)", - "displayName": "bobby", - "handle": "bob.test", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(4)", - "following": "record(3)", - "muted": false, - }, - }, -] -`; - -exports[`pds repost views fetches reposted-by for a reply 1`] = ` -Array [ - Object { - "did": "user(0)", - "handle": "eve.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - Object { - "did": "user(1)", - "handle": "dan.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "following": "record(0)", - "muted": false, - }, - }, -] -`; diff --git a/packages/ozone/tests/views/__snapshots__/thread.test.ts.snap b/packages/ozone/tests/views/__snapshots__/thread.test.ts.snap deleted file mode 100644 index fb0fd6a3224..00000000000 --- a/packages/ozone/tests/views/__snapshots__/thread.test.ts.snap +++ /dev/null @@ -1,1361 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`pds thread views fetches ancestors 1`] = ` -Object { - "$type": "app.bsky.feed.defs#threadViewPost", - "parent": Object { - "$type": "app.bsky.feed.defs#threadViewPost", - "parent": Object { - "$type": "app.bsky.feed.defs#threadViewPost", - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(2)", - "following": "record(1)", - "muted": false, - }, - }, - "cid": "cids(3)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 2, - "repostCount": 1, - "uri": "record(4)", - "viewer": Object { - "like": "record(7)", - }, - }, - "replies": Array [], - }, - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(3)/cids(1)@jpeg", - "did": "user(2)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(4)", - "embed": Object { - "$type": "app.bsky.embed.images#view", - "images": Array [ - Object { - "alt": "tests/sample-img/key-landscape-small.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(3)/cids(5)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(3)/cids(5)@jpeg", - }, - ], - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(4)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(5)", - "val": "test-label", - }, - Object { - "cid": "cids(4)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(5)", - "val": "test-label-2", - }, - ], - "likeCount": 0, - "record": 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(5)", - }, - "size": 4114, - }, - }, - ], - }, - "reply": Object { - "parent": Object { - "cid": "cids(3)", - "uri": "record(4)", - }, - "root": Object { - "cid": "cids(3)", - "uri": "record(4)", - }, - }, - "text": "hear that label_me label_me_2", - }, - "replyCount": 1, - "repostCount": 0, - "uri": "record(5)", - "viewer": Object {}, - }, - "replies": Array [], - }, - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(2)", - "following": "record(1)", - "muted": false, - }, - }, - "cid": "cids(0)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "reply": Object { - "parent": Object { - "cid": "cids(4)", - "uri": "record(5)", - }, - "root": Object { - "cid": "cids(3)", - "uri": "record(4)", - }, - }, - "text": "thanks bob", - }, - "replyCount": 0, - "repostCount": 2, - "uri": "record(0)", - "viewer": Object { - "repost": "record(6)", - }, - }, - "replies": Array [], -} -`; - -exports[`pds thread views fetches deep post thread 1`] = ` -Object { - "$type": "app.bsky.feed.defs#threadViewPost", - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(2)", - "following": "record(1)", - "muted": false, - }, - }, - "cid": "cids(0)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 2, - "repostCount": 1, - "uri": "record(0)", - "viewer": Object { - "like": "record(4)", - }, - }, - "replies": Array [ - Object { - "$type": "app.bsky.feed.defs#threadViewPost", - "post": Object { - "author": Object { - "did": "user(2)", - "handle": "carol.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "following": "record(6)", - "muted": false, - }, - }, - "cid": "cids(3)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "reply": Object { - "parent": Object { - "cid": "cids(0)", - "uri": "record(0)", - }, - "root": Object { - "cid": "cids(0)", - "uri": "record(0)", - }, - }, - "text": "of course", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(5)", - "viewer": Object {}, - }, - "replies": Array [], - }, - Object { - "$type": "app.bsky.feed.defs#threadViewPost", - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(4)/cids(1)@jpeg", - "did": "user(3)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(4)", - "embed": Object { - "$type": "app.bsky.embed.images#view", - "images": Array [ - Object { - "alt": "tests/sample-img/key-landscape-small.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(4)/cids(5)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(4)/cids(5)@jpeg", - }, - ], - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(4)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(7)", - "val": "test-label", - }, - Object { - "cid": "cids(4)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(7)", - "val": "test-label-2", - }, - ], - "likeCount": 0, - "record": 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(5)", - }, - "size": 4114, - }, - }, - ], - }, - "reply": Object { - "parent": Object { - "cid": "cids(0)", - "uri": "record(0)", - }, - "root": Object { - "cid": "cids(0)", - "uri": "record(0)", - }, - }, - "text": "hear that label_me label_me_2", - }, - "replyCount": 1, - "repostCount": 0, - "uri": "record(7)", - "viewer": Object {}, - }, - "replies": Array [ - Object { - "$type": "app.bsky.feed.defs#threadViewPost", - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(2)", - "following": "record(1)", - "muted": false, - }, - }, - "cid": "cids(6)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "reply": Object { - "parent": Object { - "cid": "cids(4)", - "uri": "record(7)", - }, - "root": Object { - "cid": "cids(0)", - "uri": "record(0)", - }, - }, - "text": "thanks bob", - }, - "replyCount": 0, - "repostCount": 2, - "uri": "record(8)", - "viewer": Object { - "repost": "record(9)", - }, - }, - "replies": Array [], - }, - ], - }, - ], -} -`; - -exports[`pds thread views fetches shallow post thread 1`] = ` -Object { - "$type": "app.bsky.feed.defs#threadViewPost", - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(2)", - "following": "record(1)", - "muted": false, - }, - }, - "cid": "cids(0)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 2, - "repostCount": 1, - "uri": "record(0)", - "viewer": Object { - "like": "record(4)", - }, - }, - "replies": Array [ - Object { - "$type": "app.bsky.feed.defs#threadViewPost", - "post": Object { - "author": Object { - "did": "user(2)", - "handle": "carol.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "following": "record(6)", - "muted": false, - }, - }, - "cid": "cids(3)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "reply": Object { - "parent": Object { - "cid": "cids(0)", - "uri": "record(0)", - }, - "root": Object { - "cid": "cids(0)", - "uri": "record(0)", - }, - }, - "text": "of course", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(5)", - "viewer": Object {}, - }, - }, - Object { - "$type": "app.bsky.feed.defs#threadViewPost", - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(4)/cids(1)@jpeg", - "did": "user(3)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(4)", - "embed": Object { - "$type": "app.bsky.embed.images#view", - "images": Array [ - Object { - "alt": "tests/sample-img/key-landscape-small.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(4)/cids(5)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(4)/cids(5)@jpeg", - }, - ], - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(4)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(7)", - "val": "test-label", - }, - Object { - "cid": "cids(4)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(7)", - "val": "test-label-2", - }, - ], - "likeCount": 0, - "record": 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(5)", - }, - "size": 4114, - }, - }, - ], - }, - "reply": Object { - "parent": Object { - "cid": "cids(0)", - "uri": "record(0)", - }, - "root": Object { - "cid": "cids(0)", - "uri": "record(0)", - }, - }, - "text": "hear that label_me label_me_2", - }, - "replyCount": 1, - "repostCount": 0, - "uri": "record(7)", - "viewer": Object {}, - }, - }, - ], -} -`; - -exports[`pds thread views handles deleted posts correctly 1`] = ` -Object { - "$type": "app.bsky.feed.defs#threadViewPost", - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(2)", - "following": "record(1)", - "muted": false, - }, - }, - "cid": "cids(0)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "text": "Deletion thread", - }, - "replyCount": 1, - "repostCount": 0, - "uri": "record(0)", - "viewer": Object {}, - }, - "replies": Array [ - Object { - "$type": "app.bsky.feed.defs#threadViewPost", - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(3)/cids(1)@jpeg", - "did": "user(2)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(3)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "reply": Object { - "parent": Object { - "cid": "cids(0)", - "uri": "record(0)", - }, - "root": Object { - "cid": "cids(0)", - "uri": "record(0)", - }, - }, - "text": "Reply", - }, - "replyCount": 1, - "repostCount": 0, - "uri": "record(4)", - "viewer": Object {}, - }, - "replies": Array [ - Object { - "$type": "app.bsky.feed.defs#threadViewPost", - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(2)", - "following": "record(1)", - "muted": false, - }, - }, - "cid": "cids(4)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "reply": Object { - "parent": Object { - "cid": "cids(3)", - "uri": "record(4)", - }, - "root": Object { - "cid": "cids(0)", - "uri": "record(0)", - }, - }, - "text": "Reply reply", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(5)", - "viewer": Object {}, - }, - "replies": Array [], - }, - ], - }, - ], -} -`; - -exports[`pds thread views handles deleted posts correctly 2`] = ` -Object { - "$type": "app.bsky.feed.defs#threadViewPost", - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(2)", - "following": "record(1)", - "muted": false, - }, - }, - "cid": "cids(0)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "text": "Deletion thread", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(0)", - "viewer": Object {}, - }, - "replies": Array [], -} -`; - -exports[`pds thread views handles deleted posts correctly 3`] = ` -Object { - "$type": "app.bsky.feed.defs#threadViewPost", - "parent": Object { - "$type": "app.bsky.feed.defs#notFoundPost", - "notFound": true, - "uri": "record(5)", - }, - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(2)", - "following": "record(1)", - "muted": false, - }, - }, - "cid": "cids(0)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "reply": Object { - "parent": Object { - "cid": "cids(4)", - "uri": "record(5)", - }, - "root": Object { - "cid": "cids(3)", - "uri": "record(4)", - }, - }, - "text": "Reply reply", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(0)", - "viewer": Object {}, - }, - "replies": Array [], -} -`; - -exports[`pds thread views takedown blocks ancestors by actor 1`] = ` -Object { - "$type": "app.bsky.feed.defs#threadViewPost", - "parent": Object { - "$type": "app.bsky.feed.defs#notFoundPost", - "notFound": true, - "uri": "record(5)", - }, - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(2)", - "following": "record(1)", - "muted": false, - }, - }, - "cid": "cids(0)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "reply": Object { - "parent": Object { - "cid": "cids(4)", - "uri": "record(5)", - }, - "root": Object { - "cid": "cids(3)", - "uri": "record(4)", - }, - }, - "text": "thanks bob", - }, - "replyCount": 0, - "repostCount": 2, - "uri": "record(0)", - "viewer": Object { - "repost": "record(6)", - }, - }, - "replies": Array [], -} -`; - -exports[`pds thread views takedown blocks ancestors by record 1`] = ` -Object { - "$type": "app.bsky.feed.defs#threadViewPost", - "parent": Object { - "$type": "app.bsky.feed.defs#notFoundPost", - "notFound": true, - "uri": "record(5)", - }, - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(2)", - "following": "record(1)", - "muted": false, - }, - }, - "cid": "cids(0)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "reply": Object { - "parent": Object { - "cid": "cids(4)", - "uri": "record(5)", - }, - "root": Object { - "cid": "cids(3)", - "uri": "record(4)", - }, - }, - "text": "thanks bob", - }, - "replyCount": 0, - "repostCount": 2, - "uri": "record(0)", - "viewer": Object { - "repost": "record(6)", - }, - }, - "replies": Array [], -} -`; - -exports[`pds thread views takedown blocks replies by actor 1`] = ` -Object { - "$type": "app.bsky.feed.defs#threadViewPost", - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(2)", - "following": "record(1)", - "muted": false, - }, - }, - "cid": "cids(0)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 2, - "repostCount": 1, - "uri": "record(0)", - "viewer": Object { - "like": "record(4)", - }, - }, - "replies": Array [ - Object { - "$type": "app.bsky.feed.defs#threadViewPost", - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(3)/cids(1)@jpeg", - "did": "user(2)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(3)", - "embed": Object { - "$type": "app.bsky.embed.images#view", - "images": Array [ - Object { - "alt": "tests/sample-img/key-landscape-small.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(3)/cids(4)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(3)/cids(4)@jpeg", - }, - ], - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(3)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(5)", - "val": "test-label", - }, - Object { - "cid": "cids(3)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(5)", - "val": "test-label-2", - }, - ], - "likeCount": 0, - "record": 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(4)", - }, - "size": 4114, - }, - }, - ], - }, - "reply": Object { - "parent": Object { - "cid": "cids(0)", - "uri": "record(0)", - }, - "root": Object { - "cid": "cids(0)", - "uri": "record(0)", - }, - }, - "text": "hear that label_me label_me_2", - }, - "replyCount": 1, - "repostCount": 0, - "uri": "record(5)", - "viewer": Object {}, - }, - "replies": Array [ - Object { - "$type": "app.bsky.feed.defs#threadViewPost", - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(2)", - "following": "record(1)", - "muted": false, - }, - }, - "cid": "cids(5)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "reply": Object { - "parent": Object { - "cid": "cids(3)", - "uri": "record(5)", - }, - "root": Object { - "cid": "cids(0)", - "uri": "record(0)", - }, - }, - "text": "thanks bob", - }, - "replyCount": 0, - "repostCount": 2, - "uri": "record(6)", - "viewer": Object { - "repost": "record(7)", - }, - }, - "replies": Array [], - }, - ], - }, - ], -} -`; - -exports[`pds thread views takedown blocks replies by record 1`] = ` -Object { - "$type": "app.bsky.feed.defs#threadViewPost", - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(3)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(2)", - "following": "record(1)", - "muted": false, - }, - }, - "cid": "cids(0)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 2, - "repostCount": 1, - "uri": "record(0)", - "viewer": Object { - "like": "record(4)", - }, - }, - "replies": Array [ - Object { - "$type": "app.bsky.feed.defs#threadViewPost", - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(3)/cids(1)@jpeg", - "did": "user(2)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(3)", - "embed": Object { - "$type": "app.bsky.embed.images#view", - "images": Array [ - Object { - "alt": "tests/sample-img/key-landscape-small.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(3)/cids(4)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(3)/cids(4)@jpeg", - }, - ], - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(3)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(5)", - "val": "test-label", - }, - Object { - "cid": "cids(3)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(5)", - "val": "test-label-2", - }, - ], - "likeCount": 0, - "record": 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(4)", - }, - "size": 4114, - }, - }, - ], - }, - "reply": Object { - "parent": Object { - "cid": "cids(0)", - "uri": "record(0)", - }, - "root": Object { - "cid": "cids(0)", - "uri": "record(0)", - }, - }, - "text": "hear that label_me label_me_2", - }, - "replyCount": 1, - "repostCount": 0, - "uri": "record(5)", - "viewer": Object {}, - }, - "replies": Array [], - }, - ], -} -`; diff --git a/packages/ozone/tests/views/__snapshots__/threadgating.test.ts.snap b/packages/ozone/tests/views/__snapshots__/threadgating.test.ts.snap deleted file mode 100644 index 1545c19e9f4..00000000000 --- a/packages/ozone/tests/views/__snapshots__/threadgating.test.ts.snap +++ /dev/null @@ -1,164 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`views with thread gating applies gate after root post is deleted. 1`] = `undefined`; - -exports[`views with thread gating applies gate for empty rules. 1`] = ` -Object { - "cid": "cids(0)", - "lists": Array [], - "record": Object { - "$type": "app.bsky.feed.threadgate", - "allow": Array [], - "createdAt": "1970-01-01T00:00:00.000Z", - "post": "record(1)", - }, - "uri": "record(0)", -} -`; - -exports[`views with thread gating applies gate for following rule. 1`] = ` -Object { - "cid": "cids(0)", - "lists": Array [], - "record": Object { - "$type": "app.bsky.feed.threadgate", - "allow": Array [ - Object { - "$type": "app.bsky.feed.threadgate#followingRule", - }, - ], - "createdAt": "1970-01-01T00:00:00.000Z", - "post": "record(1)", - }, - "uri": "record(0)", -} -`; - -exports[`views with thread gating applies gate for list rule. 1`] = ` -Object { - "cid": "cids(0)", - "lists": Array [ - Object { - "cid": "cids(1)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "name": "list a", - "purpose": "app.bsky.graph.defs#modlist", - "uri": "record(2)", - "viewer": Object { - "muted": false, - }, - }, - Object { - "cid": "cids(2)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "name": "list b", - "purpose": "app.bsky.graph.defs#modlist", - "uri": "record(3)", - "viewer": Object { - "muted": false, - }, - }, - ], - "record": Object { - "$type": "app.bsky.feed.threadgate", - "allow": Array [ - Object { - "$type": "app.bsky.feed.threadgate#listRule", - "list": "record(2)", - }, - Object { - "$type": "app.bsky.feed.threadgate#listRule", - "list": "record(3)", - }, - ], - "createdAt": "1970-01-01T00:00:00.000Z", - "post": "record(1)", - }, - "uri": "record(0)", -} -`; - -exports[`views with thread gating applies gate for mention rule. 1`] = ` -Object { - "cid": "cids(0)", - "lists": Array [], - "record": Object { - "$type": "app.bsky.feed.threadgate", - "allow": Array [ - Object { - "$type": "app.bsky.feed.threadgate#mentionRule", - }, - ], - "createdAt": "1970-01-01T00:00:00.000Z", - "post": "record(1)", - }, - "uri": "record(0)", -} -`; - -exports[`views with thread gating applies gate for missing rules, takes no action. 1`] = ` -Object { - "cid": "cids(0)", - "lists": Array [], - "record": Object { - "$type": "app.bsky.feed.threadgate", - "createdAt": "1970-01-01T00:00:00.000Z", - "post": "record(1)", - }, - "uri": "record(0)", -} -`; - -exports[`views with thread gating applies gate for multiple rules. 1`] = ` -Object { - "cid": "cids(0)", - "lists": Array [], - "record": Object { - "$type": "app.bsky.feed.threadgate", - "allow": Array [ - Object { - "$type": "app.bsky.feed.threadgate#mentionRule", - }, - Object { - "$type": "app.bsky.feed.threadgate#followingRule", - }, - ], - "createdAt": "1970-01-01T00:00:00.000Z", - "post": "record(1)", - }, - "uri": "record(0)", -} -`; - -exports[`views with thread gating applies gate for unknown list rule. 1`] = ` -Object { - "cid": "cids(0)", - "lists": Array [], - "record": Object { - "$type": "app.bsky.feed.threadgate", - "allow": Array [ - Object { - "$type": "app.bsky.feed.threadgate#listRule", - "list": "record(1)", - }, - ], - "createdAt": "1970-01-01T00:00:00.000Z", - "post": "record(1)", - }, - "uri": "record(0)", -} -`; - -exports[`views with thread gating does not apply gate to original poster. 1`] = ` -Object { - "cid": "cids(0)", - "lists": Array [], - "record": Object { - "$type": "app.bsky.feed.threadgate", - "allow": Array [], - "createdAt": "1970-01-01T00:00:00.000Z", - "post": "record(1)", - }, - "uri": "record(0)", -} -`; diff --git a/packages/ozone/tests/views/__snapshots__/timeline.test.ts.snap b/packages/ozone/tests/views/__snapshots__/timeline.test.ts.snap deleted file mode 100644 index b5863382fef..00000000000 --- a/packages/ozone/tests/views/__snapshots__/timeline.test.ts.snap +++ /dev/null @@ -1,5714 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`timeline views blocks posts, reposts, replies by actor takedown 1`] = ` -Array [ - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(0)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "reply": Object { - "parent": Object { - "cid": "cids(4)", - "uri": "record(3)", - }, - "root": Object { - "cid": "cids(3)", - "uri": "record(2)", - }, - }, - "text": "thanks bob", - }, - "replyCount": 0, - "repostCount": 1, - "uri": "record(0)", - "viewer": Object {}, - }, - "reason": Object { - "$type": "app.bsky.feed.defs#reasonRepost", - "by": Object { - "did": "user(2)", - "handle": "dan.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "following": "record(4)", - "muted": false, - }, - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - }, - }, - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(3)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 2, - "repostCount": 1, - "uri": "record(2)", - "viewer": Object {}, - }, - "reason": Object { - "$type": "app.bsky.feed.defs#reasonRepost", - "by": Object { - "did": "user(2)", - "handle": "dan.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "following": "record(4)", - "muted": false, - }, - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - }, - }, - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(0)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "reply": Object { - "parent": Object { - "cid": "cids(4)", - "uri": "record(3)", - }, - "root": Object { - "cid": "cids(3)", - "uri": "record(2)", - }, - }, - "text": "thanks bob", - }, - "replyCount": 0, - "repostCount": 1, - "uri": "record(0)", - "viewer": Object {}, - }, - }, - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(5)", - "embed": Object { - "$type": "app.bsky.embed.record#view", - "record": Object { - "$type": "app.bsky.embed.record#viewRecord", - "author": Object { - "did": "user(2)", - "handle": "dan.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "following": "record(4)", - "muted": false, - }, - }, - "cid": "cids(6)", - "embeds": Array [ - Object { - "$type": "app.bsky.embed.record#view", - "record": Object { - "$type": "app.bsky.embed.record#viewNotFound", - "notFound": true, - "uri": "record(7)", - }, - }, - ], - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "uri": "record(6)", - "value": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.record", - "record": Object { - "cid": "cids(7)", - "uri": "record(7)", - }, - }, - "facets": Array [ - Object { - "features": Array [ - Object { - "$type": "app.bsky.richtext.facet#mention", - "did": "user(0)", - }, - ], - "index": Object { - "byteEnd": 18, - "byteStart": 0, - }, - }, - ], - "text": "@alice.bluesky.xyz is the best", - }, - }, - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(5)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(5)", - "val": "test-label", - }, - ], - "likeCount": 2, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.record", - "record": Object { - "cid": "cids(6)", - "uri": "record(6)", - }, - }, - "text": "yoohoo label_me", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(5)", - "viewer": Object {}, - }, - }, - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(3)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 2, - "repostCount": 1, - "uri": "record(2)", - "viewer": Object {}, - }, - }, - Object { - "post": Object { - "author": Object { - "did": "user(2)", - "handle": "dan.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "following": "record(4)", - "muted": false, - }, - }, - "cid": "cids(6)", - "embed": Object { - "$type": "app.bsky.embed.record#view", - "record": Object { - "$type": "app.bsky.embed.record#viewNotFound", - "notFound": true, - "uri": "record(7)", - }, - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.record", - "record": Object { - "cid": "cids(7)", - "uri": "record(7)", - }, - }, - "facets": Array [ - Object { - "features": Array [ - Object { - "$type": "app.bsky.richtext.facet#mention", - "did": "user(0)", - }, - ], - "index": Object { - "byteEnd": 18, - "byteStart": 0, - }, - }, - ], - "text": "@alice.bluesky.xyz is the best", - }, - "replyCount": 0, - "repostCount": 1, - "uri": "record(6)", - "viewer": Object {}, - }, - }, - Object { - "post": Object { - "author": Object { - "did": "user(2)", - "handle": "dan.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "following": "record(4)", - "muted": false, - }, - }, - "cid": "cids(8)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "text": "dan here!", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(8)", - "viewer": Object {}, - }, - }, - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(9)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(9)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(9)", - "val": "self-label", - }, - ], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "labels": Object { - "$type": "com.atproto.label.defs#selfLabels", - "values": Array [ - Object { - "val": "self-label", - }, - ], - }, - "text": "hey there", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(9)", - "viewer": Object {}, - }, - }, -] -`; - -exports[`timeline views blocks posts, reposts, replies by record takedown. 1`] = ` -Array [ - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(0)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "reply": Object { - "parent": Object { - "cid": "cids(4)", - "uri": "record(3)", - }, - "root": Object { - "cid": "cids(3)", - "uri": "record(2)", - }, - }, - "text": "thanks bob", - }, - "replyCount": 0, - "repostCount": 1, - "uri": "record(0)", - "viewer": Object {}, - }, - "reason": Object { - "$type": "app.bsky.feed.defs#reasonRepost", - "by": Object { - "did": "user(2)", - "handle": "dan.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "following": "record(4)", - "muted": false, - }, - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - }, - }, - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(3)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 2, - "repostCount": 1, - "uri": "record(2)", - "viewer": Object {}, - }, - "reason": Object { - "$type": "app.bsky.feed.defs#reasonRepost", - "by": Object { - "did": "user(2)", - "handle": "dan.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "following": "record(4)", - "muted": false, - }, - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - }, - }, - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(0)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "reply": Object { - "parent": Object { - "cid": "cids(4)", - "uri": "record(3)", - }, - "root": Object { - "cid": "cids(3)", - "uri": "record(2)", - }, - }, - "text": "thanks bob", - }, - "replyCount": 0, - "repostCount": 1, - "uri": "record(0)", - "viewer": Object {}, - }, - }, - Object { - "post": Object { - "author": Object { - "did": "user(3)", - "handle": "carol.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(7)", - "following": "record(6)", - "muted": false, - }, - }, - "cid": "cids(5)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "reply": Object { - "parent": Object { - "cid": "cids(3)", - "uri": "record(2)", - }, - "root": Object { - "cid": "cids(3)", - "uri": "record(2)", - }, - }, - "text": "of course", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(5)", - "viewer": Object {}, - }, - "reply": Object { - "parent": Object { - "$type": "app.bsky.feed.defs#postView", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(3)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 2, - "repostCount": 1, - "uri": "record(2)", - "viewer": Object {}, - }, - "root": Object { - "$type": "app.bsky.feed.defs#postView", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(3)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 2, - "repostCount": 1, - "uri": "record(2)", - "viewer": Object {}, - }, - }, - }, - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(6)", - "embed": Object { - "$type": "app.bsky.embed.record#view", - "record": Object { - "$type": "app.bsky.embed.record#viewNotFound", - "notFound": true, - "uri": "record(9)", - }, - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(6)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(8)", - "val": "test-label", - }, - ], - "likeCount": 2, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.record", - "record": Object { - "cid": "cids(7)", - "uri": "record(9)", - }, - }, - "text": "yoohoo label_me", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(8)", - "viewer": Object {}, - }, - }, - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(5)/cids(1)@jpeg", - "did": "user(4)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(12)", - "following": "record(11)", - "muted": false, - }, - }, - "cid": "cids(8)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000+00:00", - "text": "bobby boy here", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(10)", - "viewer": Object {}, - }, - }, - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(3)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 2, - "repostCount": 1, - "uri": "record(2)", - "viewer": Object {}, - }, - }, - Object { - "post": Object { - "author": Object { - "did": "user(2)", - "handle": "dan.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "following": "record(4)", - "muted": false, - }, - }, - "cid": "cids(9)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "text": "dan here!", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(13)", - "viewer": Object {}, - }, - }, - Object { - "post": Object { - "author": Object { - "did": "user(3)", - "handle": "carol.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(7)", - "following": "record(6)", - "muted": false, - }, - }, - "cid": "cids(10)", - "embed": Object { - "$type": "app.bsky.embed.recordWithMedia#view", - "media": Object { - "$type": "app.bsky.embed.images#view", - "images": Array [ - Object { - "alt": "tests/sample-img/key-landscape-small.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(6)/cids(11)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(6)/cids(11)@jpeg", - }, - Object { - "alt": "tests/sample-img/key-alt.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(6)/cids(12)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(6)/cids(12)@jpeg", - }, - ], - }, - "record": Object { - "record": Object { - "$type": "app.bsky.embed.record#viewRecord", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(5)/cids(1)@jpeg", - "did": "user(4)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(12)", - "following": "record(11)", - "muted": false, - }, - }, - "cid": "cids(13)", - "embeds": Array [], - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(13)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(15)", - "val": "kind", - }, - ], - "uri": "record(15)", - "value": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "langs": Array [ - "en-US", - "i-klingon", - ], - "text": "bob back at it again!", - }, - }, - }, - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(10)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(14)", - "val": "kind", - }, - ], - "likeCount": 2, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.recordWithMedia", - "media": 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(11)", - }, - "size": 4114, - }, - }, - Object { - "alt": "tests/sample-img/key-alt.jpg", - "image": Object { - "$type": "blob", - "mimeType": "image/jpeg", - "ref": Object { - "$link": "cids(12)", - }, - "size": 12736, - }, - }, - ], - }, - "record": Object { - "record": Object { - "cid": "cids(13)", - "uri": "record(15)", - }, - }, - }, - "text": "hi im carol", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(14)", - "viewer": Object { - "like": "record(16)", - }, - }, - }, - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(5)/cids(1)@jpeg", - "did": "user(4)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(12)", - "following": "record(11)", - "muted": false, - }, - }, - "cid": "cids(13)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(13)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(15)", - "val": "kind", - }, - ], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "langs": Array [ - "en-US", - "i-klingon", - ], - "text": "bob back at it again!", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(15)", - "viewer": Object {}, - }, - }, - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(14)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(14)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(17)", - "val": "self-label", - }, - ], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "labels": Object { - "$type": "com.atproto.label.defs#selfLabels", - "values": Array [ - Object { - "val": "self-label", - }, - ], - }, - "text": "hey there", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(17)", - "viewer": Object {}, - }, - }, -] -`; - -exports[`timeline views fetches authenticated user's home feed w/ reverse-chronological algorithm 1`] = ` -Array [ - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(0)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "reply": Object { - "parent": Object { - "cid": "cids(4)", - "uri": "record(3)", - }, - "root": Object { - "cid": "cids(3)", - "uri": "record(2)", - }, - }, - "text": "thanks bob", - }, - "replyCount": 0, - "repostCount": 1, - "uri": "record(0)", - "viewer": Object {}, - }, - "reason": Object { - "$type": "app.bsky.feed.defs#reasonRepost", - "by": Object { - "did": "user(2)", - "handle": "dan.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "following": "record(4)", - "muted": false, - }, - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - }, - "reply": Object { - "parent": Object { - "$type": "app.bsky.feed.defs#postView", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(4)/cids(1)@jpeg", - "did": "user(3)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(6)", - "following": "record(5)", - "muted": false, - }, - }, - "cid": "cids(4)", - "embed": Object { - "$type": "app.bsky.embed.images#view", - "images": Array [ - Object { - "alt": "tests/sample-img/key-landscape-small.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(4)/cids(5)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(4)/cids(5)@jpeg", - }, - ], - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(4)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(3)", - "val": "test-label", - }, - Object { - "cid": "cids(4)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(3)", - "val": "test-label-2", - }, - ], - "likeCount": 0, - "record": 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(5)", - }, - "size": 4114, - }, - }, - ], - }, - "reply": Object { - "parent": Object { - "cid": "cids(3)", - "uri": "record(2)", - }, - "root": Object { - "cid": "cids(3)", - "uri": "record(2)", - }, - }, - "text": "hear that label_me label_me_2", - }, - "replyCount": 1, - "repostCount": 0, - "uri": "record(3)", - "viewer": Object {}, - }, - "root": Object { - "$type": "app.bsky.feed.defs#postView", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(3)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 2, - "repostCount": 1, - "uri": "record(2)", - "viewer": Object {}, - }, - }, - }, - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(3)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 2, - "repostCount": 1, - "uri": "record(2)", - "viewer": Object {}, - }, - "reason": Object { - "$type": "app.bsky.feed.defs#reasonRepost", - "by": Object { - "did": "user(2)", - "handle": "dan.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "following": "record(4)", - "muted": false, - }, - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - }, - }, - Object { - "post": Object { - "author": Object { - "did": "user(2)", - "handle": "dan.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "following": "record(4)", - "muted": false, - }, - }, - "cid": "cids(6)", - "embed": Object { - "$type": "app.bsky.embed.record#view", - "record": Object { - "$type": "app.bsky.embed.record#viewRecord", - "author": Object { - "did": "user(5)", - "handle": "carol.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(10)", - "following": "record(9)", - "muted": false, - }, - }, - "cid": "cids(7)", - "embeds": Array [ - Object { - "$type": "app.bsky.embed.recordWithMedia#view", - "media": Object { - "$type": "app.bsky.embed.images#view", - "images": Array [ - Object { - "alt": "tests/sample-img/key-landscape-small.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(6)/cids(5)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(6)/cids(5)@jpeg", - }, - Object { - "alt": "tests/sample-img/key-alt.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(6)/cids(8)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(6)/cids(8)@jpeg", - }, - ], - }, - "record": Object { - "record": Object { - "$type": "app.bsky.embed.record#viewRecord", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(4)/cids(1)@jpeg", - "did": "user(3)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(6)", - "following": "record(5)", - "muted": false, - }, - }, - "cid": "cids(9)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(9)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(11)", - "val": "kind", - }, - ], - "uri": "record(11)", - "value": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "langs": Array [ - "en-US", - "i-klingon", - ], - "text": "bob back at it again!", - }, - }, - }, - }, - ], - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(7)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(8)", - "val": "kind", - }, - ], - "uri": "record(8)", - "value": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.recordWithMedia", - "media": 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(5)", - }, - "size": 4114, - }, - }, - Object { - "alt": "tests/sample-img/key-alt.jpg", - "image": Object { - "$type": "blob", - "mimeType": "image/jpeg", - "ref": Object { - "$link": "cids(8)", - }, - "size": 12736, - }, - }, - ], - }, - "record": Object { - "record": Object { - "cid": "cids(9)", - "uri": "record(11)", - }, - }, - }, - "text": "hi im carol", - }, - }, - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.record", - "record": Object { - "cid": "cids(7)", - "uri": "record(8)", - }, - }, - "facets": Array [ - Object { - "features": Array [ - Object { - "$type": "app.bsky.richtext.facet#mention", - "did": "user(0)", - }, - ], - "index": Object { - "byteEnd": 18, - "byteStart": 0, - }, - }, - ], - "text": "@alice.bluesky.xyz is the best", - }, - "replyCount": 0, - "repostCount": 1, - "uri": "record(7)", - "viewer": Object {}, - }, - "reason": Object { - "$type": "app.bsky.feed.defs#reasonRepost", - "by": Object { - "did": "user(5)", - "handle": "carol.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(10)", - "following": "record(9)", - "muted": false, - }, - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - }, - }, - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(0)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "reply": Object { - "parent": Object { - "cid": "cids(4)", - "uri": "record(3)", - }, - "root": Object { - "cid": "cids(3)", - "uri": "record(2)", - }, - }, - "text": "thanks bob", - }, - "replyCount": 0, - "repostCount": 1, - "uri": "record(0)", - "viewer": Object {}, - }, - "reply": Object { - "parent": Object { - "$type": "app.bsky.feed.defs#postView", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(4)/cids(1)@jpeg", - "did": "user(3)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(6)", - "following": "record(5)", - "muted": false, - }, - }, - "cid": "cids(4)", - "embed": Object { - "$type": "app.bsky.embed.images#view", - "images": Array [ - Object { - "alt": "tests/sample-img/key-landscape-small.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(4)/cids(5)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(4)/cids(5)@jpeg", - }, - ], - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(4)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(3)", - "val": "test-label", - }, - Object { - "cid": "cids(4)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(3)", - "val": "test-label-2", - }, - ], - "likeCount": 0, - "record": 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(5)", - }, - "size": 4114, - }, - }, - ], - }, - "reply": Object { - "parent": Object { - "cid": "cids(3)", - "uri": "record(2)", - }, - "root": Object { - "cid": "cids(3)", - "uri": "record(2)", - }, - }, - "text": "hear that label_me label_me_2", - }, - "replyCount": 1, - "repostCount": 0, - "uri": "record(3)", - "viewer": Object {}, - }, - "root": Object { - "$type": "app.bsky.feed.defs#postView", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(3)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 2, - "repostCount": 1, - "uri": "record(2)", - "viewer": Object {}, - }, - }, - }, - Object { - "post": Object { - "author": Object { - "did": "user(5)", - "handle": "carol.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(10)", - "following": "record(9)", - "muted": false, - }, - }, - "cid": "cids(10)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "reply": Object { - "parent": Object { - "cid": "cids(3)", - "uri": "record(2)", - }, - "root": Object { - "cid": "cids(3)", - "uri": "record(2)", - }, - }, - "text": "of course", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(12)", - "viewer": Object {}, - }, - "reply": Object { - "parent": Object { - "$type": "app.bsky.feed.defs#postView", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(3)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 2, - "repostCount": 1, - "uri": "record(2)", - "viewer": Object {}, - }, - "root": Object { - "$type": "app.bsky.feed.defs#postView", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(3)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 2, - "repostCount": 1, - "uri": "record(2)", - "viewer": Object {}, - }, - }, - }, - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(4)/cids(1)@jpeg", - "did": "user(3)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(6)", - "following": "record(5)", - "muted": false, - }, - }, - "cid": "cids(4)", - "embed": Object { - "$type": "app.bsky.embed.images#view", - "images": Array [ - Object { - "alt": "tests/sample-img/key-landscape-small.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(4)/cids(5)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(4)/cids(5)@jpeg", - }, - ], - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(4)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(3)", - "val": "test-label", - }, - Object { - "cid": "cids(4)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(3)", - "val": "test-label-2", - }, - ], - "likeCount": 0, - "record": 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(5)", - }, - "size": 4114, - }, - }, - ], - }, - "reply": Object { - "parent": Object { - "cid": "cids(3)", - "uri": "record(2)", - }, - "root": Object { - "cid": "cids(3)", - "uri": "record(2)", - }, - }, - "text": "hear that label_me label_me_2", - }, - "replyCount": 1, - "repostCount": 0, - "uri": "record(3)", - "viewer": Object {}, - }, - "reply": Object { - "parent": Object { - "$type": "app.bsky.feed.defs#postView", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(3)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 2, - "repostCount": 1, - "uri": "record(2)", - "viewer": Object {}, - }, - "root": Object { - "$type": "app.bsky.feed.defs#postView", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(3)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 2, - "repostCount": 1, - "uri": "record(2)", - "viewer": Object {}, - }, - }, - }, - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(11)", - "embed": Object { - "$type": "app.bsky.embed.record#view", - "record": Object { - "$type": "app.bsky.embed.record#viewRecord", - "author": Object { - "did": "user(2)", - "handle": "dan.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "following": "record(4)", - "muted": false, - }, - }, - "cid": "cids(6)", - "embeds": Array [ - Object { - "$type": "app.bsky.embed.record#view", - "record": Object { - "$type": "app.bsky.embed.record#viewRecord", - "author": Object { - "did": "user(5)", - "handle": "carol.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(10)", - "following": "record(9)", - "muted": false, - }, - }, - "cid": "cids(7)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(7)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(8)", - "val": "kind", - }, - ], - "uri": "record(8)", - "value": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.recordWithMedia", - "media": 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(5)", - }, - "size": 4114, - }, - }, - Object { - "alt": "tests/sample-img/key-alt.jpg", - "image": Object { - "$type": "blob", - "mimeType": "image/jpeg", - "ref": Object { - "$link": "cids(8)", - }, - "size": 12736, - }, - }, - ], - }, - "record": Object { - "record": Object { - "cid": "cids(9)", - "uri": "record(11)", - }, - }, - }, - "text": "hi im carol", - }, - }, - }, - ], - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "uri": "record(7)", - "value": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.record", - "record": Object { - "cid": "cids(7)", - "uri": "record(8)", - }, - }, - "facets": Array [ - Object { - "features": Array [ - Object { - "$type": "app.bsky.richtext.facet#mention", - "did": "user(0)", - }, - ], - "index": Object { - "byteEnd": 18, - "byteStart": 0, - }, - }, - ], - "text": "@alice.bluesky.xyz is the best", - }, - }, - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(11)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(13)", - "val": "test-label", - }, - ], - "likeCount": 2, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.record", - "record": Object { - "cid": "cids(6)", - "uri": "record(7)", - }, - }, - "text": "yoohoo label_me", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(13)", - "viewer": Object {}, - }, - }, - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(4)/cids(1)@jpeg", - "did": "user(3)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(6)", - "following": "record(5)", - "muted": false, - }, - }, - "cid": "cids(12)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000+00:00", - "text": "bobby boy here", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(14)", - "viewer": Object {}, - }, - }, - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(3)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 2, - "repostCount": 1, - "uri": "record(2)", - "viewer": Object {}, - }, - }, - Object { - "post": Object { - "author": Object { - "did": "user(2)", - "handle": "dan.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "following": "record(4)", - "muted": false, - }, - }, - "cid": "cids(6)", - "embed": Object { - "$type": "app.bsky.embed.record#view", - "record": Object { - "$type": "app.bsky.embed.record#viewRecord", - "author": Object { - "did": "user(5)", - "handle": "carol.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(10)", - "following": "record(9)", - "muted": false, - }, - }, - "cid": "cids(7)", - "embeds": Array [ - Object { - "$type": "app.bsky.embed.recordWithMedia#view", - "media": Object { - "$type": "app.bsky.embed.images#view", - "images": Array [ - Object { - "alt": "tests/sample-img/key-landscape-small.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(6)/cids(5)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(6)/cids(5)@jpeg", - }, - Object { - "alt": "tests/sample-img/key-alt.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(6)/cids(8)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(6)/cids(8)@jpeg", - }, - ], - }, - "record": Object { - "record": Object { - "$type": "app.bsky.embed.record#viewRecord", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(4)/cids(1)@jpeg", - "did": "user(3)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(6)", - "following": "record(5)", - "muted": false, - }, - }, - "cid": "cids(9)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(9)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(11)", - "val": "kind", - }, - ], - "uri": "record(11)", - "value": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "langs": Array [ - "en-US", - "i-klingon", - ], - "text": "bob back at it again!", - }, - }, - }, - }, - ], - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(7)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(8)", - "val": "kind", - }, - ], - "uri": "record(8)", - "value": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.recordWithMedia", - "media": 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(5)", - }, - "size": 4114, - }, - }, - Object { - "alt": "tests/sample-img/key-alt.jpg", - "image": Object { - "$type": "blob", - "mimeType": "image/jpeg", - "ref": Object { - "$link": "cids(8)", - }, - "size": 12736, - }, - }, - ], - }, - "record": Object { - "record": Object { - "cid": "cids(9)", - "uri": "record(11)", - }, - }, - }, - "text": "hi im carol", - }, - }, - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.record", - "record": Object { - "cid": "cids(7)", - "uri": "record(8)", - }, - }, - "facets": Array [ - Object { - "features": Array [ - Object { - "$type": "app.bsky.richtext.facet#mention", - "did": "user(0)", - }, - ], - "index": Object { - "byteEnd": 18, - "byteStart": 0, - }, - }, - ], - "text": "@alice.bluesky.xyz is the best", - }, - "replyCount": 0, - "repostCount": 1, - "uri": "record(7)", - "viewer": Object {}, - }, - }, - Object { - "post": Object { - "author": Object { - "did": "user(2)", - "handle": "dan.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "following": "record(4)", - "muted": false, - }, - }, - "cid": "cids(13)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "text": "dan here!", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(15)", - "viewer": Object {}, - }, - }, - Object { - "post": Object { - "author": Object { - "did": "user(5)", - "handle": "carol.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(10)", - "following": "record(9)", - "muted": false, - }, - }, - "cid": "cids(7)", - "embed": Object { - "$type": "app.bsky.embed.recordWithMedia#view", - "media": Object { - "$type": "app.bsky.embed.images#view", - "images": Array [ - Object { - "alt": "tests/sample-img/key-landscape-small.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(6)/cids(5)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(6)/cids(5)@jpeg", - }, - Object { - "alt": "tests/sample-img/key-alt.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(6)/cids(8)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(6)/cids(8)@jpeg", - }, - ], - }, - "record": Object { - "record": Object { - "$type": "app.bsky.embed.record#viewRecord", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(4)/cids(1)@jpeg", - "did": "user(3)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(6)", - "following": "record(5)", - "muted": false, - }, - }, - "cid": "cids(9)", - "embeds": Array [], - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(9)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(11)", - "val": "kind", - }, - ], - "uri": "record(11)", - "value": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "langs": Array [ - "en-US", - "i-klingon", - ], - "text": "bob back at it again!", - }, - }, - }, - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(7)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(8)", - "val": "kind", - }, - ], - "likeCount": 2, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.recordWithMedia", - "media": 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(5)", - }, - "size": 4114, - }, - }, - Object { - "alt": "tests/sample-img/key-alt.jpg", - "image": Object { - "$type": "blob", - "mimeType": "image/jpeg", - "ref": Object { - "$link": "cids(8)", - }, - "size": 12736, - }, - }, - ], - }, - "record": Object { - "record": Object { - "cid": "cids(9)", - "uri": "record(11)", - }, - }, - }, - "text": "hi im carol", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(8)", - "viewer": Object { - "like": "record(16)", - }, - }, - }, - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(4)/cids(1)@jpeg", - "did": "user(3)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(6)", - "following": "record(5)", - "muted": false, - }, - }, - "cid": "cids(9)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(9)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(11)", - "val": "kind", - }, - ], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "langs": Array [ - "en-US", - "i-klingon", - ], - "text": "bob back at it again!", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(11)", - "viewer": Object {}, - }, - }, - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(1)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(14)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(14)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(17)", - "val": "self-label", - }, - ], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "labels": Object { - "$type": "com.atproto.label.defs#selfLabels", - "values": Array [ - Object { - "val": "self-label", - }, - ], - }, - "text": "hey there", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(17)", - "viewer": Object {}, - }, - }, -] -`; - -exports[`timeline views fetches authenticated user's home feed w/ reverse-chronological algorithm 2`] = ` -Array [ - Object { - "post": Object { - "author": Object { - "did": "user(0)", - "handle": "dan.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(1)", - "muted": false, - }, - }, - "cid": "cids(0)", - "embed": Object { - "$type": "app.bsky.embed.record#view", - "record": Object { - "$type": "app.bsky.embed.record#viewRecord", - "author": Object { - "did": "user(2)", - "handle": "carol.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "following": "record(3)", - "muted": false, - }, - }, - "cid": "cids(1)", - "embeds": Array [ - Object { - "$type": "app.bsky.embed.recordWithMedia#view", - "media": Object { - "$type": "app.bsky.embed.images#view", - "images": Array [ - Object { - "alt": "tests/sample-img/key-landscape-small.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(5)/cids(2)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(5)/cids(2)@jpeg", - }, - Object { - "alt": "tests/sample-img/key-alt.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(5)/cids(3)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(5)/cids(3)@jpeg", - }, - ], - }, - "record": Object { - "record": Object { - "$type": "app.bsky.embed.record#viewRecord", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(4)/cids(5)@jpeg", - "did": "user(3)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(4)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(4)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(4)", - "val": "kind", - }, - ], - "uri": "record(4)", - "value": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "langs": Array [ - "en-US", - "i-klingon", - ], - "text": "bob back at it again!", - }, - }, - }, - }, - ], - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(1)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(2)", - "val": "kind", - }, - ], - "uri": "record(2)", - "value": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.recordWithMedia", - "media": 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(2)", - }, - "size": 4114, - }, - }, - Object { - "alt": "tests/sample-img/key-alt.jpg", - "image": Object { - "$type": "blob", - "mimeType": "image/jpeg", - "ref": Object { - "$link": "cids(3)", - }, - "size": 12736, - }, - }, - ], - }, - "record": Object { - "record": Object { - "cid": "cids(4)", - "uri": "record(4)", - }, - }, - }, - "text": "hi im carol", - }, - }, - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.record", - "record": Object { - "cid": "cids(1)", - "uri": "record(2)", - }, - }, - "facets": Array [ - Object { - "features": Array [ - Object { - "$type": "app.bsky.richtext.facet#mention", - "did": "user(1)", - }, - ], - "index": Object { - "byteEnd": 18, - "byteStart": 0, - }, - }, - ], - "text": "@alice.bluesky.xyz is the best", - }, - "replyCount": 0, - "repostCount": 1, - "uri": "record(0)", - "viewer": Object {}, - }, - "reason": Object { - "$type": "app.bsky.feed.defs#reasonRepost", - "by": Object { - "did": "user(2)", - "handle": "carol.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "following": "record(3)", - "muted": false, - }, - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - }, - }, - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(6)/cids(5)@jpeg", - "did": "user(1)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(7)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(8)", - "val": "self-label-a", - }, - Object { - "cid": "cids(7)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(8)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(7)", - "following": "record(6)", - "muted": false, - }, - }, - "cid": "cids(6)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "reply": Object { - "parent": Object { - "cid": "cids(9)", - "uri": "record(10)", - }, - "root": Object { - "cid": "cids(8)", - "uri": "record(9)", - }, - }, - "text": "thanks bob", - }, - "replyCount": 0, - "repostCount": 1, - "uri": "record(5)", - "viewer": Object {}, - }, - "reply": Object { - "parent": Object { - "$type": "app.bsky.feed.defs#postView", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(4)/cids(5)@jpeg", - "did": "user(3)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(9)", - "embed": Object { - "$type": "app.bsky.embed.images#view", - "images": Array [ - Object { - "alt": "tests/sample-img/key-landscape-small.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(4)/cids(2)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(4)/cids(2)@jpeg", - }, - ], - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(9)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(10)", - "val": "test-label", - }, - Object { - "cid": "cids(9)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(10)", - "val": "test-label-2", - }, - ], - "likeCount": 0, - "record": 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(2)", - }, - "size": 4114, - }, - }, - ], - }, - "reply": Object { - "parent": Object { - "cid": "cids(8)", - "uri": "record(9)", - }, - "root": Object { - "cid": "cids(8)", - "uri": "record(9)", - }, - }, - "text": "hear that label_me label_me_2", - }, - "replyCount": 1, - "repostCount": 0, - "uri": "record(10)", - "viewer": Object {}, - }, - "root": Object { - "$type": "app.bsky.feed.defs#postView", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(6)/cids(5)@jpeg", - "did": "user(1)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(7)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(8)", - "val": "self-label-a", - }, - Object { - "cid": "cids(7)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(8)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(7)", - "following": "record(6)", - "muted": false, - }, - }, - "cid": "cids(8)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 2, - "repostCount": 1, - "uri": "record(9)", - "viewer": Object { - "like": "record(11)", - }, - }, - }, - }, - Object { - "post": Object { - "author": Object { - "did": "user(2)", - "handle": "carol.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "following": "record(3)", - "muted": false, - }, - }, - "cid": "cids(10)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "reply": Object { - "parent": Object { - "cid": "cids(8)", - "uri": "record(9)", - }, - "root": Object { - "cid": "cids(8)", - "uri": "record(9)", - }, - }, - "text": "of course", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(12)", - "viewer": Object {}, - }, - "reply": Object { - "parent": Object { - "$type": "app.bsky.feed.defs#postView", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(6)/cids(5)@jpeg", - "did": "user(1)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(7)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(8)", - "val": "self-label-a", - }, - Object { - "cid": "cids(7)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(8)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(7)", - "following": "record(6)", - "muted": false, - }, - }, - "cid": "cids(8)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 2, - "repostCount": 1, - "uri": "record(9)", - "viewer": Object { - "like": "record(11)", - }, - }, - "root": Object { - "$type": "app.bsky.feed.defs#postView", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(6)/cids(5)@jpeg", - "did": "user(1)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(7)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(8)", - "val": "self-label-a", - }, - Object { - "cid": "cids(7)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(8)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(7)", - "following": "record(6)", - "muted": false, - }, - }, - "cid": "cids(8)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 2, - "repostCount": 1, - "uri": "record(9)", - "viewer": Object { - "like": "record(11)", - }, - }, - }, - }, - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(4)/cids(5)@jpeg", - "did": "user(3)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(9)", - "embed": Object { - "$type": "app.bsky.embed.images#view", - "images": Array [ - Object { - "alt": "tests/sample-img/key-landscape-small.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(4)/cids(2)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(4)/cids(2)@jpeg", - }, - ], - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(9)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(10)", - "val": "test-label", - }, - Object { - "cid": "cids(9)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(10)", - "val": "test-label-2", - }, - ], - "likeCount": 0, - "record": 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(2)", - }, - "size": 4114, - }, - }, - ], - }, - "reply": Object { - "parent": Object { - "cid": "cids(8)", - "uri": "record(9)", - }, - "root": Object { - "cid": "cids(8)", - "uri": "record(9)", - }, - }, - "text": "hear that label_me label_me_2", - }, - "replyCount": 1, - "repostCount": 0, - "uri": "record(10)", - "viewer": Object {}, - }, - "reply": Object { - "parent": Object { - "$type": "app.bsky.feed.defs#postView", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(6)/cids(5)@jpeg", - "did": "user(1)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(7)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(8)", - "val": "self-label-a", - }, - Object { - "cid": "cids(7)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(8)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(7)", - "following": "record(6)", - "muted": false, - }, - }, - "cid": "cids(8)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 2, - "repostCount": 1, - "uri": "record(9)", - "viewer": Object { - "like": "record(11)", - }, - }, - "root": Object { - "$type": "app.bsky.feed.defs#postView", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(6)/cids(5)@jpeg", - "did": "user(1)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(7)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(8)", - "val": "self-label-a", - }, - Object { - "cid": "cids(7)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(8)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(7)", - "following": "record(6)", - "muted": false, - }, - }, - "cid": "cids(8)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 2, - "repostCount": 1, - "uri": "record(9)", - "viewer": Object { - "like": "record(11)", - }, - }, - }, - }, - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(6)/cids(5)@jpeg", - "did": "user(1)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(7)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(8)", - "val": "self-label-a", - }, - Object { - "cid": "cids(7)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(8)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(7)", - "following": "record(6)", - "muted": false, - }, - }, - "cid": "cids(11)", - "embed": Object { - "$type": "app.bsky.embed.record#view", - "record": Object { - "$type": "app.bsky.embed.record#viewRecord", - "author": Object { - "did": "user(0)", - "handle": "dan.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(1)", - "muted": false, - }, - }, - "cid": "cids(0)", - "embeds": Array [ - Object { - "$type": "app.bsky.embed.record#view", - "record": Object { - "$type": "app.bsky.embed.record#viewRecord", - "author": Object { - "did": "user(2)", - "handle": "carol.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "following": "record(3)", - "muted": false, - }, - }, - "cid": "cids(1)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(1)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(2)", - "val": "kind", - }, - ], - "uri": "record(2)", - "value": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.recordWithMedia", - "media": 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(2)", - }, - "size": 4114, - }, - }, - Object { - "alt": "tests/sample-img/key-alt.jpg", - "image": Object { - "$type": "blob", - "mimeType": "image/jpeg", - "ref": Object { - "$link": "cids(3)", - }, - "size": 12736, - }, - }, - ], - }, - "record": Object { - "record": Object { - "cid": "cids(4)", - "uri": "record(4)", - }, - }, - }, - "text": "hi im carol", - }, - }, - }, - ], - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "uri": "record(0)", - "value": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.record", - "record": Object { - "cid": "cids(1)", - "uri": "record(2)", - }, - }, - "facets": Array [ - Object { - "features": Array [ - Object { - "$type": "app.bsky.richtext.facet#mention", - "did": "user(1)", - }, - ], - "index": Object { - "byteEnd": 18, - "byteStart": 0, - }, - }, - ], - "text": "@alice.bluesky.xyz is the best", - }, - }, - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(11)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(13)", - "val": "test-label", - }, - ], - "likeCount": 2, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.record", - "record": Object { - "cid": "cids(0)", - "uri": "record(0)", - }, - }, - "text": "yoohoo label_me", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(13)", - "viewer": Object { - "like": "record(14)", - }, - }, - }, - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(4)/cids(5)@jpeg", - "did": "user(3)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(12)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000+00:00", - "text": "bobby boy here", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(15)", - "viewer": Object {}, - }, - }, - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(6)/cids(5)@jpeg", - "did": "user(1)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(7)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(8)", - "val": "self-label-a", - }, - Object { - "cid": "cids(7)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(8)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(7)", - "following": "record(6)", - "muted": false, - }, - }, - "cid": "cids(8)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 2, - "repostCount": 1, - "uri": "record(9)", - "viewer": Object { - "like": "record(11)", - }, - }, - }, - Object { - "post": Object { - "author": Object { - "did": "user(2)", - "handle": "carol.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "following": "record(3)", - "muted": false, - }, - }, - "cid": "cids(1)", - "embed": Object { - "$type": "app.bsky.embed.recordWithMedia#view", - "media": Object { - "$type": "app.bsky.embed.images#view", - "images": Array [ - Object { - "alt": "tests/sample-img/key-landscape-small.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(5)/cids(2)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(5)/cids(2)@jpeg", - }, - Object { - "alt": "tests/sample-img/key-alt.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(5)/cids(3)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(5)/cids(3)@jpeg", - }, - ], - }, - "record": Object { - "record": Object { - "$type": "app.bsky.embed.record#viewRecord", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(4)/cids(5)@jpeg", - "did": "user(3)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(4)", - "embeds": Array [], - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(4)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(4)", - "val": "kind", - }, - ], - "uri": "record(4)", - "value": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "langs": Array [ - "en-US", - "i-klingon", - ], - "text": "bob back at it again!", - }, - }, - }, - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(1)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(2)", - "val": "kind", - }, - ], - "likeCount": 2, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.recordWithMedia", - "media": 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(2)", - }, - "size": 4114, - }, - }, - Object { - "alt": "tests/sample-img/key-alt.jpg", - "image": Object { - "$type": "blob", - "mimeType": "image/jpeg", - "ref": Object { - "$link": "cids(3)", - }, - "size": 12736, - }, - }, - ], - }, - "record": Object { - "record": Object { - "cid": "cids(4)", - "uri": "record(4)", - }, - }, - }, - "text": "hi im carol", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(2)", - "viewer": Object { - "like": "record(16)", - }, - }, - }, - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(4)/cids(5)@jpeg", - "did": "user(3)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(4)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(4)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(4)", - "val": "kind", - }, - ], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "langs": Array [ - "en-US", - "i-klingon", - ], - "text": "bob back at it again!", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(4)", - "viewer": Object {}, - }, - }, - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(6)/cids(5)@jpeg", - "did": "user(1)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(7)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(8)", - "val": "self-label-a", - }, - Object { - "cid": "cids(7)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(8)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(7)", - "following": "record(6)", - "muted": false, - }, - }, - "cid": "cids(13)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(13)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(17)", - "val": "self-label", - }, - ], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "labels": Object { - "$type": "com.atproto.label.defs#selfLabels", - "values": Array [ - Object { - "val": "self-label", - }, - ], - }, - "text": "hey there", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(17)", - "viewer": Object {}, - }, - }, -] -`; - -exports[`timeline views fetches authenticated user's home feed w/ reverse-chronological algorithm 3`] = ` -Array [ - Object { - "post": Object { - "author": Object { - "did": "user(0)", - "handle": "dan.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(0)", - "embed": Object { - "$type": "app.bsky.embed.record#view", - "record": Object { - "$type": "app.bsky.embed.record#viewRecord", - "author": Object { - "did": "user(2)", - "handle": "carol.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(1)", - "embeds": Array [ - Object { - "$type": "app.bsky.embed.recordWithMedia#view", - "media": Object { - "$type": "app.bsky.embed.images#view", - "images": Array [ - Object { - "alt": "tests/sample-img/key-landscape-small.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(5)/cids(2)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(5)/cids(2)@jpeg", - }, - Object { - "alt": "tests/sample-img/key-alt.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(5)/cids(3)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(5)/cids(3)@jpeg", - }, - ], - }, - "record": Object { - "record": Object { - "$type": "app.bsky.embed.record#viewRecord", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(4)/cids(5)@jpeg", - "did": "user(3)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(3)", - "muted": false, - }, - }, - "cid": "cids(4)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(4)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(2)", - "val": "kind", - }, - ], - "uri": "record(2)", - "value": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "langs": Array [ - "en-US", - "i-klingon", - ], - "text": "bob back at it again!", - }, - }, - }, - }, - ], - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(1)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(1)", - "val": "kind", - }, - ], - "uri": "record(1)", - "value": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.recordWithMedia", - "media": 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(2)", - }, - "size": 4114, - }, - }, - Object { - "alt": "tests/sample-img/key-alt.jpg", - "image": Object { - "$type": "blob", - "mimeType": "image/jpeg", - "ref": Object { - "$link": "cids(3)", - }, - "size": 12736, - }, - }, - ], - }, - "record": Object { - "record": Object { - "cid": "cids(4)", - "uri": "record(2)", - }, - }, - }, - "text": "hi im carol", - }, - }, - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.record", - "record": Object { - "cid": "cids(1)", - "uri": "record(1)", - }, - }, - "facets": Array [ - Object { - "features": Array [ - Object { - "$type": "app.bsky.richtext.facet#mention", - "did": "user(1)", - }, - ], - "index": Object { - "byteEnd": 18, - "byteStart": 0, - }, - }, - ], - "text": "@alice.bluesky.xyz is the best", - }, - "replyCount": 0, - "repostCount": 1, - "uri": "record(0)", - "viewer": Object { - "repost": "record(4)", - }, - }, - "reason": Object { - "$type": "app.bsky.feed.defs#reasonRepost", - "by": Object { - "did": "user(2)", - "handle": "carol.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - }, - }, - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(6)/cids(5)@jpeg", - "did": "user(1)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(7)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(8)", - "val": "self-label-a", - }, - Object { - "cid": "cids(7)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(8)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(7)", - "following": "record(6)", - "muted": false, - }, - }, - "cid": "cids(6)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "reply": Object { - "parent": Object { - "cid": "cids(9)", - "uri": "record(10)", - }, - "root": Object { - "cid": "cids(8)", - "uri": "record(9)", - }, - }, - "text": "thanks bob", - }, - "replyCount": 0, - "repostCount": 1, - "uri": "record(5)", - "viewer": Object {}, - }, - "reply": Object { - "parent": Object { - "$type": "app.bsky.feed.defs#postView", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(4)/cids(5)@jpeg", - "did": "user(3)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(3)", - "muted": false, - }, - }, - "cid": "cids(9)", - "embed": Object { - "$type": "app.bsky.embed.images#view", - "images": Array [ - Object { - "alt": "tests/sample-img/key-landscape-small.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(4)/cids(2)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(4)/cids(2)@jpeg", - }, - ], - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(9)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(10)", - "val": "test-label", - }, - Object { - "cid": "cids(9)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(10)", - "val": "test-label-2", - }, - ], - "likeCount": 0, - "record": 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(2)", - }, - "size": 4114, - }, - }, - ], - }, - "reply": Object { - "parent": Object { - "cid": "cids(8)", - "uri": "record(9)", - }, - "root": Object { - "cid": "cids(8)", - "uri": "record(9)", - }, - }, - "text": "hear that label_me label_me_2", - }, - "replyCount": 1, - "repostCount": 0, - "uri": "record(10)", - "viewer": Object {}, - }, - "root": Object { - "$type": "app.bsky.feed.defs#postView", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(6)/cids(5)@jpeg", - "did": "user(1)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(7)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(8)", - "val": "self-label-a", - }, - Object { - "cid": "cids(7)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(8)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(7)", - "following": "record(6)", - "muted": false, - }, - }, - "cid": "cids(8)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 2, - "repostCount": 1, - "uri": "record(9)", - "viewer": Object { - "like": "record(11)", - }, - }, - }, - }, - Object { - "post": Object { - "author": Object { - "did": "user(2)", - "handle": "carol.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(10)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "reply": Object { - "parent": Object { - "cid": "cids(8)", - "uri": "record(9)", - }, - "root": Object { - "cid": "cids(8)", - "uri": "record(9)", - }, - }, - "text": "of course", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(12)", - "viewer": Object {}, - }, - "reply": Object { - "parent": Object { - "$type": "app.bsky.feed.defs#postView", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(6)/cids(5)@jpeg", - "did": "user(1)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(7)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(8)", - "val": "self-label-a", - }, - Object { - "cid": "cids(7)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(8)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(7)", - "following": "record(6)", - "muted": false, - }, - }, - "cid": "cids(8)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 2, - "repostCount": 1, - "uri": "record(9)", - "viewer": Object { - "like": "record(11)", - }, - }, - "root": Object { - "$type": "app.bsky.feed.defs#postView", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(6)/cids(5)@jpeg", - "did": "user(1)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(7)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(8)", - "val": "self-label-a", - }, - Object { - "cid": "cids(7)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(8)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(7)", - "following": "record(6)", - "muted": false, - }, - }, - "cid": "cids(8)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 2, - "repostCount": 1, - "uri": "record(9)", - "viewer": Object { - "like": "record(11)", - }, - }, - }, - }, - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(6)/cids(5)@jpeg", - "did": "user(1)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(7)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(8)", - "val": "self-label-a", - }, - Object { - "cid": "cids(7)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(8)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(7)", - "following": "record(6)", - "muted": false, - }, - }, - "cid": "cids(11)", - "embed": Object { - "$type": "app.bsky.embed.record#view", - "record": Object { - "$type": "app.bsky.embed.record#viewRecord", - "author": Object { - "did": "user(0)", - "handle": "dan.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(0)", - "embeds": Array [ - Object { - "$type": "app.bsky.embed.record#view", - "record": Object { - "$type": "app.bsky.embed.record#viewRecord", - "author": Object { - "did": "user(2)", - "handle": "carol.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(1)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(1)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(1)", - "val": "kind", - }, - ], - "uri": "record(1)", - "value": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.recordWithMedia", - "media": 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(2)", - }, - "size": 4114, - }, - }, - Object { - "alt": "tests/sample-img/key-alt.jpg", - "image": Object { - "$type": "blob", - "mimeType": "image/jpeg", - "ref": Object { - "$link": "cids(3)", - }, - "size": 12736, - }, - }, - ], - }, - "record": Object { - "record": Object { - "cid": "cids(4)", - "uri": "record(2)", - }, - }, - }, - "text": "hi im carol", - }, - }, - }, - ], - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "uri": "record(0)", - "value": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.record", - "record": Object { - "cid": "cids(1)", - "uri": "record(1)", - }, - }, - "facets": Array [ - Object { - "features": Array [ - Object { - "$type": "app.bsky.richtext.facet#mention", - "did": "user(1)", - }, - ], - "index": Object { - "byteEnd": 18, - "byteStart": 0, - }, - }, - ], - "text": "@alice.bluesky.xyz is the best", - }, - }, - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(11)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(13)", - "val": "test-label", - }, - ], - "likeCount": 2, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.record", - "record": Object { - "cid": "cids(0)", - "uri": "record(0)", - }, - }, - "text": "yoohoo label_me", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(13)", - "viewer": Object { - "like": "record(14)", - }, - }, - }, - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(6)/cids(5)@jpeg", - "did": "user(1)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(7)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(8)", - "val": "self-label-a", - }, - Object { - "cid": "cids(7)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(8)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(7)", - "following": "record(6)", - "muted": false, - }, - }, - "cid": "cids(8)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 2, - "repostCount": 1, - "uri": "record(9)", - "viewer": Object { - "like": "record(11)", - }, - }, - }, - Object { - "post": Object { - "author": Object { - "did": "user(2)", - "handle": "carol.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(1)", - "embed": Object { - "$type": "app.bsky.embed.recordWithMedia#view", - "media": Object { - "$type": "app.bsky.embed.images#view", - "images": Array [ - Object { - "alt": "tests/sample-img/key-landscape-small.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(5)/cids(2)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(5)/cids(2)@jpeg", - }, - Object { - "alt": "tests/sample-img/key-alt.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(5)/cids(3)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(5)/cids(3)@jpeg", - }, - ], - }, - "record": Object { - "record": Object { - "$type": "app.bsky.embed.record#viewRecord", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(4)/cids(5)@jpeg", - "did": "user(3)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(3)", - "muted": false, - }, - }, - "cid": "cids(4)", - "embeds": Array [], - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(4)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(2)", - "val": "kind", - }, - ], - "uri": "record(2)", - "value": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "langs": Array [ - "en-US", - "i-klingon", - ], - "text": "bob back at it again!", - }, - }, - }, - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(1)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(1)", - "val": "kind", - }, - ], - "likeCount": 2, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.recordWithMedia", - "media": 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(2)", - }, - "size": 4114, - }, - }, - Object { - "alt": "tests/sample-img/key-alt.jpg", - "image": Object { - "$type": "blob", - "mimeType": "image/jpeg", - "ref": Object { - "$link": "cids(3)", - }, - "size": 12736, - }, - }, - ], - }, - "record": Object { - "record": Object { - "cid": "cids(4)", - "uri": "record(2)", - }, - }, - }, - "text": "hi im carol", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(1)", - "viewer": Object {}, - }, - }, - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(6)/cids(5)@jpeg", - "did": "user(1)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(7)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(8)", - "val": "self-label-a", - }, - Object { - "cid": "cids(7)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(8)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(7)", - "following": "record(6)", - "muted": false, - }, - }, - "cid": "cids(12)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(12)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(1)", - "uri": "record(15)", - "val": "self-label", - }, - ], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "labels": Object { - "$type": "com.atproto.label.defs#selfLabels", - "values": Array [ - Object { - "val": "self-label", - }, - ], - }, - "text": "hey there", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(15)", - "viewer": Object {}, - }, - }, -] -`; - -exports[`timeline views fetches authenticated user's home feed w/ reverse-chronological algorithm 4`] = ` -Array [ - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(2)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(2)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(1)", - "muted": false, - }, - }, - "cid": "cids(0)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "reply": Object { - "parent": Object { - "cid": "cids(4)", - "uri": "record(4)", - }, - "root": Object { - "cid": "cids(3)", - "uri": "record(3)", - }, - }, - "text": "thanks bob", - }, - "replyCount": 0, - "repostCount": 1, - "uri": "record(0)", - "viewer": Object { - "repost": "record(5)", - }, - }, - "reason": Object { - "$type": "app.bsky.feed.defs#reasonRepost", - "by": Object { - "did": "user(2)", - "handle": "dan.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - }, - "reply": Object { - "parent": Object { - "$type": "app.bsky.feed.defs#postView", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(4)/cids(1)@jpeg", - "did": "user(3)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "following": "record(8)", - "muted": false, - }, - }, - "cid": "cids(4)", - "embed": Object { - "$type": "app.bsky.embed.images#view", - "images": Array [ - Object { - "alt": "tests/sample-img/key-landscape-small.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(4)/cids(5)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(4)/cids(5)@jpeg", - }, - ], - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(4)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(4)", - "val": "test-label", - }, - Object { - "cid": "cids(4)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(4)", - "val": "test-label-2", - }, - ], - "likeCount": 0, - "record": 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(5)", - }, - "size": 4114, - }, - }, - ], - }, - "reply": Object { - "parent": Object { - "cid": "cids(3)", - "uri": "record(3)", - }, - "root": Object { - "cid": "cids(3)", - "uri": "record(3)", - }, - }, - "text": "hear that label_me label_me_2", - }, - "replyCount": 1, - "repostCount": 0, - "uri": "record(4)", - "viewer": Object {}, - }, - "root": Object { - "$type": "app.bsky.feed.defs#postView", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(2)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(2)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(1)", - "muted": false, - }, - }, - "cid": "cids(3)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 2, - "repostCount": 1, - "uri": "record(3)", - "viewer": Object { - "like": "record(7)", - "repost": "record(6)", - }, - }, - }, - }, - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(2)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(2)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(1)", - "muted": false, - }, - }, - "cid": "cids(3)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 2, - "repostCount": 1, - "uri": "record(3)", - "viewer": Object { - "like": "record(7)", - "repost": "record(6)", - }, - }, - "reason": Object { - "$type": "app.bsky.feed.defs#reasonRepost", - "by": Object { - "did": "user(2)", - "handle": "dan.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - }, - }, - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(4)/cids(1)@jpeg", - "did": "user(3)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "following": "record(8)", - "muted": false, - }, - }, - "cid": "cids(4)", - "embed": Object { - "$type": "app.bsky.embed.images#view", - "images": Array [ - Object { - "alt": "tests/sample-img/key-landscape-small.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(4)/cids(5)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(4)/cids(5)@jpeg", - }, - ], - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(4)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(4)", - "val": "test-label", - }, - Object { - "cid": "cids(4)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(4)", - "val": "test-label-2", - }, - ], - "likeCount": 0, - "record": 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(5)", - }, - "size": 4114, - }, - }, - ], - }, - "reply": Object { - "parent": Object { - "cid": "cids(3)", - "uri": "record(3)", - }, - "root": Object { - "cid": "cids(3)", - "uri": "record(3)", - }, - }, - "text": "hear that label_me label_me_2", - }, - "replyCount": 1, - "repostCount": 0, - "uri": "record(4)", - "viewer": Object {}, - }, - "reply": Object { - "parent": Object { - "$type": "app.bsky.feed.defs#postView", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(2)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(2)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(1)", - "muted": false, - }, - }, - "cid": "cids(3)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 2, - "repostCount": 1, - "uri": "record(3)", - "viewer": Object { - "like": "record(7)", - "repost": "record(6)", - }, - }, - "root": Object { - "$type": "app.bsky.feed.defs#postView", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg", - "did": "user(0)", - "displayName": "ali", - "handle": "alice.test", - "labels": Array [ - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(2)", - "val": "self-label-a", - }, - Object { - "cid": "cids(2)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "user(0)", - "uri": "record(2)", - "val": "self-label-b", - }, - ], - "viewer": Object { - "blockedBy": false, - "followedBy": "record(1)", - "muted": false, - }, - }, - "cid": "cids(3)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 3, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000000Z", - "text": "again", - }, - "replyCount": 2, - "repostCount": 1, - "uri": "record(3)", - "viewer": Object { - "like": "record(7)", - "repost": "record(6)", - }, - }, - }, - }, - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(4)/cids(1)@jpeg", - "did": "user(3)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "following": "record(8)", - "muted": false, - }, - }, - "cid": "cids(6)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000+00:00", - "text": "bobby boy here", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(9)", - "viewer": Object {}, - }, - }, - Object { - "post": Object { - "author": Object { - "did": "user(2)", - "handle": "dan.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(7)", - "embed": Object { - "$type": "app.bsky.embed.record#view", - "record": Object { - "$type": "app.bsky.embed.record#viewRecord", - "author": Object { - "did": "user(5)", - "handle": "carol.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(8)", - "embeds": Array [ - Object { - "$type": "app.bsky.embed.recordWithMedia#view", - "media": Object { - "$type": "app.bsky.embed.images#view", - "images": Array [ - Object { - "alt": "tests/sample-img/key-landscape-small.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(6)/cids(5)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(6)/cids(5)@jpeg", - }, - Object { - "alt": "tests/sample-img/key-alt.jpg", - "fullsize": "https://bsky.public.url/img/feed_fullsize/plain/user(6)/cids(9)@jpeg", - "thumb": "https://bsky.public.url/img/feed_thumbnail/plain/user(6)/cids(9)@jpeg", - }, - ], - }, - "record": Object { - "record": Object { - "$type": "app.bsky.embed.record#viewRecord", - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(4)/cids(1)@jpeg", - "did": "user(3)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "following": "record(8)", - "muted": false, - }, - }, - "cid": "cids(10)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(10)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(12)", - "val": "kind", - }, - ], - "uri": "record(12)", - "value": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "langs": Array [ - "en-US", - "i-klingon", - ], - "text": "bob back at it again!", - }, - }, - }, - }, - ], - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(8)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(11)", - "val": "kind", - }, - ], - "uri": "record(11)", - "value": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.recordWithMedia", - "media": 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(5)", - }, - "size": 4114, - }, - }, - Object { - "alt": "tests/sample-img/key-alt.jpg", - "image": Object { - "$type": "blob", - "mimeType": "image/jpeg", - "ref": Object { - "$link": "cids(9)", - }, - "size": 12736, - }, - }, - ], - }, - "record": Object { - "record": Object { - "cid": "cids(10)", - "uri": "record(12)", - }, - }, - }, - "text": "hi im carol", - }, - }, - }, - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "embed": Object { - "$type": "app.bsky.embed.record", - "record": Object { - "cid": "cids(8)", - "uri": "record(11)", - }, - }, - "facets": Array [ - Object { - "features": Array [ - Object { - "$type": "app.bsky.richtext.facet#mention", - "did": "user(0)", - }, - ], - "index": Object { - "byteEnd": 18, - "byteStart": 0, - }, - }, - ], - "text": "@alice.bluesky.xyz is the best", - }, - "replyCount": 0, - "repostCount": 1, - "uri": "record(10)", - "viewer": Object {}, - }, - }, - Object { - "post": Object { - "author": Object { - "did": "user(2)", - "handle": "dan.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "muted": false, - }, - }, - "cid": "cids(11)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "text": "dan here!", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(13)", - "viewer": Object {}, - }, - }, - Object { - "post": Object { - "author": Object { - "avatar": "https://bsky.public.url/img/avatar/plain/user(4)/cids(1)@jpeg", - "did": "user(3)", - "displayName": "bobby", - "handle": "bob.test", - "labels": Array [], - "viewer": Object { - "blockedBy": false, - "following": "record(8)", - "muted": false, - }, - }, - "cid": "cids(10)", - "indexedAt": "1970-01-01T00:00:00.000Z", - "labels": Array [ - Object { - "cid": "cids(10)", - "cts": "1970-01-01T00:00:00.000Z", - "neg": false, - "src": "did:example:labeler", - "uri": "record(12)", - "val": "kind", - }, - ], - "likeCount": 0, - "record": Object { - "$type": "app.bsky.feed.post", - "createdAt": "1970-01-01T00:00:00.000Z", - "langs": Array [ - "en-US", - "i-klingon", - ], - "text": "bob back at it again!", - }, - "replyCount": 0, - "repostCount": 0, - "uri": "record(12)", - "viewer": Object {}, - }, - }, -] -`; diff --git a/packages/ozone/tests/views/actor-likes.test.ts b/packages/ozone/tests/views/actor-likes.test.ts deleted file mode 100644 index 642b37e6446..00000000000 --- a/packages/ozone/tests/views/actor-likes.test.ts +++ /dev/null @@ -1,119 +0,0 @@ -import AtpAgent, { AtUri } from '@atproto/api' -import { TestNetwork, SeedClient } from '@atproto/dev-env' -import basicSeed from '../seeds/basic' - -describe('bsky actor likes feed views', () => { - let network: TestNetwork - let agent: AtpAgent - let pdsAgent: AtpAgent - let sc: SeedClient - - // account dids, for convenience - let alice: string - let bob: string - let carol: string - - beforeAll(async () => { - network = await TestNetwork.create({ - dbPostgresSchema: 'bsky_views_actor_likes', - }) - agent = network.bsky.getClient() - pdsAgent = network.pds.getClient() - sc = network.getSeedClient() - await basicSeed(sc) - await network.processAll() - alice = sc.dids.alice - bob = sc.dids.bob - carol = sc.dids.carol - }) - - afterAll(async () => { - await network.close() - }) - - it('returns posts liked by actor', async () => { - const { - data: { feed: bobLikes }, - } = await agent.api.app.bsky.feed.getActorLikes( - { actor: sc.accounts[bob].handle }, - { headers: await network.serviceHeaders(bob) }, - ) - - expect(bobLikes).toHaveLength(3) - - await expect( - agent.api.app.bsky.feed.getActorLikes( - { actor: sc.accounts[bob].handle }, - { headers: await network.serviceHeaders(carol) }, - ), - ).rejects.toThrow('Profile not found') - }) - - it('viewer has blocked author of liked post(s)', async () => { - const bobBlocksAlice = await pdsAgent.api.app.bsky.graph.block.create( - { - repo: bob, // bob blocks alice - }, - { - subject: alice, - createdAt: new Date().toISOString(), - }, - sc.getHeaders(bob), - ) - - await network.processAll() - - const { - data: { feed }, - } = await agent.api.app.bsky.feed.getActorLikes( - { actor: sc.accounts[bob].handle }, - { headers: await network.serviceHeaders(bob) }, - ) - - expect( - feed.every((item) => { - return item.post.author.did !== alice - }), - ).toBe(true) - - // unblock - await pdsAgent.api.app.bsky.graph.block.delete( - { repo: bob, rkey: new AtUri(bobBlocksAlice.uri).rkey }, - sc.getHeaders(bob), - ) - }) - - it('liked post author has blocked viewer', async () => { - const aliceBlockBob = await pdsAgent.api.app.bsky.graph.block.create( - { - repo: alice, // alice blocks bob - }, - { - subject: bob, - createdAt: new Date().toISOString(), - }, - sc.getHeaders(alice), - ) - - await network.processAll() - - const { - data: { feed }, - } = await agent.api.app.bsky.feed.getActorLikes( - { actor: sc.accounts[bob].handle }, - { headers: await network.serviceHeaders(bob) }, - ) - - expect( - feed.every((item) => { - return item.post.author.did !== alice - }), - ).toBe(true) - - // unblock - await pdsAgent.api.app.bsky.graph.block.delete( - { repo: alice, rkey: new AtUri(aliceBlockBob.uri).rkey }, - sc.getHeaders(alice), - ) - }) -}) diff --git a/packages/ozone/tests/views/actor-search.test.ts b/packages/ozone/tests/views/actor-search.test.ts deleted file mode 100644 index 70f8862f7d7..00000000000 --- a/packages/ozone/tests/views/actor-search.test.ts +++ /dev/null @@ -1,266 +0,0 @@ -import AtpAgent from '@atproto/api' -import { wait } from '@atproto/common' -import { TestNetwork, SeedClient } from '@atproto/dev-env' -import { forSnapshot, paginateAll, stripViewer } from '../_util' -import usersBulkSeed from '../seeds/users-bulk' - -// @NOTE skipped to help with CI failures -// The search code is not used in production & we should switch it out for tests on the search proxy interface -describe.skip('pds actor search views', () => { - let network: TestNetwork - let agent: AtpAgent - let sc: SeedClient - let headers: { [s: string]: string } - - beforeAll(async () => { - network = await TestNetwork.create({ - dbPostgresSchema: 'bsky_views_actor_search', - }) - agent = network.bsky.getClient() - sc = network.getSeedClient() - - await wait(50) // allow pending sub to be established - await network.bsky.ingester.sub.destroy() - await usersBulkSeed(sc) - - // Skip did/handle resolution for expediency - const db = network.bsky.ctx.db.getPrimary() - const now = new Date().toISOString() - await db.db - .insertInto('actor') - .values( - Object.entries(sc.dids).map(([handle, did]) => ({ - did, - handle, - indexedAt: now, - })), - ) - .onConflict((oc) => oc.doNothing()) - .execute() - - // Process remaining profiles - network.bsky.ingester.sub.resume() - await network.processAll(50000) - await network.bsky.processAll() - headers = await network.serviceHeaders(Object.values(sc.dids)[0]) - }) - - afterAll(async () => { - await network.close() - }) - - it('typeahead gives relevant results', async () => { - const result = await agent.api.app.bsky.actor.searchActorsTypeahead( - { term: 'car' }, - { headers }, - ) - - const handles = result.data.actors.map((u) => u.handle) - - const shouldContain = [ - 'cara-wiegand69.test', - 'eudora-dietrich4.test', // Carol Littel - 'shane-torphy52.test', // Sadie Carter - 'aliya-hodkiewicz.test', // Carlton Abernathy IV - 'carlos6.test', - 'carolina-mcdermott77.test', - ] - - shouldContain.forEach((handle) => expect(handles).toContain(handle)) - expect(handles).toContain('cayla-marquardt39.test') // Fuzzy match - - const shouldNotContain = [ - 'sven70.test', - 'hilario84.test', - 'santa-hermann78.test', - 'dylan61.test', - 'preston-harris.test', - 'loyce95.test', - 'melyna-zboncak.test', - ] - - shouldNotContain.forEach((handle) => expect(handles).not.toContain(handle)) - - const sorted = result.data.actors.sort((a, b) => - a.handle > b.handle ? 1 : -1, - ) - expect(forSnapshot(sorted)).toMatchSnapshot() - }) - - it('typeahead gives empty result set when provided empty term', async () => { - const result = await agent.api.app.bsky.actor.searchActorsTypeahead( - { term: '' }, - { headers }, - ) - - expect(result.data.actors).toEqual([]) - }) - - it('typeahead applies limit', async () => { - const full = await agent.api.app.bsky.actor.searchActorsTypeahead( - { term: 'p' }, - { headers }, - ) - - expect(full.data.actors.length).toBeGreaterThan(5) - - const limited = await agent.api.app.bsky.actor.searchActorsTypeahead( - { term: 'p', limit: 5 }, - { headers }, - ) - - // @NOTE it's expected that searchActorsTypeahead doesn't have stable pagination - - const limitedIndexInFull = limited.data.actors.map((needle) => { - return full.data.actors.findIndex( - (haystack) => needle.did === haystack.did, - ) - }) - - // subset exists in full and is monotonic - expect(limitedIndexInFull.every((idx) => idx !== -1)).toEqual(true) - expect(limitedIndexInFull).toEqual( - [...limitedIndexInFull].sort((a, b) => a - b), - ) - }) - - it('typeahead gives results unauthed', async () => { - const { data: authed } = - await agent.api.app.bsky.actor.searchActorsTypeahead( - { term: 'car' }, - { headers }, - ) - const { data: unauthed } = - await agent.api.app.bsky.actor.searchActorsTypeahead({ - term: 'car', - }) - expect(unauthed.actors.length).toBeGreaterThan(0) - expect(unauthed.actors).toEqual(authed.actors.map(stripViewer)) - }) - - it('search gives relevant results', async () => { - const result = await agent.api.app.bsky.actor.searchActors( - { term: 'car' }, - { headers }, - ) - - const handles = result.data.actors.map((u) => u.handle) - - const shouldContain = [ - 'cara-wiegand69.test', - 'eudora-dietrich4.test', // Carol Littel - 'shane-torphy52.test', // Sadie Carter - 'aliya-hodkiewicz.test', // Carlton Abernathy IV - 'carlos6.test', - 'carolina-mcdermott77.test', - ] - - shouldContain.forEach((handle) => expect(handles).toContain(handle)) - expect(handles).toContain('cayla-marquardt39.test') // Fuzzy match - - const shouldNotContain = [ - 'sven70.test', - 'hilario84.test', - 'santa-hermann78.test', - 'dylan61.test', - 'preston-harris.test', - 'loyce95.test', - 'melyna-zboncak.test', - ] - - shouldNotContain.forEach((handle) => expect(handles).not.toContain(handle)) - - const sorted = result.data.actors.sort((a, b) => - a.handle > b.handle ? 1 : -1, - ) - expect(forSnapshot(sorted)).toMatchSnapshot() - }) - - it('search gives empty result set when provided empty term', async () => { - const result = await agent.api.app.bsky.actor.searchActors( - { term: '' }, - { headers }, - ) - - expect(result.data.actors).toEqual([]) - }) - - it('paginates', async () => { - const results = (results) => results.flatMap((res) => res.users) - const paginator = async (cursor?: string) => { - const res = await agent.api.app.bsky.actor.searchActors( - { term: 'p', cursor, limit: 3 }, - { headers }, - ) - return res.data - } - - const paginatedAll = await paginateAll(paginator) - paginatedAll.forEach((res) => - expect(res.actors.length).toBeLessThanOrEqual(3), - ) - - const full = await agent.api.app.bsky.actor.searchActors( - { term: 'p' }, - { headers }, - ) - - expect(full.data.actors.length).toBeGreaterThan(5) - const sortedFull = results([full.data]).sort((a, b) => - a.handle > b.handle ? 1 : -1, - ) - const sortedPaginated = results(paginatedAll).sort((a, b) => - a.handle > b.handle ? 1 : -1, - ) - expect(sortedPaginated).toEqual(sortedFull) - }) - - it('search handles bad input', async () => { - // Mostly for sqlite's benefit, since it uses LIKE and these are special characters that will - // get stripped. This input triggers a special case where there are no "safe" words for sqlite to search on. - const result = await agent.api.app.bsky.actor.searchActors( - { term: ' % _ ' }, - { headers }, - ) - - expect(result.data.actors).toEqual([]) - }) - - it('search gives results unauthed', async () => { - const { data: authed } = await agent.api.app.bsky.actor.searchActors( - { term: 'car' }, - { headers }, - ) - const { data: unauthed } = await agent.api.app.bsky.actor.searchActors({ - term: 'car', - }) - expect(unauthed.actors.length).toBeGreaterThan(0) - expect(unauthed.actors).toEqual(authed.actors.map(stripViewer)) - }) - - it('search blocks by actor takedown', async () => { - await agent.api.com.atproto.admin.emitModerationEvent( - { - event: { $type: 'com.atproto.admin.defs#modEventTakedown' }, - subject: { - $type: 'com.atproto.admin.defs#repoRef', - did: sc.dids['cara-wiegand69.test'], - }, - createdBy: 'did:example:admin', - reason: 'Y', - }, - { - encoding: 'application/json', - headers: network.pds.adminAuthHeaders(), - }, - ) - const result = await agent.api.app.bsky.actor.searchActorsTypeahead( - { term: 'car' }, - { headers }, - ) - const handles = result.data.actors.map((u) => u.handle) - expect(handles).toContain('carlos6.test') - expect(handles).toContain('carolina-mcdermott77.test') - expect(handles).not.toContain('cara-wiegand69.test') - }) -}) diff --git a/packages/ozone/tests/views/admin/repo-search.test.ts b/packages/ozone/tests/views/admin/repo-search.test.ts deleted file mode 100644 index 6d9e8468dc1..00000000000 --- a/packages/ozone/tests/views/admin/repo-search.test.ts +++ /dev/null @@ -1,133 +0,0 @@ -import AtpAgent, { ComAtprotoAdminSearchRepos } from '@atproto/api' -import { wait } from '@atproto/common' -import { TestNetwork, SeedClient } from '@atproto/dev-env' -import usersBulkSeed from '../../seeds/users-bulk' - -describe('pds admin repo search views', () => { - let network: TestNetwork - let agent: AtpAgent - let sc: SeedClient - let headers: { [s: string]: string } - // In results that don't have a related profile record, we will only have handle but not a name - // And names are usually capitalized on each word so the comparison is done on lowercase version - const handleOrNameStartsWith = - (term: string) => (handleOrName: (string | undefined)[]) => - !!handleOrName.find((str) => - str?.toLowerCase().includes(term.toLowerCase()), - ) - const resultToHandlesAndNames = ( - result: ComAtprotoAdminSearchRepos.Response, - ) => - result.data.repos.map((u: any) => [ - u.handle, - (u.relatedRecords[0] as Record)?.displayName, - ]) - - beforeAll(async () => { - network = await TestNetwork.create({ - dbPostgresSchema: 'bsky_views_repo_search', - }) - agent = network.bsky.getClient() - sc = network.getSeedClient() - - await wait(100) // allow pending sub to be established - await network.bsky.ingester.sub.destroy() - await usersBulkSeed(sc) - - // Skip did/handle resolution for expediency - const db = network.bsky.ctx.db.getPrimary() - const now = new Date().toISOString() - await db.db - .insertInto('actor') - .values( - Object.entries(sc.dids).map(([handle, did]) => ({ - did, - handle, - indexedAt: now, - })), - ) - .onConflict((oc) => oc.doNothing()) - .execute() - - // Process remaining profiles - network.bsky.ingester.sub.resume() - await network.processAll(50000) - headers = await network.adminHeaders({}) - }) - - afterAll(async () => { - await network.close() - }) - - it('gives relevant results when searched by handle', async () => { - const term = 'car' - const result = await agent.api.com.atproto.admin.searchRepos( - { term }, - { headers }, - ) - - const shouldContain = [ - // Present despite repo takedown - // First item in the array because of direct handle match - 'cara-wiegand69.test', - 'carlos6.test', - 'aliya-hodkiewicz.test', // Carlton Abernathy IV - 'eudora-dietrich4.test', // Carol Littel - 'carolina-mcdermott77.test', - 'shane-torphy52.test', // Sadie Carter - // Last item in the array because handle and display name none match very close to the the search term - 'cayla-marquardt39.test', - ] - - const handlesAndNames = resultToHandlesAndNames(result) - const handles = handlesAndNames.map(([handle]) => handle) - // Assert that all matches are found - shouldContain.forEach((handle) => expect(handles).toContain(handle)) - // Assert that the order is correct, showing the closest match by handle first - const containsTerm = handleOrNameStartsWith(term) - expect(containsTerm(handlesAndNames[0])).toBeTruthy() - expect( - containsTerm(handlesAndNames[handlesAndNames.length - 1]), - ).toBeFalsy() - }) - - it('pagination respects matching order when searched by handle', async () => { - const term = 'car' - const resultPageOne = await agent.api.com.atproto.admin.searchRepos( - { term, limit: 4 }, - { headers }, - ) - const resultPageTwo = await agent.api.com.atproto.admin.searchRepos( - { term, limit: 4, cursor: resultPageOne.data.cursor }, - { headers }, - ) - - const handlesAndNamesPageOne = resultToHandlesAndNames(resultPageOne) - const handlesAndNamesPageTwo = resultToHandlesAndNames(resultPageTwo) - const containsTerm = handleOrNameStartsWith(term) - - // First result of first page always has matches either handle or did - expect(containsTerm(handlesAndNamesPageOne[0])).toBeTruthy() - // Since we only get 4 items per page max and know that among the test dataset - // at least 4 users have the term in handle or profile, last item in first page - // should contain the term - expect( - containsTerm(handlesAndNamesPageOne[handlesAndNamesPageOne.length - 1]), - ).toBeTruthy() - // However, the last item of second page, should not contain the term - expect( - containsTerm(handlesAndNamesPageTwo[handlesAndNamesPageTwo.length - 1]), - ).toBeFalsy() - }) - - it('gives relevant results when searched by did', async () => { - const term = sc.dids['cara-wiegand69.test'] - const res = await agent.api.com.atproto.admin.searchRepos( - { term }, - { headers }, - ) - - expect(res.data.repos.length).toEqual(1) - expect(res.data.repos[0].did).toEqual(term) - }) -}) diff --git a/packages/ozone/tests/views/author-feed.test.ts b/packages/ozone/tests/views/author-feed.test.ts deleted file mode 100644 index c5d863bfb92..00000000000 --- a/packages/ozone/tests/views/author-feed.test.ts +++ /dev/null @@ -1,326 +0,0 @@ -import AtpAgent from '@atproto/api' -import { TestNetwork, SeedClient } from '@atproto/dev-env' -import { forSnapshot, paginateAll, stripViewerFromPost } from '../_util' -import authorFeedSeed from '../seeds/author-feed' -import { isRecord } from '../../src/lexicon/types/app/bsky/feed/post' -import { isView as isEmbedRecordWithMedia } from '../../src/lexicon/types/app/bsky/embed/recordWithMedia' -import { isView as isImageEmbed } from '../../src/lexicon/types/app/bsky/embed/images' - -describe('pds author feed views', () => { - let network: TestNetwork - let agent: AtpAgent - let sc: SeedClient - - // account dids, for convenience - let alice: string - let bob: string - let carol: string - let dan: string - let eve: string - - beforeAll(async () => { - network = await TestNetwork.create({ - dbPostgresSchema: 'bsky_views_author_feed', - }) - agent = network.bsky.getClient() - sc = network.getSeedClient() - await authorFeedSeed(sc) - await network.processAll() - alice = sc.dids.alice - bob = sc.dids.bob - carol = sc.dids.carol - dan = sc.dids.dan - eve = sc.dids.eve - }) - - afterAll(async () => { - await network.close() - }) - - // @TODO(bsky) blocked by actor takedown via labels. - // @TODO(bsky) blocked by record takedown via labels. - - it('fetches full author feeds for self (sorted, minimal viewer state).', async () => { - const aliceForAlice = await agent.api.app.bsky.feed.getAuthorFeed( - { actor: sc.accounts[alice].handle }, - { headers: await network.serviceHeaders(alice) }, - ) - - expect(forSnapshot(aliceForAlice.data.feed)).toMatchSnapshot() - - const bobForBob = await agent.api.app.bsky.feed.getAuthorFeed( - { actor: sc.accounts[bob].handle }, - { headers: await network.serviceHeaders(bob) }, - ) - - expect(forSnapshot(bobForBob.data.feed)).toMatchSnapshot() - - const carolForCarol = await agent.api.app.bsky.feed.getAuthorFeed( - { actor: sc.accounts[carol].handle }, - { headers: await network.serviceHeaders(carol) }, - ) - - expect(forSnapshot(carolForCarol.data.feed)).toMatchSnapshot() - - const danForDan = await agent.api.app.bsky.feed.getAuthorFeed( - { actor: sc.accounts[dan].handle }, - { headers: await network.serviceHeaders(dan) }, - ) - - expect(forSnapshot(danForDan.data.feed)).toMatchSnapshot() - }) - - it("reflects fetching user's state in the feed.", async () => { - const aliceForCarol = await agent.api.app.bsky.feed.getAuthorFeed( - { actor: sc.accounts[alice].handle }, - { headers: await network.serviceHeaders(carol) }, - ) - - aliceForCarol.data.feed.forEach((postView) => { - const { viewer, uri } = postView.post - expect(viewer?.like).toEqual(sc.likes[carol][uri]?.toString()) - expect(viewer?.repost).toEqual(sc.reposts[carol][uri]?.toString()) - }) - - expect(forSnapshot(aliceForCarol.data.feed)).toMatchSnapshot() - }) - - it('paginates', async () => { - const results = (results) => results.flatMap((res) => res.feed) - const paginator = async (cursor?: string) => { - const res = await agent.api.app.bsky.feed.getAuthorFeed( - { - actor: sc.accounts[alice].handle, - cursor, - limit: 2, - }, - { headers: await network.serviceHeaders(dan) }, - ) - return res.data - } - - const paginatedAll = await paginateAll(paginator) - paginatedAll.forEach((res) => - expect(res.feed.length).toBeLessThanOrEqual(2), - ) - - const full = await agent.api.app.bsky.feed.getAuthorFeed( - { actor: sc.accounts[alice].handle }, - { headers: await network.serviceHeaders(dan) }, - ) - - expect(full.data.feed.length).toEqual(4) - expect(results(paginatedAll)).toEqual(results([full.data])) - }) - - it('fetches results unauthed.', async () => { - const { data: authed } = await agent.api.app.bsky.feed.getAuthorFeed( - { actor: sc.accounts[alice].handle }, - { headers: await network.serviceHeaders(alice) }, - ) - const { data: unauthed } = await agent.api.app.bsky.feed.getAuthorFeed({ - actor: sc.accounts[alice].handle, - }) - expect(unauthed.feed.length).toBeGreaterThan(0) - expect(unauthed.feed).toEqual( - authed.feed.map((item) => { - const result = { - ...item, - post: stripViewerFromPost(item.post), - } - if (item.reply) { - result.reply = { - parent: stripViewerFromPost(item.reply.parent), - root: stripViewerFromPost(item.reply.root), - } - } - return result - }), - ) - }) - - it('blocked by actor takedown.', async () => { - const { data: preBlock } = await agent.api.app.bsky.feed.getAuthorFeed( - { actor: alice }, - { headers: await network.serviceHeaders(carol) }, - ) - - expect(preBlock.feed.length).toBeGreaterThan(0) - - await agent.api.com.atproto.admin.emitModerationEvent( - { - event: { $type: 'com.atproto.admin.defs#modEventTakedown' }, - subject: { - $type: 'com.atproto.admin.defs#repoRef', - did: alice, - }, - createdBy: 'did:example:admin', - reason: 'Y', - }, - { - encoding: 'application/json', - headers: network.pds.adminAuthHeaders(), - }, - ) - - const attempt = agent.api.app.bsky.feed.getAuthorFeed( - { actor: alice }, - { headers: await network.serviceHeaders(carol) }, - ) - await expect(attempt).rejects.toThrow('Profile not found') - - // Cleanup - await agent.api.com.atproto.admin.emitModerationEvent( - { - event: { $type: 'com.atproto.admin.defs#modEventReverseTakedown' }, - subject: { - $type: 'com.atproto.admin.defs#repoRef', - did: alice, - }, - createdBy: 'did:example:admin', - reason: 'Y', - }, - { - encoding: 'application/json', - headers: network.pds.adminAuthHeaders(), - }, - ) - }) - - it('blocked by record takedown.', async () => { - const { data: preBlock } = await agent.api.app.bsky.feed.getAuthorFeed( - { actor: alice }, - { headers: await network.serviceHeaders(carol) }, - ) - - expect(preBlock.feed.length).toBeGreaterThan(0) - - const post = preBlock.feed[0].post - - await agent.api.com.atproto.admin.emitModerationEvent( - { - event: { $type: 'com.atproto.admin.defs#modEventTakedown' }, - subject: { - $type: 'com.atproto.repo.strongRef', - uri: post.uri, - cid: post.cid, - }, - createdBy: 'did:example:admin', - reason: 'Y', - }, - { - encoding: 'application/json', - headers: network.pds.adminAuthHeaders(), - }, - ) - - const { data: postBlock } = await agent.api.app.bsky.feed.getAuthorFeed( - { actor: alice }, - { headers: await network.serviceHeaders(carol) }, - ) - - expect(postBlock.feed.length).toEqual(preBlock.feed.length - 1) - expect(postBlock.feed.map((item) => item.post.uri)).not.toContain(post.uri) - - // Cleanup - await agent.api.com.atproto.admin.emitModerationEvent( - { - event: { $type: 'com.atproto.admin.defs#modEventReverseTakedown' }, - subject: { - $type: 'com.atproto.repo.strongRef', - uri: post.uri, - cid: post.cid, - }, - createdBy: 'did:example:admin', - reason: 'Y', - }, - { - encoding: 'application/json', - headers: network.pds.adminAuthHeaders(), - }, - ) - }) - - it('can filter by posts_with_media', async () => { - const { data: carolFeed } = await agent.api.app.bsky.feed.getAuthorFeed({ - actor: carol, - filter: 'posts_with_media', - }) - - expect(carolFeed.feed.length).toBeGreaterThan(0) - expect( - carolFeed.feed.every(({ post }) => { - const isRecordWithActorMedia = - isEmbedRecordWithMedia(post.embed) && isImageEmbed(post.embed?.media) - const isActorMedia = isImageEmbed(post.embed) - const isFromActor = post.author.did === carol - - return (isRecordWithActorMedia || isActorMedia) && isFromActor - }), - ).toBeTruthy() - - const { data: bobFeed } = await agent.api.app.bsky.feed.getAuthorFeed({ - actor: bob, - filter: 'posts_with_media', - }) - - expect( - bobFeed.feed.every(({ post }) => { - return isImageEmbed(post.embed) && post.author.did === bob - }), - ).toBeTruthy() - - const { data: danFeed } = await agent.api.app.bsky.feed.getAuthorFeed({ - actor: dan, - filter: 'posts_with_media', - }) - - expect(danFeed.feed.length).toEqual(0) - }) - - it('filters by posts_no_replies', async () => { - const { data: carolFeed } = await agent.api.app.bsky.feed.getAuthorFeed({ - actor: carol, - filter: 'posts_no_replies', - }) - - expect( - carolFeed.feed.every(({ post }) => { - return ( - (isRecord(post.record) && !post.record.reply) || - (isRecord(post.record) && post.record.reply) - ) - }), - ).toBeTruthy() - - const { data: danFeed } = await agent.api.app.bsky.feed.getAuthorFeed({ - actor: dan, - filter: 'posts_no_replies', - }) - - expect( - danFeed.feed.every(({ post }) => { - return ( - (isRecord(post.record) && !post.record.reply) || - (isRecord(post.record) && post.record.reply) - ) - }), - ).toBeTruthy() - }) - - it('posts_and_author_threads includes self-replies', async () => { - const { data: eveFeed } = await agent.api.app.bsky.feed.getAuthorFeed({ - actor: eve, - filter: 'posts_and_author_threads', - }) - - expect(eveFeed.feed.length).toEqual(7) - expect( - eveFeed.feed.some(({ post }) => { - return ( - isRecord(post.record) && post.record.reply && post.author.did === eve - ) - }), - ).toBeTruthy() - }) -}) diff --git a/packages/ozone/tests/views/block-lists.test.ts b/packages/ozone/tests/views/block-lists.test.ts deleted file mode 100644 index 6672d690ce1..00000000000 --- a/packages/ozone/tests/views/block-lists.test.ts +++ /dev/null @@ -1,434 +0,0 @@ -import AtpAgent from '@atproto/api' -import { TestNetwork, SeedClient, RecordRef } from '@atproto/dev-env' -import { forSnapshot } from '../_util' -import basicSeed from '../seeds/basic' -import { BlockedActorError } from '@atproto/api/src/client/types/app/bsky/feed/getAuthorFeed' -import { BlockedByActorError } from '@atproto/api/src/client/types/app/bsky/feed/getAuthorFeed' - -describe('pds views with blocking from block lists', () => { - let network: TestNetwork - let agent: AtpAgent - let pdsAgent: AtpAgent - let sc: SeedClient - let aliceReplyToDan: { ref: RecordRef } - - let alice: string - let bob: string - let carol: string - let dan: string - - beforeAll(async () => { - network = await TestNetwork.create({ - dbPostgresSchema: 'views_block_lists', - }) - agent = network.bsky.getClient() - pdsAgent = network.pds.getClient() - sc = network.getSeedClient() - await basicSeed(sc) - alice = sc.dids.alice - bob = sc.dids.bob - carol = sc.dids.carol - dan = sc.dids.dan - // add follows to ensure blocks work even w follows - await sc.follow(carol, dan) - await sc.follow(dan, carol) - aliceReplyToDan = await sc.reply( - alice, - sc.posts[dan][0].ref, - sc.posts[dan][0].ref, - 'alice replies to dan', - ) - await network.processAll() - }) - - afterAll(async () => { - await network.close() - }) - - let listUri: string - - it('creates a list with some items', async () => { - const avatar = await sc.uploadFile( - alice, - 'tests/sample-img/key-portrait-small.jpg', - 'image/jpeg', - ) - // alice creates block list with bob & carol that dan uses - const list = await pdsAgent.api.app.bsky.graph.list.create( - { repo: alice }, - { - name: 'alice blocks', - purpose: 'app.bsky.graph.defs#modlist', - description: 'big list of blocks', - avatar: avatar.image, - createdAt: new Date().toISOString(), - }, - sc.getHeaders(alice), - ) - listUri = list.uri - await pdsAgent.api.app.bsky.graph.listitem.create( - { repo: alice }, - { - subject: sc.dids.bob, - list: list.uri, - createdAt: new Date().toISOString(), - }, - sc.getHeaders(alice), - ) - await pdsAgent.api.app.bsky.graph.listitem.create( - { repo: alice }, - { - subject: sc.dids.carol, - list: list.uri, - createdAt: new Date().toISOString(), - }, - sc.getHeaders(alice), - ) - await pdsAgent.api.app.bsky.graph.listitem.create( - { repo: alice }, - { - subject: sc.dids.dan, - list: list.uri, - createdAt: new Date().toISOString(), - }, - sc.getHeaders(alice), - ) - await network.processAll() - }) - - it('uses a list for blocks', async () => { - await pdsAgent.api.app.bsky.graph.listblock.create( - { repo: dan }, - { - subject: listUri, - createdAt: new Date().toISOString(), - }, - sc.getHeaders(dan), - ) - await network.processAll() - }) - - it('blocks thread post', async () => { - const { carol, dan } = sc.dids - const { data: threadAlice } = await agent.api.app.bsky.feed.getPostThread( - { depth: 1, uri: sc.posts[carol][0].ref.uriStr }, - { headers: await network.serviceHeaders(dan) }, - ) - expect(threadAlice.thread).toEqual( - expect.objectContaining({ - $type: 'app.bsky.feed.defs#blockedPost', - uri: sc.posts[carol][0].ref.uriStr, - blocked: true, - }), - ) - const { data: threadCarol } = await agent.api.app.bsky.feed.getPostThread( - { depth: 1, uri: sc.posts[dan][0].ref.uriStr }, - { headers: await network.serviceHeaders(carol) }, - ) - expect(threadCarol.thread).toEqual( - expect.objectContaining({ - $type: 'app.bsky.feed.defs#blockedPost', - uri: sc.posts[dan][0].ref.uriStr, - blocked: true, - }), - ) - }) - - it('blocks thread reply', async () => { - // Contains reply by carol - const { data: thread } = await agent.api.app.bsky.feed.getPostThread( - { depth: 1, uri: sc.posts[alice][1].ref.uriStr }, - { headers: await network.serviceHeaders(dan) }, - ) - expect(forSnapshot(thread)).toMatchSnapshot() - }) - - it('blocks thread parent', async () => { - // Parent is a post by dan - const { data: thread } = await agent.api.app.bsky.feed.getPostThread( - { depth: 1, uri: aliceReplyToDan.ref.uriStr }, - { headers: await network.serviceHeaders(carol) }, - ) - expect(forSnapshot(thread)).toMatchSnapshot() - }) - - it('blocks record embeds', async () => { - // Contains a deep embed of carol's post, blocked by dan - const { data: thread } = await agent.api.app.bsky.feed.getPostThread( - { depth: 0, uri: sc.posts[alice][2].ref.uriStr }, - { headers: await network.serviceHeaders(dan) }, - ) - expect(forSnapshot(thread)).toMatchSnapshot() - }) - - it('errors on getting author feed', async () => { - const attempt1 = agent.api.app.bsky.feed.getAuthorFeed( - { actor: carol }, - { headers: await network.serviceHeaders(dan) }, - ) - await expect(attempt1).rejects.toThrow(BlockedActorError) - - const attempt2 = agent.api.app.bsky.feed.getAuthorFeed( - { actor: dan }, - { headers: await network.serviceHeaders(carol) }, - ) - await expect(attempt2).rejects.toThrow(BlockedByActorError) - }) - - it('strips blocked users out of getTimeline', async () => { - const resCarol = await agent.api.app.bsky.feed.getTimeline( - { limit: 100 }, - { headers: await network.serviceHeaders(carol) }, - ) - expect( - resCarol.data.feed.some((post) => post.post.author.did === dan), - ).toBeFalsy() - - const resDan = await agent.api.app.bsky.feed.getTimeline( - { limit: 100 }, - { headers: await network.serviceHeaders(dan) }, - ) - expect( - resDan.data.feed.some((post) => - [bob, carol].includes(post.post.author.did), - ), - ).toBeFalsy() - }) - - it('returns block status on getProfile', async () => { - const resCarol = await agent.api.app.bsky.actor.getProfile( - { actor: dan }, - { headers: await network.serviceHeaders(carol) }, - ) - expect(resCarol.data.viewer?.blocking).toBeUndefined() - expect(resCarol.data.viewer?.blockingByList).toBeUndefined() - expect(resCarol.data.viewer?.blockedBy).toBe(true) - - const resDan = await agent.api.app.bsky.actor.getProfile( - { actor: carol }, - { headers: await network.serviceHeaders(dan) }, - ) - expect(resDan.data.viewer?.blocking).toBeDefined() - expect(resDan.data.viewer?.blockingByList?.uri).toEqual( - resDan.data.viewer?.blocking, - ) - expect(resDan.data.viewer?.blockedBy).toBe(false) - }) - - it('returns block status on getProfiles', async () => { - const resCarol = await agent.api.app.bsky.actor.getProfiles( - { actors: [alice, dan] }, - { headers: await network.serviceHeaders(carol) }, - ) - expect(resCarol.data.profiles[0].viewer?.blocking).toBeUndefined() - expect(resCarol.data.profiles[0].viewer?.blockingByList).toBeUndefined() - expect(resCarol.data.profiles[0].viewer?.blockedBy).toBe(false) - expect(resCarol.data.profiles[1].viewer?.blocking).toBeUndefined() - expect(resCarol.data.profiles[1].viewer?.blockingByList).toBeUndefined() - expect(resCarol.data.profiles[1].viewer?.blockedBy).toBe(true) - - const resDan = await agent.api.app.bsky.actor.getProfiles( - { actors: [alice, carol] }, - { headers: await network.serviceHeaders(dan) }, - ) - expect(resDan.data.profiles[0].viewer?.blocking).toBeUndefined() - expect(resDan.data.profiles[0].viewer?.blockingByList).toBeUndefined() - expect(resDan.data.profiles[0].viewer?.blockedBy).toBe(false) - expect(resDan.data.profiles[1].viewer?.blocking).toBeDefined() - expect(resDan.data.profiles[1].viewer?.blockingByList?.uri).toEqual( - resDan.data.profiles[1].viewer?.blocking, - ) - expect(resDan.data.profiles[1].viewer?.blockedBy).toBe(false) - }) - - it('ignores self-blocks', async () => { - const res = await agent.api.app.bsky.actor.getProfile( - { actor: dan }, // dan subscribes to list that contains himself - { headers: await network.serviceHeaders(dan) }, - ) - expect(res.data.viewer?.blocking).toBeUndefined() - expect(res.data.viewer?.blockingByList).toBeUndefined() - expect(res.data.viewer?.blockedBy).toBe(false) - }) - - it('does not return notifs for blocked accounts', async () => { - const resCarol = await agent.api.app.bsky.notification.listNotifications( - { - limit: 100, - }, - { headers: await network.serviceHeaders(carol) }, - ) - expect( - resCarol.data.notifications.some((notif) => notif.author.did === dan), - ).toBeFalsy() - - const resDan = await agent.api.app.bsky.notification.listNotifications( - { - limit: 100, - }, - { headers: await network.serviceHeaders(carol) }, - ) - expect( - resDan.data.notifications.some((notif) => notif.author.did === carol), - ).toBeFalsy() - }) - - it('does not return blocked accounts in actor search', async () => { - const resCarol = await agent.api.app.bsky.actor.searchActors( - { - term: 'dan.test', - }, - { headers: await network.serviceHeaders(carol) }, - ) - expect(resCarol.data.actors.some((actor) => actor.did === dan)).toBeFalsy() - - const resDan = await agent.api.app.bsky.actor.searchActors( - { - term: 'carol.test', - }, - { headers: await network.serviceHeaders(dan) }, - ) - expect(resDan.data.actors.some((actor) => actor.did === carol)).toBeFalsy() - }) - - it('does not return blocked accounts in actor search typeahead', 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)).toBeFalsy() - - 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)).toBeFalsy() - }) - - 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) - await sc.unfollow(dan, carol) - await network.processAll() - - const resCarol = await agent.api.app.bsky.actor.getSuggestions( - { - limit: 100, - }, - { headers: await network.serviceHeaders(carol) }, - ) - expect(resCarol.data.actors.some((actor) => actor.did === dan)).toBeFalsy() - - const resDan = await agent.api.app.bsky.actor.getSuggestions( - { - limit: 100, - }, - { headers: await network.serviceHeaders(dan) }, - ) - expect(resDan.data.actors.some((actor) => actor.did === carol)).toBeFalsy() - }) - - it('returns the contents of a list', async () => { - const res = await agent.api.app.bsky.graph.getList( - { list: listUri }, - { headers: await network.serviceHeaders(dan) }, - ) - expect(forSnapshot(res.data)).toMatchSnapshot() - }) - - it('paginates getList', async () => { - const full = await agent.api.app.bsky.graph.getList( - { list: listUri }, - { headers: await network.serviceHeaders(dan) }, - ) - const first = await agent.api.app.bsky.graph.getList( - { list: listUri, limit: 1 }, - { headers: await network.serviceHeaders(dan) }, - ) - const second = await agent.api.app.bsky.graph.getList( - { list: listUri, cursor: first.data.cursor }, - { headers: await network.serviceHeaders(dan) }, - ) - const combined = [...first.data.items, ...second.data.items] - expect(combined).toEqual(full.data.items) - }) - - let otherListUri: string - - it('returns lists associated with a user', async () => { - const listRes = await pdsAgent.api.app.bsky.graph.list.create( - { repo: alice }, - { - name: 'new list', - purpose: 'app.bsky.graph.defs#modlist', - description: 'blah blah', - createdAt: new Date().toISOString(), - }, - sc.getHeaders(alice), - ) - otherListUri = listRes.uri - await network.processAll() - - const res = await agent.api.app.bsky.graph.getLists( - { actor: alice }, - { headers: await network.serviceHeaders(dan) }, - ) - expect(forSnapshot(res.data)).toMatchSnapshot() - }) - - it('paginates getLists', async () => { - const full = await agent.api.app.bsky.graph.getLists( - { actor: alice }, - { headers: await network.serviceHeaders(dan) }, - ) - const first = await agent.api.app.bsky.graph.getLists( - { actor: alice, limit: 1 }, - { headers: await network.serviceHeaders(dan) }, - ) - const second = await agent.api.app.bsky.graph.getLists( - { actor: alice, cursor: first.data.cursor }, - { headers: await network.serviceHeaders(dan) }, - ) - const combined = [...first.data.lists, ...second.data.lists] - expect(combined).toEqual(full.data.lists) - }) - - it('returns a users own list blocks', async () => { - await pdsAgent.api.app.bsky.graph.listblock.create( - { repo: dan }, - { - subject: otherListUri, - createdAt: new Date().toISOString(), - }, - sc.getHeaders(dan), - ) - await network.processAll() - - const res = await agent.api.app.bsky.graph.getListBlocks( - {}, - { headers: await network.serviceHeaders(dan) }, - ) - expect(forSnapshot(res.data)).toMatchSnapshot() - }) - - it('paginates getListBlocks', async () => { - const full = await agent.api.app.bsky.graph.getListBlocks( - {}, - { headers: await network.serviceHeaders(dan) }, - ) - const first = await agent.api.app.bsky.graph.getListBlocks( - { limit: 1 }, - { headers: await network.serviceHeaders(dan) }, - ) - const second = await agent.api.app.bsky.graph.getListBlocks( - { cursor: first.data.cursor }, - { headers: await network.serviceHeaders(dan) }, - ) - const combined = [...first.data.lists, ...second.data.lists] - expect(combined).toEqual(full.data.lists) - }) -}) diff --git a/packages/ozone/tests/views/blocks.test.ts b/packages/ozone/tests/views/blocks.test.ts deleted file mode 100644 index 5d344a823d9..00000000000 --- a/packages/ozone/tests/views/blocks.test.ts +++ /dev/null @@ -1,542 +0,0 @@ -import assert from 'assert' -import { TestNetwork, RecordRef, SeedClient } from '@atproto/dev-env' -import AtpAgent, { AtUri } from '@atproto/api' -import { BlockedActorError } from '@atproto/api/src/client/types/app/bsky/feed/getAuthorFeed' -import { BlockedByActorError } from '@atproto/api/src/client/types/app/bsky/feed/getAuthorFeed' -import { isThreadViewPost } from '@atproto/api/src/client/types/app/bsky/feed/defs' -import { - isViewRecord as isEmbedViewRecord, - isViewBlocked as isEmbedViewBlocked, -} from '@atproto/api/src/client/types/app/bsky/embed/record' -import { forSnapshot } from '../_util' -import basicSeed from '../seeds/basic' - -describe('pds views with blocking', () => { - let network: TestNetwork - let agent: AtpAgent - let pdsAgent: AtpAgent - let sc: SeedClient - let danBlockCarol: { uri: string } - let aliceReplyToDan: { ref: RecordRef } - let carolReplyToDan: { ref: RecordRef } - - let alice: string - let carol: string - let dan: string - let danBlockUri: string - - beforeAll(async () => { - network = await TestNetwork.create({ - dbPostgresSchema: 'bsky_views_block', - }) - agent = network.bsky.getClient() - pdsAgent = network.pds.getClient() - sc = network.getSeedClient() - await basicSeed(sc) - alice = sc.dids.alice - carol = sc.dids.carol - dan = sc.dids.dan - // add follows to ensure blocks work even w follows - await sc.follow(carol, dan) - await sc.follow(dan, carol) - aliceReplyToDan = await sc.reply( - alice, - sc.posts[dan][0].ref, - sc.posts[dan][0].ref, - 'alice replies to dan', - ) - carolReplyToDan = await sc.reply( - carol, - sc.posts[dan][0].ref, - sc.posts[dan][0].ref, - 'carol replies to dan', - ) - // dan blocks carol - danBlockCarol = await pdsAgent.api.app.bsky.graph.block.create( - { repo: dan }, - { createdAt: new Date().toISOString(), subject: carol }, - sc.getHeaders(dan), - ) - danBlockUri = danBlockCarol.uri - await network.processAll() - }) - - afterAll(async () => { - await network.close() - }) - - it('blocks thread post', async () => { - const { data: threadAlice } = await agent.api.app.bsky.feed.getPostThread( - { depth: 1, uri: sc.posts[carol][0].ref.uriStr }, - { headers: await network.serviceHeaders(dan) }, - ) - expect(threadAlice).toEqual({ - thread: { - $type: 'app.bsky.feed.defs#blockedPost', - uri: sc.posts[carol][0].ref.uriStr, - blocked: true, - author: { - did: carol, - viewer: { - blockedBy: false, - blocking: danBlockUri, - }, - }, - }, - }) - const { data: threadCarol } = await agent.api.app.bsky.feed.getPostThread( - { depth: 1, uri: sc.posts[dan][0].ref.uriStr }, - { headers: await network.serviceHeaders(carol) }, - ) - expect(threadCarol).toEqual({ - thread: { - $type: 'app.bsky.feed.defs#blockedPost', - uri: sc.posts[dan][0].ref.uriStr, - blocked: true, - author: { - did: dan, - viewer: { - blockedBy: true, - }, - }, - }, - }) - }) - - it('blocks thread reply', async () => { - // Contains reply by carol - const { data: thread } = await agent.api.app.bsky.feed.getPostThread( - { depth: 1, uri: sc.posts[alice][1].ref.uriStr }, - { headers: await network.serviceHeaders(dan) }, - ) - expect(forSnapshot(thread)).toMatchSnapshot() - }) - - it('blocks thread parent', async () => { - // Parent is a post by dan - const { data: thread } = await agent.api.app.bsky.feed.getPostThread( - { depth: 1, uri: aliceReplyToDan.ref.uriStr }, - { headers: await network.serviceHeaders(carol) }, - ) - expect(forSnapshot(thread)).toMatchSnapshot() - }) - - it('blocks record embeds', async () => { - // Contains a deep embed of carol's post, blocked by dan - const { data: thread } = await agent.api.app.bsky.feed.getPostThread( - { depth: 0, uri: sc.posts[alice][2].ref.uriStr }, - { headers: await network.serviceHeaders(dan) }, - ) - expect(forSnapshot(thread)).toMatchSnapshot() - }) - - it('errors on getting author feed', async () => { - const attempt1 = agent.api.app.bsky.feed.getAuthorFeed( - { actor: carol }, - { headers: await network.serviceHeaders(dan) }, - ) - await expect(attempt1).rejects.toThrow(BlockedActorError) - - const attempt2 = agent.api.app.bsky.feed.getAuthorFeed( - { actor: dan }, - { headers: await network.serviceHeaders(carol) }, - ) - await expect(attempt2).rejects.toThrow(BlockedByActorError) - }) - - it('strips blocked users out of getTimeline', async () => { - const resCarol = await agent.api.app.bsky.feed.getTimeline( - { limit: 100 }, - { headers: await network.serviceHeaders(carol) }, - ) - expect( - resCarol.data.feed.some((post) => post.post.author.did === dan), - ).toBeFalsy() - - const resDan = await agent.api.app.bsky.feed.getTimeline( - { limit: 100 }, - { headers: await network.serviceHeaders(dan) }, - ) - expect( - resDan.data.feed.some((post) => post.post.author.did === carol), - ).toBeFalsy() - }) - - it('strips blocked users out of getListFeed', async () => { - const listRef = await sc.createList(alice, 'test list', 'curate') - await sc.addToList(alice, alice, listRef) - await sc.addToList(alice, carol, listRef) - await sc.addToList(alice, dan, listRef) - - const resCarol = await agent.api.app.bsky.feed.getListFeed( - { list: listRef.uriStr, limit: 100 }, - { headers: await network.serviceHeaders(carol) }, - ) - expect( - resCarol.data.feed.some((post) => post.post.author.did === dan), - ).toBeFalsy() - - const resDan = await agent.api.app.bsky.feed.getListFeed( - { list: listRef.uriStr, limit: 100 }, - { headers: await network.serviceHeaders(dan) }, - ) - expect( - resDan.data.feed.some((post) => post.post.author.did === carol), - ).toBeFalsy() - }) - - it('returns block status on getProfile', async () => { - const resCarol = await agent.api.app.bsky.actor.getProfile( - { actor: dan }, - { headers: await network.serviceHeaders(carol) }, - ) - expect(resCarol.data.viewer?.blocking).toBeUndefined() - expect(resCarol.data.viewer?.blockedBy).toBe(true) - - const resDan = await agent.api.app.bsky.actor.getProfile( - { actor: carol }, - { headers: await network.serviceHeaders(dan) }, - ) - expect(resDan.data.viewer?.blocking).toBeDefined() - expect(resDan.data.viewer?.blockedBy).toBe(false) - }) - - it('unsets viewer follow state when blocked', async () => { - // there are follows between carol and dan - const { data: profile } = await agent.api.app.bsky.actor.getProfile( - { actor: carol }, - { headers: await network.serviceHeaders(dan) }, - ) - expect(profile.viewer?.following).toBeUndefined() - expect(profile.viewer?.followedBy).toBeUndefined() - const { data: result } = await agent.api.app.bsky.graph.getBlocks( - {}, - { headers: await network.serviceHeaders(dan) }, - ) - const blocked = result.blocks.find((block) => block.did === carol) - expect(blocked).toBeDefined() - expect(blocked?.viewer?.following).toBeUndefined() - expect(blocked?.viewer?.followedBy).toBeUndefined() - }) - - it('returns block status on getProfiles', async () => { - const resCarol = await agent.api.app.bsky.actor.getProfiles( - { actors: [alice, dan] }, - { headers: await network.serviceHeaders(carol) }, - ) - expect(resCarol.data.profiles[0].viewer?.blocking).toBeUndefined() - expect(resCarol.data.profiles[0].viewer?.blockingByList).toBeUndefined() - expect(resCarol.data.profiles[0].viewer?.blockedBy).toBe(false) - expect(resCarol.data.profiles[1].viewer?.blocking).toBeUndefined() - expect(resCarol.data.profiles[1].viewer?.blockingByList).toBeUndefined() - expect(resCarol.data.profiles[1].viewer?.blockedBy).toBe(true) - - const resDan = await agent.api.app.bsky.actor.getProfiles( - { actors: [alice, carol] }, - { headers: await network.serviceHeaders(dan) }, - ) - expect(resDan.data.profiles[0].viewer?.blocking).toBeUndefined() - expect(resDan.data.profiles[0].viewer?.blockingByList).toBeUndefined() - expect(resDan.data.profiles[0].viewer?.blockedBy).toBe(false) - expect(resDan.data.profiles[1].viewer?.blocking).toBeDefined() - expect(resDan.data.profiles[1].viewer?.blockingByList).toBeUndefined() - expect(resDan.data.profiles[1].viewer?.blockedBy).toBe(false) - }) - - it('does not return block violating follows', async () => { - const resCarol = await agent.api.app.bsky.graph.getFollows( - { actor: carol }, - { headers: await network.serviceHeaders(alice) }, - ) - expect(resCarol.data.follows.some((f) => f.did === dan)).toBe(false) - - const resDan = await agent.api.app.bsky.graph.getFollows( - { actor: dan }, - { headers: await network.serviceHeaders(alice) }, - ) - expect(resDan.data.follows.some((f) => f.did === carol)).toBe(false) - }) - - it('does not return block violating followers', async () => { - const resCarol = await agent.api.app.bsky.graph.getFollowers( - { actor: carol }, - { headers: await network.serviceHeaders(alice) }, - ) - expect(resCarol.data.followers.some((f) => f.did === dan)).toBe(false) - - const resDan = await agent.api.app.bsky.graph.getFollowers( - { actor: dan }, - { headers: await network.serviceHeaders(alice) }, - ) - expect(resDan.data.followers.some((f) => f.did === carol)).toBe(false) - }) - - it('does not return posts from blocked users', async () => { - const alicePost = sc.posts[alice][0].ref.uriStr - const carolPost = sc.posts[carol][0].ref.uriStr - const danPost = sc.posts[dan][0].ref.uriStr - - const resCarol = await agent.api.app.bsky.feed.getPosts( - { uris: [alicePost, carolPost, danPost] }, - { headers: await network.serviceHeaders(carol) }, - ) - expect(resCarol.data.posts.some((p) => p.uri === alicePost)).toBe(true) - expect(resCarol.data.posts.some((p) => p.uri === carolPost)).toBe(true) - expect(resCarol.data.posts.some((p) => p.uri === danPost)).toBe(false) - - const resDan = await agent.api.app.bsky.feed.getPosts( - { uris: [alicePost, carolPost, danPost] }, - { headers: await network.serviceHeaders(dan) }, - ) - expect(resDan.data.posts.some((p) => p.uri === alicePost)).toBe(true) - expect(resDan.data.posts.some((p) => p.uri === carolPost)).toBe(false) - expect(resDan.data.posts.some((p) => p.uri === danPost)).toBe(true) - }) - - it('does not return notifs for blocked accounts', async () => { - const resCarol = await agent.api.app.bsky.notification.listNotifications( - { - limit: 100, - }, - { headers: await network.serviceHeaders(carol) }, - ) - expect( - resCarol.data.notifications.some((notif) => notif.author.did === dan), - ).toBeFalsy() - - const resDan = await agent.api.app.bsky.notification.listNotifications( - { - limit: 100, - }, - { headers: await network.serviceHeaders(dan) }, - ) - expect( - resDan.data.notifications.some((notif) => notif.author.did === carol), - ).toBeFalsy() - }) - - it('does not return blocked accounts in actor search', async () => { - const resCarol = await agent.api.app.bsky.actor.searchActors( - { - term: 'dan.test', - }, - { headers: await network.serviceHeaders(carol) }, - ) - expect(resCarol.data.actors.some((actor) => actor.did === dan)).toBeFalsy() - - const resDan = await agent.api.app.bsky.actor.searchActors( - { - term: 'carol.test', - }, - { headers: await network.serviceHeaders(dan) }, - ) - expect(resDan.data.actors.some((actor) => actor.did === carol)).toBeFalsy() - }) - - it('does not return blocked accounts in actor search typeahead', 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)).toBeFalsy() - - 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)).toBeFalsy() - }) - - 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) - await sc.unfollow(dan, carol) - await network.processAll() - - const resCarol = await agent.api.app.bsky.actor.getSuggestions( - { - limit: 100, - }, - { headers: await network.serviceHeaders(carol) }, - ) - expect(resCarol.data.actors.some((actor) => actor.did === dan)).toBeFalsy() - - const resDan = await agent.api.app.bsky.actor.getSuggestions( - { - limit: 100, - }, - { headers: await network.serviceHeaders(dan) }, - ) - expect(resDan.data.actors.some((actor) => actor.did === carol)).toBeFalsy() - }) - - it('does not serve blocked replies', async () => { - const getThreadPostUri = (r) => r?.['post']?.['uri'] - // reply then block - const { data: replyThenBlock } = - await agent.api.app.bsky.feed.getPostThread( - { depth: 1, uri: sc.posts[dan][0].ref.uriStr }, - { headers: await network.serviceHeaders(alice) }, - ) - assert(isThreadViewPost(replyThenBlock.thread)) - expect(replyThenBlock.thread.replies?.map(getThreadPostUri)).toEqual([ - aliceReplyToDan.ref.uriStr, - ]) - - // unblock - await pdsAgent.api.app.bsky.graph.block.delete( - { repo: dan, rkey: new AtUri(danBlockCarol.uri).rkey }, - sc.getHeaders(dan), - ) - await network.processAll() - const { data: unblock } = await agent.api.app.bsky.feed.getPostThread( - { depth: 1, uri: sc.posts[dan][0].ref.uriStr }, - { headers: await network.serviceHeaders(alice) }, - ) - assert(isThreadViewPost(unblock.thread)) - expect(unblock.thread.replies?.map(getThreadPostUri)).toEqual([ - carolReplyToDan.ref.uriStr, - aliceReplyToDan.ref.uriStr, - ]) - - // block then reply - danBlockCarol = await pdsAgent.api.app.bsky.graph.block.create( - { repo: dan }, - { createdAt: new Date().toISOString(), subject: carol }, - sc.getHeaders(dan), - ) - const carolReplyToDan2 = await sc.reply( - carol, - sc.posts[dan][1].ref, - sc.posts[dan][1].ref, - 'carol replies to dan again', - ) - await network.processAll() - const { data: blockThenReply } = - await agent.api.app.bsky.feed.getPostThread( - { depth: 1, uri: sc.posts[dan][0].ref.uriStr }, - { headers: await network.serviceHeaders(alice) }, - ) - assert(isThreadViewPost(blockThenReply.thread)) - expect(replyThenBlock.thread.replies?.map(getThreadPostUri)).toEqual([ - aliceReplyToDan.ref.uriStr, - ]) - - // cleanup - await pdsAgent.api.app.bsky.feed.post.delete( - { repo: carol, rkey: carolReplyToDan2.ref.uri.rkey }, - sc.getHeaders(carol), - ) - await network.processAll() - }) - - it('does not serve blocked embeds to third-party', async () => { - // embed then block - const { data: embedThenBlock } = - await agent.api.app.bsky.feed.getPostThread( - { depth: 0, uri: sc.posts[dan][1].ref.uriStr }, - { headers: await network.serviceHeaders(alice) }, - ) - assert(isThreadViewPost(embedThenBlock.thread)) - assert(isEmbedViewBlocked(embedThenBlock.thread.post.embed?.record)) - - // unblock - await pdsAgent.api.app.bsky.graph.block.delete( - { repo: dan, rkey: new AtUri(danBlockCarol.uri).rkey }, - sc.getHeaders(dan), - ) - await network.processAll() - const { data: unblock } = await agent.api.app.bsky.feed.getPostThread( - { depth: 0, uri: sc.posts[dan][1].ref.uriStr }, - { headers: await network.serviceHeaders(alice) }, - ) - assert(isThreadViewPost(unblock.thread)) - assert(isEmbedViewRecord(unblock.thread.post.embed?.record)) - - // block then embed - danBlockCarol = await pdsAgent.api.app.bsky.graph.block.create( - { repo: dan }, - { createdAt: new Date().toISOString(), subject: carol }, - sc.getHeaders(dan), - ) - const carolEmbedsDan = await sc.post( - carol, - 'carol embeds dan', - undefined, - undefined, - sc.posts[dan][0].ref, - ) - await network.processAll() - const { data: blockThenEmbed } = - await agent.api.app.bsky.feed.getPostThread( - { depth: 0, uri: carolEmbedsDan.ref.uriStr }, - { headers: await network.serviceHeaders(alice) }, - ) - assert(isThreadViewPost(blockThenEmbed.thread)) - assert(isEmbedViewBlocked(blockThenEmbed.thread.post.embed?.record)) - - // cleanup - await pdsAgent.api.app.bsky.feed.post.delete( - { repo: carol, rkey: carolEmbedsDan.ref.uri.rkey }, - sc.getHeaders(carol), - ) - await network.processAll() - }) - - it('applies third-party blocking rules in feeds.', async () => { - // alice follows carol and dan, block exists between carol and dan. - const replyBlockedUri = carolReplyToDan.ref.uriStr - const embedBlockedUri = sc.posts[dan][1].ref.uriStr - const { data: timeline } = await agent.api.app.bsky.feed.getTimeline( - { limit: 100 }, - { headers: await network.serviceHeaders(alice) }, - ) - const replyBlockedPost = timeline.feed.find( - (item) => item.post.uri === replyBlockedUri, - ) - expect(replyBlockedPost).toBeUndefined() - const embedBlockedPost = timeline.feed.find( - (item) => item.post.uri === embedBlockedUri, - ) - assert(embedBlockedPost) - assert(isEmbedViewBlocked(embedBlockedPost.post.embed?.record)) - }) - - it('returns a list of blocks', async () => { - await pdsAgent.api.app.bsky.graph.block.create( - { repo: dan }, - { createdAt: new Date().toISOString(), subject: alice }, - sc.getHeaders(dan), - ) - - await network.processAll() - - const res = await agent.api.app.bsky.graph.getBlocks( - {}, - { headers: await network.serviceHeaders(dan) }, - ) - const dids = res.data.blocks.map((block) => block.did).sort() - expect(dids).toEqual([alice, carol].sort()) - }) - - it('paginates getBlocks', async () => { - const full = await agent.api.app.bsky.graph.getBlocks( - {}, - { headers: await network.serviceHeaders(dan) }, - ) - const first = await agent.api.app.bsky.graph.getBlocks( - { limit: 1 }, - { headers: await network.serviceHeaders(dan) }, - ) - const second = await agent.api.app.bsky.graph.getBlocks( - { cursor: first.data.cursor }, - { headers: await network.serviceHeaders(dan) }, - ) - const combined = [...first.data.blocks, ...second.data.blocks] - expect(combined).toEqual(full.data.blocks) - }) -}) diff --git a/packages/ozone/tests/views/follows.test.ts b/packages/ozone/tests/views/follows.test.ts deleted file mode 100644 index f290ec622d5..00000000000 --- a/packages/ozone/tests/views/follows.test.ts +++ /dev/null @@ -1,296 +0,0 @@ -import AtpAgent from '@atproto/api' -import { TestNetwork, SeedClient } from '@atproto/dev-env' -import { forSnapshot, paginateAll, stripViewer } from '../_util' -import followsSeed from '../seeds/follows' - -describe('pds follow views', () => { - let agent: AtpAgent - let network: TestNetwork - let sc: SeedClient - - // account dids, for convenience - let alice: string - - beforeAll(async () => { - network = await TestNetwork.create({ - dbPostgresSchema: 'bsky_views_follows', - }) - agent = network.bsky.getClient() - sc = network.getSeedClient() - await followsSeed(sc) - await network.processAll() - await network.bsky.processAll() - alice = sc.dids.alice - }) - - afterAll(async () => { - await network.close() - }) - - // TODO(bsky) blocks followers by actor takedown via labels - // TODO(bsky) blocks follows by actor takedown via labels - - it('fetches followers', async () => { - const aliceFollowers = await agent.api.app.bsky.graph.getFollowers( - { actor: sc.dids.alice }, - { headers: await network.serviceHeaders(alice) }, - ) - - expect(forSnapshot(aliceFollowers.data)).toMatchSnapshot() - - const bobFollowers = await agent.api.app.bsky.graph.getFollowers( - { actor: sc.dids.bob }, - { headers: await network.serviceHeaders(alice) }, - ) - - expect(forSnapshot(bobFollowers.data)).toMatchSnapshot() - - const carolFollowers = await agent.api.app.bsky.graph.getFollowers( - { actor: sc.dids.carol }, - { headers: await network.serviceHeaders(alice) }, - ) - - expect(forSnapshot(carolFollowers.data)).toMatchSnapshot() - - const danFollowers = await agent.api.app.bsky.graph.getFollowers( - { actor: sc.dids.dan }, - { headers: await network.serviceHeaders(alice) }, - ) - - expect(forSnapshot(danFollowers.data)).toMatchSnapshot() - - const eveFollowers = await agent.api.app.bsky.graph.getFollowers( - { actor: sc.dids.eve }, - { headers: await network.serviceHeaders(alice) }, - ) - - expect(forSnapshot(eveFollowers.data)).toMatchSnapshot() - }) - - it('fetches followers by handle', async () => { - const byDid = await agent.api.app.bsky.graph.getFollowers( - { actor: sc.dids.alice }, - { headers: await network.serviceHeaders(alice) }, - ) - const byHandle = await agent.api.app.bsky.graph.getFollowers( - { actor: sc.accounts[alice].handle }, - { headers: await network.serviceHeaders(alice) }, - ) - expect(byHandle.data).toEqual(byDid.data) - }) - - it('paginates followers', async () => { - const results = (results) => results.flatMap((res) => res.followers) - const paginator = async (cursor?: string) => { - const res = await agent.api.app.bsky.graph.getFollowers( - { - actor: sc.dids.alice, - cursor, - limit: 2, - }, - { headers: await network.serviceHeaders(alice) }, - ) - return res.data - } - - const paginatedAll = await paginateAll(paginator) - paginatedAll.forEach((res) => - expect(res.followers.length).toBeLessThanOrEqual(2), - ) - - const full = await agent.api.app.bsky.graph.getFollowers( - { actor: sc.dids.alice }, - { headers: await network.serviceHeaders(alice) }, - ) - - expect(full.data.followers.length).toEqual(4) - expect(results(paginatedAll)).toEqual(results([full.data])) - }) - - it('fetches followers unauthed', async () => { - const { data: authed } = await agent.api.app.bsky.graph.getFollowers( - { actor: sc.dids.alice }, - { headers: await network.serviceHeaders(alice) }, - ) - const { data: unauthed } = await agent.api.app.bsky.graph.getFollowers({ - actor: sc.dids.alice, - }) - expect(unauthed.followers.length).toBeGreaterThan(0) - expect(unauthed.followers).toEqual(authed.followers.map(stripViewer)) - }) - - it('blocks followers by actor takedown', async () => { - await agent.api.com.atproto.admin.emitModerationEvent( - { - event: { $type: 'com.atproto.admin.defs#modEventTakedown' }, - subject: { - $type: 'com.atproto.admin.defs#repoRef', - did: sc.dids.dan, - }, - createdBy: 'did:example:admin', - reason: 'Y', - }, - { - encoding: 'application/json', - headers: network.pds.adminAuthHeaders(), - }, - ) - - const aliceFollowers = await agent.api.app.bsky.graph.getFollowers( - { actor: sc.dids.alice }, - { headers: await network.serviceHeaders(alice) }, - ) - - expect(aliceFollowers.data.followers.map((f) => f.did)).not.toContain( - sc.dids.dan, - ) - - await agent.api.com.atproto.admin.emitModerationEvent( - { - event: { $type: 'com.atproto.admin.defs#modEventReverseTakedown' }, - subject: { - $type: 'com.atproto.admin.defs#repoRef', - did: sc.dids.dan, - }, - createdBy: 'did:example:admin', - reason: 'Y', - }, - { - encoding: 'application/json', - headers: network.pds.adminAuthHeaders(), - }, - ) - }) - - it('fetches follows', async () => { - const aliceFollowers = await agent.api.app.bsky.graph.getFollows( - { actor: sc.dids.alice }, - { headers: await network.serviceHeaders(alice) }, - ) - - expect(forSnapshot(aliceFollowers.data)).toMatchSnapshot() - - const bobFollowers = await agent.api.app.bsky.graph.getFollows( - { actor: sc.dids.bob }, - { headers: await network.serviceHeaders(alice) }, - ) - - expect(forSnapshot(bobFollowers.data)).toMatchSnapshot() - - const carolFollowers = await agent.api.app.bsky.graph.getFollows( - { actor: sc.dids.carol }, - { headers: await network.serviceHeaders(alice) }, - ) - - expect(forSnapshot(carolFollowers.data)).toMatchSnapshot() - - const danFollowers = await agent.api.app.bsky.graph.getFollows( - { actor: sc.dids.dan }, - { headers: await network.serviceHeaders(alice) }, - ) - - expect(forSnapshot(danFollowers.data)).toMatchSnapshot() - - const eveFollowers = await agent.api.app.bsky.graph.getFollows( - { actor: sc.dids.eve }, - { headers: await network.serviceHeaders(alice) }, - ) - - expect(forSnapshot(eveFollowers.data)).toMatchSnapshot() - }) - - it('fetches follows by handle', async () => { - const byDid = await agent.api.app.bsky.graph.getFollows( - { actor: sc.dids.alice }, - { headers: await network.serviceHeaders(alice) }, - ) - const byHandle = await agent.api.app.bsky.graph.getFollows( - { actor: sc.accounts[alice].handle }, - { headers: await network.serviceHeaders(alice) }, - ) - expect(byHandle.data).toEqual(byDid.data) - }) - - it('paginates follows', async () => { - const results = (results) => results.flatMap((res) => res.follows) - const paginator = async (cursor?: string) => { - const res = await agent.api.app.bsky.graph.getFollows( - { - actor: sc.dids.alice, - cursor, - limit: 2, - }, - { headers: await network.serviceHeaders(alice) }, - ) - return res.data - } - - const paginatedAll = await paginateAll(paginator) - paginatedAll.forEach((res) => - expect(res.follows.length).toBeLessThanOrEqual(2), - ) - - const full = await agent.api.app.bsky.graph.getFollows( - { actor: sc.dids.alice }, - { headers: await network.serviceHeaders(alice) }, - ) - - expect(full.data.follows.length).toEqual(4) - expect(results(paginatedAll)).toEqual(results([full.data])) - }) - - it('fetches follows unauthed', async () => { - const { data: authed } = await agent.api.app.bsky.graph.getFollows( - { actor: sc.dids.alice }, - { headers: await network.serviceHeaders(alice) }, - ) - const { data: unauthed } = await agent.api.app.bsky.graph.getFollows({ - actor: sc.dids.alice, - }) - expect(unauthed.follows.length).toBeGreaterThan(0) - expect(unauthed.follows).toEqual(authed.follows.map(stripViewer)) - }) - - it('blocks follows by actor takedown', async () => { - await agent.api.com.atproto.admin.emitModerationEvent( - { - event: { $type: 'com.atproto.admin.defs#modEventTakedown' }, - subject: { - $type: 'com.atproto.admin.defs#repoRef', - did: sc.dids.dan, - }, - createdBy: 'did:example:admin', - reason: 'Y', - }, - { - encoding: 'application/json', - headers: network.pds.adminAuthHeaders(), - }, - ) - - const aliceFollows = await agent.api.app.bsky.graph.getFollows( - { actor: sc.dids.alice }, - { headers: await network.serviceHeaders(alice) }, - ) - - expect(aliceFollows.data.follows.map((f) => f.did)).not.toContain( - sc.dids.dan, - ) - - await agent.api.com.atproto.admin.emitModerationEvent( - { - event: { $type: 'com.atproto.admin.defs#modEventReverseTakedown' }, - subject: { - $type: 'com.atproto.admin.defs#repoRef', - did: sc.dids.dan, - }, - createdBy: 'did:example:admin', - reason: 'Y', - }, - { - encoding: 'application/json', - headers: network.pds.adminAuthHeaders(), - }, - ) - }) -}) diff --git a/packages/ozone/tests/views/likes.test.ts b/packages/ozone/tests/views/likes.test.ts deleted file mode 100644 index f8f9c9a7fef..00000000000 --- a/packages/ozone/tests/views/likes.test.ts +++ /dev/null @@ -1,109 +0,0 @@ -import AtpAgent from '@atproto/api' -import { TestNetwork, SeedClient } from '@atproto/dev-env' -import likesSeed from '../seeds/likes' -import { constantDate, forSnapshot, paginateAll, stripViewer } from '../_util' - -describe('pds like views', () => { - let network: TestNetwork - let agent: AtpAgent - let sc: SeedClient - - // account dids, for convenience - let alice: string - let bob: string - - beforeAll(async () => { - network = await TestNetwork.create({ - dbPostgresSchema: 'bsky_views_likes', - }) - agent = network.bsky.getClient() - sc = network.getSeedClient() - await likesSeed(sc) - await network.processAll() - alice = sc.dids.alice - bob = sc.dids.bob - }) - - afterAll(async () => { - await network.close() - }) - - const getCursors = (items: { createdAt?: string }[]) => - items.map((item) => item.createdAt ?? constantDate) - - const getSortedCursors = (items: { createdAt?: string }[]) => - getCursors(items).sort((a, b) => tstamp(b) - tstamp(a)) - - const tstamp = (x: string) => new Date(x).getTime() - - it('fetches post likes', async () => { - const alicePost = await agent.api.app.bsky.feed.getLikes( - { uri: sc.posts[alice][1].ref.uriStr }, - { headers: await network.serviceHeaders(alice) }, - ) - - expect(forSnapshot(alicePost.data)).toMatchSnapshot() - expect(getCursors(alicePost.data.likes)).toEqual( - getSortedCursors(alicePost.data.likes), - ) - }) - - it('fetches reply likes', async () => { - const bobReply = await agent.api.app.bsky.feed.getLikes( - { uri: sc.replies[bob][0].ref.uriStr }, - { headers: await network.serviceHeaders(alice) }, - ) - - expect(forSnapshot(bobReply.data)).toMatchSnapshot() - expect(getCursors(bobReply.data.likes)).toEqual( - getSortedCursors(bobReply.data.likes), - ) - }) - - it('paginates', async () => { - const results = (results) => results.flatMap((res) => res.likes) - const paginator = async (cursor?: string) => { - const res = await agent.api.app.bsky.feed.getLikes( - { - uri: sc.posts[alice][1].ref.uriStr, - cursor, - limit: 2, - }, - { headers: await network.serviceHeaders(alice) }, - ) - return res.data - } - - const paginatedAll = await paginateAll(paginator) - paginatedAll.forEach((res) => - expect(res.likes.length).toBeLessThanOrEqual(2), - ) - - const full = await agent.api.app.bsky.feed.getLikes( - { uri: sc.posts[alice][1].ref.uriStr }, - { headers: await network.serviceHeaders(alice) }, - ) - - expect(full.data.likes.length).toEqual(4) - expect(results(paginatedAll)).toEqual(results([full.data])) - }) - - it('fetches post likes unauthed', async () => { - const { data: authed } = await agent.api.app.bsky.feed.getLikes( - { uri: sc.posts[alice][1].ref.uriStr }, - { headers: await network.serviceHeaders(alice) }, - ) - const { data: unauthed } = await agent.api.app.bsky.feed.getLikes({ - uri: sc.posts[alice][1].ref.uriStr, - }) - expect(unauthed.likes.length).toBeGreaterThan(0) - expect(unauthed.likes).toEqual( - authed.likes.map((like) => { - return { - ...like, - actor: stripViewer(like.actor), - } - }), - ) - }) -}) diff --git a/packages/ozone/tests/views/list-feed.test.ts b/packages/ozone/tests/views/list-feed.test.ts deleted file mode 100644 index b8cd977922b..00000000000 --- a/packages/ozone/tests/views/list-feed.test.ts +++ /dev/null @@ -1,200 +0,0 @@ -import AtpAgent from '@atproto/api' -import { TestNetwork, SeedClient, RecordRef } from '@atproto/dev-env' -import { forSnapshot, paginateAll, stripViewerFromPost } from '../_util' -import basicSeed from '../seeds/basic' - -describe('list feed views', () => { - let network: TestNetwork - let agent: AtpAgent - let sc: SeedClient - - // account dids, for convenience - let alice: string - let bob: string - let carol: string - - let listRef: RecordRef - - beforeAll(async () => { - network = await TestNetwork.create({ - dbPostgresSchema: 'bsky_views_list_feed', - }) - agent = network.bsky.getClient() - sc = network.getSeedClient() - await basicSeed(sc) - alice = sc.dids.alice - bob = sc.dids.bob - carol = sc.dids.carol - listRef = await sc.createList(alice, 'test list', 'curate') - await sc.addToList(alice, alice, listRef) - await sc.addToList(alice, bob, listRef) - await network.processAll() - }) - - afterAll(async () => { - await network.close() - }) - - it('fetches list feed', async () => { - const res = await agent.api.app.bsky.feed.getListFeed( - { list: listRef.uriStr }, - { headers: await network.serviceHeaders(carol) }, - ) - expect(forSnapshot(res.data.feed)).toMatchSnapshot() - - // all posts are from alice or bob - expect( - res.data.feed.every((row) => [alice, bob].includes(row.post.author.did)), - ).toBeTruthy() - }) - - it('paginates', async () => { - const results = (results) => results.flatMap((res) => res.feed) - const paginator = async (cursor?: string) => { - const res = await agent.api.app.bsky.feed.getListFeed( - { - list: listRef.uriStr, - cursor, - limit: 2, - }, - { headers: await network.serviceHeaders(carol) }, - ) - return res.data - } - - const paginatedAll = await paginateAll(paginator) - paginatedAll.forEach((res) => - expect(res.feed.length).toBeLessThanOrEqual(2), - ) - - const full = await agent.api.app.bsky.feed.getListFeed( - { list: listRef.uriStr }, - { headers: await network.serviceHeaders(carol) }, - ) - - expect(full.data.feed.length).toEqual(7) - expect(results(paginatedAll)).toEqual(results([full.data])) - }) - - it('fetches results unauthed', async () => { - const { data: authed } = await agent.api.app.bsky.feed.getListFeed( - { list: listRef.uriStr }, - { headers: await network.serviceHeaders(alice) }, - ) - const { data: unauthed } = await agent.api.app.bsky.feed.getListFeed({ - list: listRef.uriStr, - }) - expect(unauthed.feed.length).toBeGreaterThan(0) - expect(unauthed.feed).toEqual( - authed.feed.map((item) => { - const result = { - ...item, - post: stripViewerFromPost(item.post), - } - if (item.reply) { - result.reply = { - parent: stripViewerFromPost(item.reply.parent), - root: stripViewerFromPost(item.reply.root), - } - } - return result - }), - ) - }) - - it('works for empty lists', async () => { - const emptyList = await sc.createList(alice, 'empty list', 'curate') - const res = await agent.api.app.bsky.feed.getListFeed({ - list: emptyList.uriStr, - }) - - expect(res.data.feed.length).toEqual(0) - }) - - it('blocks posts by actor takedown', async () => { - await agent.api.com.atproto.admin.emitModerationEvent( - { - event: { $type: 'com.atproto.admin.defs#modEventTakedown' }, - subject: { - $type: 'com.atproto.admin.defs#repoRef', - did: bob, - }, - createdBy: 'did:example:admin', - reason: 'Y', - }, - { - encoding: 'application/json', - headers: network.pds.adminAuthHeaders(), - }, - ) - - const res = await agent.api.app.bsky.feed.getListFeed({ - list: listRef.uriStr, - }) - const hasBob = res.data.feed.some((item) => item.post.author.did === bob) - expect(hasBob).toBe(false) - - // Cleanup - await agent.api.com.atproto.admin.emitModerationEvent( - { - event: { $type: 'com.atproto.admin.defs#modEventReverseTakedown' }, - subject: { - $type: 'com.atproto.admin.defs#repoRef', - did: bob, - }, - createdBy: 'did:example:admin', - reason: 'Y', - }, - { - encoding: 'application/json', - headers: network.pds.adminAuthHeaders(), - }, - ) - }) - - it('blocks posts by record takedown.', async () => { - const postRef = sc.replies[bob][0].ref // Post and reply parent - await agent.api.com.atproto.admin.emitModerationEvent( - { - event: { $type: 'com.atproto.admin.defs#modEventTakedown' }, - subject: { - $type: 'com.atproto.repo.strongRef', - uri: postRef.uriStr, - cid: postRef.cidStr, - }, - createdBy: 'did:example:admin', - reason: 'Y', - }, - { - encoding: 'application/json', - headers: network.pds.adminAuthHeaders(), - }, - ) - - const res = await agent.api.app.bsky.feed.getListFeed({ - list: listRef.uriStr, - }) - const hasPost = res.data.feed.some( - (item) => item.post.uri === postRef.uriStr, - ) - expect(hasPost).toBe(false) - - // Cleanup - await agent.api.com.atproto.admin.emitModerationEvent( - { - event: { $type: 'com.atproto.admin.defs#modEventReverseTakedown' }, - subject: { - $type: 'com.atproto.repo.strongRef', - uri: postRef.uriStr, - cid: postRef.cidStr, - }, - createdBy: 'did:example:admin', - reason: 'Y', - }, - { - encoding: 'application/json', - headers: network.pds.adminAuthHeaders(), - }, - ) - }) -}) diff --git a/packages/ozone/tests/views/mute-lists.test.ts b/packages/ozone/tests/views/mute-lists.test.ts deleted file mode 100644 index 07a6690f910..00000000000 --- a/packages/ozone/tests/views/mute-lists.test.ts +++ /dev/null @@ -1,383 +0,0 @@ -import AtpAgent, { AtUri } from '@atproto/api' -import { TestNetwork, SeedClient, RecordRef } from '@atproto/dev-env' -import { forSnapshot } from '../_util' -import basicSeed from '../seeds/basic' - -describe('bsky views with mutes from mute lists', () => { - let network: TestNetwork - let agent: AtpAgent - let pdsAgent: AtpAgent - let sc: SeedClient - - let alice: string - let bob: string - let carol: string - let dan: string - - beforeAll(async () => { - network = await TestNetwork.create({ - dbPostgresSchema: 'bsky_views_mute_lists', - }) - agent = network.bsky.getClient() - pdsAgent = network.pds.getClient() - sc = network.getSeedClient() - await basicSeed(sc) - alice = sc.dids.alice - bob = sc.dids.bob - carol = sc.dids.carol - dan = sc.dids.dan - // add follows to ensure mutes work even w follows - await sc.follow(carol, dan) - await sc.follow(dan, carol) - await network.processAll() - }) - - afterAll(async () => { - await network.close() - }) - - let listUri: string - let listCid: string - - it('creates a list with some items', async () => { - const avatar = await sc.uploadFile( - alice, - 'tests/sample-img/key-portrait-small.jpg', - 'image/jpeg', - ) - // alice creates mute list with bob & carol that dan uses - const list = await pdsAgent.api.app.bsky.graph.list.create( - { repo: alice }, - { - name: 'alice mutes', - purpose: 'app.bsky.graph.defs#modlist', - description: 'big list of mutes', - avatar: avatar.image, - createdAt: new Date().toISOString(), - }, - sc.getHeaders(alice), - ) - listUri = list.uri - listCid = list.cid - await pdsAgent.api.app.bsky.graph.listitem.create( - { repo: alice }, - { - subject: sc.dids.bob, - list: list.uri, - reason: 'because', - createdAt: new Date().toISOString(), - }, - sc.getHeaders(alice), - ) - await pdsAgent.api.app.bsky.graph.listitem.create( - { repo: alice }, - { - subject: sc.dids.carol, - list: list.uri, - reason: 'idk', - createdAt: new Date().toISOString(), - }, - sc.getHeaders(alice), - ) - await pdsAgent.api.app.bsky.graph.listitem.create( - { repo: alice }, - { - subject: sc.dids.dan, - list: list.uri, - reason: 'idk', - createdAt: new Date().toISOString(), - }, - sc.getHeaders(alice), - ) - await network.processAll() - }) - - it('uses a list for mutes', async () => { - // @TODO proxy through appview - await agent.api.app.bsky.graph.muteActorList( - { - list: listUri, - }, - { - encoding: 'application/json', - headers: await network.serviceHeaders(dan), - }, - ) - }) - - it('flags mutes in threads', async () => { - const res = await agent.api.app.bsky.feed.getPostThread( - { depth: 1, uri: sc.posts[alice][1].ref.uriStr }, - { headers: await network.serviceHeaders(dan) }, - ) - expect(forSnapshot(res.data.thread)).toMatchSnapshot() - }) - - it('does not show reposted content from a muted account in author feed', async () => { - await sc.repost(alice, sc.posts[carol][0].ref) - await network.processAll() - - const res = await agent.api.app.bsky.feed.getAuthorFeed( - { actor: alice }, - { headers: await network.serviceHeaders(dan) }, - ) - expect( - res.data.feed.some((post) => [bob, carol].includes(post.post.author.did)), - ).toBe(false) - }) - - it('removes content from muted users on getTimeline', async () => { - const res = await agent.api.app.bsky.feed.getTimeline( - { limit: 100 }, - { headers: await network.serviceHeaders(dan) }, - ) - expect( - res.data.feed.some((post) => [bob, carol].includes(post.post.author.did)), - ).toBe(false) - }) - - it('removes content from muted users on getListFeed', async () => { - const listRef = await sc.createList(bob, 'test list', 'curate') - await sc.addToList(alice, bob, listRef) - await sc.addToList(alice, carol, listRef) - await sc.addToList(alice, dan, listRef) - const res = await agent.api.app.bsky.feed.getListFeed( - { list: listRef.uriStr }, - { headers: await network.serviceHeaders(alice) }, - ) - expect( - res.data.feed.some((post) => [bob, carol].includes(post.post.author.did)), - ).toBe(false) - }) - - it('returns mute status on getProfile', async () => { - const res = await agent.api.app.bsky.actor.getProfile( - { actor: carol }, - { headers: await network.serviceHeaders(dan) }, - ) - expect(res.data.viewer?.muted).toBe(true) - expect(res.data.viewer?.mutedByList?.uri).toBe(listUri) - }) - - it('returns mute status on getProfiles', async () => { - const res = await agent.api.app.bsky.actor.getProfiles( - { actors: [alice, carol] }, - { headers: await network.serviceHeaders(dan) }, - ) - expect(res.data.profiles[0].viewer?.muted).toBe(false) - expect(res.data.profiles[0].viewer?.mutedByList).toBeUndefined() - expect(res.data.profiles[1].viewer?.muted).toBe(true) - expect(res.data.profiles[1].viewer?.mutedByList?.uri).toEqual(listUri) - }) - - it('ignores self-mutes', async () => { - const res = await agent.api.app.bsky.actor.getProfile( - { actor: dan }, // dan subscribes to list that contains himself - { headers: await network.serviceHeaders(dan) }, - ) - expect(res.data.viewer?.muted).toBe(false) - expect(res.data.viewer?.mutedByList).toBeUndefined() - }) - - it('does not return notifs for muted accounts', async () => { - const res = await agent.api.app.bsky.notification.listNotifications( - { - limit: 100, - }, - { headers: await network.serviceHeaders(dan) }, - ) - expect( - res.data.notifications.some((notif) => - [bob, carol].includes(notif.author.did), - ), - ).toBeFalsy() - }) - - it('flags muted accounts in get suggestions', async () => { - // unfollow so they _would_ show up in suggestions if not for mute - await sc.unfollow(dan, carol) - await network.processAll() - await network.bsky.processAll() - - const res = await agent.api.app.bsky.actor.getSuggestions( - { - limit: 100, - }, - { headers: await network.serviceHeaders(dan) }, - ) - for (const actor of res.data.actors) { - if ([bob, carol].includes(actor.did)) { - expect(actor.viewer?.muted).toBe(true) - expect(actor.viewer?.mutedByList?.uri).toEqual(listUri) - } else { - expect(actor.viewer?.muted).toBe(false) - expect(actor.viewer?.mutedByList).toBeUndefined() - } - } - }) - - it('returns the contents of a list', async () => { - const res = await agent.api.app.bsky.graph.getList( - { list: listUri }, - { headers: await network.serviceHeaders(dan) }, - ) - expect(forSnapshot(res.data)).toMatchSnapshot() - }) - - it('paginates getList', async () => { - const full = await agent.api.app.bsky.graph.getList( - { list: listUri }, - { headers: await network.serviceHeaders(dan) }, - ) - const first = await agent.api.app.bsky.graph.getList( - { list: listUri, limit: 1 }, - { headers: await network.serviceHeaders(dan) }, - ) - const second = await agent.api.app.bsky.graph.getList( - { list: listUri, cursor: first.data.cursor }, - { headers: await network.serviceHeaders(dan) }, - ) - const combined = [...first.data.items, ...second.data.items] - expect(combined).toEqual(full.data.items) - }) - - let otherListUri: string - - it('returns lists associated with a user', async () => { - const listRes = await pdsAgent.api.app.bsky.graph.list.create( - { repo: alice }, - { - name: 'new list', - purpose: 'app.bsky.graph.defs#modlist', - description: 'blah blah', - createdAt: new Date().toISOString(), - }, - sc.getHeaders(alice), - ) - otherListUri = listRes.uri - - await network.processAll() - - const res = await agent.api.app.bsky.graph.getLists( - { actor: alice }, - { headers: await network.serviceHeaders(dan) }, - ) - expect(forSnapshot(res.data)).toMatchSnapshot() - }) - - it('paginates getLists', async () => { - const full = await agent.api.app.bsky.graph.getLists( - { actor: alice }, - { headers: await network.serviceHeaders(dan) }, - ) - const first = await agent.api.app.bsky.graph.getLists( - { actor: alice, limit: 1 }, - { headers: await network.serviceHeaders(dan) }, - ) - const second = await agent.api.app.bsky.graph.getLists( - { actor: alice, cursor: first.data.cursor }, - { headers: await network.serviceHeaders(dan) }, - ) - const combined = [...first.data.lists, ...second.data.lists] - expect(combined).toEqual(full.data.lists) - }) - - it('returns a users own list mutes', async () => { - await agent.api.app.bsky.graph.muteActorList( - { - list: otherListUri, - }, - { - encoding: 'application/json', - headers: await network.serviceHeaders(dan), - }, - ) - - const res = await agent.api.app.bsky.graph.getListMutes( - {}, - { headers: await network.serviceHeaders(dan) }, - ) - expect(forSnapshot(res.data)).toMatchSnapshot() - }) - - it('paginates getListMutes', async () => { - const full = await agent.api.app.bsky.graph.getListMutes( - {}, - { headers: await network.serviceHeaders(dan) }, - ) - const first = await agent.api.app.bsky.graph.getListMutes( - { limit: 1 }, - { headers: await network.serviceHeaders(dan) }, - ) - const second = await agent.api.app.bsky.graph.getListMutes( - { cursor: first.data.cursor }, - { headers: await network.serviceHeaders(dan) }, - ) - const combined = [...first.data.lists, ...second.data.lists] - expect(combined).toEqual(full.data.lists) - }) - - it('allows unsubscribing from a mute list', async () => { - await agent.api.app.bsky.graph.unmuteActorList( - { - list: otherListUri, - }, - { - encoding: 'application/json', - headers: await network.serviceHeaders(dan), - }, - ) - - const res = await agent.api.app.bsky.graph.getListMutes( - {}, - { headers: await network.serviceHeaders(dan) }, - ) - expect(res.data.lists.length).toBe(1) - }) - - it('updates list', async () => { - const uri = new AtUri(listUri) - await pdsAgent.api.com.atproto.repo.putRecord( - { - repo: uri.hostname, - collection: uri.collection, - rkey: uri.rkey, - record: { - name: 'updated alice mutes', - purpose: 'app.bsky.graph.defs#modlist', - description: 'new descript', - createdAt: new Date().toISOString(), - }, - }, - { headers: sc.getHeaders(alice), encoding: 'application/json' }, - ) - - await network.processAll() - - const got = await agent.api.app.bsky.graph.getList( - { list: listUri }, - { headers: await network.serviceHeaders(alice) }, - ) - expect(got.data.list.name).toBe('updated alice mutes') - expect(got.data.list.description).toBe('new descript') - expect(got.data.list.avatar).toBeUndefined() - expect(got.data.items.length).toBe(3) - }) - - it('embeds lists in posts', async () => { - const postRef = await sc.post( - alice, - 'list embed!', - undefined, - undefined, - new RecordRef(listUri, listCid), - ) - await network.processAll() - const res = await agent.api.app.bsky.feed.getPosts( - { uris: [postRef.ref.uriStr] }, - { headers: await network.serviceHeaders(alice) }, - ) - expect(res.data.posts.length).toBe(1) - expect(forSnapshot(res.data.posts[0])).toMatchSnapshot() - }) -}) diff --git a/packages/ozone/tests/views/mutes.test.ts b/packages/ozone/tests/views/mutes.test.ts deleted file mode 100644 index 6a00c427124..00000000000 --- a/packages/ozone/tests/views/mutes.test.ts +++ /dev/null @@ -1,230 +0,0 @@ -import AtpAgent from '@atproto/api' -import { TestNetwork, SeedClient } from '@atproto/dev-env' -import { forSnapshot, paginateAll } from '../_util' -import basicSeed from '../seeds/basic' -import usersBulkSeed from '../seeds/users-bulk' - -describe('mute views', () => { - let network: TestNetwork - let agent: AtpAgent - let sc: SeedClient - let alice: string - let bob: string - let carol: string - let dan: string - - let mutes: string[] - - beforeAll(async () => { - network = await TestNetwork.create({ - dbPostgresSchema: 'bsky_views_mutes', - }) - agent = network.bsky.getClient() - sc = network.getSeedClient() - await basicSeed(sc) - await usersBulkSeed(sc, 10) - alice = sc.dids.alice - bob = sc.dids.bob - carol = sc.dids.carol - dan = sc.dids.dan - mutes = [ - bob, - carol, - 'aliya-hodkiewicz.test', - 'adrienne49.test', - 'jeffrey-sawayn87.test', - 'nicolas-krajcik10.test', - 'magnus53.test', - 'elta48.test', - ] - await network.processAll() - for (const did of mutes) { - await agent.api.app.bsky.graph.muteActor( - { actor: did }, - { - headers: await network.serviceHeaders(alice), - encoding: 'application/json', - }, - ) - } - }) - - afterAll(async () => { - await network.close() - }) - - it('flags mutes in threads', async () => { - const res = await agent.api.app.bsky.feed.getPostThread( - { depth: 1, uri: sc.posts[alice][1].ref.uriStr }, - { headers: await network.serviceHeaders(alice) }, - ) - expect(forSnapshot(res.data.thread)).toMatchSnapshot() - }) - - it('does not show reposted content from a muted account in author feed', async () => { - await sc.repost(dan, sc.posts[bob][0].ref) - await sc.repost(dan, sc.posts[bob][1].ref) - await network.processAll() - - const res = await agent.api.app.bsky.feed.getAuthorFeed( - { actor: dan }, - { headers: await network.serviceHeaders(alice) }, - ) - expect( - res.data.feed.some((post) => [bob, carol].includes(post.post.author.did)), - ).toBe(false) - }) - - it('removes content from muted users on getTimeline', async () => { - const res = await agent.api.app.bsky.feed.getTimeline( - { limit: 100 }, - { headers: await network.serviceHeaders(alice) }, - ) - expect( - res.data.feed.some((post) => [bob, carol].includes(post.post.author.did)), - ).toBe(false) - }) - - it('removes content from muted users on getListFeed', async () => { - const listRef = await sc.createList(bob, 'test list', 'curate') - await sc.addToList(alice, bob, listRef) - await sc.addToList(alice, carol, listRef) - await sc.addToList(alice, dan, listRef) - const res = await agent.api.app.bsky.feed.getListFeed( - { list: listRef.uriStr }, - { headers: await network.serviceHeaders(alice) }, - ) - expect( - res.data.feed.some((post) => [bob, carol].includes(post.post.author.did)), - ).toBe(false) - }) - - it('returns mute status on getProfile', async () => { - const res = await agent.api.app.bsky.actor.getProfile( - { actor: bob }, - { headers: await network.serviceHeaders(alice) }, - ) - expect(res.data.viewer?.muted).toBe(true) - }) - - it('returns mute status on getProfiles', async () => { - const res = await agent.api.app.bsky.actor.getProfiles( - { actors: [bob, carol, dan] }, - { headers: await network.serviceHeaders(alice) }, - ) - expect(res.data.profiles[0].viewer?.muted).toBe(true) - expect(res.data.profiles[1].viewer?.muted).toBe(true) - expect(res.data.profiles[2].viewer?.muted).toBe(false) - }) - - it('does not return notifs for muted accounts', async () => { - const res = await agent.api.app.bsky.notification.listNotifications( - { - limit: 100, - }, - { headers: await network.serviceHeaders(alice) }, - ) - expect( - res.data.notifications.some((notif) => - [bob, carol].includes(notif.author.did), - ), - ).toBeFalsy() - }) - - it('flags muted accounts in get suggestions', async () => { - // unfollow so they _would_ show up in suggestions if not for mute - await sc.unfollow(alice, bob) - await sc.unfollow(alice, carol) - - await network.processAll() - - const res = await agent.api.app.bsky.actor.getSuggestions( - { - limit: 100, - }, - { headers: await network.serviceHeaders(alice) }, - ) - for (const actor of res.data.actors) { - if (mutes.includes(actor.did) || mutes.includes(actor.handle)) { - expect(actor.viewer?.muted).toBe(true) - } else { - expect(actor.viewer?.muted).toBe(false) - } - } - }) - - it('fetches mutes for the logged-in user.', async () => { - const { data: view } = await agent.api.app.bsky.graph.getMutes( - {}, - { headers: await network.serviceHeaders(alice) }, - ) - expect(forSnapshot(view.mutes)).toMatchSnapshot() - }) - - it('paginates.', async () => { - const results = (results) => results.flatMap((res) => res.mutes) - const paginator = async (cursor?: string) => { - const { data: view } = await agent.api.app.bsky.graph.getMutes( - { cursor, limit: 2 }, - { headers: await network.serviceHeaders(alice) }, - ) - return view - } - - const paginatedAll = await paginateAll(paginator) - paginatedAll.forEach((res) => - expect(res.mutes.length).toBeLessThanOrEqual(2), - ) - - const full = await agent.api.app.bsky.graph.getMutes( - {}, - { headers: await network.serviceHeaders(alice) }, - ) - - expect(full.data.mutes.length).toEqual(8) - expect(results(paginatedAll)).toEqual(results([full.data])) - }) - - it('removes mute.', async () => { - const { data: initial } = await agent.api.app.bsky.graph.getMutes( - {}, - { headers: await network.serviceHeaders(alice) }, - ) - expect(initial.mutes.length).toEqual(8) - expect(initial.mutes.map((m) => m.handle)).toContain('elta48.test') - - await agent.api.app.bsky.graph.unmuteActor( - { actor: sc.dids['elta48.test'] }, - { - headers: await network.serviceHeaders(alice), - encoding: 'application/json', - }, - ) - - const { data: final } = await agent.api.app.bsky.graph.getMutes( - {}, - { headers: await network.serviceHeaders(alice) }, - ) - expect(final.mutes.length).toEqual(7) - expect(final.mutes.map((m) => m.handle)).not.toContain('elta48.test') - - await agent.api.app.bsky.graph.muteActor( - { actor: sc.dids['elta48.test'] }, - { - headers: await network.serviceHeaders(alice), - encoding: 'application/json', - }, - ) - }) - - it('does not allow muting self.', async () => { - const promise = agent.api.app.bsky.graph.muteActor( - { actor: alice }, - { - headers: await network.serviceHeaders(alice), - encoding: 'application/json', - }, - ) - await expect(promise).rejects.toThrow('Cannot mute oneself') - }) -}) diff --git a/packages/ozone/tests/views/notifications.test.ts b/packages/ozone/tests/views/notifications.test.ts deleted file mode 100644 index c75ee7b699e..00000000000 --- a/packages/ozone/tests/views/notifications.test.ts +++ /dev/null @@ -1,299 +0,0 @@ -import AtpAgent from '@atproto/api' -import { TestNetwork, SeedClient } from '@atproto/dev-env' -import { forSnapshot, paginateAll } from '../_util' -import basicSeed from '../seeds/basic' -import { Notification } from '../../src/lexicon/types/app/bsky/notification/listNotifications' - -describe('notification views', () => { - let network: TestNetwork - let agent: AtpAgent - let sc: SeedClient - - // account dids, for convenience - let alice: string - - beforeAll(async () => { - network = await TestNetwork.create({ - dbPostgresSchema: 'bsky_views_notifications', - }) - agent = network.bsky.getClient() - sc = network.getSeedClient() - await basicSeed(sc) - await network.processAll() - await network.bsky.processAll() - alice = sc.dids.alice - }) - - afterAll(async () => { - await network.close() - }) - - const sort = (notifs: Notification[]) => { - // Need to sort because notification ordering is not well-defined - return notifs.sort((a, b) => { - const stableUriA = a.uri.replace( - /\/did:plc:.+?\//, - `/${a.author.handle}/`, - ) - const stableUriB = b.uri.replace( - /\/did:plc:.+?\//, - `/${b.author.handle}/`, - ) - if (stableUriA === stableUriB) { - return a.indexedAt > b.indexedAt ? -1 : 1 - } - return stableUriA > stableUriB ? -1 : 1 - }) - } - - it('fetches notification count without a last-seen', async () => { - const notifCountAlice = - await agent.api.app.bsky.notification.getUnreadCount( - {}, - { headers: await network.serviceHeaders(alice) }, - ) - - expect(notifCountAlice.data.count).toBe(12) - - const notifCountBob = await agent.api.app.bsky.notification.getUnreadCount( - {}, - { headers: await network.serviceHeaders(sc.dids.bob) }, - ) - - expect(notifCountBob.data.count).toBeGreaterThanOrEqual(3) - }) - - it('generates notifications for all reply ancestors', async () => { - // Add to reply chain, post ancestors: alice -> bob -> alice -> carol. - // Should have added one notification for each of alice and bob. - await sc.reply( - sc.dids.carol, - sc.posts[alice][1].ref, - sc.replies[alice][0].ref, - 'indeed', - ) - await network.processAll() - await network.bsky.processAll() - - const notifCountAlice = - await agent.api.app.bsky.notification.getUnreadCount( - {}, - { headers: await network.serviceHeaders(alice) }, - ) - - expect(notifCountAlice.data.count).toBe(13) - - const notifCountBob = await agent.api.app.bsky.notification.getUnreadCount( - {}, - { headers: await network.serviceHeaders(sc.dids.bob) }, - ) - - expect(notifCountBob.data.count).toBeGreaterThanOrEqual(4) - }) - - it('does not give notifs for a deleted subject', async () => { - const root = await sc.post(sc.dids.alice, 'root') - const first = await sc.reply(sc.dids.bob, root.ref, root.ref, 'first') - await sc.deletePost(sc.dids.alice, root.ref.uri) - const second = await sc.reply(sc.dids.carol, root.ref, first.ref, 'second') - await network.processAll() - await network.bsky.processAll() - - const notifsAlice = await agent.api.app.bsky.notification.listNotifications( - {}, - { headers: await network.serviceHeaders(sc.dids.alice) }, - ) - const hasNotif = notifsAlice.data.notifications.some( - (notif) => notif.uri === second.ref.uriStr, - ) - expect(hasNotif).toBe(false) - - // cleanup - await sc.deletePost(sc.dids.bob, first.ref.uri) - await sc.deletePost(sc.dids.carol, second.ref.uri) - await network.processAll() - }) - - it('generates notifications for quotes', async () => { - // Dan was quoted by alice - const notifsDan = await agent.api.app.bsky.notification.listNotifications( - {}, - { headers: await network.serviceHeaders(sc.dids.dan) }, - ) - expect(forSnapshot(sort(notifsDan.data.notifications))).toMatchSnapshot() - }) - - it('fetches notifications without a last-seen', async () => { - const notifRes = await agent.api.app.bsky.notification.listNotifications( - {}, - { headers: await network.serviceHeaders(alice) }, - ) - - const notifs = notifRes.data.notifications - expect(notifs.length).toBe(13) - - const readStates = notifs.map((notif) => notif.isRead) - expect(readStates).toEqual(notifs.map(() => false)) - - expect(forSnapshot(sort(notifs))).toMatchSnapshot() - }) - - it('paginates', async () => { - const results = (results) => - sort(results.flatMap((res) => res.notifications)) - const paginator = async (cursor?: string) => { - const res = await agent.api.app.bsky.notification.listNotifications( - { cursor, limit: 6 }, - { headers: await network.serviceHeaders(alice) }, - ) - return res.data - } - - const paginatedAll = await paginateAll(paginator) - paginatedAll.forEach((res) => - expect(res.notifications.length).toBeLessThanOrEqual(6), - ) - - const full = await agent.api.app.bsky.notification.listNotifications( - {}, - { headers: await network.serviceHeaders(alice) }, - ) - - expect(full.data.notifications.length).toEqual(13) - expect(results(paginatedAll)).toEqual(results([full.data])) - }) - - it('fetches notification count with a last-seen', async () => { - const full = await agent.api.app.bsky.notification.listNotifications( - {}, - { headers: await network.serviceHeaders(alice) }, - ) - const seenAt = full.data.notifications[3].indexedAt - await agent.api.app.bsky.notification.updateSeen( - { seenAt }, - { - headers: await network.serviceHeaders(alice), - encoding: 'application/json', - }, - ) - const full2 = await agent.api.app.bsky.notification.listNotifications( - {}, - { headers: await network.serviceHeaders(alice) }, - ) - expect(full2.data.notifications.length).toBe(full.data.notifications.length) - expect(full2.data.seenAt).toEqual(seenAt) - - const notifCount = await agent.api.app.bsky.notification.getUnreadCount( - {}, - { headers: await network.serviceHeaders(alice) }, - ) - - expect(notifCount.data.count).toBe( - full.data.notifications.filter((n) => n.indexedAt > seenAt).length, - ) - expect(notifCount.data.count).toBeGreaterThan(0) - - // reset last-seen - await agent.api.app.bsky.notification.updateSeen( - { seenAt: new Date(0).toISOString() }, - { - headers: await network.serviceHeaders(alice), - encoding: 'application/json', - }, - ) - }) - - it('fetches notifications with a last-seen', async () => { - const full = await agent.api.app.bsky.notification.listNotifications( - {}, - { headers: await network.serviceHeaders(alice) }, - ) - const seenAt = full.data.notifications[3].indexedAt - await agent.api.app.bsky.notification.updateSeen( - { seenAt }, - { - headers: await network.serviceHeaders(alice), - encoding: 'application/json', - }, - ) - const notifRes = await agent.api.app.bsky.notification.listNotifications( - {}, - { headers: await network.serviceHeaders(alice) }, - ) - - const notifs = notifRes.data.notifications - expect(notifs.length).toBe(13) - - const readStates = notifs.map((notif) => notif.isRead) - expect(readStates).toEqual(notifs.map((n) => n.indexedAt <= seenAt)) - // reset last-seen - await agent.api.app.bsky.notification.updateSeen( - { seenAt: new Date(0).toISOString() }, - { - headers: await network.serviceHeaders(alice), - encoding: 'application/json', - }, - ) - }) - - it('fetches notifications omitting mentions and replies for taken-down posts', async () => { - const postRef1 = sc.replies[sc.dids.carol][0].ref // Reply - const postRef2 = sc.posts[sc.dids.dan][1].ref // Mention - await Promise.all( - [postRef1, postRef2].map((postRef) => - agent.api.com.atproto.admin.emitModerationEvent( - { - event: { $type: 'com.atproto.admin.defs#modEventTakedown' }, - subject: { - $type: 'com.atproto.repo.strongRef', - uri: postRef.uriStr, - cid: postRef.cidStr, - }, - createdBy: 'did:example:admin', - reason: 'Y', - }, - { - encoding: 'application/json', - headers: network.pds.adminAuthHeaders(), - }, - ), - ), - ) - - const notifRes = await agent.api.app.bsky.notification.listNotifications( - {}, - { headers: await network.serviceHeaders(alice) }, - ) - const notifCount = await agent.api.app.bsky.notification.getUnreadCount( - {}, - { headers: await network.serviceHeaders(alice) }, - ) - - const notifs = sort(notifRes.data.notifications) - expect(notifs.length).toBe(11) - expect(forSnapshot(notifs)).toMatchSnapshot() - expect(notifCount.data.count).toBe(11) - - // Cleanup - await Promise.all( - [postRef1, postRef2].map((postRef) => - agent.api.com.atproto.admin.emitModerationEvent( - { - event: { $type: 'com.atproto.admin.defs#modEventReverseTakedown' }, - subject: { - $type: 'com.atproto.repo.strongRef', - uri: postRef.uriStr, - cid: postRef.cidStr, - }, - createdBy: 'did:example:admin', - reason: 'Y', - }, - { - encoding: 'application/json', - headers: network.pds.adminAuthHeaders(), - }, - ), - ), - ) - }) -}) diff --git a/packages/ozone/tests/views/posts.test.ts b/packages/ozone/tests/views/posts.test.ts deleted file mode 100644 index 69bade5b91a..00000000000 --- a/packages/ozone/tests/views/posts.test.ts +++ /dev/null @@ -1,107 +0,0 @@ -import AtpAgent, { AppBskyFeedPost } from '@atproto/api' -import { TestNetwork, SeedClient } from '@atproto/dev-env' -import { forSnapshot, stripViewerFromPost } from '../_util' -import basicSeed from '../seeds/basic' - -describe('pds posts views', () => { - let network: TestNetwork - let agent: AtpAgent - let pdsAgent: AtpAgent - let sc: SeedClient - - beforeAll(async () => { - network = await TestNetwork.create({ - dbPostgresSchema: 'bsky_views_posts', - }) - agent = network.bsky.getClient() - pdsAgent = network.pds.getClient() - sc = network.getSeedClient() - await basicSeed(sc) - await network.processAll() - }) - - afterAll(async () => { - await network.close() - }) - - it('fetches posts', async () => { - const uris = [ - sc.posts[sc.dids.alice][0].ref.uriStr, - sc.posts[sc.dids.alice][1].ref.uriStr, - sc.posts[sc.dids.bob][0].ref.uriStr, - sc.posts[sc.dids.carol][0].ref.uriStr, - sc.posts[sc.dids.dan][1].ref.uriStr, - sc.replies[sc.dids.alice][0].ref.uriStr, - ] - const posts = await agent.api.app.bsky.feed.getPosts( - { uris }, - { headers: await network.serviceHeaders(sc.dids.alice) }, - ) - - expect(posts.data.posts.length).toBe(uris.length) - expect(forSnapshot(posts.data.posts)).toMatchSnapshot() - }) - - it('fetches posts unauthed', async () => { - const uris = [ - sc.posts[sc.dids.alice][0].ref.uriStr, - sc.posts[sc.dids.alice][1].ref.uriStr, - sc.posts[sc.dids.bob][0].ref.uriStr, - sc.posts[sc.dids.carol][0].ref.uriStr, - sc.posts[sc.dids.dan][1].ref.uriStr, - sc.replies[sc.dids.alice][0].ref.uriStr, - ] - - const authed = await agent.api.app.bsky.feed.getPosts( - { uris }, - { headers: await network.serviceHeaders(sc.dids.alice) }, - ) - const unauthed = await agent.api.app.bsky.feed.getPosts({ - uris, - }) - const stripped = authed.data.posts.map((p) => stripViewerFromPost(p)) - expect(unauthed.data.posts).toEqual(stripped) - }) - - it('handles repeat uris', async () => { - const uris = [ - sc.posts[sc.dids.alice][0].ref.uriStr, - sc.posts[sc.dids.alice][0].ref.uriStr, - sc.posts[sc.dids.bob][0].ref.uriStr, - sc.posts[sc.dids.alice][0].ref.uriStr, - sc.posts[sc.dids.bob][0].ref.uriStr, - ] - - const posts = await agent.api.app.bsky.feed.getPosts({ uris }) - - expect(posts.data.posts.length).toBe(2) - const receivedUris = posts.data.posts.map((p) => p.uri).sort() - const expected = [ - sc.posts[sc.dids.alice][0].ref.uriStr, - sc.posts[sc.dids.bob][0].ref.uriStr, - ].sort() - expect(receivedUris).toEqual(expected) - }) - - it('allows for creating posts with tags', async () => { - const post: AppBskyFeedPost.Record = { - text: 'hello world', - tags: ['javascript', 'hehe'], - createdAt: new Date().toISOString(), - } - - const { uri } = await pdsAgent.api.app.bsky.feed.post.create( - { repo: sc.dids.alice }, - post, - sc.getHeaders(sc.dids.alice), - ) - - await network.processAll() - - const { data } = await agent.api.app.bsky.feed.getPosts({ uris: [uri] }) - - expect(data.posts.length).toBe(1) - // @ts-ignore we know it's a post record - expect(data.posts[0].record.tags).toEqual(['javascript', 'hehe']) - }) -}) diff --git a/packages/ozone/tests/views/profile.test.ts b/packages/ozone/tests/views/profile.test.ts deleted file mode 100644 index fe3f689894b..00000000000 --- a/packages/ozone/tests/views/profile.test.ts +++ /dev/null @@ -1,284 +0,0 @@ -import fs from 'fs/promises' -import AtpAgent from '@atproto/api' -import { TestNetwork, SeedClient } from '@atproto/dev-env' -import { forSnapshot, stripViewer } from '../_util' -import { ids } from '../../src/lexicon/lexicons' -import basicSeed from '../seeds/basic' - -describe('pds profile views', () => { - let network: TestNetwork - let agent: AtpAgent - let pdsAgent: AtpAgent - let sc: SeedClient - - // account dids, for convenience - let alice: string - let bob: string - let dan: string - - beforeAll(async () => { - network = await TestNetwork.create({ - dbPostgresSchema: 'bsky_views_profile', - }) - agent = network.bsky.getClient() - pdsAgent = network.pds.getClient() - sc = network.getSeedClient() - await basicSeed(sc) - await network.processAll() - alice = sc.dids.alice - bob = sc.dids.bob - dan = sc.dids.dan - }) - - afterAll(async () => { - await network.close() - }) - - // @TODO(bsky) blocked by actor takedown via labels. - - it('fetches own profile', async () => { - const aliceForAlice = await agent.api.app.bsky.actor.getProfile( - { actor: alice }, - { headers: await network.serviceHeaders(alice) }, - ) - - expect(forSnapshot(aliceForAlice.data)).toMatchSnapshot() - }) - - it('reflects self-labels', async () => { - const aliceForBob = await agent.api.app.bsky.actor.getProfile( - { actor: alice }, - { headers: await network.serviceHeaders(bob) }, - ) - - const labels = aliceForBob.data.labels - ?.filter((label) => label.src === alice) - .map((label) => label.val) - .sort() - - expect(labels).toEqual(['self-label-a', 'self-label-b']) - }) - - it("fetches other's profile, with a follow", async () => { - const aliceForBob = await agent.api.app.bsky.actor.getProfile( - { actor: alice }, - { headers: await network.serviceHeaders(bob) }, - ) - - expect(forSnapshot(aliceForBob.data)).toMatchSnapshot() - }) - - it("fetches other's profile, without a follow", async () => { - const danForBob = await agent.api.app.bsky.actor.getProfile( - { actor: dan }, - { headers: await network.serviceHeaders(bob) }, - ) - - expect(forSnapshot(danForBob.data)).toMatchSnapshot() - }) - - it('fetches multiple profiles', async () => { - const { - data: { profiles }, - } = await agent.api.app.bsky.actor.getProfiles( - { - actors: [ - alice, - 'bob.test', - 'did:example:missing', - 'carol.test', - dan, - 'missing.test', - ], - }, - { headers: await network.serviceHeaders(bob) }, - ) - - expect(profiles.map((p) => p.handle)).toEqual([ - 'alice.test', - 'bob.test', - 'carol.test', - 'dan.test', - ]) - - expect(forSnapshot(profiles)).toMatchSnapshot() - }) - - it('presents avatars & banners', async () => { - const avatarImg = await fs.readFile( - 'tests/sample-img/key-portrait-small.jpg', - ) - const bannerImg = await fs.readFile( - 'tests/sample-img/key-landscape-small.jpg', - ) - const avatarRes = await pdsAgent.api.com.atproto.repo.uploadBlob( - avatarImg, - { - headers: sc.getHeaders(alice), - encoding: 'image/jpeg', - }, - ) - const bannerRes = await pdsAgent.api.com.atproto.repo.uploadBlob( - bannerImg, - { - headers: sc.getHeaders(alice), - encoding: 'image/jpeg', - }, - ) - - await updateProfile(alice, { - displayName: 'ali', - description: 'new descript', - avatar: avatarRes.data.blob, - banner: bannerRes.data.blob, - }) - await network.processAll() - - const aliceForAlice = await agent.api.app.bsky.actor.getProfile( - { actor: alice }, - { headers: await network.serviceHeaders(alice) }, - ) - - expect(forSnapshot(aliceForAlice.data)).toMatchSnapshot() - }) - - it('fetches profile by handle', async () => { - const byDid = await agent.api.app.bsky.actor.getProfile( - { actor: alice }, - { - headers: await network.serviceHeaders(bob), - }, - ) - - const byHandle = await agent.api.app.bsky.actor.getProfile( - { actor: sc.accounts[alice].handle }, - { headers: await network.serviceHeaders(bob) }, - ) - - expect(byHandle.data).toEqual(byDid.data) - }) - - it('fetches profile unauthed', async () => { - const { data: authed } = await agent.api.app.bsky.actor.getProfile( - { actor: alice }, - { headers: await network.serviceHeaders(bob) }, - ) - const { data: unauthed } = await agent.api.app.bsky.actor.getProfile({ - actor: alice, - }) - expect(unauthed).toEqual(stripViewer(authed)) - }) - - it('fetches multiple profiles unauthed', async () => { - const { data: authed } = await agent.api.app.bsky.actor.getProfiles( - { - actors: [alice, 'bob.test', 'missing.test'], - }, - { headers: await network.serviceHeaders(bob) }, - ) - const { data: unauthed } = await agent.api.app.bsky.actor.getProfiles({ - actors: [alice, 'bob.test', 'missing.test'], - }) - expect(unauthed.profiles.length).toBeGreaterThan(0) - expect(unauthed.profiles).toEqual(authed.profiles.map(stripViewer)) - }) - - it('blocked by actor takedown', async () => { - await agent.api.com.atproto.admin.emitModerationEvent( - { - event: { $type: 'com.atproto.admin.defs#modEventTakedown' }, - subject: { - $type: 'com.atproto.admin.defs#repoRef', - did: alice, - }, - createdBy: 'did:example:admin', - reason: 'Y', - }, - { - encoding: 'application/json', - headers: network.pds.adminAuthHeaders(), - }, - ) - const promise = agent.api.app.bsky.actor.getProfile( - { actor: alice }, - { headers: await network.serviceHeaders(bob) }, - ) - - await expect(promise).rejects.toThrow('Account has been taken down') - - // Cleanup - await agent.api.com.atproto.admin.emitModerationEvent( - { - event: { $type: 'com.atproto.admin.defs#modEventReverseTakedown' }, - subject: { - $type: 'com.atproto.admin.defs#repoRef', - did: alice, - }, - createdBy: 'did:example:admin', - reason: 'Y', - }, - { - encoding: 'application/json', - headers: network.pds.adminAuthHeaders(), - }, - ) - }) - - it('blocked by actor suspension', async () => { - await agent.api.com.atproto.admin.emitModerationEvent( - { - event: { - $type: 'com.atproto.admin.defs#modEventTakedown', - durationInHours: 1, - }, - subject: { - $type: 'com.atproto.admin.defs#repoRef', - did: alice, - }, - createdBy: 'did:example:admin', - reason: 'Y', - }, - { - encoding: 'application/json', - headers: network.pds.adminAuthHeaders(), - }, - ) - const promise = agent.api.app.bsky.actor.getProfile( - { actor: alice }, - { headers: await network.serviceHeaders(bob) }, - ) - - await expect(promise).rejects.toThrow( - 'Account has been temporarily suspended', - ) - - // Cleanup - await agent.api.com.atproto.admin.emitModerationEvent( - { - event: { $type: 'com.atproto.admin.defs#modEventReverseTakedown' }, - subject: { - $type: 'com.atproto.admin.defs#repoRef', - did: alice, - }, - createdBy: 'did:example:admin', - reason: 'Y', - }, - { - encoding: 'application/json', - headers: network.pds.adminAuthHeaders(), - }, - ) - }) - - async function updateProfile(did: string, record: Record) { - return await pdsAgent.api.com.atproto.repo.putRecord( - { - repo: did, - collection: ids.AppBskyActorProfile, - rkey: 'self', - record, - }, - { headers: sc.getHeaders(did), encoding: 'application/json' }, - ) - } -}) diff --git a/packages/ozone/tests/views/reposts.test.ts b/packages/ozone/tests/views/reposts.test.ts deleted file mode 100644 index 4d386121137..00000000000 --- a/packages/ozone/tests/views/reposts.test.ts +++ /dev/null @@ -1,88 +0,0 @@ -import AtpAgent from '@atproto/api' -import { TestNetwork, SeedClient } from '@atproto/dev-env' -import { forSnapshot, paginateAll, stripViewer } from '../_util' -import repostsSeed from '../seeds/reposts' - -describe('pds repost views', () => { - let network: TestNetwork - let agent: AtpAgent - let sc: SeedClient - - // account dids, for convenience - let alice: string - let bob: string - - beforeAll(async () => { - network = await TestNetwork.create({ - dbPostgresSchema: 'bsky_views_reposts', - }) - agent = network.bsky.getClient() - sc = network.getSeedClient() - await repostsSeed(sc) - await network.processAll() - alice = sc.dids.alice - bob = sc.dids.bob - }) - - afterAll(async () => { - await network.close() - }) - - it('fetches reposted-by for a post', async () => { - const view = await agent.api.app.bsky.feed.getRepostedBy( - { uri: sc.posts[alice][2].ref.uriStr }, - { headers: await network.serviceHeaders(alice) }, - ) - expect(view.data.uri).toEqual(sc.posts[sc.dids.alice][2].ref.uriStr) - expect(forSnapshot(view.data.repostedBy)).toMatchSnapshot() - }) - - it('fetches reposted-by for a reply', async () => { - const view = await agent.api.app.bsky.feed.getRepostedBy( - { uri: sc.replies[bob][0].ref.uriStr }, - { headers: await network.serviceHeaders(alice) }, - ) - expect(view.data.uri).toEqual(sc.replies[sc.dids.bob][0].ref.uriStr) - expect(forSnapshot(view.data.repostedBy)).toMatchSnapshot() - }) - - it('paginates', async () => { - const results = (results) => results.flatMap((res) => res.repostedBy) - const paginator = async (cursor?: string) => { - const res = await agent.api.app.bsky.feed.getRepostedBy( - { - uri: sc.posts[alice][2].ref.uriStr, - cursor, - limit: 2, - }, - { headers: await network.serviceHeaders(alice) }, - ) - return res.data - } - - const paginatedAll = await paginateAll(paginator) - paginatedAll.forEach((res) => - expect(res.repostedBy.length).toBeLessThanOrEqual(2), - ) - - const full = await agent.api.app.bsky.feed.getRepostedBy( - { uri: sc.posts[alice][2].ref.uriStr }, - { headers: await network.serviceHeaders(alice) }, - ) - - expect(full.data.repostedBy.length).toEqual(4) - expect(results(paginatedAll)).toEqual(results([full.data])) - }) - - it('fetches reposted-by unauthed', async () => { - const { data: authed } = await agent.api.app.bsky.feed.getRepostedBy( - { uri: sc.posts[alice][2].ref.uriStr }, - { headers: await network.serviceHeaders(alice) }, - ) - const { data: unauthed } = await agent.api.app.bsky.feed.getRepostedBy({ - uri: sc.posts[alice][2].ref.uriStr, - }) - expect(unauthed.repostedBy.length).toBeGreaterThan(0) - expect(unauthed.repostedBy).toEqual(authed.repostedBy.map(stripViewer)) - }) -}) diff --git a/packages/ozone/tests/views/suggested-follows.test.ts b/packages/ozone/tests/views/suggested-follows.test.ts deleted file mode 100644 index e9aa3248df7..00000000000 --- a/packages/ozone/tests/views/suggested-follows.test.ts +++ /dev/null @@ -1,146 +0,0 @@ -import AtpAgent, { AtUri } from '@atproto/api' -import { TestNetwork, SeedClient } from '@atproto/dev-env' -import likesSeed from '../seeds/likes' - -describe('suggested follows', () => { - let network: TestNetwork - let agent: AtpAgent - let pdsAgent: AtpAgent - let sc: SeedClient - - beforeAll(async () => { - network = await TestNetwork.create({ - dbPostgresSchema: 'bsky_views_suggested_follows', - }) - agent = network.bsky.getClient() - pdsAgent = network.pds.getClient() - sc = network.getSeedClient() - await likesSeed(sc) - await network.processAll() - await network.bsky.processAll() - - const suggestions = [ - { did: sc.dids.alice, order: 1 }, - { did: sc.dids.bob, order: 2 }, - { did: sc.dids.carol, order: 3 }, - { did: sc.dids.dan, order: 4 }, - { did: sc.dids.fred, order: 5 }, - { did: sc.dids.gina, order: 6 }, - ] - await network.bsky.ctx.db - .getPrimary() - .db.insertInto('suggested_follow') - .values(suggestions) - .execute() - }) - - afterAll(async () => { - await network.close() - }) - - it('returns sorted suggested follows for carol', async () => { - const result = await agent.api.app.bsky.graph.getSuggestedFollowsByActor( - { - actor: sc.dids.alice, - }, - { headers: await network.serviceHeaders(sc.dids.carol) }, - ) - - expect(result.data.suggestions.length).toBe(4) // backfilled with 2 NPCs - expect( - result.data.suggestions.find((sug) => { - return [sc.dids.alice, sc.dids.carol].includes(sug.did) - }), - ).toBeFalsy() // not actor or viewer - }) - - it('returns sorted suggested follows for fred', async () => { - const result = await agent.api.app.bsky.graph.getSuggestedFollowsByActor( - { - actor: sc.dids.alice, - }, - { headers: await network.serviceHeaders(sc.dids.fred) }, - ) - - expect(result.data.suggestions.length).toBe(4) // backfilled with 2 NPCs - expect( - result.data.suggestions.find((sug) => { - return [sc.dids.fred, sc.dids.alice].includes(sug.did) - }), - ).toBeFalsy() // not actor or viewer or followed - }) - - it('exludes users muted by viewer', async () => { - await pdsAgent.api.app.bsky.graph.muteActor( - { actor: sc.dids.bob }, - { headers: sc.getHeaders(sc.dids.carol), encoding: 'application/json' }, - ) - const result = await agent.api.app.bsky.graph.getSuggestedFollowsByActor( - { - actor: sc.dids.alice, - }, - { headers: await network.serviceHeaders(sc.dids.carol) }, - ) - - expect( - result.data.suggestions.find((sug) => { - return [sc.dids.alice, sc.dids.carol, sc.dids.bob].includes(sug.did) - }), - ).toBeFalsy() // not actor or viewer or muted - - await pdsAgent.api.app.bsky.graph.muteActor( - { actor: sc.dids.bob }, - { headers: sc.getHeaders(sc.dids.carol), encoding: 'application/json' }, - ) - }) - - it('exludes users blocked by viewer', async () => { - const carolBlocksBob = await pdsAgent.api.app.bsky.graph.block.create( - { repo: sc.dids.carol }, - { createdAt: new Date().toISOString(), subject: sc.dids.bob }, - sc.getHeaders(sc.dids.carol), - ) - const result = await agent.api.app.bsky.graph.getSuggestedFollowsByActor( - { - actor: sc.dids.alice, - }, - { headers: await network.serviceHeaders(sc.dids.carol) }, - ) - - expect( - result.data.suggestions.find((sug) => { - return [sc.dids.alice, sc.dids.carol, sc.dids.bob].includes(sug.did) - }), - ).toBeFalsy() // not actor or viewer or muted - - await pdsAgent.api.app.bsky.graph.block.delete( - { repo: sc.dids.carol, rkey: new AtUri(carolBlocksBob.uri).rkey }, - sc.getHeaders(sc.dids.carol), - ) - }) - - it('exludes users blocking viewer', async () => { - const bobBlocksCarol = await pdsAgent.api.app.bsky.graph.block.create( - { repo: sc.dids.bob }, - { createdAt: new Date().toISOString(), subject: sc.dids.carol }, - sc.getHeaders(sc.dids.bob), - ) - const result = await agent.api.app.bsky.graph.getSuggestedFollowsByActor( - { - actor: sc.dids.alice, - }, - { headers: await network.serviceHeaders(sc.dids.carol) }, - ) - - expect( - result.data.suggestions.find((sug) => { - return [sc.dids.alice, sc.dids.carol, sc.dids.bob].includes(sug.did) - }), - ).toBeFalsy() // not actor or viewer or muted - - await pdsAgent.api.app.bsky.graph.block.delete( - { repo: sc.dids.bob, rkey: new AtUri(bobBlocksCarol.uri).rkey }, - sc.getHeaders(sc.dids.bob), - ) - }) -}) diff --git a/packages/ozone/tests/views/suggestions.test.ts b/packages/ozone/tests/views/suggestions.test.ts deleted file mode 100644 index 4253f528b13..00000000000 --- a/packages/ozone/tests/views/suggestions.test.ts +++ /dev/null @@ -1,100 +0,0 @@ -import AtpAgent from '@atproto/api' -import { TestNetwork, SeedClient } from '@atproto/dev-env' -import { stripViewer } from '../_util' -import basicSeed from '../seeds/basic' - -describe('pds user search views', () => { - let network: TestNetwork - let agent: AtpAgent - let sc: SeedClient - - beforeAll(async () => { - network = await TestNetwork.create({ - dbPostgresSchema: 'bsky_views_suggestions', - }) - agent = network.bsky.getClient() - sc = network.getSeedClient() - await basicSeed(sc) - await network.processAll() - await network.bsky.processAll() - - const suggestions = [ - { did: sc.dids.alice, order: 1 }, - { did: sc.dids.bob, order: 2 }, - { did: sc.dids.carol, order: 3 }, - { did: sc.dids.dan, order: 4 }, - ] - - await network.bsky.ctx.db - .getPrimary() - .db.insertInto('suggested_follow') - .values(suggestions) - .execute() - }) - - afterAll(async () => { - await network.close() - }) - - it('actor suggestion gives users', async () => { - const result = await agent.api.app.bsky.actor.getSuggestions( - {}, - { headers: await network.serviceHeaders(sc.dids.carol) }, - ) - - // does not include carol, because she is requesting - expect(result.data.actors.length).toBe(2) - expect(result.data.actors[0].handle).toEqual('bob.test') - expect(result.data.actors[0].displayName).toEqual('bobby') - expect(result.data.actors[1].handle).toEqual('dan.test') - expect(result.data.actors[1].displayName).toBeUndefined() - }) - - it('does not suggest followed users', async () => { - const result = await agent.api.app.bsky.actor.getSuggestions( - {}, - { headers: await network.serviceHeaders(sc.dids.alice) }, - ) - - // alice follows everyone - expect(result.data.actors.length).toBe(0) - }) - - it('paginates', async () => { - const result1 = await agent.api.app.bsky.actor.getSuggestions( - { limit: 1 }, - { headers: await network.serviceHeaders(sc.dids.carol) }, - ) - expect(result1.data.actors.length).toBe(1) - expect(result1.data.actors[0].handle).toEqual('bob.test') - - const result2 = await agent.api.app.bsky.actor.getSuggestions( - { limit: 1, cursor: result1.data.cursor }, - { headers: await network.serviceHeaders(sc.dids.carol) }, - ) - expect(result2.data.actors.length).toBe(1) - expect(result2.data.actors[0].handle).toEqual('dan.test') - - const result3 = await agent.api.app.bsky.actor.getSuggestions( - { limit: 1, cursor: result2.data.cursor }, - { headers: await network.serviceHeaders(sc.dids.carol) }, - ) - expect(result3.data.actors.length).toBe(0) - expect(result3.data.cursor).toBeUndefined() - }) - - it('fetches suggestions unauthed', async () => { - const { data: authed } = await agent.api.app.bsky.actor.getSuggestions( - {}, - { headers: await network.serviceHeaders(sc.dids.carol) }, - ) - const { data: unauthed } = await agent.api.app.bsky.actor.getSuggestions({}) - const omitViewerFollows = ({ did }) => { - return did !== sc.dids.carol && !sc.follows[sc.dids.carol][did] - } - expect(unauthed.actors.length).toBeGreaterThan(0) - expect(unauthed.actors.filter(omitViewerFollows)).toEqual( - authed.actors.map(stripViewer), - ) - }) -}) diff --git a/packages/ozone/tests/views/thread.test.ts b/packages/ozone/tests/views/thread.test.ts deleted file mode 100644 index d42378aec6e..00000000000 --- a/packages/ozone/tests/views/thread.test.ts +++ /dev/null @@ -1,459 +0,0 @@ -import AtpAgent, { AppBskyFeedGetPostThread } from '@atproto/api' -import { TestNetwork, SeedClient } from '@atproto/dev-env' -import { forSnapshot, stripViewerFromThread } from '../_util' -import basicSeed from '../seeds/basic' -import assert from 'assert' -import { isThreadViewPost } from '@atproto/api/src/client/types/app/bsky/feed/defs' - -describe('pds thread views', () => { - let network: TestNetwork - let agent: AtpAgent - let sc: SeedClient - - // account dids, for convenience - let alice: string - let bob: string - let carol: string - - beforeAll(async () => { - network = await TestNetwork.create({ - dbPostgresSchema: 'bsky_views_thread', - }) - agent = network.bsky.getClient() - sc = network.getSeedClient() - await basicSeed(sc) - alice = sc.dids.alice - bob = sc.dids.bob - carol = sc.dids.carol - }) - - beforeAll(async () => { - // Add a repost of a reply so that we can confirm myState in the thread - await sc.repost(bob, sc.replies[alice][0].ref) - await network.processAll() - await network.bsky.processAll() - }) - - afterAll(async () => { - await network.close() - }) - - it('fetches deep post thread', async () => { - const thread = await agent.api.app.bsky.feed.getPostThread( - { uri: sc.posts[alice][1].ref.uriStr }, - { headers: await network.serviceHeaders(bob) }, - ) - - expect(forSnapshot(thread.data.thread)).toMatchSnapshot() - }) - - it('fetches shallow post thread', async () => { - const thread = await agent.api.app.bsky.feed.getPostThread( - { depth: 1, uri: sc.posts[alice][1].ref.uriStr }, - { headers: await network.serviceHeaders(bob) }, - ) - - expect(forSnapshot(thread.data.thread)).toMatchSnapshot() - }) - - it('fetches ancestors', async () => { - const thread = await agent.api.app.bsky.feed.getPostThread( - { depth: 1, uri: sc.replies[alice][0].ref.uriStr }, - { headers: await network.serviceHeaders(bob) }, - ) - - expect(forSnapshot(thread.data.thread)).toMatchSnapshot() - }) - - it('fails for an unknown post', async () => { - const promise = agent.api.app.bsky.feed.getPostThread( - { uri: 'at://did:example:fake/does.not.exist/self' }, - { headers: await network.serviceHeaders(bob) }, - ) - - await expect(promise).rejects.toThrow( - AppBskyFeedGetPostThread.NotFoundError, - ) - }) - - it('fetches post thread unauthed', async () => { - const { data: authed } = await agent.api.app.bsky.feed.getPostThread( - { uri: sc.posts[alice][1].ref.uriStr }, - { headers: await network.serviceHeaders(bob) }, - ) - const { data: unauthed } = await agent.api.app.bsky.feed.getPostThread({ - uri: sc.posts[alice][1].ref.uriStr, - }) - expect(unauthed.thread).toEqual(stripViewerFromThread(authed.thread)) - }) - - it('handles deleted posts correctly', async () => { - const alice = sc.dids.alice - const bob = sc.dids.bob - - const indexes = { - aliceRoot: -1, - bobReply: -1, - aliceReplyReply: -1, - } - - await sc.post(alice, 'Deletion thread') - indexes.aliceRoot = sc.posts[alice].length - 1 - - await sc.reply( - bob, - sc.posts[alice][indexes.aliceRoot].ref, - sc.posts[alice][indexes.aliceRoot].ref, - 'Reply', - ) - indexes.bobReply = sc.replies[bob].length - 1 - await sc.reply( - alice, - sc.posts[alice][indexes.aliceRoot].ref, - sc.replies[bob][indexes.bobReply].ref, - 'Reply reply', - ) - indexes.aliceReplyReply = sc.replies[alice].length - 1 - await network.processAll() - await network.bsky.processAll() - - const thread1 = await agent.api.app.bsky.feed.getPostThread( - { uri: sc.posts[alice][indexes.aliceRoot].ref.uriStr }, - { headers: await network.serviceHeaders(bob) }, - ) - expect(forSnapshot(thread1.data.thread)).toMatchSnapshot() - - await sc.deletePost(bob, sc.replies[bob][indexes.bobReply].ref.uri) - await network.processAll() - await network.bsky.processAll() - - const thread2 = await agent.api.app.bsky.feed.getPostThread( - { uri: sc.posts[alice][indexes.aliceRoot].ref.uriStr }, - { headers: await network.serviceHeaders(bob) }, - ) - expect(forSnapshot(thread2.data.thread)).toMatchSnapshot() - - const thread3 = await agent.api.app.bsky.feed.getPostThread( - { uri: sc.replies[alice][indexes.aliceReplyReply].ref.uriStr }, - { headers: await network.serviceHeaders(bob) }, - ) - expect(forSnapshot(thread3.data.thread)).toMatchSnapshot() - }) - - it('reflects self-labels', async () => { - const { data: thread } = await agent.api.app.bsky.feed.getPostThread( - { uri: sc.posts[alice][0].ref.uriStr }, - { headers: await network.serviceHeaders(bob) }, - ) - - assert(isThreadViewPost(thread.thread), 'post does not exist') - const post = thread.thread.post - - const postSelfLabels = post.labels - ?.filter((label) => label.src === alice) - .map((label) => label.val) - - expect(postSelfLabels).toEqual(['self-label']) - - const authorSelfLabels = post.author.labels - ?.filter((label) => label.src === alice) - .map((label) => label.val) - .sort() - - expect(authorSelfLabels).toEqual(['self-label-a', 'self-label-b']) - }) - - describe('takedown', () => { - it('blocks post by actor', async () => { - await agent.api.com.atproto.admin.emitModerationEvent( - { - event: { $type: 'com.atproto.admin.defs#modEventTakedown' }, - subject: { - $type: 'com.atproto.admin.defs#repoRef', - did: alice, - }, - createdBy: 'did:example:admin', - reason: 'Y', - }, - { - encoding: 'application/json', - headers: network.pds.adminAuthHeaders(), - }, - ) - - // Same as shallow post thread test, minus alice - const promise = agent.api.app.bsky.feed.getPostThread( - { depth: 1, uri: sc.posts[alice][1].ref.uriStr }, - { headers: await network.serviceHeaders(bob) }, - ) - - await expect(promise).rejects.toThrow( - AppBskyFeedGetPostThread.NotFoundError, - ) - - // Cleanup - await agent.api.com.atproto.admin.emitModerationEvent( - { - event: { $type: 'com.atproto.admin.defs#modEventReverseTakedown' }, - subject: { - $type: 'com.atproto.admin.defs#repoRef', - did: alice, - }, - createdBy: 'did:example:admin', - reason: 'Y', - }, - { - encoding: 'application/json', - headers: network.pds.adminAuthHeaders(), - }, - ) - }) - - it('blocks replies by actor', async () => { - await agent.api.com.atproto.admin.emitModerationEvent( - { - event: { $type: 'com.atproto.admin.defs#modEventTakedown' }, - subject: { - $type: 'com.atproto.admin.defs#repoRef', - did: carol, - }, - createdBy: 'did:example:admin', - reason: 'Y', - }, - { - encoding: 'application/json', - headers: network.pds.adminAuthHeaders(), - }, - ) - - // Same as deep post thread test, minus carol - const thread = await agent.api.app.bsky.feed.getPostThread( - { uri: sc.posts[alice][1].ref.uriStr }, - { headers: await network.serviceHeaders(bob) }, - ) - - expect(forSnapshot(thread.data.thread)).toMatchSnapshot() - - // Cleanup - await agent.api.com.atproto.admin.emitModerationEvent( - { - event: { $type: 'com.atproto.admin.defs#modEventReverseTakedown' }, - subject: { - $type: 'com.atproto.admin.defs#repoRef', - did: carol, - }, - createdBy: 'did:example:admin', - reason: 'Y', - }, - { - encoding: 'application/json', - headers: network.pds.adminAuthHeaders(), - }, - ) - }) - - it('blocks ancestors by actor', async () => { - await agent.api.com.atproto.admin.emitModerationEvent( - { - event: { $type: 'com.atproto.admin.defs#modEventTakedown' }, - subject: { - $type: 'com.atproto.admin.defs#repoRef', - did: bob, - }, - createdBy: 'did:example:admin', - reason: 'Y', - }, - { - encoding: 'application/json', - headers: network.pds.adminAuthHeaders(), - }, - ) - - // Same as ancestor post thread test, minus bob - const thread = await agent.api.app.bsky.feed.getPostThread( - { depth: 1, uri: sc.replies[alice][0].ref.uriStr }, - { headers: await network.serviceHeaders(bob) }, - ) - - expect(forSnapshot(thread.data.thread)).toMatchSnapshot() - - // Cleanup - await agent.api.com.atproto.admin.emitModerationEvent( - { - event: { $type: 'com.atproto.admin.defs#modEventReverseTakedown' }, - subject: { - $type: 'com.atproto.admin.defs#repoRef', - did: bob, - }, - createdBy: 'did:example:admin', - reason: 'Y', - }, - { - encoding: 'application/json', - headers: network.pds.adminAuthHeaders(), - }, - ) - }) - - it('blocks post by record', async () => { - const postRef = sc.posts[alice][1].ref - await agent.api.com.atproto.admin.emitModerationEvent( - { - event: { $type: 'com.atproto.admin.defs#modEventTakedown' }, - subject: { - $type: 'com.atproto.repo.strongRef', - uri: postRef.uriStr, - cid: postRef.cidStr, - }, - createdBy: 'did:example:admin', - reason: 'Y', - }, - { - encoding: 'application/json', - headers: network.pds.adminAuthHeaders(), - }, - ) - - const promise = agent.api.app.bsky.feed.getPostThread( - { depth: 1, uri: postRef.uriStr }, - { headers: await network.serviceHeaders(bob) }, - ) - - await expect(promise).rejects.toThrow( - AppBskyFeedGetPostThread.NotFoundError, - ) - - // Cleanup - await agent.api.com.atproto.admin.emitModerationEvent( - { - event: { $type: 'com.atproto.admin.defs#modEventReverseTakedown' }, - subject: { - $type: 'com.atproto.repo.strongRef', - uri: postRef.uriStr, - cid: postRef.cidStr, - }, - createdBy: 'did:example:admin', - reason: 'Y', - }, - { - encoding: 'application/json', - headers: network.pds.adminAuthHeaders(), - }, - ) - }) - - it('blocks ancestors by record', async () => { - const threadPreTakedown = await agent.api.app.bsky.feed.getPostThread( - { depth: 1, uri: sc.replies[alice][0].ref.uriStr }, - { headers: await network.serviceHeaders(bob) }, - ) - - const parent = threadPreTakedown.data.thread.parent?.['post'] - - await agent.api.com.atproto.admin.emitModerationEvent( - { - event: { $type: 'com.atproto.admin.defs#modEventTakedown' }, - subject: { - $type: 'com.atproto.repo.strongRef', - uri: parent.uri, - cid: parent.cid, - }, - createdBy: 'did:example:admin', - reason: 'Y', - }, - { - encoding: 'application/json', - headers: network.pds.adminAuthHeaders(), - }, - ) - - // Same as ancestor post thread test, minus parent post - const thread = await agent.api.app.bsky.feed.getPostThread( - { depth: 1, uri: sc.replies[alice][0].ref.uriStr }, - { headers: await network.serviceHeaders(bob) }, - ) - - expect(forSnapshot(thread.data.thread)).toMatchSnapshot() - - // Cleanup - await agent.api.com.atproto.admin.emitModerationEvent( - { - event: { $type: 'com.atproto.admin.defs#modEventReverseTakedown' }, - subject: { - $type: 'com.atproto.repo.strongRef', - uri: parent.uri, - cid: parent.cid, - }, - createdBy: 'did:example:admin', - reason: 'Y', - }, - { - encoding: 'application/json', - headers: network.pds.adminAuthHeaders(), - }, - ) - }) - - it('blocks replies by record', async () => { - const threadPreTakedown = await agent.api.app.bsky.feed.getPostThread( - { uri: sc.posts[alice][1].ref.uriStr }, - { headers: await network.serviceHeaders(bob) }, - ) - const post1 = threadPreTakedown.data.thread.replies?.[0].post - const post2 = threadPreTakedown.data.thread.replies?.[1].replies[0].post - - await Promise.all( - [post1, post2].map((post) => - agent.api.com.atproto.admin.emitModerationEvent( - { - event: { $type: 'com.atproto.admin.defs#modEventTakedown' }, - subject: { - $type: 'com.atproto.repo.strongRef', - uri: post.uri, - cid: post.cid, - }, - createdBy: 'did:example:admin', - reason: 'Y', - }, - { - encoding: 'application/json', - headers: network.pds.adminAuthHeaders(), - }, - ), - ), - ) - - // Same as deep post thread test, minus some replies - const thread = await agent.api.app.bsky.feed.getPostThread( - { uri: sc.posts[alice][1].ref.uriStr }, - { headers: await network.serviceHeaders(bob) }, - ) - - expect(forSnapshot(thread.data.thread)).toMatchSnapshot() - - // Cleanup - await Promise.all( - [post1, post2].map((post) => - agent.api.com.atproto.admin.emitModerationEvent( - { - event: { - $type: 'com.atproto.admin.defs#modEventReverseTakedown', - }, - subject: { - $type: 'com.atproto.repo.strongRef', - uri: post.uri, - cid: post.cid, - }, - createdBy: 'did:example:admin', - reason: 'Y', - }, - { - encoding: 'application/json', - headers: network.pds.adminAuthHeaders(), - }, - ), - ), - ) - }) - }) -}) diff --git a/packages/ozone/tests/views/threadgating.test.ts b/packages/ozone/tests/views/threadgating.test.ts deleted file mode 100644 index c0667bcf874..00000000000 --- a/packages/ozone/tests/views/threadgating.test.ts +++ /dev/null @@ -1,640 +0,0 @@ -import assert from 'assert' -import AtpAgent from '@atproto/api' -import { TestNetwork, SeedClient } from '@atproto/dev-env' -import { - isNotFoundPost, - isThreadViewPost, -} from '../../src/lexicon/types/app/bsky/feed/defs' -import basicSeed from '../seeds/basic' -import { forSnapshot } from '../_util' - -describe('views with thread gating', () => { - let network: TestNetwork - let agent: AtpAgent - let pdsAgent: AtpAgent - let sc: SeedClient - - beforeAll(async () => { - network = await TestNetwork.create({ - dbPostgresSchema: 'bsky_views_thread_gating', - }) - agent = network.bsky.getClient() - pdsAgent = network.pds.getClient() - sc = network.getSeedClient() - await basicSeed(sc) - await network.processAll() - }) - - afterAll(async () => { - await network.close() - }) - - // check that replyDisabled state is applied correctly in a simple method like getPosts - const checkReplyDisabled = async ( - uri: string, - user: string, - blocked: boolean | undefined, - ) => { - const res = await agent.api.app.bsky.feed.getPosts( - { uris: [uri] }, - { headers: await network.serviceHeaders(user) }, - ) - expect(res.data.posts[0].viewer?.replyDisabled).toBe(blocked) - } - - it('applies gate for empty rules.', async () => { - const post = await sc.post(sc.dids.carol, 'empty rules') - await pdsAgent.api.app.bsky.feed.threadgate.create( - { repo: sc.dids.carol, rkey: post.ref.uri.rkey }, - { post: post.ref.uriStr, createdAt: iso(), allow: [] }, - sc.getHeaders(sc.dids.carol), - ) - await network.processAll() - await sc.reply(sc.dids.alice, post.ref, post.ref, 'empty rules reply') - await network.processAll() - const { - data: { thread }, - } = await agent.api.app.bsky.feed.getPostThread( - { uri: post.ref.uriStr }, - { headers: await network.serviceHeaders(sc.dids.alice) }, - ) - assert(isThreadViewPost(thread)) - expect(forSnapshot(thread.post.threadgate)).toMatchSnapshot() - expect(thread.post.viewer).toEqual({ replyDisabled: true }) - expect(thread.replies?.length).toEqual(0) - await checkReplyDisabled(post.ref.uriStr, sc.dids.alice, true) - }) - - it('does not generate notifications when post violates threadgate.', async () => { - const post = await sc.post(sc.dids.carol, 'notifications') - await pdsAgent.api.app.bsky.feed.threadgate.create( - { repo: sc.dids.carol, rkey: post.ref.uri.rkey }, - { post: post.ref.uriStr, createdAt: iso(), allow: [] }, - sc.getHeaders(sc.dids.carol), - ) - await network.processAll() - const reply = await sc.reply( - sc.dids.alice, - post.ref, - post.ref, - 'notifications reply', - ) - await network.processAll() - const { - data: { notifications }, - } = await agent.api.app.bsky.notification.listNotifications( - {}, - { headers: await network.serviceHeaders(sc.dids.carol) }, - ) - const notificationFromReply = notifications.find( - (notif) => notif.uri === reply.ref.uriStr, - ) - expect(notificationFromReply).toBeUndefined() - }) - - it('applies gate for mention rule.', async () => { - const post = await sc.post( - sc.dids.carol, - 'mention rules @carol.test @dan.test', - [ - { - index: { byteStart: 14, byteEnd: 25 }, - features: [ - { $type: 'app.bsky.richtext.facet#mention', did: sc.dids.carol }, - ], - }, - { - index: { byteStart: 26, byteEnd: 35 }, - features: [ - { $type: 'app.bsky.richtext.facet#mention', did: sc.dids.dan }, - ], - }, - ], - ) - await pdsAgent.api.app.bsky.feed.threadgate.create( - { repo: sc.dids.carol, rkey: post.ref.uri.rkey }, - { - post: post.ref.uriStr, - createdAt: iso(), - allow: [{ $type: 'app.bsky.feed.threadgate#mentionRule' }], - }, - sc.getHeaders(sc.dids.carol), - ) - await network.processAll() - await sc.reply( - sc.dids.alice, - post.ref, - post.ref, - 'mention rule reply disallow', - ) - const danReply = await sc.reply( - sc.dids.dan, - post.ref, - post.ref, - 'mention rule reply allow', - ) - await network.processAll() - const { - data: { thread: aliceThread }, - } = await agent.api.app.bsky.feed.getPostThread( - { uri: post.ref.uriStr }, - { headers: await network.serviceHeaders(sc.dids.alice) }, - ) - assert(isThreadViewPost(aliceThread)) - expect(aliceThread.post.viewer).toEqual({ replyDisabled: true }) - await checkReplyDisabled(post.ref.uriStr, sc.dids.alice, true) - const { - data: { thread: danThread }, - } = await agent.api.app.bsky.feed.getPostThread( - { uri: post.ref.uriStr }, - { headers: await network.serviceHeaders(sc.dids.dan) }, - ) - assert(isThreadViewPost(danThread)) - expect(forSnapshot(danThread.post.threadgate)).toMatchSnapshot() - expect(danThread.post.viewer).toEqual({ replyDisabled: false }) - await checkReplyDisabled(post.ref.uriStr, sc.dids.dan, false) - const [reply, ...otherReplies] = danThread.replies ?? [] - assert(isThreadViewPost(reply)) - expect(otherReplies.length).toEqual(0) - expect(reply.post.uri).toEqual(danReply.ref.uriStr) - }) - - it('applies gate for following rule.', async () => { - const post = await sc.post(sc.dids.carol, 'following rule') - await pdsAgent.api.app.bsky.feed.threadgate.create( - { repo: sc.dids.carol, rkey: post.ref.uri.rkey }, - { - post: post.ref.uriStr, - createdAt: iso(), - allow: [{ $type: 'app.bsky.feed.threadgate#followingRule' }], - }, - sc.getHeaders(sc.dids.carol), - ) - await network.processAll() - // carol only follows alice - await sc.reply( - sc.dids.dan, - post.ref, - post.ref, - 'following rule reply disallow', - ) - const aliceReply = await sc.reply( - sc.dids.alice, - post.ref, - post.ref, - 'following rule reply allow', - ) - await network.processAll() - const { - data: { thread: danThread }, - } = await agent.api.app.bsky.feed.getPostThread( - { uri: post.ref.uriStr }, - { headers: await network.serviceHeaders(sc.dids.dan) }, - ) - assert(isThreadViewPost(danThread)) - expect(danThread.post.viewer).toEqual({ replyDisabled: true }) - await checkReplyDisabled(post.ref.uriStr, sc.dids.dan, true) - const { - data: { thread: aliceThread }, - } = await agent.api.app.bsky.feed.getPostThread( - { uri: post.ref.uriStr }, - { headers: await network.serviceHeaders(sc.dids.alice) }, - ) - assert(isThreadViewPost(aliceThread)) - expect(forSnapshot(aliceThread.post.threadgate)).toMatchSnapshot() - expect(aliceThread.post.viewer).toEqual({ replyDisabled: false }) - await checkReplyDisabled(post.ref.uriStr, sc.dids.alice, false) - const [reply, ...otherReplies] = aliceThread.replies ?? [] - assert(isThreadViewPost(reply)) - expect(otherReplies.length).toEqual(0) - expect(reply.post.uri).toEqual(aliceReply.ref.uriStr) - }) - - it('applies gate for list rule.', async () => { - const post = await sc.post(sc.dids.carol, 'following rule') - // setup lists to allow alice and dan - const listA = await pdsAgent.api.app.bsky.graph.list.create( - { repo: sc.dids.carol }, - { - name: 'list a', - purpose: 'app.bsky.graph.defs#modlist', - createdAt: iso(), - }, - sc.getHeaders(sc.dids.carol), - ) - await pdsAgent.api.app.bsky.graph.listitem.create( - { repo: sc.dids.carol }, - { - list: listA.uri, - subject: sc.dids.alice, - createdAt: iso(), - }, - sc.getHeaders(sc.dids.carol), - ) - const listB = await pdsAgent.api.app.bsky.graph.list.create( - { repo: sc.dids.carol }, - { - name: 'list b', - purpose: 'app.bsky.graph.defs#modlist', - createdAt: iso(), - }, - sc.getHeaders(sc.dids.carol), - ) - await pdsAgent.api.app.bsky.graph.listitem.create( - { repo: sc.dids.carol }, - { - list: listB.uri, - subject: sc.dids.dan, - createdAt: iso(), - }, - sc.getHeaders(sc.dids.carol), - ) - await pdsAgent.api.app.bsky.feed.threadgate.create( - { repo: sc.dids.carol, rkey: post.ref.uri.rkey }, - { - post: post.ref.uriStr, - createdAt: iso(), - allow: [ - { $type: 'app.bsky.feed.threadgate#listRule', list: listA.uri }, - { $type: 'app.bsky.feed.threadgate#listRule', list: listB.uri }, - ], - }, - sc.getHeaders(sc.dids.carol), - ) - await network.processAll() - // - await sc.reply(sc.dids.bob, post.ref, post.ref, 'list rule reply disallow') - const aliceReply = await sc.reply( - sc.dids.alice, - post.ref, - post.ref, - 'list rule reply allow (list a)', - ) - const danReply = await sc.reply( - sc.dids.dan, - post.ref, - post.ref, - 'list rule reply allow (list b)', - ) - await network.processAll() - const { - data: { thread: bobThread }, - } = await agent.api.app.bsky.feed.getPostThread( - { uri: post.ref.uriStr }, - { headers: await network.serviceHeaders(sc.dids.bob) }, - ) - assert(isThreadViewPost(bobThread)) - expect(bobThread.post.viewer).toEqual({ replyDisabled: true }) - await checkReplyDisabled(post.ref.uriStr, sc.dids.bob, true) - const { - data: { thread: aliceThread }, - } = await agent.api.app.bsky.feed.getPostThread( - { uri: post.ref.uriStr }, - { headers: await network.serviceHeaders(sc.dids.alice) }, - ) - assert(isThreadViewPost(aliceThread)) - expect(aliceThread.post.viewer).toEqual({ replyDisabled: false }) - await checkReplyDisabled(post.ref.uriStr, sc.dids.alice, false) - const { - data: { thread: danThread }, - } = await agent.api.app.bsky.feed.getPostThread( - { uri: post.ref.uriStr }, - { headers: await network.serviceHeaders(sc.dids.dan) }, - ) - assert(isThreadViewPost(danThread)) - expect(forSnapshot(danThread.post.threadgate)).toMatchSnapshot() - expect(danThread.post.viewer).toEqual({ replyDisabled: false }) - await checkReplyDisabled(post.ref.uriStr, sc.dids.dan, false) - const [reply1, reply2, ...otherReplies] = aliceThread.replies ?? [] - assert(isThreadViewPost(reply1)) - assert(isThreadViewPost(reply2)) - expect(otherReplies.length).toEqual(0) - expect(reply1.post.uri).toEqual(danReply.ref.uriStr) - expect(reply2.post.uri).toEqual(aliceReply.ref.uriStr) - }) - - it('applies gate for unknown list rule.', async () => { - const post = await sc.post(sc.dids.carol, 'unknown list rules') - await pdsAgent.api.app.bsky.feed.threadgate.create( - { repo: sc.dids.carol, rkey: post.ref.uri.rkey }, - { - post: post.ref.uriStr, - createdAt: iso(), - allow: [ - { - $type: 'app.bsky.feed.threadgate#listRule', - list: post.ref.uriStr, // bad list link, references a post - }, - ], - }, - sc.getHeaders(sc.dids.carol), - ) - await network.processAll() - await sc.reply( - sc.dids.alice, - post.ref, - post.ref, - 'unknown list rules reply', - ) - await network.processAll() - const { - data: { thread }, - } = await agent.api.app.bsky.feed.getPostThread( - { uri: post.ref.uriStr }, - { headers: await network.serviceHeaders(sc.dids.alice) }, - ) - assert(isThreadViewPost(thread)) - expect(forSnapshot(thread.post.threadgate)).toMatchSnapshot() - expect(thread.post.viewer).toEqual({ replyDisabled: true }) - expect(thread.replies?.length).toEqual(0) - await checkReplyDisabled(post.ref.uriStr, sc.dids.alice, true) - }) - - it('applies gate for multiple rules.', async () => { - const post = await sc.post(sc.dids.carol, 'multi rules @dan.test', [ - { - index: { byteStart: 12, byteEnd: 21 }, - features: [ - { $type: 'app.bsky.richtext.facet#mention', did: sc.dids.dan }, - ], - }, - ]) - await pdsAgent.api.app.bsky.feed.threadgate.create( - { repo: sc.dids.carol, rkey: post.ref.uri.rkey }, - { - post: post.ref.uriStr, - createdAt: iso(), - allow: [ - { $type: 'app.bsky.feed.threadgate#mentionRule' }, - { $type: 'app.bsky.feed.threadgate#followingRule' }, - ], - }, - sc.getHeaders(sc.dids.carol), - ) - await network.processAll() - // carol only follows alice, and the post mentions dan. - await sc.reply(sc.dids.bob, post.ref, post.ref, 'multi rule reply disallow') - const aliceReply = await sc.reply( - sc.dids.alice, - post.ref, - post.ref, - 'multi rule reply allow (following)', - ) - const danReply = await sc.reply( - sc.dids.dan, - post.ref, - post.ref, - 'multi rule reply allow (mention)', - ) - await network.processAll() - const { - data: { thread: bobThread }, - } = await agent.api.app.bsky.feed.getPostThread( - { uri: post.ref.uriStr }, - { headers: await network.serviceHeaders(sc.dids.bob) }, - ) - assert(isThreadViewPost(bobThread)) - expect(bobThread.post.viewer).toEqual({ replyDisabled: true }) - await checkReplyDisabled(post.ref.uriStr, sc.dids.bob, true) - const { - data: { thread: aliceThread }, - } = await agent.api.app.bsky.feed.getPostThread( - { uri: post.ref.uriStr }, - { headers: await network.serviceHeaders(sc.dids.alice) }, - ) - assert(isThreadViewPost(aliceThread)) - expect(aliceThread.post.viewer).toEqual({ replyDisabled: false }) - await checkReplyDisabled(post.ref.uriStr, sc.dids.alice, false) - const { - data: { thread: danThread }, - } = await agent.api.app.bsky.feed.getPostThread( - { uri: post.ref.uriStr }, - { headers: await network.serviceHeaders(sc.dids.dan) }, - ) - assert(isThreadViewPost(danThread)) - expect(forSnapshot(danThread.post.threadgate)).toMatchSnapshot() - expect(danThread.post.viewer).toEqual({ replyDisabled: false }) - await checkReplyDisabled(post.ref.uriStr, sc.dids.dan, false) - const [reply1, reply2, ...otherReplies] = aliceThread.replies ?? [] - assert(isThreadViewPost(reply1)) - assert(isThreadViewPost(reply2)) - expect(otherReplies.length).toEqual(0) - expect(reply1.post.uri).toEqual(danReply.ref.uriStr) - expect(reply2.post.uri).toEqual(aliceReply.ref.uriStr) - }) - - it('applies gate for missing rules, takes no action.', async () => { - const post = await sc.post(sc.dids.carol, 'missing rules') - await pdsAgent.api.app.bsky.feed.threadgate.create( - { repo: sc.dids.carol, rkey: post.ref.uri.rkey }, - { post: post.ref.uriStr, createdAt: iso() }, - sc.getHeaders(sc.dids.carol), - ) - await network.processAll() - const aliceReply = await sc.reply( - sc.dids.alice, - post.ref, - post.ref, - 'missing rules reply', - ) - await network.processAll() - const { - data: { thread }, - } = await agent.api.app.bsky.feed.getPostThread( - { uri: post.ref.uriStr }, - { headers: await network.serviceHeaders(sc.dids.alice) }, - ) - assert(isThreadViewPost(thread)) - expect(forSnapshot(thread.post.threadgate)).toMatchSnapshot() - expect(thread.post.viewer).toEqual({ replyDisabled: false }) - await checkReplyDisabled(post.ref.uriStr, sc.dids.alice, false) - const [reply, ...otherReplies] = thread.replies ?? [] - assert(isThreadViewPost(reply)) - expect(otherReplies.length).toEqual(0) - expect(reply.post.uri).toEqual(aliceReply.ref.uriStr) - }) - - it('applies gate after root post is deleted.', async () => { - // @NOTE also covers rule application more than one level deep - const post = await sc.post(sc.dids.carol, 'following rule w/ post deletion') - await pdsAgent.api.app.bsky.feed.threadgate.create( - { repo: sc.dids.carol, rkey: post.ref.uri.rkey }, - { - post: post.ref.uriStr, - createdAt: iso(), - allow: [{ $type: 'app.bsky.feed.threadgate#followingRule' }], - }, - sc.getHeaders(sc.dids.carol), - ) - await network.processAll() - // carol only follows alice - const orphanedReply = await sc.reply( - sc.dids.alice, - post.ref, - post.ref, - 'following rule reply allow', - ) - await pdsAgent.api.app.bsky.feed.post.delete( - { repo: sc.dids.carol, rkey: post.ref.uri.rkey }, - sc.getHeaders(sc.dids.carol), - ) - await network.processAll() - await sc.reply( - sc.dids.dan, - post.ref, - orphanedReply.ref, - 'following rule reply disallow', - ) - const aliceReply = await sc.reply( - sc.dids.alice, - post.ref, - orphanedReply.ref, - 'following rule reply allow', - ) - await network.processAll() - const { - data: { thread: danThread }, - } = await agent.api.app.bsky.feed.getPostThread( - { uri: orphanedReply.ref.uriStr }, - { headers: await network.serviceHeaders(sc.dids.dan) }, - ) - assert(isThreadViewPost(danThread)) - expect(danThread.post.viewer).toEqual({ replyDisabled: true }) - await checkReplyDisabled(orphanedReply.ref.uriStr, sc.dids.dan, true) - const { - data: { thread: aliceThread }, - } = await agent.api.app.bsky.feed.getPostThread( - { uri: orphanedReply.ref.uriStr }, - { headers: await network.serviceHeaders(sc.dids.alice) }, - ) - assert(isThreadViewPost(aliceThread)) - assert( - isNotFoundPost(aliceThread.parent) && - aliceThread.parent.uri === post.ref.uriStr, - ) - expect(aliceThread.post.threadgate).toMatchSnapshot() - expect(aliceThread.post.viewer).toEqual({ replyDisabled: false }) - await checkReplyDisabled(orphanedReply.ref.uriStr, sc.dids.alice, false) - const [reply, ...otherReplies] = aliceThread.replies ?? [] - assert(isThreadViewPost(reply)) - expect(otherReplies.length).toEqual(0) - expect(reply.post.uri).toEqual(aliceReply.ref.uriStr) - }) - - it('does not apply gate to original poster.', async () => { - const post = await sc.post(sc.dids.carol, 'empty rules') - await pdsAgent.api.app.bsky.feed.threadgate.create( - { repo: sc.dids.carol, rkey: post.ref.uri.rkey }, - { post: post.ref.uriStr, createdAt: iso(), allow: [] }, - sc.getHeaders(sc.dids.carol), - ) - await network.processAll() - const selfReply = await sc.reply( - sc.dids.carol, - post.ref, - post.ref, - 'empty rules reply allow', - ) - await network.processAll() - const { - data: { thread }, - } = await agent.api.app.bsky.feed.getPostThread( - { uri: post.ref.uriStr }, - { headers: await network.serviceHeaders(sc.dids.carol) }, - ) - assert(isThreadViewPost(thread)) - expect(forSnapshot(thread.post.threadgate)).toMatchSnapshot() - expect(thread.post.viewer).toEqual({ replyDisabled: false }) - await checkReplyDisabled(post.ref.uriStr, sc.dids.carol, false) - const [reply, ...otherReplies] = thread.replies ?? [] - assert(isThreadViewPost(reply)) - expect(otherReplies.length).toEqual(0) - expect(reply.post.uri).toEqual(selfReply.ref.uriStr) - }) - - it('displays gated posts in feed and thread anchor without reply context.', async () => { - const post = await sc.post(sc.dids.carol, 'following rule') - await pdsAgent.api.app.bsky.feed.threadgate.create( - { repo: sc.dids.carol, rkey: post.ref.uri.rkey }, - { - post: post.ref.uriStr, - createdAt: iso(), - allow: [{ $type: 'app.bsky.feed.threadgate#followingRule' }], - }, - sc.getHeaders(sc.dids.carol), - ) - await network.processAll() - // carol only follows alice - const badReply = await sc.reply( - sc.dids.dan, - post.ref, - post.ref, - 'following rule reply disallow', - ) - // going to ensure this one doesn't appear in badReply's thread - await sc.reply(sc.dids.alice, post.ref, badReply.ref, 'reply to disallowed') - await network.processAll() - // check thread view - const { - data: { thread }, - } = await agent.api.app.bsky.feed.getPostThread( - { uri: badReply.ref.uriStr }, - { headers: await network.serviceHeaders(sc.dids.alice) }, - ) - assert(isThreadViewPost(thread)) - expect(thread.post.viewer).toEqual({ replyDisabled: true }) // nobody can reply to this, not even alice. - expect(thread.replies).toBeUndefined() - expect(thread.parent).toBeUndefined() - expect(thread.post.threadgate).toBeUndefined() - await checkReplyDisabled(badReply.ref.uriStr, sc.dids.alice, true) - // check feed view - const { - data: { feed }, - } = await agent.api.app.bsky.feed.getAuthorFeed( - { actor: sc.dids.dan }, - { headers: await network.serviceHeaders(sc.dids.alice) }, - ) - const [feedItem] = feed - expect(feedItem.post.uri).toEqual(badReply.ref.uriStr) - expect(feedItem.post.threadgate).toBeUndefined() - expect(feedItem.reply).toBeUndefined() - }) - - it('does not apply gate unless it matches post rkey.', async () => { - const postA = await sc.post(sc.dids.carol, 'ungated a') - const postB = await sc.post(sc.dids.carol, 'ungated b') - await pdsAgent.api.app.bsky.feed.threadgate.create( - { repo: sc.dids.carol, rkey: postA.ref.uri.rkey }, - { post: postB.ref.uriStr, createdAt: iso(), allow: [] }, - sc.getHeaders(sc.dids.carol), - ) - await network.processAll() - await sc.reply(sc.dids.alice, postA.ref, postA.ref, 'ungated reply') - await sc.reply(sc.dids.alice, postB.ref, postB.ref, 'ungated reply') - await network.processAll() - const { - data: { thread: threadA }, - } = await agent.api.app.bsky.feed.getPostThread( - { uri: postA.ref.uriStr }, - { headers: await network.serviceHeaders(sc.dids.alice) }, - ) - assert(isThreadViewPost(threadA)) - expect(threadA.post.threadgate).toBeUndefined() - expect(threadA.post.viewer).toEqual({}) - expect(threadA.replies?.length).toEqual(1) - await checkReplyDisabled(postA.ref.uriStr, sc.dids.alice, undefined) - const { - data: { thread: threadB }, - } = await agent.api.app.bsky.feed.getPostThread( - { uri: postB.ref.uriStr }, - { headers: await network.serviceHeaders(sc.dids.alice) }, - ) - assert(isThreadViewPost(threadB)) - expect(threadB.post.threadgate).toBeUndefined() - expect(threadB.post.viewer).toEqual({}) - await checkReplyDisabled(postB.ref.uriStr, sc.dids.alice, undefined) - expect(threadB.replies?.length).toEqual(1) - }) -}) - -const iso = (date = new Date()) => date.toISOString() diff --git a/packages/ozone/tests/views/timeline.test.ts b/packages/ozone/tests/views/timeline.test.ts deleted file mode 100644 index 5410d792a1f..00000000000 --- a/packages/ozone/tests/views/timeline.test.ts +++ /dev/null @@ -1,286 +0,0 @@ -import assert from 'assert' -import AtpAgent from '@atproto/api' -import { TestNetwork, SeedClient } from '@atproto/dev-env' -import { forSnapshot, getOriginator, paginateAll } from '../_util' -import basicSeed from '../seeds/basic' -import { FeedAlgorithm } from '../../src/api/app/bsky/util/feed' -import { FeedViewPost } from '../../src/lexicon/types/app/bsky/feed/defs' - -describe('timeline views', () => { - let network: TestNetwork - let agent: AtpAgent - let sc: SeedClient - - // account dids, for convenience - let alice: string - let bob: string - let carol: string - let dan: string - - beforeAll(async () => { - network = await TestNetwork.create({ - dbPostgresSchema: 'bsky_views_home_feed', - }) - agent = network.bsky.getClient() - sc = network.getSeedClient() - await basicSeed(sc) - await network.processAll() - alice = sc.dids.alice - bob = sc.dids.bob - carol = sc.dids.carol - dan = sc.dids.dan - // Label posts as "kind" to check labels on embed views - const labelPostA = sc.posts[bob][0].ref - const labelPostB = sc.posts[carol][0].ref - await network.bsky.ctx.services - .label(network.bsky.ctx.db.getPrimary()) - .formatAndCreate( - network.bsky.ctx.cfg.labelerDid, - labelPostA.uriStr, - labelPostA.cidStr, - { create: ['kind'] }, - ) - await network.bsky.ctx.services - .label(network.bsky.ctx.db.getPrimary()) - .formatAndCreate( - network.bsky.ctx.cfg.labelerDid, - labelPostB.uriStr, - labelPostB.cidStr, - { create: ['kind'] }, - ) - await network.bsky.processAll() - }) - - afterAll(async () => { - await network.close() - }) - - // @TODO(bsky) blocks posts, reposts, replies by actor takedown via labels - // @TODO(bsky) blocks posts, reposts, replies by record takedown via labels - - it("fetches authenticated user's home feed w/ reverse-chronological algorithm", async () => { - const expectOriginatorFollowedBy = (did) => (item: FeedViewPost) => { - const originator = getOriginator(item) - // The user expects to see posts & reposts from themselves and follows - if (did !== originator) { - expect(sc.follows[did]).toHaveProperty(originator) - } - } - - const aliceTL = await agent.api.app.bsky.feed.getTimeline( - { algorithm: FeedAlgorithm.ReverseChronological }, - { - headers: await network.serviceHeaders(alice), - }, - ) - - expect(forSnapshot(aliceTL.data.feed)).toMatchSnapshot() - aliceTL.data.feed.forEach(expectOriginatorFollowedBy(alice)) - - const bobTL = await agent.api.app.bsky.feed.getTimeline( - { algorithm: FeedAlgorithm.ReverseChronological }, - { - headers: await network.serviceHeaders(bob), - }, - ) - - expect(forSnapshot(bobTL.data.feed)).toMatchSnapshot() - bobTL.data.feed.forEach(expectOriginatorFollowedBy(bob)) - - const carolTL = await agent.api.app.bsky.feed.getTimeline( - { algorithm: FeedAlgorithm.ReverseChronological }, - { - headers: await network.serviceHeaders(carol), - }, - ) - - expect(forSnapshot(carolTL.data.feed)).toMatchSnapshot() - carolTL.data.feed.forEach(expectOriginatorFollowedBy(carol)) - - const danTL = await agent.api.app.bsky.feed.getTimeline( - { algorithm: FeedAlgorithm.ReverseChronological }, - { - headers: await network.serviceHeaders(dan), - }, - ) - - expect(forSnapshot(danTL.data.feed)).toMatchSnapshot() - danTL.data.feed.forEach(expectOriginatorFollowedBy(dan)) - }) - - it("fetches authenticated user's home feed w/ default algorithm", async () => { - const defaultTL = await agent.api.app.bsky.feed.getTimeline( - {}, - { - headers: await network.serviceHeaders(alice), - }, - ) - const reverseChronologicalTL = await agent.api.app.bsky.feed.getTimeline( - { algorithm: FeedAlgorithm.ReverseChronological }, - { - headers: await network.serviceHeaders(alice), - }, - ) - expect(defaultTL.data.feed).toEqual(reverseChronologicalTL.data.feed) - }) - - it('paginates reverse-chronological feed', async () => { - const results = (results) => results.flatMap((res) => res.feed) - const paginator = async (cursor?: string) => { - const res = await agent.api.app.bsky.feed.getTimeline( - { - algorithm: FeedAlgorithm.ReverseChronological, - cursor, - limit: 4, - }, - { headers: await network.serviceHeaders(carol) }, - ) - return res.data - } - - const paginatedAll = await paginateAll(paginator) - paginatedAll.forEach((res) => - expect(res.feed.length).toBeLessThanOrEqual(4), - ) - - const full = await agent.api.app.bsky.feed.getTimeline( - { - algorithm: FeedAlgorithm.ReverseChronological, - }, - { headers: await network.serviceHeaders(carol) }, - ) - - expect(full.data.feed.length).toEqual(7) - expect(results(paginatedAll)).toEqual(results([full.data])) - }) - - it('reflects self-labels', async () => { - const carolTL = await agent.api.app.bsky.feed.getTimeline( - {}, - { headers: await network.serviceHeaders(carol) }, - ) - - const alicePost = carolTL.data.feed.find( - ({ post }) => post.uri === sc.posts[alice][0].ref.uriStr, - )?.post - - assert(alicePost, 'post does not exist') - - const postSelfLabels = alicePost.labels - ?.filter((label) => label.src === alice) - .map((label) => label.val) - - expect(postSelfLabels).toEqual(['self-label']) - - const authorSelfLabels = alicePost.author.labels - ?.filter((label) => label.src === alice) - .map((label) => label.val) - .sort() - - expect(authorSelfLabels).toEqual(['self-label-a', 'self-label-b']) - }) - - it('blocks posts, reposts, replies by actor takedown', async () => { - await Promise.all( - [bob, carol].map((did) => - agent.api.com.atproto.admin.emitModerationEvent( - { - event: { $type: 'com.atproto.admin.defs#modEventTakedown' }, - subject: { - $type: 'com.atproto.admin.defs#repoRef', - did, - }, - createdBy: 'did:example:admin', - reason: 'Y', - }, - { - encoding: 'application/json', - headers: network.pds.adminAuthHeaders(), - }, - ), - ), - ) - - const aliceTL = await agent.api.app.bsky.feed.getTimeline( - { algorithm: FeedAlgorithm.ReverseChronological }, - { headers: await network.serviceHeaders(alice) }, - ) - - expect(forSnapshot(aliceTL.data.feed)).toMatchSnapshot() - - // Cleanup - await Promise.all( - [bob, carol].map((did) => - agent.api.com.atproto.admin.emitModerationEvent( - { - event: { $type: 'com.atproto.admin.defs#modEventReverseTakedown' }, - subject: { - $type: 'com.atproto.admin.defs#repoRef', - did, - }, - createdBy: 'did:example:admin', - reason: 'Y', - }, - { - encoding: 'application/json', - headers: network.pds.adminAuthHeaders(), - }, - ), - ), - ) - }) - - it('blocks posts, reposts, replies by record takedown.', async () => { - const postRef1 = sc.posts[dan][1].ref // Repost - const postRef2 = sc.replies[bob][0].ref // Post and reply parent - await Promise.all( - [postRef1, postRef2].map((postRef) => - agent.api.com.atproto.admin.emitModerationEvent( - { - event: { $type: 'com.atproto.admin.defs#modEventTakedown' }, - subject: { - $type: 'com.atproto.repo.strongRef', - uri: postRef.uriStr, - cid: postRef.cidStr, - }, - createdBy: 'did:example:admin', - reason: 'Y', - }, - { - encoding: 'application/json', - headers: network.pds.adminAuthHeaders(), - }, - ), - ), - ) - - const aliceTL = await agent.api.app.bsky.feed.getTimeline( - { algorithm: FeedAlgorithm.ReverseChronological }, - { headers: await network.serviceHeaders(alice) }, - ) - - expect(forSnapshot(aliceTL.data.feed)).toMatchSnapshot() - - // Cleanup - await Promise.all( - [postRef1, postRef2].map((postRef) => - agent.api.com.atproto.admin.emitModerationEvent( - { - event: { $type: 'com.atproto.admin.defs#modEventReverseTakedown' }, - subject: { - $type: 'com.atproto.repo.strongRef', - uri: postRef.uriStr, - cid: postRef.cidStr, - }, - createdBy: 'did:example:admin', - reason: 'Y', - }, - { - encoding: 'application/json', - headers: network.pds.adminAuthHeaders(), - }, - ), - ), - ) - }) -})