@ -68,14 +68,14 @@ describe('StandardAnnotationQueryEditor', () => {
) ;
} ) ;
it ( 'v2 dashboard - should preserve o ptions field when changing target' , ( ) = > {
// Setup with annotation that has o ptions
it ( 'v2 dashboard - should preserve legacyO ptions field when changing target' , ( ) = > {
// Setup with annotation that has legacyO ptions
const mockOnChange = jest . fn ( ) ;
const { props } = setup ( {
annotation : {
name : 'annotationWithOptions' ,
name : 'annotationWithLegacy Options' ,
target : { refId : 'refId1' } ,
o ptions: {
legacyO ptions: {
expr : 'rate(http_requests_total[5m])' ,
queryType : 'range' ,
} ,
@ -98,11 +98,11 @@ describe('StandardAnnotationQueryEditor', () => {
// Simulate changing the target
componentInstance . onChange ( { refId : 'refId2' , newField : 'value' } ) ;
// Check that o ptions are preserved
// Check that legacyO ptions are preserved
expect ( mockOnChange ) . toHaveBeenCalledWith (
expect . objectContaining ( {
target : { refId : 'refId2' , newField : 'value' } ,
o ptions: {
legacyO ptions: {
expr : 'rate(http_requests_total[5m])' ,
queryType : 'range' ,
} ,
@ -110,13 +110,13 @@ describe('StandardAnnotationQueryEditor', () => {
) ;
} ) ;
it ( 'should preserve o ptions field when using onAnnotationChange' , ( ) = > {
// Setup with annotation that has o ptions
it ( 'should preserve legacyO ptions field when using onAnnotationChange' , ( ) = > {
// Setup with annotation that has legacyO ptions
const mockOnChange = jest . fn ( ) ;
const { props } = setup ( {
annotation : {
name : 'annotationWithOptions' ,
o ptions: {
name : 'annotationWithLegacy Options' ,
legacyO ptions: {
expr : 'rate(http_requests_total[5m])' ,
queryType : 'range' ,
} ,
@ -142,12 +142,12 @@ describe('StandardAnnotationQueryEditor', () => {
iconColor : 'red' ,
} ) ;
// Check that o ptions are preserved
// Check that legacyO ptions are preserved
expect ( mockOnChange ) . toHaveBeenCalledWith (
expect . objectContaining ( {
name : 'newName' ,
iconColor : 'red' ,
o ptions: {
legacyO ptions: {
expr : 'rate(http_requests_total[5m])' ,
queryType : 'range' ,
} ,
@ -187,17 +187,17 @@ describe('StandardAnnotationQueryEditor', () => {
) ;
} ) ;
it ( 'should propagate o ptions to root level for v2 dashboards' , ( ) = > {
it ( 'should propagate legacyO ptions to root level for v2 dashboards' , ( ) = > {
const { props } = setup ( {
annotation : {
name : 'v2annotationWithOptions' ,
name : 'v2annotationWithLegacy Options' ,
query : {
kind : 'prometheus' ,
spec : {
refId : 'A' ,
} ,
} ,
o ptions: {
legacyO ptions: {
expr : 'rate(http_requests_total[5m])' ,
legendFormat : '{{method}} {{endpoint}}' ,
} ,
@ -210,13 +210,13 @@ describe('StandardAnnotationQueryEditor', () => {
} as unknown as DataSourceApi ,
} ) ;
// Check that o ptions are propagated to root level for the editor
// Check that legacyO ptions are propagated to root level for the editor
expect ( props . datasource ? . annotations ? . QueryEditor ) . toHaveBeenCalledWith (
expect . objectContaining ( {
annotation : expect.objectContaining ( {
name : 'v2annotationWithOptions' ,
name : 'v2annotationWithLegacy Options' ,
query : expect.anything ( ) ,
o ptions : expect.anything ( ) ,
legacyO ptions : expect.anything ( ) ,
expr : 'rate(http_requests_total[5m])' ,
legendFormat : '{{method}} {{endpoint}}' ,
} ) ,
@ -235,7 +235,7 @@ describe('StandardAnnotationQueryEditor', () => {
type : 'prometheus' ,
uid : 'abc123' ,
} ,
// v1 dashboards don't have o ptions field
// v1 dashboards don't have legacyO ptions field
enable : true ,
iconColor : 'red' ,
hide : false ,