Skip to content

feat/CUS-10637-Used consolidated plan counts in test plan results email#344

Merged
akhil-testsigma merged 1 commit into
devfrom
feat/CUS-10637-Used-consolidated-plan-counts-in-test-plan-results-email
Feb 25, 2026
Merged

feat/CUS-10637-Used consolidated plan counts in test plan results email#344
akhil-testsigma merged 1 commit into
devfrom
feat/CUS-10637-Used-consolidated-plan-counts-in-test-plan-results-email

Conversation

@akhil-testsigma
Copy link
Copy Markdown
Contributor

@akhil-testsigma akhil-testsigma commented Feb 24, 2026

Publish this addon as public (IN Region)

Addon Name: Send TestPlan Results To Email
Jarvis Link: https://jarvis-in.testsigma.com/ui/tenants/3/addons
Jira : https://testsigma.atlassian.net/browse/CUS-10637
Used consolidated plan counts in test plan results email

Summary by CodeRabbit

  • Chores
    • Updated project version to 1.0.2
    • Updated API endpoints to regional configuration for improved regional service delivery

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 24, 2026

📝 Walkthrough

Walkthrough

Version bump and refactoring of test plan results email addon to consolidate count extraction logic into a helper method while updating API endpoints from standard to in-region domains.

Changes

Cohort / File(s) Summary
Version Update
send_testplan_results_to_email/pom.xml
Project version incremented from 1.0.0 to 1.0.2.
Helper Method Refactoring
send_testplan_results_to_email/src/main/java/com/testsigma/addons/hook/SendTestPlanResultsToEmail.java
Added private helper method getCountsFromTestPlanResultMetric() to centralize count extraction logic using consolidated plan fields. Updated getPlanCountsFromTestCaseResultContent() and getCountsFromRunDetails() to delegate to the new helper. Updated API endpoints from app.testsigma.com to app-in.testsigma.com.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • Ganesh-Testsigma
  • vigneshtestsigma

Poem

🐰 A version hops from one to two, point two,
Consolidated fields make counting true, hooray!
In-region endpoints now the addon uses with care,
Helper methods tidy, refactored with flair,
Test plans email with confidence fair! 📧✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: using consolidated plan counts in test plan results email functionality, matching the core modifications in the codebase.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/CUS-10637-Used-consolidated-plan-counts-in-test-plan-results-email

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
send_testplan_results_to_email/src/main/java/com/testsigma/addons/hook/SendTestPlanResultsToEmail.java (2)

47-48: ⚠️ Potential issue | 🔴 Critical

Hardcoded SMTP App Password will be exposed when addon is published publicly.

SMTP_PASSWORD contains what appears to be a Google App Password hardcoded in source. The PR objective explicitly states this addon will be "published as public (IN Region)." Publishing a JAR or source with a hardcoded credential exposes the sending account to abuse, allows third parties to send mail as ent_support@testsigma.com, and the secret cannot be rotated without a code change and redeployment.

The credential should be moved to a @TestData-annotated field (like apiKey), injected at runtime, and the plaintext constant removed entirely.

🔒 Proposed fix: convert to runtime-injected TestData
-    private static final String SMTP_PASSWORD = "asla sdqa frwa uynz";
+    `@TestData`(reference = "{SMTP PASSWORD}")
+    private com.testsigma.sdk.TestData smtpPassword;

Then in execute():

-        String smtpPass = SMTP_PASSWORD != null ? SMTP_PASSWORD.trim().replaceAll("\\s+", "") : "";
+        String smtpPass = smtpPassword != null && smtpPassword.getValue() != null
+                ? smtpPassword.getValue().toString().trim().replaceAll("\\s+", "") : "";
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@send_testplan_results_to_email/src/main/java/com/testsigma/addons/hook/SendTestPlanResultsToEmail.java`
around lines 47 - 48, Replace the hardcoded SMTP_PASSWORD constant in
SendTestPlanResultsToEmail with a runtime-injected TestData field: remove the
SMTP_PASSWORD static constant and add a non-static field annotated with
`@TestData` (e.g. apiKey or smtpPassword) alongside or replacing SMTP_USER as
needed; update the execute() method to read the injected TestData value at
runtime and use it for SMTP authentication, validating null/empty and failing
gracefully with a clear error if not provided, and ensure no plaintext secret
remains in source or constants.

349-352: ⚠️ Potential issue | 🟡 Minor

Stale Javadoc still references old field names.

The comment still lists totalCount, passedCount, failedCount as the extracted fields, but after the refactor the code reads consolidatedPlanTotalCount, consolidatedPlanPassedCount, consolidatedPlanFailedCount, etc. via getCountsFromTestPlanResultMetric.

📝 Proposed fix
-     * Fetches test_case_results with executionResultId = lastRunId (one page), extracts Total, Passed, Failure, etc.
-     * from content[].environmentResult.executionResult.testPlanResultMetric (totalCount, passedCount, failedCount, ...).
+     * Fetches test_case_results with executionResultId = lastRunId (one page), extracts consolidated plan counts
+     * from content[].environmentResult.executionResult.testPlanResultMetric
+     * (consolidatedPlanTotalCount, consolidatedPlanPassedCount, consolidatedPlanFailedCount, ...).
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@send_testplan_results_to_email/src/main/java/com/testsigma/addons/hook/SendTestPlanResultsToEmail.java`
around lines 349 - 352, The Javadoc above the method that fetches
test_case_results (referencing executionResultId = lastRunId and
environmentResult.executionResult.testPlanResultMetric) is stale: update the
comment in SendTestPlanResultsToEmail to list the current metric fields
returned/used by getCountsFromTestPlanResultMetric (e.g.,
consolidatedPlanTotalCount, consolidatedPlanPassedCount,
consolidatedPlanFailedCount, etc.) instead of the old
totalCount/passedCount/failedCount names and ensure the description matches the
actual extraction logic in that method.
🧹 Nitpick comments (1)
send_testplan_results_to_email/pom.xml (1)

9-9: Version skips 1.0.1.

The version jumped from 1.0.0 directly to 1.0.2. If 1.0.1 was published for another region/environment, this is fine — otherwise consider whether 1.0.1 should be accounted for or the jump is intentional.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@send_testplan_results_to_email/pom.xml` at line 9, The project POM version
tag currently jumps from 1.0.0 to <version>1.0.2</version>; confirm whether
1.0.1 was intentionally skipped or missing and either set the <version> element
to the correct next version (e.g., 1.0.1) or document/justify the skip (add a
CHANGELOG entry or release note) so the version history is consistent; update
the <version> element in the pom.xml (or add the explanatory release note)
accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@send_testplan_results_to_email/src/main/java/com/testsigma/addons/hook/SendTestPlanResultsToEmail.java`:
- Around line 259-270: getCountsFromTestPlanResultMetric currently builds a map
of zeros when metric exists but contains none of the consolidatedPlan* keys,
which prevents the fallback chain in execute() from running; update
getCountsFromTestPlanResultMetric to first detect presence of any
consolidatedPlan* fields (e.g.,
"consolidatedPlanTotalCount","consolidatedPlanPassedCount","consolidatedPlanFailedCount","consolidatedPlanStoppedCount","consolidatedPlanNotExecutedCount","consolidatedPlanQueuedCount","consolidatedPlanRunningCount")
and return null if none are present, otherwise build and return the
LinkedHashMap as before; ensure callers getCountsFromRunDetails and
getPlanCountsFromTestCaseResultContent continue to rely on null to trigger
fallback paths referenced in execute().

---

Outside diff comments:
In
`@send_testplan_results_to_email/src/main/java/com/testsigma/addons/hook/SendTestPlanResultsToEmail.java`:
- Around line 47-48: Replace the hardcoded SMTP_PASSWORD constant in
SendTestPlanResultsToEmail with a runtime-injected TestData field: remove the
SMTP_PASSWORD static constant and add a non-static field annotated with
`@TestData` (e.g. apiKey or smtpPassword) alongside or replacing SMTP_USER as
needed; update the execute() method to read the injected TestData value at
runtime and use it for SMTP authentication, validating null/empty and failing
gracefully with a clear error if not provided, and ensure no plaintext secret
remains in source or constants.
- Around line 349-352: The Javadoc above the method that fetches
test_case_results (referencing executionResultId = lastRunId and
environmentResult.executionResult.testPlanResultMetric) is stale: update the
comment in SendTestPlanResultsToEmail to list the current metric fields
returned/used by getCountsFromTestPlanResultMetric (e.g.,
consolidatedPlanTotalCount, consolidatedPlanPassedCount,
consolidatedPlanFailedCount, etc.) instead of the old
totalCount/passedCount/failedCount names and ensure the description matches the
actual extraction logic in that method.

---

Nitpick comments:
In `@send_testplan_results_to_email/pom.xml`:
- Line 9: The project POM version tag currently jumps from 1.0.0 to
<version>1.0.2</version>; confirm whether 1.0.1 was intentionally skipped or
missing and either set the <version> element to the correct next version (e.g.,
1.0.1) or document/justify the skip (add a CHANGELOG entry or release note) so
the version history is consistent; update the <version> element in the pom.xml
(or add the explanatory release note) accordingly.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c7688e5 and b6bfe3e.

📒 Files selected for processing (2)
  • send_testplan_results_to_email/pom.xml
  • send_testplan_results_to_email/src/main/java/com/testsigma/addons/hook/SendTestPlanResultsToEmail.java

Comment on lines +259 to 270
private Map<String, Integer> getCountsFromTestPlanResultMetric(JsonObject metric) {
if (metric == null) return null;
Map<String, Integer> counts = new LinkedHashMap<>();
counts.put("total", getInt(metric, "totalCount", null, 0));
counts.put("passed", getInt(metric, "passedCount", null, 0));
counts.put("failure", getInt(metric, "failedCount", null, 0));
counts.put("stopped", getInt(metric, "stoppedCount", null, 0));
counts.put("not_executed", getInt(metric, "notExecutedCount", null, 0));
counts.put("queued", getInt(metric, "queuedCount", null, 0));
counts.put("running", getInt(metric, "runningCount", null, 0));
counts.put("total", getInt(metric, "consolidatedPlanTotalCount", null, 0));
counts.put("passed", getInt(metric, "consolidatedPlanPassedCount", null, 0));
counts.put("failure", getInt(metric, "consolidatedPlanFailedCount", null, 0));
counts.put("stopped", getInt(metric, "consolidatedPlanStoppedCount", null, 0));
counts.put("not_executed", getInt(metric, "consolidatedPlanNotExecutedCount", null, 0));
counts.put("queued", getInt(metric, "consolidatedPlanQueuedCount", null, 0));
counts.put("running", getInt(metric, "consolidatedPlanRunningCount", null, 0));
return counts;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

getCountsFromTestPlanResultMetric returns an all-zeros map instead of null when consolidated fields are absent — this silently breaks the fallback chain.

When metric is non-null but lacks consolidatedPlan* keys (e.g., older API response format), every getInt call falls through to its defaultValue of 0. The method returns a non-null map of all zeros. The fallback chain in execute() (lines 104–111) only activates when counts == null, so all three fallback paths (fetchPlanCountsFromTestCaseResultsByExecutionResultId, resultsData.planCountsFromApi, defaultCounts()) are bypassed. The resulting email silently reports zeros for every metric.

Add a presence guard before building the map:

🐛 Proposed fix
 private Map<String, Integer> getCountsFromTestPlanResultMetric(JsonObject metric) {
     if (metric == null) return null;
+    // Return null so callers can fall back when consolidated fields are absent (e.g., older API format).
+    if (!metric.has("consolidatedPlanTotalCount")
+            && !metric.has("consolidatedPlanPassedCount")
+            && !metric.has("consolidatedPlanFailedCount")) {
+        return null;
+    }
     Map<String, Integer> counts = new LinkedHashMap<>();
     counts.put("total", getInt(metric, "consolidatedPlanTotalCount", null, 0));
     counts.put("passed", getInt(metric, "consolidatedPlanPassedCount", null, 0));
     counts.put("failure", getInt(metric, "consolidatedPlanFailedCount", null, 0));
     counts.put("stopped", getInt(metric, "consolidatedPlanStoppedCount", null, 0));
     counts.put("not_executed", getInt(metric, "consolidatedPlanNotExecutedCount", null, 0));
     counts.put("queued", getInt(metric, "consolidatedPlanQueuedCount", null, 0));
     counts.put("running", getInt(metric, "consolidatedPlanRunningCount", null, 0));
     return counts;
 }

This fix also benefits getCountsFromRunDetails (Line 423) and getPlanCountsFromTestCaseResultContent (Line 253), which both delegate here and rely on a null return to signal "not available."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@send_testplan_results_to_email/src/main/java/com/testsigma/addons/hook/SendTestPlanResultsToEmail.java`
around lines 259 - 270, getCountsFromTestPlanResultMetric currently builds a map
of zeros when metric exists but contains none of the consolidatedPlan* keys,
which prevents the fallback chain in execute() from running; update
getCountsFromTestPlanResultMetric to first detect presence of any
consolidatedPlan* fields (e.g.,
"consolidatedPlanTotalCount","consolidatedPlanPassedCount","consolidatedPlanFailedCount","consolidatedPlanStoppedCount","consolidatedPlanNotExecutedCount","consolidatedPlanQueuedCount","consolidatedPlanRunningCount")
and return null if none are present, otherwise build and return the
LinkedHashMap as before; ensure callers getCountsFromRunDetails and
getPlanCountsFromTestCaseResultContent continue to rely on null to trigger
fallback paths referenced in execute().

@akhil-testsigma akhil-testsigma merged commit 7ad5f32 into dev Feb 25, 2026
2 checks passed
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