2020-04-30 02:26:59 -05:00
|
|
|
import { e2e } from '@grafana/e2e';
|
|
|
|
import { expect } from '../../../public/test/lib/common';
|
|
|
|
|
|
|
|
const PANEL_UNDER_TEST = 'Random walk series';
|
2021-05-05 02:09:57 -05:00
|
|
|
const flakyTimeout = 10000;
|
2020-04-30 02:26:59 -05:00
|
|
|
|
|
|
|
e2e.scenario({
|
|
|
|
describeName: 'Panel edit tests - queries',
|
|
|
|
itName: 'Testes various Panel edit queries scenarios',
|
|
|
|
addScenarioDataSource: false,
|
|
|
|
addScenarioDashBoard: false,
|
|
|
|
skipScenario: false,
|
|
|
|
scenario: () => {
|
2020-06-26 12:33:05 -05:00
|
|
|
e2e.flows.openDashboard({ uid: '5SdHCadmz' });
|
2020-04-30 02:26:59 -05:00
|
|
|
|
|
|
|
e2e.flows.openPanelMenuItem(e2e.flows.PanelMenuItems.Edit, PANEL_UNDER_TEST);
|
|
|
|
|
|
|
|
// New panel editor opens when navigating from Panel menu
|
|
|
|
e2e.components.PanelEditor.General.content().should('be.visible');
|
|
|
|
|
|
|
|
// Queries tab is rendered and open by default
|
|
|
|
e2e.components.PanelEditor.DataPane.content().should('be.visible');
|
|
|
|
|
|
|
|
// We expect row with refId A to exist and be visible
|
2021-01-20 00:59:48 -06:00
|
|
|
e2e.components.QueryEditorRows.rows().within((rows) => {
|
2020-04-30 02:26:59 -05:00
|
|
|
expect(rows.length).equals(1);
|
|
|
|
});
|
|
|
|
|
|
|
|
// Add query button should be visible and clicking on it should create a new row
|
2021-01-20 00:59:48 -06:00
|
|
|
e2e.components.QueryTab.addQuery().scrollIntoView().should('be.visible').click();
|
2020-04-30 02:26:59 -05:00
|
|
|
|
|
|
|
// We expect row with refId A and B to exist and be visible
|
2021-05-05 02:09:57 -05:00
|
|
|
e2e.components.QueryEditorRows.rows({ timeout: flakyTimeout }).should('have.length', 2);
|
2020-04-30 02:26:59 -05:00
|
|
|
|
|
|
|
// Remove refId A
|
2021-01-20 00:59:48 -06:00
|
|
|
e2e.components.QueryEditorRow.actionButton('Remove query').eq(0).should('be.visible').click();
|
2020-04-30 02:26:59 -05:00
|
|
|
|
|
|
|
// We expect row with refId B to exist and be visible
|
2021-05-05 02:09:57 -05:00
|
|
|
e2e.components.QueryEditorRows.rows({ timeout: flakyTimeout }).should('have.length', 1);
|
2020-04-30 02:26:59 -05:00
|
|
|
|
|
|
|
// Duplicate refId B
|
2021-01-20 00:59:48 -06:00
|
|
|
e2e.components.QueryEditorRow.actionButton('Duplicate query').eq(0).should('be.visible').click();
|
2020-04-30 02:26:59 -05:00
|
|
|
|
|
|
|
// We expect row with refId Band and A to exist and be visible
|
2021-01-20 00:59:48 -06:00
|
|
|
e2e.components.QueryEditorRows.rows().within((rows) => {
|
2020-04-30 02:26:59 -05:00
|
|
|
expect(rows.length).equals(2);
|
|
|
|
});
|
|
|
|
|
|
|
|
// Change to CSV Metric Values scenario for A
|
2020-10-14 05:08:35 -05:00
|
|
|
e2e.components.DataSource.TestData.QueryTab.scenarioSelectContainer()
|
|
|
|
.should('be.visible')
|
|
|
|
.within(() => {
|
2021-10-12 23:09:35 -05:00
|
|
|
e2e().get('input[id*="test-data-scenario-select-"]').eq(0).should('be.visible').click();
|
2020-10-14 05:08:35 -05:00
|
|
|
});
|
2020-04-30 02:26:59 -05:00
|
|
|
|
2021-07-14 08:04:23 -05:00
|
|
|
cy.contains('CSV Metric Values').scrollIntoView().should('be.visible').eq(0).click();
|
|
|
|
|
2020-04-30 02:26:59 -05:00
|
|
|
// Disable / enable row
|
2021-01-20 00:59:48 -06:00
|
|
|
expectInspectorResultAndClose((keys) => {
|
2020-04-30 02:26:59 -05:00
|
|
|
const length = keys.length;
|
2021-03-31 10:35:03 -05:00
|
|
|
const resultIds = new Set<string>([
|
|
|
|
keys[length - 2].innerText, // last 2
|
|
|
|
keys[length - 1].innerText, // last 2
|
|
|
|
]);
|
|
|
|
|
|
|
|
expect(resultIds.has('A:')).equals(true);
|
|
|
|
expect(resultIds.has('B:')).equals(true);
|
2020-04-30 02:26:59 -05:00
|
|
|
});
|
|
|
|
|
2020-09-14 01:54:42 -05:00
|
|
|
// Disable row with refId A
|
2021-01-20 00:59:48 -06:00
|
|
|
e2e.components.QueryEditorRow.actionButton('Disable/enable query').eq(1).should('be.visible').click();
|
2020-04-30 02:26:59 -05:00
|
|
|
|
2021-01-20 00:59:48 -06:00
|
|
|
expectInspectorResultAndClose((keys) => {
|
2020-04-30 02:26:59 -05:00
|
|
|
const length = keys.length;
|
2020-09-14 01:54:42 -05:00
|
|
|
expect(keys[length - 1].innerText).equals('B:');
|
2020-04-30 02:26:59 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
// Enable row with refId B
|
2021-01-20 00:59:48 -06:00
|
|
|
e2e.components.QueryEditorRow.actionButton('Disable/enable query').eq(1).should('be.visible').click();
|
2020-04-30 02:26:59 -05:00
|
|
|
|
2021-01-20 00:59:48 -06:00
|
|
|
expectInspectorResultAndClose((keys) => {
|
2020-04-30 02:26:59 -05:00
|
|
|
const length = keys.length;
|
2021-03-31 10:35:03 -05:00
|
|
|
const resultIds = new Set<string>([
|
|
|
|
keys[length - 2].innerText, // last 2
|
|
|
|
keys[length - 1].innerText, // last 2
|
|
|
|
]);
|
|
|
|
|
|
|
|
expect(resultIds.has('A:')).equals(true);
|
|
|
|
expect(resultIds.has('B:')).equals(true);
|
2020-04-30 02:26:59 -05:00
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
const expectInspectorResultAndClose = (expectCallBack: (keys: any[]) => void) => {
|
2021-01-20 00:59:48 -06:00
|
|
|
e2e.components.QueryTab.queryInspectorButton().should('be.visible').click();
|
2020-04-30 02:26:59 -05:00
|
|
|
|
2021-01-20 00:59:48 -06:00
|
|
|
e2e.components.PanelInspector.Query.refreshButton().should('be.visible').click();
|
2020-04-30 02:26:59 -05:00
|
|
|
|
2021-05-05 02:09:57 -05:00
|
|
|
e2e.components.PanelInspector.Query.jsonObjectKeys({ timeout: flakyTimeout })
|
2020-04-30 02:26:59 -05:00
|
|
|
.should('be.visible')
|
|
|
|
.within((keys: any) => expectCallBack(keys));
|
|
|
|
|
2021-01-20 00:59:48 -06:00
|
|
|
e2e.components.Drawer.General.close().should('be.visible').click();
|
2020-04-30 02:26:59 -05:00
|
|
|
};
|