Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
type TimerHistoryGroup,
type ActivityHistoryGroup,
type LocalActivityHistoryGroup,
type SingleEventHistoryGroup,
type DecisionHistoryGroup,
type ChildWorkflowExecutionHistoryGroup,
Expand All @@ -12,6 +13,7 @@ import {
import { completedActivityTaskEvents } from './workflow-history-activity-events';
import { completedChildWorkflowEvents } from './workflow-history-child-workflow-events';
import { completedDecisionTaskEvents } from './workflow-history-decision-events';
import { localActivityMarkerEvent } from './workflow-history-local-activity-events';
import { requestedCancelExternalWorkflowEvents } from './workflow-history-request-cancel-external-workflow-events';
import { signaledExternalWorkflowEvents } from './workflow-history-signal-external-workflow-events';
import { startWorkflowExecutionEvent } from './workflow-history-single-events';
Expand All @@ -31,6 +33,19 @@ export const mockActivityEventGroup: ActivityHistoryGroup = {
firstEventId: completedActivityTaskEvents[0].eventId,
};

export const mockLocalActivityEventGroup: LocalActivityHistoryGroup = {
label: 'Mock local activity',
groupType: 'LocalActivity',
status: 'COMPLETED',
eventsMetadata: [],
hasMissingEvents: false,
timeMs: 1724747615549,
startTimeMs: 1724747615549,
timeLabel: 'Mock time label',
events: [localActivityMarkerEvent],
firstEventId: localActivityMarkerEvent.eventId,
};

export const mockDecisionEventGroup: DecisionHistoryGroup = {
label: 'Mock decision',
groupType: 'Decision',
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { type EventGroupTypeToCategoryConfig } from '../workflow-history-filters-menu/workflow-history-filters-menu.types';
import { type HistoryEventGroupType } from '../workflow-history-v2.types';

const workflowHistoryEventGroupTypeToCategoryConfig = {
Activity: 'ACTIVITY',
LocalActivity: 'ACTIVITY',
ChildWorkflowExecution: 'CHILDWORKFLOW',
Decision: 'DECISION',
SignalExternalWorkflowExecution: 'SIGNAL',
WorkflowSignaled: 'SIGNAL',
Timer: 'TIMER',
RequestCancelExternalWorkflowExecution: 'WORKFLOW',
Event: 'WORKFLOW',
} as const satisfies Record<
HistoryEventGroupType,
EventGroupTypeToCategoryConfig
>;

export default workflowHistoryEventGroupTypeToCategoryConfig;
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { type HistoryEventsGroup } from '../../workflow-history-v2.types';
import getEventGroupCategory from '../get-event-group-category';

jest.mock(
'../../config/workflow-history-event-group-type-to-category.config',
() => ({
__esModule: true,
default: {
Activity: 'ACTIVITY',
Decision: jest.fn((group: HistoryEventsGroup) =>
group.status === 'COMPLETED' ? 'DECISION' : 'WORKFLOW'
),
},
})
);

describe(getEventGroupCategory.name, () => {
it('should return the category directly when config value is a string', () => {
const group = { groupType: 'Activity' } as HistoryEventsGroup;

expect(getEventGroupCategory(group)).toBe('ACTIVITY');
});

it('should call the config function and return its result when config value is a function', () => {
const completedGroup = {
groupType: 'Decision',
status: 'COMPLETED',
} as HistoryEventsGroup;

expect(getEventGroupCategory(completedGroup)).toBe('DECISION');

const ongoingGroup = {
groupType: 'Decision',
status: 'ONGOING',
} as HistoryEventsGroup;

expect(getEventGroupCategory(ongoingGroup)).toBe('WORKFLOW');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,6 @@ import {
} from '../../workflow-history-v2.types';
import getNavigationBarEventsMenuItems from '../get-navigation-bar-events-menu-items';

jest.mock(
'../../workflow-history-event-group/helpers/get-event-group-filtering-type',
() =>
jest.fn((group: HistoryEventsGroup) => {
if (group.groupType === 'Activity') return 'ACTIVITY';
if (group.groupType === 'Decision') return 'DECISION';
return 'WORKFLOW';
})
);

describe(getNavigationBarEventsMenuItems.name, () => {
it('should return an empty array when eventGroupsEntries is empty', () => {
const eventGroupsEntries: Array<EventGroupEntry> = [];
Expand Down Expand Up @@ -66,7 +56,7 @@ describe(getNavigationBarEventsMenuItems.name, () => {
expect(result[0]).toEqual({
eventId: '4', // last eventId from completedDecisionTaskEvents
label: 'Mock decision',
type: 'DECISION',
category: 'DECISION',
});
});

Expand All @@ -85,12 +75,12 @@ describe(getNavigationBarEventsMenuItems.name, () => {
expect(result[0]).toEqual({
eventId: '10', // last eventId from completedActivityTaskEvents
label: 'Mock event',
type: 'ACTIVITY',
category: 'ACTIVITY',
});
expect(result[1]).toEqual({
eventId: '4', // last eventId from completedDecisionTaskEvents
label: 'Mock decision',
type: 'DECISION',
category: 'DECISION',
});
});

Expand Down
13 changes: 13 additions & 0 deletions src/views/workflow-history-v2/helpers/get-event-group-category.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import workflowHistoryEventGroupTypeToCategoryConfig from '../config/workflow-history-event-group-type-to-category.config';
import { type EventGroupTypeToCategoryConfig } from '../workflow-history-filters-menu/workflow-history-filters-menu.types';
import { type HistoryEventsGroup } from '../workflow-history-v2.types';

export default function getEventGroupCategory(group: HistoryEventsGroup) {
const categoryConfig = workflowHistoryEventGroupTypeToCategoryConfig[
group.groupType
] as EventGroupTypeToCategoryConfig;

return typeof categoryConfig === 'function'
? categoryConfig(group)
: categoryConfig;
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import getEventGroupFilteringType from '../workflow-history-event-group/helpers/get-event-group-filtering-type';
import { type NavigationBarEventsMenuItem } from '../workflow-history-navigation-bar-events-menu/workflow-history-navigation-bar-events-menu.types';
import {
type HistoryEventsGroup,
type EventGroupEntry,
} from '../workflow-history-v2.types';

import getEventGroupCategory from './get-event-group-category';

export default function getNavigationBarEventsMenuItems(
eventGroupsEntries: Array<EventGroupEntry>,
filterFn: (group: HistoryEventsGroup) => boolean
Expand All @@ -19,7 +20,7 @@ export default function getNavigationBarEventsMenuItems(
acc.push({
eventId: lastEventId,
label: group.shortLabel ?? group.label,
type: getEventGroupFilteringType(group),
category: getEventGroupCategory(group),
});

return acc;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,6 @@ jest.mock(
() => jest.fn(() => <span>1m 30s</span>)
);

jest.mock('../helpers/get-event-group-filtering-type', () =>
jest.fn(() => 'ACTIVITY')
);

const mockActivityEventGroupWithMetadata: HistoryEventsGroup = {
...mockActivityEventGroup,
eventsMetadata: [
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import WorkflowHistoryGroupLabel from '@/views/workflow-history/workflow-history
import WorkflowHistoryTimelineResetButton from '@/views/workflow-history/workflow-history-timeline-reset-button/workflow-history-timeline-reset-button';

import workflowHistoryEventGroupCategoryColorsConfig from '../config/workflow-history-event-group-category-colors.config';
import getEventGroupCategory from '../helpers/get-event-group-category';
import useGroupDetailsEntries from '../hooks/use-group-details-entries';
import WorkflowHistoryDetailsRow from '../workflow-history-details-row/workflow-history-details-row';
import WorkflowHistoryEventGroupDuration from '../workflow-history-event-group-duration/workflow-history-event-group-duration';
import WorkflowHistoryEventStatusBadge from '../workflow-history-event-status-badge/workflow-history-event-status-badge';
import WorkflowHistoryGroupDetails from '../workflow-history-group-details/workflow-history-group-details';

import getEventGroupFilteringType from './helpers/get-event-group-filtering-type';
import {
overrides as getOverrides,
styled,
Expand Down Expand Up @@ -48,7 +48,7 @@ export default function WorkflowHistoryEventGroup({
resetToDecisionEventId,
} = eventGroup;

const eventFilteringType = getEventGroupFilteringType(eventGroup);
const eventGroupCategory = getEventGroupCategory(eventGroup);

const handleReset = useCallback(() => {
if (onReset) {
Expand Down Expand Up @@ -77,15 +77,15 @@ export default function WorkflowHistoryEventGroup({
[groupDetailsEntriesWithSummary, selectedEventId]
);

const overrides = getOverrides(eventFilteringType, animateOnEnter);
const overrides = getOverrides(eventGroupCategory, animateOnEnter);

return (
<Panel
title={
<styled.HeaderContent>
<MdCircle
color={
workflowHistoryEventGroupCategoryColorsConfig[eventFilteringType]
workflowHistoryEventGroupCategoryColorsConfig[eventGroupCategory]
.content
}
/>
Expand Down
Loading