Skip to content

test(ts-sdk): replace duplicate datasets test with real dataset coverage#4032

Open
sushaan-k wants to merge 1 commit into
devflowinc:mainfrom
sushaan-k:aarya/fix-datasets-test-copy-paste
Open

test(ts-sdk): replace duplicate datasets test with real dataset coverage#4032
sushaan-k wants to merge 1 commit into
devflowinc:mainfrom
sushaan-k:aarya/fix-datasets-test-copy-paste

Conversation

@sushaan-k
Copy link
Copy Markdown

What does this PR do?

Replaces clients/ts-sdk/src/functions/datasets/datasets.test.ts — which was a verbatim copy of events.test.ts — with an actual test suite for the datasets module.

Why?

datasets.test.ts on `main` is identical to `events.test.ts`: same `describe("Events Tests")` block, same `getEventsForDataset({})` body, same `EventReturn` type assertion. It tests none of the 14 functions in `functions/datasets/index.ts` — so the datasets module looks tested at a glance, but in reality has zero coverage. Easy to miss, easy to regress.

Changes

  • Rename the `describe` block to "Dataset Tests".
  • Drop the copy-pasted `getEventsForDataset` call (that's already covered in `events.test.ts`).
  • Add tests for the read-only dataset functions, using the same `expectTypeOf` pattern as `chunkGroup.test.ts` and `analytics.test.ts`:
    • `getDatasetById`
    • `getDatasetUsageById`
    • `getDatasetsFromOrganization`
    • `getAllDatasetTags`
    • `getDatasetQueueLengths`

The destructive functions (`createDataset`, `updateDataset`, `batchCreateDatasets`, `clearDataset`, `deleteDataset`) are intentionally not included — running them on the shared sandbox dataset in CI on every PR would either leak data or wipe out the fixtures the other test files rely on.

Testing

  • `yarn build` ✅
  • `yarn lint` ✅
  • The new tests follow the existing pattern used in `analytics.test.ts`, `chunk.test.ts`, `chunkGroup.test.ts`, etc. (live API call + `expectTypeOf` return-type check, with the standard retry/timeout wrapper from `tests/utils.ts`).

…erage

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 — providing zero coverage for the 14
functions exported by the `datasets` module.

This rewrites the file to actually test the datasets module. The selected
calls are read-only (no datasets are 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`
Copilot AI review requested due to automatic review settings May 18, 2026 03:17
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 getEventsForDataset type 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!);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants