Skip to content

Commit

Permalink
fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
matthieusieben committed Dec 16, 2024
1 parent 4e71da9 commit 344ac6b
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 11 deletions.
1 change: 1 addition & 0 deletions packages/api/tests/moderation-mutewords.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,7 @@ describe(`hasMutedWord`, () => {
features: [
{
$type: 'com.example.richtext.facet#other',
// @ts-expect-error
foo: 'bar',
},
{
Expand Down
9 changes: 7 additions & 2 deletions packages/ozone/tests/_util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { CID } from 'multiformats/cid'
import {
FeedViewPost,
PostView,
ThreadViewPost,
isPostView,
isReasonRepost,
isThreadViewPost,
Expand Down Expand Up @@ -191,7 +192,9 @@ export const stripViewerFromPost = (postUnknown: object): PostView => {
}

// @NOTE mutates
export const stripViewerFromThread = <T>(thread: T): T => {
export const stripViewerFromThread = <T extends ThreadViewPost>(
thread: T,
): Omit<T, 'viewer'> => {
if (!isThreadViewPost(thread)) return thread
// @ts-expect-error
delete thread.viewer
Expand All @@ -200,7 +203,9 @@ export const stripViewerFromThread = <T>(thread: T): T => {
thread.parent = stripViewerFromThread(thread.parent)
}
if (thread.replies) {
thread.replies = thread.replies.map(stripViewerFromThread)
thread.replies = thread.replies.map((r) =>
isThreadViewPost(r) ? stripViewerFromThread(r) : r,
)
}
return thread
}
6 changes: 4 additions & 2 deletions packages/ozone/tests/blob-divert.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import assert from 'node:assert'
import { ToolsOzoneModerationDefs } from '@atproto/api'
import {
ModeratorClient,
SeedClient,
Expand Down Expand Up @@ -50,10 +51,11 @@ describe('blob divert', () => {
modClient.emitEvent(
{
subject: getSubject(),
event: {
// @ts-expect-error modClient.emitEvent does not declare #modEventDivert
event: ((f: ToolsOzoneModerationDefs.ModEventDivert) => f)({
$type: 'tools.ozone.moderation.defs#modEventDivert',
comment: 'Diverting for test',
},
}),
createdBy: sc.dids.alice,
subjectBlobCids: sc.posts[sc.dids.carol][0].images.map((img) =>
img.image.ref.toString(),
Expand Down
19 changes: 13 additions & 6 deletions packages/ozone/tests/moderation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import {
basicSeed,
ModeratorClient,
} from '@atproto/dev-env'
import { AtpAgent, ToolsOzoneModerationEmitEvent } from '@atproto/api'
import {
AtpAgent,
ChatBskyConvoDefs,
ToolsOzoneModerationEmitEvent,
} from '@atproto/api'
import { AtUri } from '@atproto/syntax'
import { forSnapshot } from './_util'
import {
Expand Down Expand Up @@ -157,23 +161,26 @@ describe('moderation', () => {
const reportA = await sc.createReport({
reportedBy: sc.dids.alice,
reasonType: REASONSPAM,
subject: {
// @ts-expect-error chat.bsky.convo.defs#messageRef is not spec'd as subject
subject: ((f: ChatBskyConvoDefs.MessageRef) => f)({
$type: 'chat.bsky.convo.defs#messageRef',
did: sc.dids.carol,
messageId: messageId1,
convoId: 'testconvoid1',
},
}),
})
const reportB = await sc.createReport({
reportedBy: sc.dids.carol,
reasonType: REASONOTHER,
reason: 'defamation',
subject: {
// @ts-expect-error chat.bsky.convo.defs#messageRef is not spec'd as subject
subject: ((f: ChatBskyConvoDefs.MessageRef) => f)({
$type: 'chat.bsky.convo.defs#messageRef',
did: sc.dids.carol,
messageId: messageId2,
// @TODO convoId intentionally missing, restore once this behavior is deprecated
},
// @ts-expect-error convoId intentionally missing, restore once this behavior is deprecated
convoId: undefined,
}),
})
expect(forSnapshot([reportA, reportB])).toMatchSnapshot()
const events = await ozone.ctx.db.db
Expand Down
1 change: 1 addition & 0 deletions packages/pds/tests/preferences.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ describe('user preferences', () => {
{ $type: 'app.bsky.actor.defs#adultContentPref', enabled: false },
{
$type: 'com.atproto.server.defs#unknown',
// @ts-expect-error un-spec'ed prop
hello: 'world',
},
],
Expand Down
2 changes: 1 addition & 1 deletion packages/pds/tests/seeds/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default async (
index: { byteStart: 0, byteEnd: 18 },
features: [
{
$type: `${ids.AppBskyRichtextFacet}#mention`,
$type: `${ids.AppBskyRichtextFacet}#mention` as const,
did: alice,
},
],
Expand Down

0 comments on commit 344ac6b

Please sign in to comment.