Skip to content

Commit b200178

Browse files
committed
chore(notion): replace non-null assertions in tests and shrink the explicit-any baseline
1 parent 627acc8 commit b200178

2 files changed

Lines changed: 14 additions & 11 deletions

File tree

‎apps/sim/tools/notion/responses.test.ts‎

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
import { afterEach, describe, expect, it, vi } from 'vitest'
1+
import { describe, expect, it, vi } from 'vitest'
22
import { notionCreateCommentTool } from '@/tools/notion/create_comment'
33
import { notionCreatePageTool, notionCreatePageV2Tool } from '@/tools/notion/create_page'
44
import { notionReadTool, notionReadV2Tool } from '@/tools/notion/read'
55
import { notionUpdatePageTool, notionUpdatePageV2Tool } from '@/tools/notion/update_page'
66
import { notionWriteTool } from '@/tools/notion/write'
77

8+
function defined<T>(value: T | undefined): T {
9+
if (value === undefined) throw new Error('Expected the tool to define this handler')
10+
return value
11+
}
12+
813
const PAGE_TITLE = 'Project Apollo'
914

1015
function pageResponse(): Response {
@@ -75,14 +80,18 @@ describe('Notion rich text length limit', () => {
7580
id: notionWriteTool.id,
7681
richText: () =>
7782
paragraphRichText(
78-
notionWriteTool.request.body!({ accessToken: 't', pageId: 'p', content: longText })
83+
defined(notionWriteTool.request.body)({
84+
accessToken: 't',
85+
pageId: 'p',
86+
content: longText,
87+
})
7988
),
8089
},
8190
{
8291
id: notionCreatePageTool.id,
8392
richText: () =>
8493
paragraphRichText(
85-
notionCreatePageTool.request.body!({
94+
defined(notionCreatePageTool.request.body)({
8695
accessToken: 't',
8796
parentId: 'p',
8897
content: longText,
@@ -93,7 +102,7 @@ describe('Notion rich text length limit', () => {
93102
id: notionCreateCommentTool.id,
94103
richText: () =>
95104
(
96-
notionCreateCommentTool.request.body!({
105+
defined(notionCreateCommentTool.request.body)({
97106
accessToken: 't',
98107
pageId: 'p',
99108
content: longText,
@@ -111,10 +120,6 @@ describe('Notion rich text length limit', () => {
111120
})
112121

113122
describe('Notion read page content pagination', () => {
114-
afterEach(() => {
115-
vi.unstubAllGlobals()
116-
})
117-
118123
it('follows next_cursor past the first 100 blocks', async () => {
119124
const paragraph = (text: string) => ({
120125
type: 'paragraph',
@@ -130,7 +135,7 @@ describe('Notion read page content pagination', () => {
130135
)
131136
vi.stubGlobal('fetch', fetchMock)
132137

133-
const result = await notionReadV2Tool.transformResponse!(pageResponse(), {
138+
const result = await defined(notionReadV2Tool.transformResponse)(pageResponse(), {
134139
accessToken: 't',
135140
pageId: 'page-1',
136141
})

‎scripts/check-explicit-any.baseline.json‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@
7777
"apps/sim/background/workflow-execution.ts": 2,
7878
"apps/sim/blocks/blocks/agent.test.ts": 1,
7979
"apps/sim/blocks/blocks/agent.ts": 6,
80-
"apps/sim/blocks/blocks/airtable.ts": 5,
8180
"apps/sim/blocks/blocks/apify.ts": 2,
8281
"apps/sim/blocks/blocks/browser_use.ts": 2,
8382
"apps/sim/blocks/blocks/context_dev.ts": 1,
@@ -742,7 +741,6 @@
742741
"apps/sim/tools/notion/list_comments.ts": 1,
743742
"apps/sim/tools/notion/list_users.ts": 1,
744743
"apps/sim/tools/notion/query_database.ts": 4,
745-
"apps/sim/tools/notion/read.ts": 16,
746744
"apps/sim/tools/notion/read_database.ts": 4,
747745
"apps/sim/tools/notion/retrieve_block.ts": 1,
748746
"apps/sim/tools/notion/retrieve_block_children.ts": 1,

0 commit comments

Comments
 (0)