Skip to content

Conversation

@ArtemHoruzhenko
Copy link
Contributor

@ArtemHoruzhenko ArtemHoruzhenko commented Dec 3, 2025

What

Fixes two issues in the cloud database discovery flow:

  1. Multiple notifications bug: The "Successfully discovered database(s)..." notification was showing multiple times when interacting with the search field
  2. Limited search: Search in subscriptions table only worked for name and id fields

Root Cause

When search filtered items, the notification counts were recalculated from filtered data. This caused the variant prop to change (e.g., from "attention" to "success" when filtered results had no failures), which triggered the MessageBar's useEffect to show a new toast.

Solution

  • Calculate notification counts from original subscriptions prop instead of filtered items state
  • Expand search fields to include all relevant columns:
    • Subscriptions: name, id, type, provider, region, status
    • Database results: added statusAdded (success/fail)

Testing

  1. Navigate to Redis Cloud database discovery
  2. Verify the summary notification appears only once when data loads
  3. Type in the search field - notification should NOT reappear
  4. Search by different fields (provider, region, status) - should filter correctly

Fixes #RI-7776


Note

Stabilizes notifications by deriving counts from original data and broadens search across subscriptions and database results, with tests added for search behavior.

  • UI (Cloud Discovery):
    • Notifications: Compute countStatusActive/countStatusFailed from subscriptions (not filtered items) in RedisCloudSubscriptions.tsx to avoid re-triggering toasts on search.
    • Search Enhancements:
      • RedisCloudSubscriptions.tsx: Search now matches name, id, type, provider, region, status.
      • RedisCloudDatabasesResult.tsx: Search now includes statusAdded in addition to existing fields.
  • Tests:
    • RedisCloudSubscriptions.spec.tsx: Add comprehensive search tests (name, id, provider, region, status, type; case-insensitive) and test scaffolding with faker.

Written by Cursor Bugbot for commit 93f8edb. This will update automatically on new commits. Configure here.

…discovery

- Calculate notification counts from original data instead of filtered items
  to prevent re-triggering toast when search filters change
- Expand search fields in subscriptions page (type, provider, region, status)
- Add statusAdded field to search in databases result page
- Add comprehensive search tests for subscriptions page

Fixes #RI-7776
Use empty string fallback to prevent false positives when statusAdded is undefined
@github-actions
Copy link
Contributor

github-actions bot commented Dec 3, 2025

Code Coverage - Integration Tests

Status Category Percentage Covered / Total
🟢 Statements 81.47% 16317/20028
🟡 Branches 64.48% 7363/11418
🟡 Functions 70.36% 2286/3249
🟢 Lines 81.1% 15351/18927

@github-actions
Copy link
Contributor

github-actions bot commented Dec 3, 2025

Code Coverage - Backend unit tests

St.
Category Percentage Covered / Total
🟢 Statements 92.32% 13948/15109
🟡 Branches 74.05% 4206/5680
🟢 Functions 85.87% 2146/2499
🟢 Lines 92.12% 13335/14475

Test suite run success

2990 tests passing in 287 suites.

Report generated by 🧪jest coverage report action from 93f8edb

@github-actions
Copy link
Contributor

github-actions bot commented Dec 3, 2025

Code Coverage - Frontend unit tests

St.
Category Percentage Covered / Total
🟢 Statements 82.91% 21025/25360
🟡 Branches 68.09% 8858/13010
🟡 Functions 78.05% 5758/7377
🟢 Lines 83.31% 20591/24715

Test suite run success

5475 tests passing in 703 suites.

Report generated by 🧪jest coverage report action from 93f8edb

(item: RedisCloudSubscription) =>
item.name?.toLowerCase()?.indexOf(value) !== -1 ||
item.id?.toString()?.toLowerCase().indexOf(value) !== -1,
item.id?.toString()?.indexOf(value) !== -1 ||
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering can't we add such util:

export const filterBySearchTerm = <T extends Record<string, unknown>>(
  items: T[],
  searchTerm: string,
  fields: (keyof T)[],
): T[] => {
  const term = searchTerm.toLowerCase()
  
  return items.filter((item) =>
    fields.some((field) => {
      const value = item[field]
      return String(value ?? '').toLowerCase().includes(term)
    }),
  )
}


or

export const matchesSearch = (
  fieldValue: unknown,
  searchTerm: string, // expected to be already lowercased
): boolean => String(fieldValue ?? '').toLowerCase().includes(searchTerm)

and then this syntax would be easier to be read and moreover we have it in the RedisCloudDatabasesResult.tsx as well.

Maybe not for this PR, but actually, why not 😸

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants