Skip to content

test(query.test.ts): added test cases for query endpoint#92

Open
0xanshu wants to merge 1 commit into
ScrawnDotDev:devfrom
0xanshu:test/adding-tests
Open

test(query.test.ts): added test cases for query endpoint#92
0xanshu wants to merge 1 commit into
ScrawnDotDev:devfrom
0xanshu:test/adding-tests

Conversation

@0xanshu

@0xanshu 0xanshu commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@greptile-apps

greptile-apps Bot commented Jun 20, 2026

Copy link
Copy Markdown

Greptile Summary

Adds integration test coverage for the Data Query gRPC endpoint.
Introduces a queryData test helper around DataQueryServiceClient.query.
Covers authenticated queries, missing auth, invalid tables, invalid integer filters, empty results, unfiltered results, and pagination.

Confidence Score: 3/5

The PR is test-only, but several new assertions are brittle or miss the ordering behavior they are intended to cover.

The changed tests improve endpoint coverage but can fail against dirty data, rely on unspecified row ordering, and do not exercise the non-empty ordering contract.

src/tests/query.test.ts

T-Rex T-Rex Logs

What T-Rex did

  • I prepared a focused Vitest repro that seeds the PREMIUM_CALL tag row, inserts the same row used by the query test, logs the matching row counts and the query total, and runs the exact total and row-length expectations, but execution was blocked by the environment's lack of Docker and an unreachable test database.
  • I created a focused Vitest repro for order pagination that inserts tag rows, issues three DataQueryServiceClient.query requests with empty orderBy and offset/limit, and logs the Drizzle SQL and returned page IDs; running the repro was blocked because docker is not installed, so the Postgres test service could not be started.
  • I built a focused Vitest gRPC repro that inserts tags in non-descending order, sends DataQueryServiceClient.query with a non-empty generated orderBy, logs the request and response orders, and asserts descending order, but the test could not run because the local Postgres test database was unavailable and there was no docker to start docker-compose.
  • I documented environment diagnostics and blockers, noting Node v20.9.0 and Bun 1.3.10, and concluding the blocker is an external test-runner startup incompatibility rather than a query endpoint failure.
  • I reviewed before/after test integration artifacts and observed a Bun Vitest import-time TypeError: undefined is not an object (evaluating 'z.string') in src/config/identifiers.ts, preventing tests from executing.

View all artifacts

T-Rex Ran code and verified through T-Rex

Reviews (1): Last reviewed commit: "test(query.test.ts): added test cases fo..." | Re-trigger Greptile


expect(response.columns).toContain("key");
expect(response.columns).toContain("amount");
expect(response.total).toBe(1);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Clear test state first This test asserts the global query total is exactly 1, but the suite only calls clearDatabase() in afterAll. If a previous run failed before cleanup, or this test is run against a dirty test database, an existing matching tags row makes this assertion fail even though the query endpoint is behaving correctly. Clear the database before the suite or use a unique key and assert only on the inserted row.

{
table: "tags",
where: FilterGroup.create({ logical: 1, conditions: [], groups: [] }),
orderBy: [],

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Order pagination deterministically This pagination test uses offset while leaving orderBy empty. Postgres does not guarantee row order without ORDER BY, so the three pages can overlap, skip rows, or change order as table contents and query plans change. Add a stable ordering and assert the page contents so this test verifies pagination instead of only checking row counts.

],
groups: [],
}),
orderBy: [],

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Exercise ordering contract Every request in this new coverage sends orderBy, but the server-side schema currently reads orderByList before transforming it to orderBy. Because these tests only send an empty list, they pass even if client-supplied ordering is ignored by the endpoint. Add a non-empty ordering case using the actual generated request field so the test catches this API/schema mismatch.

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.

1 participant