@ -700,6 +700,78 @@ describe('logSeriesToLogsModel', () => {
expect ( logSeriesToLogsModel ( logSeries ) ) . toMatchObject ( metaData ) ;
} ) ;
it ( 'should return correct metaData when some data frames have empty fields' , ( ) = > {
const logSeries : DataFrame [ ] = [
toDataFrame ( {
fields : [
{
name : 'ts' ,
type : FieldType . time ,
values : [ '1970-01-01T00:00:01Z' , '1970-02-01T00:00:01Z' , '1970-03-01T00:00:01Z' ] ,
} ,
{
name : 'line' ,
type : FieldType . string ,
values : [ 'WARN boooo 0' , 'WARN boooo 1' , 'WARN boooo 2' ] ,
labels : {
foo : 'bar' ,
level : 'dbug' ,
} ,
} ,
{
name : 'id' ,
type : FieldType . string ,
values : [ '0' , '1' , '2' ] ,
} ,
] ,
refId : 'A' ,
meta : {
searchWords : [ 'test' ] ,
limit : 1000 ,
stats : [ { displayName : 'Summary: total bytes processed' , value : 97048 , unit : 'decbytes' } ] ,
custom : { lokiQueryStatKey : 'Summary: total bytes processed' } ,
preferredVisualisationType : 'logs' ,
} ,
} ) ,
toDataFrame ( {
fields : [ ] ,
length : 0 ,
refId : 'B' ,
meta : {
searchWords : [ 'test' ] ,
limit : 1000 ,
stats : [ { displayName : 'Summary: total bytes processed' , value : 97048 , unit : 'decbytes' } ] ,
custom : { lokiQueryStatKey : 'Summary: total bytes processed' } ,
preferredVisualisationType : 'logs' ,
} ,
} ) ,
] ;
const logsModel = dataFrameToLogsModel ( logSeries , 0 , 'utc' ) ;
expect ( logsModel . meta ) . toMatchObject ( [
{ kind : 2 , label : 'Common labels' , value : { foo : 'bar' , level : 'dbug' } } ,
{ kind : 1 , label : 'Limit' , value : '2000 (3 returned)' } ,
{ kind : 1 , label : 'Total bytes processed' , value : '194 kB' } ,
] ) ;
expect ( logsModel . rows ) . toHaveLength ( 3 ) ;
expect ( logsModel . rows ) . toMatchObject ( [
{
entry : 'WARN boooo 0' ,
labels : { foo : 'bar' } ,
logLevel : LogLevel.debug ,
} ,
{
entry : 'WARN boooo 1' ,
labels : { foo : 'bar' } ,
logLevel : LogLevel.debug ,
} ,
{
entry : 'WARN boooo 2' ,
labels : { foo : 'bar' } ,
logLevel : LogLevel.debug ,
} ,
] ) ;
} ) ;
} ) ;
describe ( 'getSeriesProperties()' , ( ) = > {