2023-09-08 16:51:59 +01:00
|
|
|
import { e2e } from '../utils';
|
2022-04-22 14:33:13 +01:00
|
|
|
|
2021-05-05 09:09:57 +02:00
|
|
|
const flakyTimeout = 10000;
|
2020-04-30 09:26:59 +02:00
|
|
|
|
2023-09-13 13:24:20 +01:00
|
|
|
describe('Panel edit tests - queries', () => {
|
|
|
|
|
beforeEach(() => {
|
2023-09-27 11:33:00 +01:00
|
|
|
e2e.flows.login(Cypress.env('USERNAME'), Cypress.env('PASSWORD'));
|
2023-09-13 13:24:20 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('Tests various Panel edit queries scenarios', () => {
|
2021-10-28 09:56:21 +02:00
|
|
|
e2e.flows.openDashboard({ uid: '5SdHCadmz', queryParams: { editPanel: 3 } });
|
2020-04-30 09:26:59 +02:00
|
|
|
|
|
|
|
|
// 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 07:59:48 +01:00
|
|
|
e2e.components.QueryEditorRows.rows().within((rows) => {
|
2020-04-30 09:26:59 +02:00
|
|
|
expect(rows.length).equals(1);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Add query button should be visible and clicking on it should create a new row
|
2021-01-20 07:59:48 +01:00
|
|
|
e2e.components.QueryTab.addQuery().scrollIntoView().should('be.visible').click();
|
2020-04-30 09:26:59 +02:00
|
|
|
|
|
|
|
|
// We expect row with refId A and B to exist and be visible
|
2021-05-05 09:09:57 +02:00
|
|
|
e2e.components.QueryEditorRows.rows({ timeout: flakyTimeout }).should('have.length', 2);
|
2020-04-30 09:26:59 +02:00
|
|
|
|
|
|
|
|
// Remove refId A
|
2023-01-04 14:59:53 +00:00
|
|
|
e2e.components.QueryEditorRow.actionButton('Remove query').eq(0).scrollIntoView();
|
2021-01-20 07:59:48 +01:00
|
|
|
e2e.components.QueryEditorRow.actionButton('Remove query').eq(0).should('be.visible').click();
|
2020-04-30 09:26:59 +02:00
|
|
|
|
|
|
|
|
// We expect row with refId B to exist and be visible
|
2021-05-05 09:09:57 +02:00
|
|
|
e2e.components.QueryEditorRows.rows({ timeout: flakyTimeout }).should('have.length', 1);
|
2020-04-30 09:26:59 +02:00
|
|
|
|
|
|
|
|
// Duplicate refId B
|
2021-01-20 07:59:48 +01:00
|
|
|
e2e.components.QueryEditorRow.actionButton('Duplicate query').eq(0).should('be.visible').click();
|
2020-04-30 09:26:59 +02:00
|
|
|
|
|
|
|
|
// We expect row with refId Band and A to exist and be visible
|
2023-09-08 16:51:59 +01:00
|
|
|
e2e.components.QueryEditorRows.rows().should('have.length', 2);
|
2020-04-30 09:26:59 +02:00
|
|
|
|
|
|
|
|
// Change to CSV Metric Values scenario for A
|
2020-10-14 13:08:35 +03:00
|
|
|
e2e.components.DataSource.TestData.QueryTab.scenarioSelectContainer()
|
2023-09-08 16:51:59 +01:00
|
|
|
.first()
|
2020-10-14 13:08:35 +03:00
|
|
|
.should('be.visible')
|
|
|
|
|
.within(() => {
|
2023-09-11 11:20:54 +01:00
|
|
|
cy.get('input[id*="test-data-scenario-select-"]').eq(0).should('be.visible').click();
|
2020-10-14 13:08:35 +03:00
|
|
|
});
|
2020-04-30 09:26:59 +02:00
|
|
|
|
2021-07-14 14:04:23 +01:00
|
|
|
cy.contains('CSV Metric Values').scrollIntoView().should('be.visible').eq(0).click();
|
|
|
|
|
|
2020-04-30 09:26:59 +02:00
|
|
|
// Disable / enable row
|
2021-01-20 07:59:48 +01:00
|
|
|
expectInspectorResultAndClose((keys) => {
|
2020-04-30 09:26:59 +02:00
|
|
|
const length = keys.length;
|
2021-03-31 08:35:03 -07: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 09:26:59 +02:00
|
|
|
});
|
|
|
|
|
|
2020-09-14 08:54:42 +02:00
|
|
|
// Disable row with refId A
|
2023-05-10 11:57:08 +01:00
|
|
|
e2e.components.QueryEditorRow.actionButton('Disable query').eq(1).should('be.visible').click();
|
2020-04-30 09:26:59 +02:00
|
|
|
|
2021-01-20 07:59:48 +01:00
|
|
|
expectInspectorResultAndClose((keys) => {
|
2020-04-30 09:26:59 +02:00
|
|
|
const length = keys.length;
|
2020-09-14 08:54:42 +02:00
|
|
|
expect(keys[length - 1].innerText).equals('B:');
|
2020-04-30 09:26:59 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Enable row with refId B
|
2023-05-10 11:57:08 +01:00
|
|
|
e2e.components.QueryEditorRow.actionButton('Disable query').eq(1).should('be.visible').click();
|
2020-04-30 09:26:59 +02:00
|
|
|
|
2021-01-20 07:59:48 +01:00
|
|
|
expectInspectorResultAndClose((keys) => {
|
2020-04-30 09:26:59 +02:00
|
|
|
const length = keys.length;
|
2021-03-31 08:35:03 -07: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 09:26:59 +02:00
|
|
|
});
|
2023-09-13 13:24:20 +01:00
|
|
|
});
|
2020-04-30 09:26:59 +02:00
|
|
|
});
|
|
|
|
|
|
2023-03-14 09:51:44 +00:00
|
|
|
const expectInspectorResultAndClose = (expectCallBack: (keys: JQuery<HTMLElement>) => void) => {
|
2021-01-20 07:59:48 +01:00
|
|
|
e2e.components.QueryTab.queryInspectorButton().should('be.visible').click();
|
2020-04-30 09:26:59 +02:00
|
|
|
|
2021-01-20 07:59:48 +01:00
|
|
|
e2e.components.PanelInspector.Query.refreshButton().should('be.visible').click();
|
2020-04-30 09:26:59 +02:00
|
|
|
|
2021-05-05 09:09:57 +02:00
|
|
|
e2e.components.PanelInspector.Query.jsonObjectKeys({ timeout: flakyTimeout })
|
2020-04-30 09:26:59 +02:00
|
|
|
.should('be.visible')
|
2023-09-08 16:51:59 +01:00
|
|
|
.should((keys) => expectCallBack(keys));
|
2020-04-30 09:26:59 +02:00
|
|
|
|
2021-01-20 07:59:48 +01:00
|
|
|
e2e.components.Drawer.General.close().should('be.visible').click();
|
2020-04-30 09:26:59 +02:00
|
|
|
};
|