Skip to content

Handle if no default HTML report template present in Solution.#4143

Merged
Maheshkale447 merged 2 commits into
masterfrom
Bug-New-HTML-Report-Template-Not-MarkedAs-Default
Mar 28, 2025
Merged

Handle if no default HTML report template present in Solution.#4143
Maheshkale447 merged 2 commits into
masterfrom
Bug-New-HTML-Report-Template-Not-MarkedAs-Default

Conversation

@rathimayur

@rathimayur rathimayur commented Mar 12, 2025

Copy link
Copy Markdown
Contributor

Handled below scenarios,

  1. Handle if no default HTML report template present in Solution.
  2. If Production HTML Report action added to runset and no default report template available
  3. If Send HTML Report action added to runset and no default report template available for both Body content type as HTML Report or in case of plain text if the attachment is of type HTML Report.

Thank you for your contribution.
Before submitting this PR, please make sure:

  • PR description and commit message should describe the changes done in this PR
  • Verify the PR is pointing to correct branch i.e. Release or Beta branch if the code fix is for specific release , else point it to master
  • Latest Code from master or specific release branch is merged to your branch
  • No unwanted\commented\junk code is included
  • No new warning upon build solution
  • Code Summary\Comments are added to my code which explains what my code is doing
  • Existing unit test cases are passed
  • New Unit tests are added for your development
  • Sanity Tests are successfully executed for New and Existing Functionality
  • Verify that changes are compatible with all relevant browsers and platforms.
  • After creating pull request there should not be any conflicts
  • Resolve all Codacy comments
  • Builds and checks are passed before PR is sent for review
  • Resolve code review comments
  • Update the Help Library document to match any feature changes

Summary by CodeRabbit

  • Bug Fixes
    • Introduced validations that ensure the required report template is set before generating reports.
    • Improved error handling during report generation and email operations to provide clear feedback when configurations are missing.
    • Updated the configuration process to automatically designate a new report template as the default when none exists, ensuring consistent report management.

@coderabbitai

coderabbitai Bot commented Mar 12, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

This update adds validation checks to ensure that a default HTML report configuration is present before proceeding with report generation and email operations. Various methods now query the solution repository for a default configuration, log error messages, and return early if the configuration is missing. Additionally, when adding new report templates, the system automatically assigns the default flag if no default exists, ensuring consistency in how report configurations are managed.

Changes

File(s) Change Summary
Ginger/.../AutomatePageLib/NewAutomatePage.xaml.cs
GingerCoreNET/Run/RunSetActions/RunSetActionHTMLReportOperations.cs
GingerCoreNET/Run/RunSetActions/RunSetActionHTMLReportSendEmailOperations.cs
Added validation steps in the report generation and email sending operations to check for a default HTML report configuration. Logs error messages and returns early if no default is found.
Ginger/.../SolutionWindows/TreeViewItems/HTMLGingerReportsTreeItem.cs Modified the AddNewTemplateItem method to check for an existing default configuration and, if absent, set the new report configuration as the default.

Sequence Diagram(s)

sequenceDiagram
   participant Caller as Method Caller
   participant Reporter as Report Generator/Operation
   participant Repo as SolutionRepository
   participant Logger as Logger
   Caller->>Reporter: Initiate report/email execution
   Reporter->>Repo: Query for default HTMLReportConfiguration
   alt Default exists
      Repo-->>Reporter: Return configuration
      Reporter->>Reporter: Proceed with report generation/email sending
   else No default found
      Repo-->>Reporter: Return empty
      Reporter->>Logger: Log error message
      Reporter-->>Caller: Terminate execution (early exit)
   end
Loading
sequenceDiagram
   participant User as User Action
   participant TreeView as Template Manager
   participant Repo as SolutionRepository
   User->>TreeView: Request to add new template
   TreeView->>Repo: Check for existing default configuration
   alt No default exists
      TreeView->>TreeView: Mark new template as default
   end
   TreeView->>Repo: Add new HTMLReportConfiguration to repository
Loading

Possibly related PRs

Suggested reviewers

  • Maheshkale447

Poem

I'm a coding rabbit on a happy hop,
Ensuring defaults never make our workflow stop.
With checks in place, our reports dance with light,
Bugs scurry away in the early exit fight.
Hopping through code, my whiskers shine bright!
🐰💻


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4851e2a and bac1539.

📒 Files selected for processing (4)
  • Ginger/Ginger/AutomatePageLib/NewAutomatePage.xaml.cs (1 hunks)
  • Ginger/Ginger/SolutionWindows/TreeViewItems/HTMLGingerReportsTreeItem.cs (1 hunks)
  • Ginger/GingerCoreNET/Run/RunSetActions/RunSetActionHTMLReportOperations.cs (1 hunks)
  • Ginger/GingerCoreNET/Run/RunSetActions/RunSetActionHTMLReportSendEmailOperations.cs (2 hunks)
🔇 Additional comments (5)
Ginger/GingerCoreNET/Run/RunSetActions/RunSetActionHTMLReportOperations.cs (1)

55-62: Good defensive programming for template validation.

Adding this validation check for default HTML report templates ensures the system fails gracefully with a clear error message rather than proceeding with potentially invalid operations. The error message clearly directs users to set a default template in the appropriate configuration section.

Ginger/Ginger/SolutionWindows/TreeViewItems/HTMLGingerReportsTreeItem.cs (1)

160-164: Excellent user experience enhancement.

This change ensures there's always a default HTML report template by automatically setting the first created template as default. This complements the validation checks added elsewhere and reduces the likelihood of encountering template-related errors during report generation.

Ginger/Ginger/AutomatePageLib/NewAutomatePage.xaml.cs (1)

1837-1842: Consistent validation pattern applied.

Adding this validation check for default HTML report templates in the GenerateReport method ensures consistent behavior across the application. The error message clearly directs users to set a default template in the appropriate configuration section.

Ginger/GingerCoreNET/Run/RunSetActions/RunSetActionHTMLReportSendEmailOperations.cs (2)

76-94: Good addition of validation for default HTML report template.

This code adds proper error checking to ensure a default HTML report template exists before attempting to generate a report. It handles two specific cases:

  1. When HTMLReportTemplate is set to HTMLReport
  2. When email attachments of type Report are present

The implementation provides clear error messages that guide the user to set a default template in the configurations, improving error handling and user experience.


132-136: Clean implementation of conditional report generation.

This change properly encapsulates the WebReportGenerator creation and HTML report generation logic within a conditional check, ensuring the report is only generated when the appropriate template type is selected. This is consistent with the validation added earlier in the method.

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

{
if (RunSetActionHTMLReportSendEmail.HTMLReportTemplate == RunSetActionHTMLReportSendEmail.eHTMLReportTemplate.HTMLReport)
{
Reporter.ToLog(eLogLevel.ERROR, "Invalid Body Content type, No Default HTML Report template available to generate report. Please set a default template in Configurations -> Reports -> Reports Template.");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please add this messages to Message dictionary and use from there

@Maheshkale447
Maheshkale447 merged commit dabccab into master Mar 28, 2025
@Maheshkale447
Maheshkale447 deleted the Bug-New-HTML-Report-Template-Not-MarkedAs-Default branch March 28, 2025 13:02
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