-
Notifications
You must be signed in to change notification settings - Fork 125
feat: Workflow History V2 - Ungrouped Event Table #1109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
adhityamamallan
merged 5 commits into
cadence-workflow:master
from
adhityamamallan:history-ungrouped-table
Dec 9, 2025
+721
−8
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4db12a9
Add basic ungrouped table
adhityamamallan 31d1d3c
Change types and add helper
adhityamamallan dda574d
address comments
adhityamamallan dfd235a
fix types
adhityamamallan 5c8c2b2
Merge branch 'master' into history-ungrouped-table
adhityamamallan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
...ow-history-v2/workflow-history-ungrouped-event/workflow-history-ungrouped-event.styles.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import { styled as createStyled, type Theme } from 'baseui'; | ||
|
|
||
| export const styled = { | ||
| TempContainer: createStyled('div', ({ $theme }: { $theme: Theme }) => ({ | ||
| ...$theme.typography.MonoParagraphXSmall, | ||
| padding: $theme.sizing.scale300, | ||
| ...$theme.borders.border100, | ||
| })), | ||
| }; |
8 changes: 8 additions & 0 deletions
8
...workflow-history-v2/workflow-history-ungrouped-event/workflow-history-ungrouped-event.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import { styled } from './workflow-history-ungrouped-event.styles'; | ||
| import { type Props } from './workflow-history-ungrouped-event.types'; | ||
|
|
||
| export default function WorkflowHistoryUngroupedEvent({ eventInfo }: Props) { | ||
| return ( | ||
| <styled.TempContainer>{JSON.stringify(eventInfo)}</styled.TempContainer> | ||
| ); | ||
| } | ||
18 changes: 18 additions & 0 deletions
18
...low-history-v2/workflow-history-ungrouped-event/workflow-history-ungrouped-event.types.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import { type WorkflowPageTabsParams } from '@/views/workflow-page/workflow-page-tabs/workflow-page-tabs.types'; | ||
|
|
||
| import { type UngroupedEventInfo } from '../workflow-history-ungrouped-table/workflow-history-ungrouped-table.types'; | ||
|
|
||
| export type Props = { | ||
| // Core data props | ||
| eventInfo: UngroupedEventInfo; | ||
| workflowStartTimeMs: number | null; | ||
| decodedPageUrlParams: WorkflowPageTabsParams; | ||
|
|
||
| // Expansion state | ||
| isExpanded: boolean; | ||
| toggleIsExpanded: () => void; | ||
|
|
||
| // UI behavior | ||
| animateOnEnter?: boolean; | ||
| onReset?: () => void; | ||
| }; |
265 changes: 265 additions & 0 deletions
265
...y-v2/workflow-history-ungrouped-table/__tests__/workflow-history-ungrouped-table.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,265 @@ | ||
| import React from 'react'; | ||
|
|
||
| import { VirtuosoMockContext } from 'react-virtuoso'; | ||
|
|
||
| import { render, screen, userEvent, waitFor } from '@/test-utils/rtl'; | ||
|
|
||
| import { type RequestError } from '@/utils/request/request-error'; | ||
| import { mockActivityEventGroup } from '@/views/workflow-history/__fixtures__/workflow-history-event-groups'; | ||
| import { type HistoryEventsGroup } from '@/views/workflow-history/workflow-history.types'; | ||
| import { type WorkflowPageTabsParams } from '@/views/workflow-page/workflow-page-tabs/workflow-page-tabs.types'; | ||
|
|
||
| import WorkflowHistoryUngroupedTable from '../workflow-history-ungrouped-table'; | ||
|
|
||
| jest.mock( | ||
| '@/views/workflow-history/workflow-history-timeline-load-more/workflow-history-timeline-load-more', | ||
| () => | ||
| jest.fn(({ error, hasNextPage, isFetchingNextPage, fetchNextPage }) => ( | ||
| <div data-testid="timeline-load-more"> | ||
| {error && <div data-testid="load-more-error">Error loading more</div>} | ||
| {hasNextPage && <div data-testid="has-next-page">Has more</div>} | ||
| {isFetchingNextPage && <div data-testid="is-fetching">Fetching...</div>} | ||
| <button onClick={fetchNextPage} data-testid="fetch-more-button"> | ||
| Fetch More | ||
| </button> | ||
| </div> | ||
| )) | ||
| ); | ||
|
|
||
| jest.mock( | ||
| '../../workflow-history-ungrouped-event/workflow-history-ungrouped-event', | ||
| () => | ||
| jest.fn( | ||
| ({ | ||
| eventInfo, | ||
| isExpanded, | ||
| toggleIsExpanded, | ||
| onReset, | ||
| animateOnEnter, | ||
| }) => ( | ||
| <div | ||
| data-testid="workflow-history-ungrouped-event" | ||
| data-expanded={isExpanded} | ||
| data-animate-on-enter={animateOnEnter} | ||
| data-event-id={eventInfo.id} | ||
| > | ||
| <button onClick={toggleIsExpanded}>Toggle Event</button> | ||
| <div>Event ID: {eventInfo.id}</div> | ||
| <div>Label: {eventInfo.label}</div> | ||
| {onReset && <button onClick={onReset}>Reset Event</button>} | ||
| </div> | ||
| ) | ||
| ) | ||
| ); | ||
|
|
||
| describe(WorkflowHistoryUngroupedTable.name, () => { | ||
| it('should render all column headers in correct order', () => { | ||
| setup(); | ||
|
|
||
| expect(screen.getByText('ID')).toBeInTheDocument(); | ||
| expect(screen.getByText('Event group')).toBeInTheDocument(); | ||
| expect(screen.getByText('Status')).toBeInTheDocument(); | ||
| expect(screen.getByText('Time')).toBeInTheDocument(); | ||
| expect(screen.getByText('Duration')).toBeInTheDocument(); | ||
| expect(screen.getByText('Details')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('should render events from event groups', () => { | ||
| const mockEventGroups: Array<[string, HistoryEventsGroup]> = [ | ||
| ['group-1', mockActivityEventGroup], | ||
| ]; | ||
| setup({ eventGroupsById: mockEventGroups }); | ||
|
|
||
| const events = screen.getAllByTestId('workflow-history-ungrouped-event'); | ||
| expect(events.length).toBeGreaterThan(0); | ||
| expect(events[0]).toHaveTextContent('Event ID:'); | ||
| }); | ||
|
|
||
| it('should render events with correct labels from groups', () => { | ||
| const mockEventGroups: Array<[string, HistoryEventsGroup]> = [ | ||
| ['group-1', mockActivityEventGroup], | ||
| ]; | ||
| setup({ eventGroupsById: mockEventGroups }); | ||
|
|
||
| const events = screen.getAllByTestId('workflow-history-ungrouped-event'); | ||
| expect(events[0]).toHaveTextContent( | ||
| `Label: ${mockActivityEventGroup.label}` | ||
| ); | ||
| }); | ||
|
|
||
| it('should handle event expansion toggle', async () => { | ||
| const { user, mockToggleIsEventExpanded } = setup({ | ||
| eventGroupsById: [['group-1', mockActivityEventGroup]], | ||
| }); | ||
|
|
||
| const toggleButtons = screen.getAllByText('Toggle Event'); | ||
| await user.click(toggleButtons[0]); | ||
|
|
||
| const firstEventId = | ||
| mockActivityEventGroup.events[0].eventId ?? | ||
| mockActivityEventGroup.events[0].computedEventId; | ||
| expect(mockToggleIsEventExpanded).toHaveBeenCalledWith(firstEventId); | ||
| }); | ||
|
|
||
| it('should pass isExpanded state to events', () => { | ||
| const mockEventGroups: Array<[string, HistoryEventsGroup]> = [ | ||
| ['group-1', mockActivityEventGroup], | ||
| ]; | ||
| const firstEventId = | ||
| mockActivityEventGroup.events[0].eventId ?? | ||
| mockActivityEventGroup.events[0].computedEventId; | ||
|
|
||
| setup({ | ||
| eventGroupsById: mockEventGroups, | ||
| getIsEventExpanded: jest.fn((id) => id === firstEventId), | ||
| }); | ||
|
|
||
| const events = screen.getAllByTestId('workflow-history-ungrouped-event'); | ||
| expect(events[0]).toHaveAttribute('data-expanded', 'true'); | ||
| if (events.length > 1) { | ||
| expect(events[1]).toHaveAttribute('data-expanded', 'false'); | ||
| } | ||
| }); | ||
|
|
||
| it('should pass hasMoreEvents to load more component', () => { | ||
| setup({ | ||
| hasMoreEvents: true, | ||
| isFetchingMoreEvents: false, | ||
| fetchMoreEvents: jest.fn(), | ||
| }); | ||
|
|
||
| expect(screen.getByTestId('timeline-load-more')).toBeInTheDocument(); | ||
| expect(screen.getByTestId('has-next-page')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('should pass animateOnEnter for selectedEventId', async () => { | ||
| const mockEventGroups: Array<[string, HistoryEventsGroup]> = [ | ||
| ['group-1', mockActivityEventGroup], | ||
| ]; | ||
| const firstEventId = | ||
| mockActivityEventGroup.events[0].eventId ?? | ||
| mockActivityEventGroup.events[0].computedEventId; | ||
|
|
||
| setup({ | ||
| eventGroupsById: mockEventGroups, | ||
| selectedEventId: firstEventId, | ||
| }); | ||
|
|
||
| await waitFor(() => { | ||
| const events = screen.getAllByTestId('workflow-history-ungrouped-event'); | ||
| expect(events[0]).toHaveAttribute('data-animate-on-enter', 'true'); | ||
| }); | ||
| }); | ||
|
|
||
| it('should call resetToDecisionEventId when reset button is clicked on resettable event', async () => { | ||
| const mockEventGroups: Array<[string, HistoryEventsGroup]> = [ | ||
| [ | ||
| 'group-1', | ||
| { | ||
| ...mockActivityEventGroup, | ||
| resetToDecisionEventId: mockActivityEventGroup.events[0].eventId, | ||
| }, | ||
| ], | ||
| ]; | ||
| const { user, mockResetToDecisionEventId } = setup({ | ||
| eventGroupsById: mockEventGroups, | ||
| }); | ||
|
|
||
| const resetButtons = screen.getAllByText('Reset Event'); | ||
| await user.click(resetButtons[0]); | ||
|
|
||
| const firstEventId = | ||
| mockActivityEventGroup.events[0].eventId ?? | ||
| mockActivityEventGroup.events[0].computedEventId; | ||
| expect(mockResetToDecisionEventId).toHaveBeenCalledWith(firstEventId); | ||
| }); | ||
|
|
||
| it('should not show reset button for non-resettable events', () => { | ||
| const mockEventGroups: Array<[string, HistoryEventsGroup]> = [ | ||
| [ | ||
| 'group-1', | ||
| { | ||
| ...mockActivityEventGroup, | ||
| resetToDecisionEventId: undefined, | ||
| }, | ||
| ], | ||
| ]; | ||
| setup({ eventGroupsById: mockEventGroups }); | ||
|
|
||
| expect(screen.queryByText('Reset Event')).not.toBeInTheDocument(); | ||
| }); | ||
| }); | ||
|
|
||
| function setup({ | ||
| eventGroupsById = [], | ||
| error = null, | ||
| hasMoreEvents = false, | ||
| isFetchingMoreEvents = false, | ||
| fetchMoreEvents = jest.fn(), | ||
| setVisibleRange = jest.fn(), | ||
| initialStartIndex, | ||
| decodedPageUrlParams = { | ||
| domain: 'test-domain', | ||
| cluster: 'test-cluster', | ||
| workflowId: 'test-workflow-id', | ||
| runId: 'test-run-id', | ||
| workflowTab: 'history', | ||
| }, | ||
| selectedEventId, | ||
| getIsEventExpanded = jest.fn(() => false), | ||
| toggleIsEventExpanded = jest.fn(), | ||
| resetToDecisionEventId = jest.fn(), | ||
| }: { | ||
| eventGroupsById?: Array<[string, HistoryEventsGroup]>; | ||
| error?: RequestError | null; | ||
| hasMoreEvents?: boolean; | ||
| isFetchingMoreEvents?: boolean; | ||
| fetchMoreEvents?: () => void; | ||
| setVisibleRange?: ({ | ||
| startIndex, | ||
| endIndex, | ||
| }: { | ||
| startIndex: number; | ||
| endIndex: number; | ||
| }) => void; | ||
| initialStartIndex?: number; | ||
| decodedPageUrlParams?: WorkflowPageTabsParams; | ||
| selectedEventId?: string; | ||
| getIsEventExpanded?: (eventId: string) => boolean; | ||
| toggleIsEventExpanded?: (eventId: string) => void; | ||
| resetToDecisionEventId?: (decisionEventId: string) => void; | ||
| } = {}) { | ||
| const virtuosoRef = { current: null }; | ||
| const user = userEvent.setup(); | ||
|
|
||
| render( | ||
| <VirtuosoMockContext.Provider | ||
| value={{ viewportHeight: 1000, itemHeight: 36 }} | ||
| > | ||
| <WorkflowHistoryUngroupedTable | ||
| eventGroupsById={eventGroupsById} | ||
| virtuosoRef={virtuosoRef} | ||
| initialStartIndex={initialStartIndex} | ||
| setVisibleRange={setVisibleRange} | ||
| decodedPageUrlParams={decodedPageUrlParams} | ||
| selectedEventId={selectedEventId} | ||
| getIsEventExpanded={getIsEventExpanded} | ||
| toggleIsEventExpanded={toggleIsEventExpanded} | ||
| resetToDecisionEventId={resetToDecisionEventId} | ||
| error={error} | ||
| hasMoreEvents={hasMoreEvents} | ||
| fetchMoreEvents={fetchMoreEvents} | ||
| isFetchingMoreEvents={isFetchingMoreEvents} | ||
| /> | ||
| </VirtuosoMockContext.Provider> | ||
| ); | ||
|
|
||
| return { | ||
| user, | ||
| virtuosoRef, | ||
| mockFetchMoreEvents: fetchMoreEvents, | ||
| mockSetVisibleRange: setVisibleRange, | ||
| mockToggleIsEventExpanded: toggleIsEventExpanded, | ||
| mockResetToDecisionEventId: resetToDecisionEventId, | ||
| }; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The component receives multiple props (
workflowStartTimeMs,decodedPageUrlParams,isExpanded,toggleIsExpanded,animateOnEnter,onReset) but only destructures and useseventInfo. While this is a placeholder implementation, consider at least destructuring the unused props to avoid ESLint warnings, or using a rest parameter pattern if they're genuinely not needed yet.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, does this shows a warning ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, it would show a warning if I implemented Copilot's suggestion though.
I think this is a good argument in favour of having inline "Props" instead of keeping them in a separate file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does inline props help here ?