Skip to content

Conversation

@ShaileshParmar11
Copy link
Contributor

Fixes #22921

Screen.Recording.2025-12-12.at.9.25.09.PM.mov

This pull request enhances the Playwright test suite and supporting utilities for notification alerts, focusing on improved handling and testing of advanced destination configurations (such as headers and query parameters) for external alert destinations. The changes ensure that destinations with empty configurations are excluded from test API calls, and introduce normalization utilities to maintain consistency in config comparisons.

Advanced destination configuration support:

  • The addExternalDestination utility now accepts an advancedConfig parameter, allowing Playwright tests to specify headers, query parameters, and secret keys for external destinations. The function fills out these fields in the UI as part of the test flow. [1] [2]
  • The notification alert test (NotificationAlerts.spec.ts) adds coverage for advanced destination configuration, verifying that values are correctly set and that empty configs are not sent in test API calls. [1] [2]

Destination config normalization and filtering:

  • Introduced normalizeDestinationConfig in AlertsUtil.tsx to standardize destination config objects (converting headers and query parameters to arrays) for reliable comparison and processing. [1] [2] [3]
  • Updated the filtering logic in DestinationFormItem.component.tsx to exclude external destinations with empty configs from test API calls, preventing unnecessary or invalid requests.

Test utility and UI improvements:

  • Added data-testid attributes to "add header" and "add query param" buttons to improve Playwright test reliability and clarity. [1] [2]
  • Improved status display in the destination select item to handle missing reasons gracefully.

Code cleanup and import formatting:

  • Cleaned up and consistently formatted import statements across affected files for better readability and maintainability. [1] [2] [3] [4] [5] [6] [7]

These changes collectively make destination configuration handling in alert tests more robust and maintainable, while improving test coverage for advanced scenarios.

Type of change:

  • Bug fix
  • Improvement
  • New feature
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation>
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: I updated the migration scripts or explained why it is not needed.

@ShaileshParmar11 ShaileshParmar11 requested a review from a team as a code owner December 12, 2025 15:58
@ShaileshParmar11 ShaileshParmar11 added the To release Will cherry-pick this PR into the release branch label Dec 12, 2025
@github-actions github-actions bot added safe to test Add this label to run secure Github workflows on PRs UI UI specific issues labels Dec 12, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request fixes issue #22921 where the return code was not displayed after modifying Advanced Configurations in the Alerts UI. The changes enhance the handling and testing of advanced destination configurations (headers, query parameters, and secret keys) for external alert destinations.

Key changes:

  • Introduces normalizeDestinationConfig utility function to standardize destination config formats for reliable comparison
  • Updates getFormattedDestinations to use omitBy for cleaner undefined value filtering
  • Adds defensive handling for missing reason field in status display (fixes the bug in #22921)
  • Filters out external destinations with empty configs from test API calls
  • Enhances Playwright test utilities to support advanced configuration testing
  • Adds comprehensive unit and integration test coverage for new functionality

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
AlertsUtil.tsx Added normalizeDestinationConfig function to convert headers/queryParams from object to array format for consistent comparison; updated getFormattedDestinations to use omitBy for cleaner handling of undefined values; added data-testid attributes to add-header and add-query-param buttons
AlertsUtil.test.tsx Added comprehensive test coverage for normalizeDestinationConfig and getFormattedDestinations functions; improved test assertions by changing primitive comparisons from toStrictEqual to toBe
DestinationSelectItem.tsx Refactored to use normalizeDestinationConfig utility instead of inline normalization; added nullish coalescing operator to handle missing reason field in status display (fixes #22921)
DestinationSelectItem.test.tsx Added extensive test suite for destination status comparison scenarios including headers/queryParams handling; moved act import from @testing-library/react to react per React 18 best practices
DestinationFormItem.component.tsx Added filtering logic to exclude external destinations with empty configs from test API calls
DestinationFormItem.test.tsx Added comprehensive test coverage for handleTestDestinationClick including filtering behavior for internal destinations and empty configs
observabilityAlert.ts Enhanced addExternalDestination utility to accept optional advancedConfig parameter for testing headers, query parameters, and secret keys
NotificationAlerts.spec.ts Added E2E test coverage for advanced destination configuration; validates that empty configs are filtered from test API calls

@github-actions
Copy link
Contributor

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 63%
64.02% (50515/78908) 41.49% (24477/58998) 45% (7733/17184)

@ShaileshParmar11
Copy link
Contributor Author

I’ve addressed some of the code smells; the remaining ones are from older code.

@sonarqubecloud
Copy link

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

Labels

safe to test Add this label to run secure Github workflows on PRs To release Will cherry-pick this PR into the release branch UI UI specific issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Alerts UI: Return code not displayed after modifying Advanced Configurations

2 participants