mirror of
https://github.com/grafana/grafana.git
synced 2024-12-01 21:19:28 -06:00
639bf3036d
* update selectors for prom * add selector to switch component, needs id instead of testid * add testid and ids to Prom settings * add e2e tests for prom config * add config to editor test * export select function * start query editor spec * clean up describe * add selectors for general query editor * add selectors to components in options in best locations * wrap header switch in id because component doesn't accept testid nor id * add id to wrap legend components in one selector * update selector in shared folder component, note to change in shared library * update selector in shared folder component, note to change in shared library * add notes for selectors in shared folder * add tests and file for query editor * add selectors for metrics browser in code editor * add selector to component to open metrics browser * add selectors to components within the metrics browser * add tests for metrics browser and stub resource calls * add selectors to query builder components * add e2e tests for query builder * generic query builder test with hints * add selectors for more code editor parts * add test for code and update selector * fix tests with selector * remove shared folder changes and use data-testid where possible * remove unused import * share getResources * create variable query editor selectors * add selectors to the variable query editor * add e2e tests for the Prometheus variable query editor * fix test function * refactor add data source method * add annotation selectors * add selectors to annotation components * add annotation e2e tests * commit for yarn i18n:extract error in drone
76 lines
2.6 KiB
TypeScript
76 lines
2.6 KiB
TypeScript
import { selectors } from '@grafana/e2e-selectors';
|
|
|
|
import { e2e } from '../utils';
|
|
import { addDashboard } from '../utils/flows';
|
|
|
|
import { createPromDS, getResources } from './helpers/prometheus-helpers';
|
|
|
|
const DATASOURCE_ID = 'Prometheus';
|
|
|
|
const DATASOURCE_NAME = 'aprometheusAnnotationDS';
|
|
|
|
/**
|
|
* Click dashboard settings and then the variables tab
|
|
*
|
|
*/
|
|
function navigateToAnnotations() {
|
|
e2e.components.PageToolbar.item('Dashboard settings').click();
|
|
e2e.components.Tab.title('Annotations').click();
|
|
}
|
|
|
|
function addPrometheusAnnotation(annotationName: string) {
|
|
e2e.pages.Dashboard.Settings.Annotations.List.addAnnotationCTAV2().click();
|
|
getResources();
|
|
e2e.pages.Dashboard.Settings.Annotations.Settings.name().clear().type(annotationName);
|
|
e2e.components.DataSourcePicker.container().should('be.visible').click();
|
|
cy.contains(DATASOURCE_NAME).scrollIntoView().should('be.visible').click();
|
|
}
|
|
|
|
describe('Prometheus annotations', () => {
|
|
beforeEach(() => {
|
|
createPromDS(DATASOURCE_ID, DATASOURCE_NAME);
|
|
});
|
|
|
|
it('should navigate to variable query editor', () => {
|
|
const annotationName = 'promAnnotation';
|
|
addDashboard();
|
|
navigateToAnnotations();
|
|
addPrometheusAnnotation(annotationName);
|
|
|
|
e2e.components.DataSource.Prometheus.queryEditor.code.metricsBrowser
|
|
.openButton()
|
|
.contains('Metrics browser')
|
|
.click();
|
|
|
|
e2e.components.DataSource.Prometheus.queryEditor.code.metricsBrowser.selectMetric().should('exist').type('met');
|
|
|
|
e2e.components.DataSource.Prometheus.queryEditor.code.metricsBrowser
|
|
.metricList()
|
|
.should('exist')
|
|
.contains('metric1')
|
|
.click();
|
|
|
|
e2e.components.DataSource.Prometheus.queryEditor.code.metricsBrowser.useQuery().should('exist').click();
|
|
|
|
e2e.components.DataSource.Prometheus.queryEditor.code.queryField().should('exist').contains('metric1');
|
|
|
|
// check for other parts of the annotations
|
|
// min step
|
|
cy.get(`#${selectors.components.DataSource.Prometheus.annotations.minStep}`);
|
|
|
|
// title
|
|
e2e.components.DataSource.Prometheus.annotations.title().scrollIntoView().should('exist');
|
|
// tags
|
|
e2e.components.DataSource.Prometheus.annotations.tags().scrollIntoView().should('exist');
|
|
// text
|
|
e2e.components.DataSource.Prometheus.annotations.text().scrollIntoView().should('exist');
|
|
// series value as timestamp
|
|
e2e.components.DataSource.Prometheus.annotations.seriesValueAsTimestamp().scrollIntoView().should('exist');
|
|
|
|
e2e.pages.Dashboard.Settings.Annotations.NewAnnotation.previewInDashboard().click();
|
|
|
|
// check that annotation exists
|
|
cy.get('body').contains(annotationName);
|
|
});
|
|
});
|