Skip to content

Commit

Permalink
update test
Browse files Browse the repository at this point in the history
  • Loading branch information
shahzad31 committed Aug 1, 2023
1 parent 8cbf9c4 commit 86da439
Showing 1 changed file with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import type { SavedObjectMigrationContext } from '@kbn/core/server';
import type { SavedObjectModelTransformationContext } from '@kbn/core-saved-objects-server';

import { getBrowserPolicy } from './fixtures/8.7.0';

Expand All @@ -14,26 +14,30 @@ import { migrateSyntheticsPackagePolicyToV8100 as migration } from './to_v8_10_0
describe('8.10.0 Synthetics Package Policy migration', () => {
describe('processors migration', () => {
it('handles processors field for empty values', () => {
const actual = migration(getBrowserPolicy('false'), {} as SavedObjectMigrationContext);
const { document: actual } = migration(
getBrowserPolicy('false'),
{} as SavedObjectModelTransformationContext
);
expect(actual.attributes?.inputs[3]?.streams[0]?.vars?.processors?.value).toEqual(
'[{"add_fields":{"fields":{"monitor.fleet_managed":true},"target":""}}]'
'[{"add_fields":{"fields":{"monitor.fleet_managed":true,"config_id":"420754e9-40f2-486c-bc2e-265bafd735c5"},"target":""}}]'
);
expect(actual.attributes?.inputs[3]?.streams[0]?.compiled_stream?.processors).toEqual(
'[{"add_fields":{"fields":{"monitor.fleet_managed":true},"target":""}}]'
'[{"add_fields":{"fields":{"monitor.fleet_managed":true,"config_id":"420754e9-40f2-486c-bc2e-265bafd735c5"},"target":""}}]'
);
});

it('handles processors field for project monitor', () => {
const actual = migration(
const { document: actual } = migration(
getBrowserPolicy('', 'test-project'),
{} as SavedObjectMigrationContext
{} as SavedObjectModelTransformationContext
);
expect(actual.attributes?.inputs[3]?.streams[0]?.vars?.processors?.value).toEqual(
JSON.stringify([
{
add_fields: {
fields: {
'monitor.fleet_managed': true,
config_id: '420754e9-40f2-486c-bc2e-265bafd735c5',
'monitor.project.name': 'test-project',
'monitor.project.id': 'test-project',
},
Expand All @@ -48,6 +52,7 @@ describe('8.10.0 Synthetics Package Policy migration', () => {
add_fields: {
fields: {
'monitor.fleet_managed': true,
config_id: '420754e9-40f2-486c-bc2e-265bafd735c5',
'monitor.project.name': 'test-project',
'monitor.project.id': 'test-project',
},
Expand All @@ -59,9 +64,9 @@ describe('8.10.0 Synthetics Package Policy migration', () => {
});

it('handles processors field for test now fields', () => {
const actual = migration(
const { document: actual } = migration(
getBrowserPolicy('', 'test-project', 'test-run-id', true),
{} as SavedObjectMigrationContext
{} as SavedObjectModelTransformationContext
);
expect(actual.attributes?.inputs[3]?.streams[0]?.vars?.processors?.value).toEqual(
JSON.stringify([
Expand All @@ -71,6 +76,7 @@ describe('8.10.0 Synthetics Package Policy migration', () => {
'monitor.fleet_managed': true,
test_run_id: 'test-run-id',
run_once: true,
config_id: '420754e9-40f2-486c-bc2e-265bafd735c5',
'monitor.project.name': 'test-project',
'monitor.project.id': 'test-project',
},
Expand All @@ -87,6 +93,7 @@ describe('8.10.0 Synthetics Package Policy migration', () => {
'monitor.fleet_managed': true,
test_run_id: 'test-run-id',
run_once: true,
config_id: '420754e9-40f2-486c-bc2e-265bafd735c5',
'monitor.project.name': 'test-project',
'monitor.project.id': 'test-project',
},
Expand Down

0 comments on commit 86da439

Please sign in to comment.