Skip to content

test: cover transactions query resolver - #28

Open
PunkJam wants to merge 1 commit into
AuthorPrime:mainfrom
PunkJam:codex/transactions-query-tests
Open

test: cover transactions query resolver#28
PunkJam wants to merge 1 commit into
AuthorPrime:mainfrom
PunkJam:codex/transactions-query-tests

Conversation

@PunkJam

@PunkJam PunkJam commented May 21, 2026

Copy link
Copy Markdown

Contributes to #8.

Summary

  • add focused Vitest coverage for the Query.transactions resolver
  • cover the default pagination and ordering chain
  • cover the agent/type filtered path with explicit limit and offset arguments

Tests

  • docker run --rm -v "C:\AI workspace\issue\ds-defi-core:/workspace:ro" -w /work node:22-bookworm bash -lc "cp -R /workspace/. /work && npm install --no-audit --no-fund >/tmp/npm-install.log && npm test -- --run tests/graphql/transactions-query.test.ts"
  • docker run --rm -v "C:\AI workspace\issue\ds-defi-core:/workspace:ro" -w /work node:22-bookworm bash -lc "cp -R /workspace/. /work && npm install --no-audit --no-fund >/tmp/npm-install.log && npm test -- --run"
  • git diff --check

Bounty note: issue #8 lists ongoing test coverage at 50 sats per test file merged. I can provide a Lightning invoice if this test slice is accepted.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces unit tests for the transactions GraphQL query resolver, covering default pagination and filtering logic. The review feedback suggests improving the robustness of these tests by verifying the specific arguments passed to the query builder methods, such as from and orderBy, and splitting the filter tests into separate cases to ensure each filter is correctly applied.

Comment on lines +33 to +37
expect(query.from).toHaveBeenCalledOnce();
expect(query.where).toHaveBeenCalledWith(undefined);
expect(query.limit).toHaveBeenCalledWith(50);
expect(query.offset).toHaveBeenCalledWith(0);
expect(query.orderBy).toHaveBeenCalledOnce();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The assertions for the query chain are relatively weak as they only verify that the methods were called, but not the arguments they were called with. This means the test would still pass even if the resolver was querying the wrong table or using an incorrect sort order. To improve the robustness of the test, consider importing the transactions table and the desc helper from the schema/ORM to verify that from and orderBy are called with the correct parameters.

Comment on lines +54 to +55
expect(query.where).toHaveBeenCalledOnce();
expect(query.where.mock.calls[0][0]).toBeDefined();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The assertion expect(query.where.mock.calls[0][0]).toBeDefined() does not sufficiently verify the filtering logic. Since both agentId and type are provided in this test case, the test would still pass even if one of these filters was accidentally ignored by the resolver (as long as the other one is present and triggers the where call). To ensure each filter is correctly implemented, it is recommended to split this into separate test cases—one for each filter—and verify that the where clause is correctly populated (or at least called) in each scenario.

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