mirror of https://github.com/grafana/grafana
Loki Monaco Editor: grab operator documentation from the operations module (#57525)
* feat(loki-operations): add method to resolve operation docs * feat(loki-operations): read operation and strip markdown links * feat(loki-monaco-editor): read parser docs from operations * feat(loki-monaco-editor): grab docs for more operations * Chore: update completions test * Chore: add tests for the operations module * Chore: fix typo Co-authored-by: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com> * Chore: fix typo Co-authored-by: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com> Co-authored-by: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com>pull/57684/head
parent
e81ce1dae7
commit
c8689fd591
@ -0,0 +1,50 @@ |
||||
import { explainOperator, getOperationDefinitions } from './operations'; |
||||
import { LokiOperationId } from './types'; |
||||
|
||||
const undocumentedOperationsIds: string[] = [ |
||||
LokiOperationId.Addition, |
||||
LokiOperationId.Subtraction, |
||||
LokiOperationId.MultiplyBy, |
||||
LokiOperationId.DivideBy, |
||||
LokiOperationId.Modulo, |
||||
LokiOperationId.Exponent, |
||||
LokiOperationId.NestedQuery, |
||||
LokiOperationId.EqualTo, |
||||
LokiOperationId.NotEqualTo, |
||||
LokiOperationId.GreaterThan, |
||||
LokiOperationId.LessThan, |
||||
LokiOperationId.GreaterOrEqual, |
||||
LokiOperationId.LessOrEqual, |
||||
]; |
||||
|
||||
describe('explainOperator', () => { |
||||
let operations = []; |
||||
let undocumentedOperations = []; |
||||
|
||||
const definitions = getOperationDefinitions(); |
||||
for (const definition of definitions) { |
||||
if (!undocumentedOperationsIds.includes(definition.id)) { |
||||
operations.push(definition.id); |
||||
} else { |
||||
undocumentedOperations.push(definition.id); |
||||
} |
||||
} |
||||
|
||||
test('Resolves operation definitions', () => { |
||||
expect(definitions.length).toBeGreaterThan(0); |
||||
}); |
||||
|
||||
test.each(operations)('Returns docs for the %s operation', (operation) => { |
||||
const explain = explainOperator(operation); |
||||
|
||||
expect(explain).toBeDefined(); |
||||
expect(explain).not.toBe(''); |
||||
}); |
||||
|
||||
test.each(undocumentedOperations)('Returns empty docs for the %s operation', (operation) => { |
||||
const explain = explainOperator(operation); |
||||
|
||||
expect(explain).toBeDefined(); |
||||
expect(explain).toBe(''); |
||||
}); |
||||
}); |
Loading…
Reference in new issue