Skip to content

Commit

Permalink
test that filter migrations are applied to lens migration map
Browse files Browse the repository at this point in the history
  • Loading branch information
drewdaemon committed Jan 5, 2022
1 parent 97494a7 commit e63a5d7
Showing 1 changed file with 52 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1511,4 +1511,56 @@ describe('Lens migrations', () => {
expect(result.attributes.state.filters).toEqual(expectedFilters);
});
});

test('should properly apply a filter migration within a lens visualization', () => {
const migrationVersion = 'some-version';

const lensVisualizationDoc = {
attributes: {
state: {
filters: [
{
filter: 1,
migrated: false,
},
{
filter: 2,
migrated: false,
},
],
},
},
};

const migrationFunctionsObject = getAllMigrations({
[migrationVersion]: (filterState) => {
return {
...filterState,
migrated: true,
};
},
});

const migratedLensDoc = migrationFunctionsObject[migrationVersion](
lensVisualizationDoc as SavedObjectUnsanitizedDoc,
{} as SavedObjectMigrationContext
);

expect(migratedLensDoc).toEqual({
attributes: {
state: {
filters: [
{
filter: 1,
migrated: true,
},
{
filter: 2,
migrated: true,
},
],
},
},
});
});
});

0 comments on commit e63a5d7

Please sign in to comment.