Skip to content

Commit

Permalink
Make task_cost_check test resilient to changes in order (elastic#20…
Browse files Browse the repository at this point in the history
…4045)

## Summary

Addresses failures such as
https://buildkite.com/elastic/kibana-pull-request/builds/259739#0193bb07-c759-4749-965e-10e63ac0810a.

We believe the order in which task types are registered might have been
affected by the relocation of the
`@kbn/observability-ai-assistant-app-plugin` in the scope of
_Sustainable Kibana Architecture_.
  • Loading branch information
gsoldevila authored Dec 12, 2024
1 parent 2ab38a3 commit a4e4a60
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 35 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
import { TaskCost, TaskDefinition } from '../task';
import { setupTestServers } from './lib';
import { TaskTypeDictionary } from '../task_type_dictionary';
import { sortBy } from 'lodash';

jest.mock('../task_type_dictionary', () => {
const actual = jest.requireActual('../task_type_dictionary');
Expand Down Expand Up @@ -50,14 +51,17 @@ describe('Task cost checks', () => {

it('detects tasks with cost definitions', async () => {
const taskTypes = taskTypeDictionary.getAllDefinitions();
const taskTypesWithCost = taskTypes
.map((taskType: TaskDefinition) =>
!!taskType.cost ? { taskType: taskType.type, cost: taskType.cost } : null
)
.filter(
(tt: { taskType: string; cost: TaskCost } | null) =>
null != tt && tt.cost !== TaskCost.Normal
);
const taskTypesWithCost = sortBy(
taskTypes
.map((taskType: TaskDefinition) =>
!!taskType.cost ? { taskType: taskType.type, cost: taskType.cost } : null
)
.filter(
(tt: { taskType: string; cost: TaskCost } | null) =>
null != tt && tt.cost !== TaskCost.Normal
),
'taskType'
);
expect(taskTypesWithCost).toMatchSnapshot();
});
});

0 comments on commit a4e4a60

Please sign in to comment.