Skip to content

test(agent-service): raise unit-test coverage of core modules#5274

Open
bobbai00 wants to merge 1 commit into
apache:mainfrom
bobbai00:test/5266-agent-service-coverage
Open

test(agent-service): raise unit-test coverage of core modules#5274
bobbai00 wants to merge 1 commit into
apache:mainfrom
bobbai00:test/5266-agent-service-coverage

Conversation

@bobbai00
Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

The agent service had low automated test coverage (~52% line / ~54% function), concentrated in its core logic. This PR adds unit tests for the previously under-tested modules:

Area New test file(s)
API clients (mocked fetch, positive + non-ok + malformed) api/workflow-api.test.ts, api/compile-api.test.ts, api/backend-api.test.ts
JWT decode / expiry / auth headers api/auth-api.test.ts
System prompt builder (operator filtering, UDF guides) agent/prompts.test.ts
Context assembly (completed/ongoing tasks, DAG, results) agent/util/context-utils.test.ts
Operator materialization & input-schema resolution agent/util/workflow-utils.test.ts
Workflow CRUD tools (add/modify/delete, error paths) agent/tools/workflow-crud-tools.test.ts
Workflow execution tool (validation, run, formatting, failures) agent/tools/workflow-execution-tools.test.ts
TexeraAgent in-memory surface (state, settings, tools, lifecycle) agent/texera-agent.test.ts

A shared operator-metadata fixture (agent/util/metadata-fixture.ts) lets tests run without a live backend. No production code was changed.

Coverage (bun test --coverage): line 51.6% → 88.5%, function 54.2% → 90.0%.

Any related issues, documentation, discussions?

Closes #5266

How was this PR tested?

cd agent-service
bun test            # 165 pass, 0 fail, 372 expect() calls
bun run typecheck   # tsc --noEmit, clean
bun run format:check

Both positive and negative paths are covered (invalid input, missing config, non-ok HTTP responses, malformed responses).

Was this PR authored or co-authored using generative AI tooling?

Generated-by: Claude Opus 4.8 (1M context)

Adds unit tests for the agent service's previously under-tested modules:
API clients (workflow/compile/backend/auth, via mocked fetch), the system
prompt builder, context assembly, workflow utilities, the workflow CRUD and
execution tools, and the in-memory surface of TexeraAgent. Introduces a
shared operator-metadata fixture so tests need no live backend.

Line coverage rises from ~52% to ~89% and function coverage from ~54% to
~90% (bun test --coverage).

Closes apache#5266
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 52.05%. Comparing base (7bd6550) to head (3103719).

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #5274      +/-   ##
============================================
+ Coverage     49.01%   52.05%   +3.03%     
  Complexity     2378     2378              
============================================
  Files          1050     1051       +1     
  Lines         40336    40173     -163     
  Branches       4277     4277              
============================================
+ Hits          19772    20911    +1139     
+ Misses        19407    18105    -1302     
  Partials       1157     1157              
Flag Coverage Δ *Carryforward flag
access-control-service 39.53% <ø> (ø) Carriedforward from 7bd6550
agent-service 71.80% <100.00%> (+38.03%) ⬆️
amber 51.58% <ø> (ø) Carriedforward from 7bd6550
computing-unit-managing-service 0.00% <ø> (ø) Carriedforward from 7bd6550
config-service 0.00% <ø> (ø) Carriedforward from 7bd6550
file-service 37.99% <ø> (ø) Carriedforward from 7bd6550
frontend 40.82% <ø> (ø) Carriedforward from 7bd6550
python 90.79% <ø> (ø) Carriedforward from 7bd6550
workflow-compiling-service 56.81% <ø> (ø) Carriedforward from 7bd6550

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve test coverage of the agent service

2 participants