Skip to content

[Master] Expense Agent - Added Automated Test For API Pages - #10081

Open
v-rohangarg20 wants to merge 2 commits into
mainfrom
bugs/Bug-Expense-Agent-Added-Automated-Test-For-API-Pages
Open

[Master] Expense Agent - Added Automated Test For API Pages#10081
v-rohangarg20 wants to merge 2 commits into
mainfrom
bugs/Bug-Expense-Agent-Added-Automated-Test-For-API-Pages

Conversation

@v-rohangarg20

@v-rohangarg20 v-rohangarg20 commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Fixes AB#637260

Summary

Adds comprehensive automated integration tests for all Expense Agent API pages, validating API exposure, data retrieval, field accuracy, and related-entity expansion.

Changes

  • src/Apps/W1/ExpenseAgent/test/src/API/ExpenseAPIPagesTest.Codeunit.al: ~1,300 lines, 40+ test methods covering expense categories, subcategories, groups, expenses, itemizations, participants, rules, and posted reports.
  • Verifies API entity exposure via VerifyRecordVisibleInApi().
  • Validates $expand for related entities (expenseItemizations, expenseParticipants, expenseRuleViolations).
  • Confirms service-enabled actions for creating expense users and initializing test data via ExpenseTestHandler.
  • Verifies correct field values returned by API GET requests.

Type of change

  • Test automation (no product behavior change)

@github-actions github-actions Bot added AL: Apps (W1) Add-on apps for W1 Team: Integrations GitHub request for Integrations area labels Aug 10, 2026
@github-actions github-actions Bot added this to the Version 29.0 milestone Aug 10, 2026
@v-rohangarg20 v-rohangarg20 reopened this Aug 31, 2026
@github-actions github-actions Bot added Team: Finance GitHub request for Finance area and removed Team: Integrations GitHub request for Integrations area labels Aug 31, 2026
@v-rohangarg20 v-rohangarg20 reopened this Aug 31, 2026
@v-rohangarg20
v-rohangarg20 marked this pull request as ready for review September 2, 2026 05:10
@v-rohangarg20
v-rohangarg20 requested a review from a team September 2, 2026 05:10
@v-rohangarg20
v-rohangarg20 requested a review from a team as a code owner September 2, 2026 05:10
@alexei-dobriansky

Copy link
Copy Markdown
Contributor

Good Sense Reviewer - Round 1

Recommendation: Accept with Suggestions

What this PR does

This adds a new integration test codeunit for Expense Agent API pages and a small helper for appending $expand to API URLs. The read and expand tests mostly use committed test records and real API GET calls, and several action tests assert the resulting status changes. The action tests target the published service-enabled procedure names, and the remaining points are test-quality improvements rather than blockers.

Problem-solution fit

Fit: Strong

The reported scenario is a missing automated coverage gap for Expense Agent API pages. The diff is clearly test-only and is aimed at that gap, with useful end-to-end checks for visibility, expansions, and service-enabled actions.

Suggestions

S1 (🟠 Moderate): Assert violations are fully cleared
After correcting the expense, the tests only check that the first violation ID is gone. A bug that deletes and recreates another violation would still pass. Assert that the expanded violation collection has no violation for the expense after the fix.

S2 (🟠 Moderate): Send typed action payload values
The LogAIConsumption test sends integer and enum action parameters as text strings. Build this body with typed JSON values so the test checks the client contract without relying on string-to-type coercion.

S3 (🟠 Moderate): Reset committed data per test
This codeunit disables test isolation and commits data in many tests, but Initialize() skips cleanup after the first test. Move the cleanup and setup reset before the IsInitialized exit, or add per-test cleanup, so one failed test cannot leave setup or data that changes the next test.

Risk assessment and necessity

Risk: This is test-only, so there is no direct product behavior or upgrade risk. The risk is in the validation signal: partial cleanup and weaker assertions can make the suite flaky or give false confidence about some API behavior.

Necessity: The coverage is useful because these API pages are an automation contract for the Expense Agent. The scope is appropriate for a test-only change, and the remaining findings are improvements that should be considered without blocking the PR.


[AI-PR-REVIEW] version=1 promptVersion=4 system=github pr=10081 round=1 by=alexei-dobriansky at=2026-09-02T07:22:24Z lastSha=77e8dc678b9abcb422572301d743c1ee996227f1 reviewKey=7b624061bc250a9f80cced5cb9c159eb90737788ed579c46e1fa3df6cf207167 suggestions=S1@383dbc91,S2@11da62af,S3@252741fe

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

⚠️ Stale Status Check Deleted

The Pull Request Build workflow run for this PR was older than 72 hours and has been deleted.

📋 Why was it deleted?

Status checks that are too old may no longer reflect the current state of the target branch. To ensure this PR is validated against the latest code and passes up-to-date checks, a fresh build is required.


🔄 How to trigger a new status check:

  1. 📤 Push a new commit to the PR branch, or
  2. 🔁 Close and reopen the PR

This will automatically trigger a new Pull Request Build workflow run.

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

Labels

AL: Apps (W1) Add-on apps for W1 Team: Finance GitHub request for Finance area

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants