mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* feat(loki-monaco-editor): update tests * chore(loki): use unified datasource mock function in tests * chore: enable monaco feature flag in tests * feat(loki-monaco-editor): add test case for disabled feature * feat(loki-monaco-editor): enable by default * Revert "feat(loki-monaco-editor): enable by default" This reverts commit 08904f94a707a4fa32aa1e7f3f0de377575a7636. * feat(loki-monaco-editor): enable from registry * feat(loki-monaco-editor): make feature flag frontend only
57 lines
2.0 KiB
TypeScript
57 lines
2.0 KiB
TypeScript
import { e2e } from '@grafana/e2e';
|
|
|
|
const dataSourceName = 'LokiEditor';
|
|
const addDataSource = () => {
|
|
e2e.flows.addDataSource({
|
|
type: 'Loki',
|
|
expectedAlertMessage:
|
|
'Unable to fetch labels from Loki (Failed to call resource), please check the server logs for more details',
|
|
name: dataSourceName,
|
|
form: () => {
|
|
e2e.components.DataSource.DataSourceHttpSettings.urlInput().type('http://loki-url:3100');
|
|
},
|
|
});
|
|
};
|
|
|
|
e2e.scenario({
|
|
describeName: 'Loki Query Editor',
|
|
itName: 'Autocomplete features should work as expected.',
|
|
addScenarioDataSource: false,
|
|
addScenarioDashBoard: false,
|
|
skipScenario: false,
|
|
scenario: () => {
|
|
addDataSource();
|
|
|
|
e2e().intercept(/labels?/, (req) => {
|
|
req.reply({ status: 'success', data: ['instance', 'job', 'source'] });
|
|
});
|
|
|
|
e2e().intercept(/series?/, (req) => {
|
|
req.reply({ status: 'success', data: [{ instance: 'instance1' }] });
|
|
});
|
|
|
|
// Go to Explore and choose Loki data source
|
|
e2e.pages.Explore.visit();
|
|
e2e.components.DataSourcePicker.container().should('be.visible').click();
|
|
e2e().contains(dataSourceName).scrollIntoView().should('be.visible').click();
|
|
|
|
cy.contains('label', 'Code').click();
|
|
|
|
// we need to wait for the query-field being lazy-loaded, in two steps:
|
|
// it is a two-step process:
|
|
// 1. first we wait for the text 'Loading...' to appear
|
|
// 1. then we wait for the text 'Loading...' to disappear
|
|
const monacoLoadingText = 'Loading...';
|
|
const queryText = `rate(http_requests_total{job="grafana"}[5m])`;
|
|
e2e.components.QueryField.container().should('be.visible').should('have.text', monacoLoadingText);
|
|
e2e.components.QueryField.container().should('be.visible').should('not.have.text', monacoLoadingText);
|
|
e2e.components.QueryField.container().type(queryText, { parseSpecialCharSequences: false }).type('{backspace}');
|
|
|
|
cy.contains(queryText.slice(0, -1)).should('be.visible');
|
|
|
|
e2e.components.QueryField.container().type(e2e.typings.undo());
|
|
|
|
cy.contains(queryText).should('be.visible');
|
|
},
|
|
});
|