Skip to content

Conversation

@sg00dwin
Copy link
Member

Includes tests for

  • Sorts events by timestamp across namespaces
  • Filters events by selected namespace
  • Clears and re-filters events when namespace changes
  • Validates event type filtering

@openshift-ci-robot openshift-ci-robot added jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Dec 11, 2025
@openshift-ci-robot
Copy link
Contributor

@sg00dwin: This pull request references Jira Issue OCPBUGS-63159, which is invalid:

  • expected the bug to target the "4.21.0" version, but no target version was set

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

Details

In response to this:

Includes tests for

  • Sorts events by timestamp across namespaces
  • Filters events by selected namespace
  • Clears and re-filters events when namespace changes
  • Validates event type filtering

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@coderabbitai
Copy link

coderabbitai bot commented Dec 11, 2025

Walkthrough

Adds a new test suite for event utilities and updates EventStream to close its WebSocket and clear the local event cache when effect dependencies change. No public API signatures were modified.

Changes

Cohort / File(s) Change Summary
Tests: event utilities
frontend/public/components/__tests__/events.spec.tsx
New test suite covering sortEvents and typeFilter: verifies descending lastTimestamp ordering across namespaces, order preservation with multiple namespaces, type-based filtering including missing-type defaults, and integration scenarios for namespace filtering and sorting.
Component: EventStream state reset
frontend/public/components/events.jsx
In the effect responding to dependent prop changes, explicitly closes the existing WebSocket and clears sortedEvents (resets local event cache) before establishing a new connection. No other reconnection or error-handling changes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15–30 minutes

  • Review the new tests for completeness and edge cases around missing type and cross-namespace ordering.
  • Confirm the WebSocket closure and sortedEvents reset timing do not introduce race conditions or break expected event stream reconnection behavior.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

@openshift-ci openshift-ci bot requested review from TheRealJon and cajieh December 11, 2025 22:41
@openshift-ci openshift-ci bot added the component/core Related to console core functionality label Dec 11, 2025
@sg00dwin
Copy link
Member Author

/jira refresh

@openshift-ci-robot openshift-ci-robot added the jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. label Dec 11, 2025
@openshift-ci-robot
Copy link
Contributor

@sg00dwin: This pull request references Jira Issue OCPBUGS-63159, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.21.0) matches configured target version for branch (4.21.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, POST)
Details

In response to this:

/jira refresh

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot openshift-ci-robot removed the jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. label Dec 11, 2025
Copy link

@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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between 335ed77 and f27d919.

📒 Files selected for processing (2)
  • frontend/public/components/__tests__/events.spec.tsx (1 hunks)
  • frontend/public/components/events.jsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**

⚙️ CodeRabbit configuration file

-Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity.

Files:

  • frontend/public/components/events.jsx
  • frontend/public/components/__tests__/events.spec.tsx
🧬 Code graph analysis (1)
frontend/public/components/__tests__/events.spec.tsx (1)
frontend/public/components/events.jsx (4)
  • sortEvents (61-63)
  • sortEvents (61-63)
  • typeFilter (66-72)
  • typeFilter (66-72)
🔇 Additional comments (2)
frontend/public/components/events.jsx (1)

394-462: Clearing sortedEvents on dependency changes correctly prevents stale cross-namespace events

Resetting the local cache with setSortedEvents([]) when namespace / fieldSelector / mock change ensures events from the previously selected project are not displayed while establishing the new stream. Combined with the existing WebSocket teardown, this is a clean, low-risk fix that matches the PR objective.

frontend/public/components/__tests__/events.spec.tsx (1)

21-48: sortEvents tests give good coverage for cross-namespace ordering

The tests around sortEvents (including the “Integration with namespace filtering” block) exercise the key ordering behavior across namespaces and verify that namespace-based filtering preserves sort order. This should help prevent regressions in event ordering for the scenarios described in the bug.

Also applies to: 90-142

@sg00dwin sg00dwin force-pushed the OCPBUGS-63159-events-project-bug branch from f27d919 to c07ed11 Compare December 11, 2025 22:53
Copy link

@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: 0

🧹 Nitpick comments (2)
frontend/public/components/__tests__/events.spec.tsx (2)

21-48: Consider adding tests for fallback sorting behavior.

The tests correctly validate timestamp-based sorting across namespaces. However, the sortEvents implementation uses multiple sort keys ([getLastTime, getFirstTime, 'name']), but the current tests only verify lastTimestamp sorting.

Consider adding tests for scenarios where lastTimestamp is identical and the fallback sorting by firstTime or name would apply. This would ensure complete coverage of the sorting logic.

Example test case to add:

it('falls back to firstTime and name when lastTimestamp is identical', () => {
  const events = [
    { ...createMockEvent('ns', 'event-b', 'uid1', '2025-12-10T10:00:00Z'), firstTimestamp: '2025-12-10T09:00:00Z' },
    { ...createMockEvent('ns', 'event-a', 'uid2', '2025-12-10T10:00:00Z'), firstTimestamp: '2025-12-10T09:00:00Z' },
  ];
  
  const sorted = sortEvents(events);
  
  expect(sorted[0].metadata.name).toBe('event-a'); // sorted by name when timestamps match
  expect(sorted[1].metadata.name).toBe('event-b');
});

96-148: LGTM! Integration tests effectively validate namespace filtering.

The integration tests thoroughly validate the PR objectives by demonstrating that:

  1. Events are sorted by timestamp across namespaces
  2. Namespace filtering preserves sort order
  3. Changing the namespace filter produces different results

These tests directly address the bug described in the PR title about preventing display of events from projects other than the currently selected project.

For added robustness, consider tests for edge cases:

it('handles empty event arrays', () => {
  const sorted = sortEvents([]);
  expect(sorted).toEqual([]);
});

it('handles single event', () => {
  const event = createMockEvent('ns', 'event', 'uid', '2025-12-10T10:00:00Z');
  const sorted = sortEvents([event]);
  expect(sorted).toHaveLength(1);
  expect(sorted[0]).toBe(event);
});
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between f27d919 and c07ed11.

📒 Files selected for processing (2)
  • frontend/public/components/__tests__/events.spec.tsx (1 hunks)
  • frontend/public/components/events.jsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • frontend/public/components/events.jsx
🧰 Additional context used
📓 Path-based instructions (1)
**

⚙️ CodeRabbit configuration file

-Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity.

Files:

  • frontend/public/components/__tests__/events.spec.tsx
🧬 Code graph analysis (1)
frontend/public/components/__tests__/events.spec.tsx (1)
frontend/public/components/events.jsx (5)
  • sortEvents (61-63)
  • sortEvents (61-63)
  • typeFilter (66-72)
  • typeFilter (66-72)
  • filteredEvents (390-392)
🔇 Additional comments (3)
frontend/public/components/__tests__/events.spec.tsx (3)

1-2: LGTM!

The imports are clean and properly reference the utility functions under test.


3-19: LGTM!

The mock event helper is well-structured and creates realistic test fixtures. The previous concern about always including the type property has been properly addressed in the test at lines 82-93, where the type is explicitly removed via destructuring.


50-94: LGTM!

The type filtering tests comprehensively cover all scenarios:

  • 'all' filter behavior
  • Specific type matching (normal/warning)
  • Default handling when type property is missing

The previous review concern has been properly addressed at lines 82-93, where the type property is explicitly removed via destructuring before testing the default behavior. The test now correctly validates that events without a type property are treated as 'normal' type.

@sg00dwin
Copy link
Member Author

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Dec 11, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@rhamilto
Copy link
Member

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Dec 15, 2025
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Dec 15, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rhamilto, sg00dwin

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 15, 2025
@sg00dwin
Copy link
Member Author

/retest-required

@sg00dwin
Copy link
Member Author

/jira refresh

@openshift-ci-robot openshift-ci-robot added jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. and removed jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. labels Dec 16, 2025
@openshift-ci-robot
Copy link
Contributor

@sg00dwin: This pull request references Jira Issue OCPBUGS-63159, which is invalid:

  • expected the bug to target either version "4.22." or "openshift-4.22.", but it targets "4.21.0" instead

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

Details

In response to this:

/jira refresh

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@sg00dwin
Copy link
Member Author

/jira refresh

@openshift-ci-robot openshift-ci-robot added jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. and removed jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Dec 16, 2025
@openshift-ci-robot
Copy link
Contributor

@sg00dwin: This pull request references Jira Issue OCPBUGS-63159, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.22.0) matches configured target version for branch (4.22.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST)
Details

In response to this:

/jira refresh

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@sg00dwin
Copy link
Member Author

/cherrypick release-4.21

@openshift-cherrypick-robot

@sg00dwin: once the present PR merges, I will cherry-pick it on top of release-4.21 in a new PR and assign it to you.

Details

In response to this:

/cherrypick release-4.21

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@sg00dwin
Copy link
Member Author

sg00dwin commented Dec 16, 2025

Needs backport to 4.20, 4.19

@sg00dwin
Copy link
Member Author

/verified later @yanpzhan

@openshift-ci-robot openshift-ci-robot added verified-later verified Signifies that the PR passed pre-merge verification criteria labels Dec 17, 2025
@openshift-ci-robot
Copy link
Contributor

@sg00dwin: This PR has been marked to be verified later by @yanpzhan.

Details

In response to this:

/verified later @yanpzhan

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@sg00dwin
Copy link
Member Author

/label acknowledge-critical-fixes-only

@openshift-ci openshift-ci bot added the acknowledge-critical-fixes-only Indicates if the issuer of the label is OK with the policy. label Dec 17, 2025
@openshift-ci-robot
Copy link
Contributor

/retest-required

Remaining retests: 0 against base HEAD 9ac9e36 and 2 for PR HEAD c07ed11 in total

@sg00dwin
Copy link
Member Author

/retest-required

1 similar comment
@sg00dwin
Copy link
Member Author

/retest-required

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Dec 18, 2025

@sg00dwin: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@openshift-merge-bot openshift-merge-bot bot merged commit f0a01ae into openshift:main Dec 19, 2025
8 checks passed
@openshift-ci-robot
Copy link
Contributor

@sg00dwin: Jira Issue OCPBUGS-63159: All pull requests linked via external trackers have merged:

This pull request has the verified-later tag and will need to be manually moved to VERIFIED after testing. Jira Issue OCPBUGS-63159 has been moved to the MODIFIED state.

Details

In response to this:

Includes tests for

  • Sorts events by timestamp across namespaces
  • Filters events by selected namespace
  • Clears and re-filters events when namespace changes
  • Validates event type filtering

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-cherrypick-robot

@sg00dwin: new pull request created: #15867

Details

In response to this:

/cherrypick release-4.21

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@openshift-merge-robot
Copy link
Contributor

Fix included in accepted release 4.22.0-0.nightly-2025-12-21-224908

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

Labels

acknowledge-critical-fixes-only Indicates if the issuer of the label is OK with the policy. approved Indicates a PR has been approved by an approver from all required OWNERS files. component/core Related to console core functionality jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. verified Signifies that the PR passed pre-merge verification criteria verified-later

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants