Skip to content

Commit a85b9ef

Browse files
author
Roman Snapko
committed
Refactor context enrichment service tests to mock getStepById and remove unused stepDisplayName logic
1 parent 262660c commit a85b9ef

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

packages/server/api/test/unit/ai/context-enrichment.service.test.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { jest } from '@jest/globals';
22
import {
3+
Action,
34
ChatFlowContext,
45
EngineResponseStatus,
56
flowHelper,
@@ -59,6 +60,7 @@ jest.mock('server-worker', () => ({
5960
jest.mock('@openops/shared', () => ({
6061
flowHelper: {
6162
getAllStepIds: jest.fn(),
63+
getStepById: jest.fn(),
6264
},
6365
groupStepOutputsById: jest.fn(),
6466
}));
@@ -99,6 +101,12 @@ describe('ContextEnrichmentService', () => {
99101
mockEngineToken,
100102
);
101103
mockFlowHelper.getAllStepIds.mockReturnValue(['step-1']);
104+
mockFlowHelper.getStepById.mockImplementation((_version, stepId) => {
105+
if (stepId === 'step-1') {
106+
return { name: 'step_1' } as Action;
107+
}
108+
return { name: stepId } as Action;
109+
});
102110
mockFlowStepTestOutputService.listEncrypted.mockResolvedValue([]);
103111
mockGroupStepOutputsById.mockReturnValue({});
104112

@@ -111,7 +119,6 @@ describe('ContextEnrichmentService', () => {
111119
steps: [
112120
{
113121
id: 'step-1',
114-
stepDisplayName: 'step_1',
115122
variables: [
116123
{
117124
name: 'variable1',
@@ -159,7 +166,6 @@ describe('ContextEnrichmentService', () => {
159166
steps: [
160167
{
161168
id: 'step-1',
162-
stepDisplayName: 'step_1',
163169
variables: [
164170
{
165171
name: 'variable1',
@@ -196,7 +202,6 @@ describe('ContextEnrichmentService', () => {
196202
steps: [
197203
{
198204
id: 'step-1',
199-
stepDisplayName: 'step_1',
200205
},
201206
],
202207
};
@@ -219,7 +224,6 @@ describe('ContextEnrichmentService', () => {
219224
steps: [
220225
{
221226
id: 'step-1',
222-
stepDisplayName: 'step_1',
223227
variables: undefined,
224228
},
225229
],
@@ -241,7 +245,6 @@ describe('ContextEnrichmentService', () => {
241245
steps: [
242246
{
243247
id: 'step-1',
244-
stepDisplayName: 'step_1',
245248
variables: [
246249
{
247250
name: 'variable1',
@@ -280,7 +283,6 @@ describe('ContextEnrichmentService', () => {
280283
steps: [
281284
{
282285
id: 'step-1',
283-
stepDisplayName: 'step_1',
284286
variables: [
285287
{
286288
name: 'variable1',
@@ -305,7 +307,6 @@ describe('ContextEnrichmentService', () => {
305307
steps: [
306308
{
307309
id: 'step-1',
308-
stepDisplayName: 'step_1',
309310
variables: [
310311
{
311312
name: 'variable1',
@@ -338,8 +339,6 @@ describe('ContextEnrichmentService', () => {
338339
steps: [
339340
{
340341
id: 'step-1',
341-
stepDisplayName: 'step_1',
342-
stepIndex: undefined,
343342
variables: [
344343
{
345344
name: 'variable1',

0 commit comments

Comments
 (0)