mirror of
https://github.com/grafana/grafana.git
synced 2024-12-24 08:00:08 -06:00
0dcdfc261b
* chore(monaco): bump monaco-editor to latest version * feat(codeeditor): use esm to load monaco editor * revert(monaco): put back previous version * feat(monaco): setup MonacoEnvironment when bootstrapping app * feat(monaco): load monaco languages from registry as workers * feat(webpack): clean up warnings, remove need to copy monaco into lib * fix(plugins): wip - remove amd loader workaround in systemjs hooks * chore(azure): clean up so QueryField passes typecheck * test(jest): update config to fix failing tests due to missing monaco-editor * test(jest): update config to work with monaco-editor and kusto * test(jest): prevent message eventlistener in nodeGraph/layout.worker tripping up monaco tests * test(plugins): wip - remove amd related tests from systemjs hooks * test(alerting): prefer clearAllMocks to prevent monaco editor failing due to missing matchMedia * test(parca): fix failing test due to undefined backendSrv * chore: move monacoEnv to app/core * test: increase testing-lib timeout to 2secs, fix parca test to assert dom element * feat(plugins): share kusto via systemjs * test(e2e): increase timeout for checking monaco editor in exemplars spec * test(e2e): assert monaco has loaded by checking the spinner is gone and window.monaco exists * test(e2e): check for monaco editor textarea * test(e2e): check monaco editor is loaded before assertions * test(e2e): add waitForMonacoToLoad util to reduce duplication * test(e2e): fix failing mysql spec * chore(jest): add comment to setupTests explaining need to incresae default timeout * chore(nodegraph): improve comment in layout.worker.utils to better explain the need for file
89 lines
3.0 KiB
TypeScript
89 lines
3.0 KiB
TypeScript
import { e2e } from '../utils';
|
|
import { waitForMonacoToLoad } from '../utils/support/monaco';
|
|
|
|
const dataSourceName = 'LokiEditor';
|
|
const addDataSource = () => {
|
|
e2e.flows.addDataSource({
|
|
type: 'Loki',
|
|
expectedAlertMessage: 'Unable to connect with Loki. Please check the server logs for more details.',
|
|
name: dataSourceName,
|
|
form: () => {
|
|
cy.get('#connection-url').type('http://loki-url:3100');
|
|
},
|
|
});
|
|
};
|
|
|
|
describe('Loki Query Editor', () => {
|
|
beforeEach(() => {
|
|
e2e.flows.login(Cypress.env('USERNAME'), Cypress.env('PASSWORD'));
|
|
});
|
|
|
|
afterEach(() => {
|
|
e2e.flows.revertAllChanges();
|
|
});
|
|
|
|
it('Autocomplete features should work as expected.', () => {
|
|
addDataSource();
|
|
|
|
cy.intercept(/labels?/, (req) => {
|
|
req.reply({ status: 'success', data: ['instance', 'job', 'source'] });
|
|
});
|
|
|
|
cy.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();
|
|
cy.contains(dataSourceName).scrollIntoView().should('be.visible').click();
|
|
|
|
e2e.components.RadioButton.container().filter(':contains("Code")').click();
|
|
|
|
waitForMonacoToLoad();
|
|
|
|
// adds closing braces around empty value
|
|
e2e.components.QueryField.container().type('time(');
|
|
cy.get('.monaco-editor textarea:first').should(($el) => {
|
|
expect($el.val()).to.eq('time()');
|
|
});
|
|
|
|
// removes closing brace when opening brace is removed
|
|
e2e.components.QueryField.container().type('{selectall}{backspace}avg_over_time({backspace}');
|
|
cy.get('.monaco-editor textarea:first').should(($el) => {
|
|
expect($el.val()).to.eq('avg_over_time');
|
|
});
|
|
|
|
// keeps closing brace when opening brace is removed and inner values exist
|
|
e2e.components.QueryField.container().type(
|
|
'{selectall}{backspace}time(test{leftArrow}{leftArrow}{leftArrow}{leftArrow}{backspace}'
|
|
);
|
|
cy.get('.monaco-editor textarea:first').should(($el) => {
|
|
expect($el.val()).to.eq('timetest)');
|
|
});
|
|
|
|
// overrides an automatically inserted brace
|
|
e2e.components.QueryField.container().type('{selectall}{backspace}time()');
|
|
cy.get('.monaco-editor textarea:first').should(($el) => {
|
|
expect($el.val()).to.eq('time()');
|
|
});
|
|
|
|
// does not override manually inserted braces
|
|
e2e.components.QueryField.container().type('{selectall}{backspace}))');
|
|
cy.get('.monaco-editor textarea:first').should(($el) => {
|
|
expect($el.val()).to.eq('))');
|
|
});
|
|
|
|
/** Runner plugin */
|
|
|
|
// Should execute the query when enter with shift is pressed
|
|
e2e.components.QueryField.container().type('{selectall}{backspace}{shift+enter}');
|
|
cy.get('[data-testid="explore-no-data"]').should('be.visible');
|
|
|
|
/** Suggestions plugin */
|
|
e2e.components.QueryField.container().type('{selectall}av');
|
|
cy.contains('avg').should('be.visible');
|
|
cy.contains('avg_over_time').should('be.visible');
|
|
});
|
|
});
|