2019-01-15 18:53:27 -05:00
|
|
|
/**
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one
|
|
|
|
* or more contributor license agreements. See the NOTICE file
|
|
|
|
* distributed with this work for additional information
|
|
|
|
* regarding copyright ownership. The ASF licenses this file
|
|
|
|
* to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance
|
|
|
|
* with the License. You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing,
|
|
|
|
* software distributed under the License is distributed on an
|
|
|
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
* KIND, either express or implied. See the License for the
|
|
|
|
* specific language governing permissions and limitations
|
|
|
|
* under the License.
|
|
|
|
*/
|
2018-10-11 17:13:04 -04:00
|
|
|
// ***********************************************
|
|
|
|
// Tests for links in the explore UI
|
|
|
|
// ***********************************************
|
|
|
|
|
2020-07-23 03:26:29 -04:00
|
|
|
import rison from 'rison';
|
|
|
|
import shortid from 'shortid';
|
2021-01-29 06:12:09 -05:00
|
|
|
import { interceptChart } from 'cypress/utils';
|
2018-10-11 17:13:04 -04:00
|
|
|
import { HEALTH_POP_FORM_DATA_DEFAULTS } from './visualizations/shared.helper';
|
|
|
|
|
2021-01-29 06:12:09 -05:00
|
|
|
const apiURL = (endpoint: string, queryObject: Record<string, unknown>) =>
|
2021-01-10 20:26:35 -05:00
|
|
|
`${endpoint}?q=${rison.encode(queryObject)}`;
|
2020-07-23 03:26:29 -04:00
|
|
|
|
2022-07-29 10:38:04 -04:00
|
|
|
describe('Test explore links', () => {
|
2018-10-11 17:13:04 -04:00
|
|
|
beforeEach(() => {
|
|
|
|
cy.login();
|
2021-01-29 06:12:09 -05:00
|
|
|
interceptChart({ legacy: true }).as('chartData');
|
2018-10-11 17:13:04 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
it('Open and close view query modal', () => {
|
|
|
|
cy.visitChartByName('Growth Rate');
|
2021-01-29 06:12:09 -05:00
|
|
|
cy.verifySliceSuccess({ waitAlias: '@chartData' });
|
2018-10-11 17:13:04 -04:00
|
|
|
|
2022-03-31 14:41:15 -04:00
|
|
|
cy.get('[aria-label="Menu actions trigger"]').click();
|
2020-05-07 17:18:10 -04:00
|
|
|
cy.get('span').contains('View query').parent().click();
|
2021-01-29 06:12:09 -05:00
|
|
|
cy.wait('@chartData').then(() => {
|
2018-10-11 17:13:04 -04:00
|
|
|
cy.get('code');
|
|
|
|
});
|
2020-11-02 02:04:53 -05:00
|
|
|
cy.get('.ant-modal-content').within(() => {
|
|
|
|
cy.get('button.ant-modal-close').first().click({ force: true });
|
2018-10-11 17:13:04 -04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('Test iframe link', () => {
|
|
|
|
cy.visitChartByName('Growth Rate');
|
2021-01-29 06:12:09 -05:00
|
|
|
cy.verifySliceSuccess({ waitAlias: '@chartData' });
|
2018-10-11 17:13:04 -04:00
|
|
|
|
2022-03-31 14:41:15 -04:00
|
|
|
cy.get('[aria-label="Menu actions trigger"]').click();
|
|
|
|
cy.get('div[title="Share"]').trigger('mouseover');
|
|
|
|
// need to use [id= syntax, otherwise error gets triggered because of special character in id
|
|
|
|
cy.get('[id="share_submenu$Menu"]').within(() => {
|
|
|
|
cy.contains('Embed code').parent().click();
|
|
|
|
});
|
2018-10-11 17:13:04 -04:00
|
|
|
cy.get('#embed-code-popover').within(() => {
|
|
|
|
cy.get('textarea[name=embedCode]').contains('iframe');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-07-23 03:26:29 -04:00
|
|
|
it('Test chart save as AND overwrite', () => {
|
2021-01-29 06:12:09 -05:00
|
|
|
interceptChart({ legacy: false }).as('tableChartData');
|
|
|
|
|
2018-10-11 17:13:04 -04:00
|
|
|
const formData = {
|
|
|
|
...HEALTH_POP_FORM_DATA_DEFAULTS,
|
|
|
|
viz_type: 'table',
|
|
|
|
metrics: ['sum__SP_POP_TOTL'],
|
|
|
|
groupby: ['country_name'],
|
|
|
|
};
|
2020-07-23 03:26:29 -04:00
|
|
|
const newChartName = `Test chart [${shortid.generate()}]`;
|
2018-10-11 17:13:04 -04:00
|
|
|
|
2022-06-30 15:06:51 -04:00
|
|
|
cy.visitChartByParams(formData);
|
2021-01-29 06:12:09 -05:00
|
|
|
cy.verifySliceSuccess({ waitAlias: '@tableChartData' });
|
2020-08-24 17:04:27 -04:00
|
|
|
cy.url().then(() => {
|
2020-10-27 16:01:45 -04:00
|
|
|
cy.get('[data-test="query-save-button"]').click();
|
|
|
|
cy.get('[data-test="saveas-radio"]').check();
|
|
|
|
cy.get('[data-test="new-chart-name"]').type(newChartName);
|
|
|
|
cy.get('[data-test="btn-modal-save"]').click();
|
2021-01-29 06:12:09 -05:00
|
|
|
cy.verifySliceSuccess({ waitAlias: '@tableChartData' });
|
2020-07-23 03:26:29 -04:00
|
|
|
cy.visitChartByName(newChartName);
|
2018-10-11 17:13:04 -04:00
|
|
|
|
2020-07-23 03:26:29 -04:00
|
|
|
// Overwriting!
|
2020-10-27 16:01:45 -04:00
|
|
|
cy.get('[data-test="query-save-button"]').click();
|
|
|
|
cy.get('[data-test="save-overwrite-radio"]').check();
|
|
|
|
cy.get('[data-test="btn-modal-save"]').click();
|
2021-01-29 06:12:09 -05:00
|
|
|
cy.verifySliceSuccess({ waitAlias: '@tableChartData' });
|
2020-07-23 03:26:29 -04:00
|
|
|
const query = {
|
|
|
|
filters: [
|
|
|
|
{
|
|
|
|
col: 'slice_name',
|
|
|
|
opr: 'eq',
|
|
|
|
value: newChartName,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
2021-01-29 06:12:09 -05:00
|
|
|
|
2020-07-23 03:26:29 -04:00
|
|
|
cy.request(apiURL('/api/v1/chart/', query)).then(response => {
|
|
|
|
expect(response.body.count).equals(1);
|
|
|
|
});
|
2022-09-12 10:48:36 -04:00
|
|
|
cy.deleteChartByName(newChartName, true);
|
2018-10-11 17:13:04 -04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('Test chart save as and add to new dashboard', () => {
|
2020-07-23 03:26:29 -04:00
|
|
|
const chartName = 'Growth Rate';
|
|
|
|
const newChartName = `${chartName} [${shortid.generate()}]`;
|
|
|
|
const dashboardTitle = `Test dashboard [${shortid.generate()}]`;
|
|
|
|
|
|
|
|
cy.visitChartByName(chartName);
|
2021-01-29 06:12:09 -05:00
|
|
|
cy.verifySliceSuccess({ waitAlias: '@chartData' });
|
2018-10-11 17:13:04 -04:00
|
|
|
|
2020-10-27 16:01:45 -04:00
|
|
|
cy.get('[data-test="query-save-button"]').click();
|
|
|
|
cy.get('[data-test="saveas-radio"]').check();
|
|
|
|
cy.get('[data-test="new-chart-name"]').click().clear().type(newChartName);
|
|
|
|
// Add a new option using the "CreatableSelect" feature
|
|
|
|
cy.get('[data-test="save-chart-modal-select-dashboard-form"]')
|
2021-09-27 11:14:58 -04:00
|
|
|
.find('input[aria-label="Select a dashboard"]')
|
|
|
|
.type(`${dashboardTitle}`, { force: true });
|
|
|
|
|
|
|
|
cy.get(`.ant-select-item[label="${dashboardTitle}"]`).click({
|
|
|
|
force: true,
|
|
|
|
});
|
2020-10-27 16:01:45 -04:00
|
|
|
|
|
|
|
cy.get('[data-test="btn-modal-save"]').click();
|
2021-01-29 06:12:09 -05:00
|
|
|
cy.verifySliceSuccess({ waitAlias: '@chartData' });
|
2020-07-23 03:26:29 -04:00
|
|
|
let query = {
|
|
|
|
filters: [
|
|
|
|
{
|
|
|
|
col: 'dashboard_title',
|
|
|
|
opr: 'eq',
|
|
|
|
value: dashboardTitle,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
|
|
|
cy.request(apiURL('/api/v1/dashboard/', query)).then(response => {
|
|
|
|
expect(response.body.count).equals(1);
|
2018-10-11 17:13:04 -04:00
|
|
|
});
|
|
|
|
|
2020-07-23 03:26:29 -04:00
|
|
|
cy.visitChartByName(newChartName);
|
2021-01-29 06:12:09 -05:00
|
|
|
cy.verifySliceSuccess({ waitAlias: '@chartData' });
|
2018-10-11 17:13:04 -04:00
|
|
|
|
2020-10-27 16:01:45 -04:00
|
|
|
cy.get('[data-test="query-save-button"]').click();
|
|
|
|
cy.get('[data-test="save-overwrite-radio"]').check();
|
|
|
|
cy.get('[data-test="new-chart-name"]').click().clear().type(newChartName);
|
|
|
|
// This time around, typing the same dashboard name
|
|
|
|
// will select the existing one
|
|
|
|
cy.get('[data-test="save-chart-modal-select-dashboard-form"]')
|
2021-09-27 11:14:58 -04:00
|
|
|
.find('input[aria-label="Select a dashboard"]')
|
|
|
|
.type(`${dashboardTitle}{enter}`, { force: true });
|
|
|
|
|
|
|
|
cy.get(`.ant-select-item[label="${dashboardTitle}"]`).click({
|
|
|
|
force: true,
|
|
|
|
});
|
2020-10-27 16:01:45 -04:00
|
|
|
|
|
|
|
cy.get('[data-test="btn-modal-save"]').click();
|
2021-01-29 06:12:09 -05:00
|
|
|
cy.verifySliceSuccess({ waitAlias: '@chartData' });
|
2020-07-23 03:26:29 -04:00
|
|
|
query = {
|
|
|
|
filters: [
|
|
|
|
{
|
|
|
|
col: 'slice_name',
|
|
|
|
opr: 'eq',
|
|
|
|
value: chartName,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
|
|
|
cy.request(apiURL('/api/v1/chart/', query)).then(response => {
|
|
|
|
expect(response.body.count).equals(1);
|
|
|
|
});
|
|
|
|
query = {
|
|
|
|
filters: [
|
|
|
|
{
|
|
|
|
col: 'dashboard_title',
|
|
|
|
opr: 'eq',
|
|
|
|
value: dashboardTitle,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
|
|
|
cy.request(apiURL('/api/v1/dashboard/', query)).then(response => {
|
|
|
|
expect(response.body.count).equals(1);
|
2018-10-11 17:13:04 -04:00
|
|
|
});
|
2022-09-12 10:48:36 -04:00
|
|
|
cy.deleteDashboardByName(dashboardTitle, true);
|
2018-10-11 17:13:04 -04:00
|
|
|
});
|
|
|
|
});
|