test(ts-sdk): replace duplicate datasets test with real dataset coverage#4032
Open
sushaan-k wants to merge 1 commit into
Open
test(ts-sdk): replace duplicate datasets test with real dataset coverage#4032sushaan-k wants to merge 1 commit into
sushaan-k wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates the TS SDK dataset tests to cover dataset-related endpoints/types instead of events.
Changes:
- Replace the prior
getEventsForDatasettype test with dataset-focused tests. - Add type-level assertions for dataset retrieval, usage, org datasets listing, tags, and queue lengths.
- Update imported generated types to match the new tests.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| import { test } from "../../__tests__/utils"; | ||
|
|
||
| describe("Events Tests", async () => { | ||
| describe("Dataset Tests", async () => { |
Comment on lines
+19
to
+22
| test("getDatasetById", async () => { | ||
| const data = await trieve.getDatasetById(trieve.datasetId!); | ||
| expectTypeOf(data).toEqualTypeOf<Dataset>(); | ||
| }); |
| const data = await trieve.getEventsForDataset({}); | ||
| expectTypeOf(data).toEqualTypeOf<EventReturn>(); | ||
| test("getDatasetById", async () => { | ||
| const data = await trieve.getDatasetById(trieve.datasetId!); |
| }); | ||
|
|
||
| test("getDatasetUsageById", async () => { | ||
| const data = await trieve.getDatasetUsageById(trieve.datasetId!); |
Comment on lines
+30
to
+32
| const data = await trieve.getDatasetsFromOrganization( | ||
| trieve.organizationId!, | ||
| ); |
| { | ||
| page: 1, | ||
| }, | ||
| trieve.datasetId!, |
| }); | ||
|
|
||
| test("getDatasetQueueLengths", async () => { | ||
| const data = await trieve.getDatasetQueueLengths(trieve.datasetId!); |
The previous clients/ts-sdk/src/functions/datasets/datasets.test.ts was a
verbatim copy of events.test.ts (same describe("Events Tests") block, same
getEventsForDataset call), so the datasets module had zero coverage.
This rewrites the file to test the datasets module. The selected calls are
read-only (no datasets created, modified, or deleted), so the suite is safe
to run repeatedly against the shared sandbox dataset that backs the other
ts-sdk integration tests.
Coverage added:
- getDatasetById
- getDatasetUsageById
- getDatasetsFromOrganization
- getAllDatasetTags
- getDatasetQueueLengths
df94f0b to
3a9db60
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
clients/ts-sdk/src/functions/datasets/datasets.test.tson main is a verbatim copy ofevents.test.ts: samedescribe("Events Tests")block, samegetEventsForDataset({})body, sameEventReturntype assertion. None of the 14 functions exported byfunctions/datasets/index.tsare actually exercised, so the datasets module shows up as "tested" without having any coverage at all.This PR rewrites the file to actually test the datasets module, using the same
expectTypeOfpattern aschunkGroup.test.ts,analytics.test.ts, etc.Added coverage:
getDatasetByIdgetDatasetUsageByIdgetDatasetsFromOrganizationgetAllDatasetTagsgetDatasetQueueLengthsThe destructive functions (
createDataset,updateDataset,batchCreateDatasets,clearDataset,deleteDataset) are intentionally not in here. Running them on every PR against the shared sandbox dataset would either leak data or wipe fixtures the rest of the test files rely on.yarn buildandyarn lintboth pass.