|
| 1 | +import { afterAll, beforeAll, describe, expect, test } from "@jest/globals" |
| 2 | +import { AtpAgent } from "@atproto/api" |
| 3 | +import { TestNetwork, SeedClient, usersSeed } from "@atproto/dev-env" |
| 4 | + |
| 5 | +import { Trotsky } from "../../lib/trotsky" |
| 6 | + |
| 7 | +describe("StepActorUnmute", () => { |
| 8 | + let network: TestNetwork |
| 9 | + let agent: AtpAgent |
| 10 | + let sc: SeedClient |
| 11 | + let alice: { "did": string; "handle": string; "password": string } |
| 12 | + let bob: { "did": string; "handle": string; "password": string } |
| 13 | + let carol: { "did": string; "handle": string; "password": string } |
| 14 | + |
| 15 | + beforeAll(async () => { |
| 16 | + network = await TestNetwork.create({ "dbPostgresSchema": "step_actor_unmute" }) |
| 17 | + agent = network.pds.getClient() |
| 18 | + |
| 19 | + sc = network.getSeedClient() |
| 20 | + await usersSeed(sc) |
| 21 | + |
| 22 | + bob = sc.accounts[sc.dids.bob] |
| 23 | + alice = sc.accounts[sc.dids.alice] |
| 24 | + carol = sc.accounts[sc.dids.carol] |
| 25 | + |
| 26 | + await network.processAll() |
| 27 | + await agent.login({ "identifier": bob.handle, "password": bob.password }) |
| 28 | + }) |
| 29 | + |
| 30 | + afterAll(async () => { |
| 31 | + await network.close() |
| 32 | + }) |
| 33 | + |
| 34 | + test("unmute Alice", async () => { |
| 35 | + await Trotsky.init(agent).actor(alice.handle).mute().wait(1e3).run() |
| 36 | + await Trotsky.init(agent).actor(alice.handle).unmute().wait(1e3).run() |
| 37 | + |
| 38 | + const { "data": { mutes } } = await agent.app.bsky.graph.getMutes() |
| 39 | + |
| 40 | + expect(mutes).not.toEqual( |
| 41 | + expect.arrayContaining([ |
| 42 | + expect.objectContaining({ |
| 43 | + "handle": alice.handle |
| 44 | + }) |
| 45 | + ]) |
| 46 | + ) |
| 47 | + }) |
| 48 | + |
| 49 | + test("unmute Carol does nothing even if she is not muted", async () => { |
| 50 | + await Trotsky.init(agent).actor(carol.handle).unmute().wait(1e3).run() |
| 51 | + |
| 52 | + const { "data": { mutes } } = await agent.app.bsky.graph.getMutes() |
| 53 | + |
| 54 | + expect(mutes).not.toEqual( |
| 55 | + expect.arrayContaining([ |
| 56 | + expect.objectContaining({ |
| 57 | + "handle": carol.handle |
| 58 | + }) |
| 59 | + ]) |
| 60 | + ) |
| 61 | + }) |
| 62 | +}) |
0 commit comments