Skip to content

Commit

Permalink
✅ Update snapshot check for tags array (#3340)
Browse files Browse the repository at this point in the history
  • Loading branch information
foysalit authored Jan 8, 2025
1 parent 5b6e061 commit 9dc7251
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
19 changes: 19 additions & 0 deletions packages/pds/tests/_util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { CID } from 'multiformats/cid'
import { Server } from 'node:http'
import { AddressInfo } from 'node:net'
import { FeedViewPost } from '../src/lexicon/types/app/bsky/feed/defs'
import { ToolsOzoneModerationDefs } from '@atproto/api'

// Swap out identifiers and dates with stable
// values for the purpose of snapshot testing
Expand Down Expand Up @@ -202,3 +203,21 @@ export async function stopServer(server: Server) {
})
})
}

const normalizeSubjectStatus = (
subject: ToolsOzoneModerationDefs.SubjectStatusView,
) => {
return { ...subject, tags: subject.tags?.sort() }
}

export const forSubjectStatusSnapshot = (
status:
| ToolsOzoneModerationDefs.SubjectStatusView
| ToolsOzoneModerationDefs.SubjectStatusView[],
) => {
if (Array.isArray(status)) {
return forSnapshot(status.map(normalizeSubjectStatus))
}

return forSnapshot(normalizeSubjectStatus(status))
}
6 changes: 4 additions & 2 deletions packages/pds/tests/takedown-appeal.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AtpAgent, ComAtprotoModerationDefs } from '@atproto/api'
import { SeedClient, TestNetwork } from '@atproto/dev-env'
import { forSnapshot } from './_util'
import { forSubjectStatusSnapshot } from './_util'
import { ids } from '../src/lexicon/lexicons'

describe('appeal account takedown', () => {
Expand Down Expand Up @@ -97,7 +97,9 @@ describe('appeal account takedown', () => {
)

expect(result.subjectStatuses[0].appealed).toBe(true)
expect(forSnapshot(result.subjectStatuses[0])).toMatchSnapshot()
expect(
forSubjectStatusSnapshot(result.subjectStatuses[0]),
).toMatchSnapshot()
})

it('takendown actor is not allowed to create reports.', async () => {
Expand Down

0 comments on commit 9dc7251

Please sign in to comment.