atproto/packages/ozone/tests/get-repos.test.ts
Matthieu Sieben 61dc0d60e1
Add linting rule to sort imports (#3220)
* Add linting rule to sort imports

* remove spacing between import groups

* changeset

* changeset

* prettier config fine tuning

* forbid use of deprecated imports

* tidy
2025-02-05 15:06:58 +01:00

92 lines
2.3 KiB
TypeScript

import { AtpAgent } from '@atproto/api'
import {
ModeratorClient,
SeedClient,
TestNetwork,
TestOzone,
basicSeed,
} from '@atproto/dev-env'
import { ids } from '../src/lexicon/lexicons'
import {
REASONOTHER,
REASONSPAM,
} from '../src/lexicon/types/com/atproto/moderation/defs'
import { forSnapshot } from './_util'
describe('admin get multiple repos', () => {
let network: TestNetwork
let ozone: TestOzone
let agent: AtpAgent
let pdsAgent: AtpAgent
let sc: SeedClient
let modClient: ModeratorClient
beforeAll(async () => {
network = await TestNetwork.create({
dbPostgresSchema: 'ozone_admin_get_repos',
})
ozone = network.ozone
agent = ozone.getClient()
pdsAgent = network.pds.getClient()
sc = network.getSeedClient()
modClient = ozone.getModClient()
await basicSeed(sc)
await pdsAgent.com.atproto.server.deactivateAccount(
{},
{ encoding: 'application/json', headers: sc.getHeaders(sc.dids.dan) },
)
await network.processAll()
})
beforeEach(async () => {
await network.processAll()
})
afterAll(async () => {
await network.close()
})
beforeAll(async () => {
await modClient.emitEvent({
event: { $type: 'tools.ozone.moderation.defs#modEventAcknowledge' },
subject: {
$type: 'com.atproto.admin.defs#repoRef',
did: sc.dids.alice,
},
})
await sc.createReport({
reportedBy: sc.dids.bob,
reasonType: REASONSPAM,
subject: {
$type: 'com.atproto.admin.defs#repoRef',
did: sc.dids.alice,
},
})
await sc.createReport({
reportedBy: sc.dids.carol,
reasonType: REASONOTHER,
reason: 'defamation',
subject: {
$type: 'com.atproto.admin.defs#repoRef',
did: sc.dids.alice,
},
})
await modClient.emitEvent({
event: { $type: 'tools.ozone.moderation.defs#modEventTakedown' },
subject: {
$type: 'com.atproto.admin.defs#repoRef',
did: sc.dids.alice,
},
})
})
it('gets multiple repos by did', async () => {
const { data } = await agent.tools.ozone.moderation.getRepos(
{ dids: [sc.dids.alice, sc.dids.bob, 'did:web:xyz'] },
{ headers: await ozone.modHeaders(ids.ToolsOzoneModerationGetRepos) },
)
expect(forSnapshot(data)).toMatchSnapshot()
})
})