Skip to content

Commit d91adfe

Browse files
committed
Fix tests that were broken because shape definition would not match when the table was passed.
1 parent 81f51c1 commit d91adfe

3 files changed

Lines changed: 9 additions & 6 deletions

File tree

‎packages/typescript-client/test/client.test.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ describe.for(fetchAndSse)(`Shape (liveSSE=$liveSse)`, ({ liveSse }) => {
277277
await deleteIssue({ id: id1, title: `foo1` })
278278
await insertIssues({ id: id2, title: `foo2` })
279279
await waitForIssues({ numChangesExpected: 3 })
280-
await clearIssuesShape(shapeStream.shapeHandle)
280+
await clearIssuesShape(shapeStream.shapeHandle!)
281281
})
282282

283283
rotationTime = Date.now()
@@ -1012,7 +1012,7 @@ describe.for(fetchAndSse)(`Shape (liveSSE=$liveSse)`, ({ liveSse }) => {
10121012
unsub()
10131013
// the normal cleanup doesn't work because our shape definition is
10141014
// changed by the updates: 'full' param
1015-
await clearIssuesShape(shapeStream.shapeHandle)
1015+
await clearIssuesShape(shapeStream.shapeHandle!)
10161016
}
10171017
})
10181018

@@ -2037,7 +2037,7 @@ describe.for(fetchAndSse)(
20372037
await deleteIssue({ id: id2, title: `snap2` })
20382038
await insertIssues({ title: `snap3` })
20392039
await waitForIssues({ numChangesExpected: 2 })
2040-
await clearIssuesShape(shapeStream.shapeHandle)
2040+
await clearIssuesShape(shapeStream.shapeHandle!)
20412041
})
20422042

20432043
// Wait until shape reflects re-executed snapshot on the new shape

‎packages/typescript-client/test/integration.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -973,7 +973,7 @@ describe(`HTTP Sync`, () => {
973973
// that the existing shape is deleted and some more data is inserted
974974
if (numRequests === 2) {
975975
await insertIssues({ id: rowId2, title: `foo2` })
976-
await clearIssuesShape(issueStream.shapeHandle)
976+
await clearIssuesShape(issueStream.shapeHandle!)
977977
}
978978

979979
numRequests++

‎packages/typescript-client/test/support/test-context.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export type GeneratedIssueRow = { id?: string; title: string }
1111
export type UpdateIssueFn = (row: IssueRow) => Promise<QueryResult<IssueRow>>
1212
export type DeleteIssueFn = (row: IssueRow) => Promise<QueryResult<IssueRow>>
1313
export type InsertIssuesFn = (...rows: GeneratedIssueRow[]) => Promise<string[]>
14-
export type ClearIssuesShapeFn = (handle?: string) => Promise<void>
14+
export type ClearIssuesShapeFn = (handle: string) => Promise<void>
1515
export type ClearShapeFn = (
1616
table: string,
1717
options?: { handle?: string }
@@ -52,10 +52,13 @@ export const testWithDbClient = test.extend<{
5252
) => {
5353
const baseUrl = inject(`baseUrl`)
5454
const url = new URL(`${baseUrl}/v1/shape`)
55-
url.searchParams.set(`table`, table)
5655

56+
// if an handle is provided, don't pass the table
57+
// as the shape definition might have more params
5758
if (options.handle) {
5859
url.searchParams.set(SHAPE_HANDLE_QUERY_PARAM, options.handle)
60+
} else {
61+
url.searchParams.set(`table`, table)
5962
}
6063

6164
const resp = await fetch(url.toString(), { method: `DELETE` })

0 commit comments

Comments
 (0)