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';
|
2018-10-11 17:13:04 -04:00
|
|
|
import { HEALTH_POP_FORM_DATA_DEFAULTS } from './visualizations/shared.helper';
|
|
|
|
|
2021-01-10 20:26:35 -05:00
|
|
|
const apiURL = (endpoint, queryObject) =>
|
|
|
|
`${endpoint}?q=${rison.encode(queryObject)}`;
|
2020-07-23 03:26:29 -04:00
|
|
|
|
2018-10-11 17:13:04 -04:00
|
|
|
describe('Test explore links', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
cy.login();
|
|
|
|
cy.server();
|
2019-04-03 15:11:08 -04:00
|
|
|
cy.route('GET', '/superset/explore_json/**').as('getJson');
|
|
|
|
cy.route('POST', '/superset/explore_json/**').as('postJson');
|
2018-10-11 17:13:04 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
it('Open and close view query modal', () => {
|
|
|
|
cy.visitChartByName('Growth Rate');
|
Fix control validation handling (#7231)
Fixes a series of unexpected things around control validation.
* when a chart opens in a state where a control is invalid, it still
runs the query, and sometimes gets stuck in what appears to be a 'running'
state. After this change, no query is run, and a warning is displayed
in the chart panel body, just like any other error would
* validation used to be done in the <Control> component and alter the
redux store as it went. Clearly this is not the right approach, now
validation occurs on loading the initial redux state, as well as in
the reducer when controls are changed
* currently, when going from a invalid control state to a valid one
(user addresses what is needed), it auto-triggers a query which can be
unexpected. After this change, the error message disappears, and the
"Run Query" overlay gets displayed
* when changing viz type, it's common to get new validation
errors, and currently when that occurs it will still go ahead and run
a query with invalid inputs, which often results in errors
that are not well handled, since much of the logic
assumes control-validated input.
* prettier control validation messages
(cherry picked from commit a3212eba5df95bca834d8d6d98c11d522d9172f3)
2019-04-18 14:36:38 -04:00
|
|
|
cy.verifySliceSuccess({ waitAlias: '@postJson' });
|
2018-10-11 17:13:04 -04:00
|
|
|
|
|
|
|
cy.get('button#query').click();
|
2020-05-07 17:18:10 -04:00
|
|
|
cy.get('span').contains('View query').parent().click();
|
2019-04-03 15:11:08 -04:00
|
|
|
cy.wait('@postJson').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('Visit short link', () => {
|
2018-10-18 13:40:30 -04:00
|
|
|
cy.route('POST', 'r/shortner/').as('getShortUrl');
|
|
|
|
|
2018-10-11 17:13:04 -04:00
|
|
|
cy.visitChartByName('Growth Rate');
|
Fix control validation handling (#7231)
Fixes a series of unexpected things around control validation.
* when a chart opens in a state where a control is invalid, it still
runs the query, and sometimes gets stuck in what appears to be a 'running'
state. After this change, no query is run, and a warning is displayed
in the chart panel body, just like any other error would
* validation used to be done in the <Control> component and alter the
redux store as it went. Clearly this is not the right approach, now
validation occurs on loading the initial redux state, as well as in
the reducer when controls are changed
* currently, when going from a invalid control state to a valid one
(user addresses what is needed), it auto-triggers a query which can be
unexpected. After this change, the error message disappears, and the
"Run Query" overlay gets displayed
* when changing viz type, it's common to get new validation
errors, and currently when that occurs it will still go ahead and run
a query with invalid inputs, which often results in errors
that are not well handled, since much of the logic
assumes control-validated input.
* prettier control validation messages
(cherry picked from commit a3212eba5df95bca834d8d6d98c11d522d9172f3)
2019-04-18 14:36:38 -04:00
|
|
|
cy.verifySliceSuccess({ waitAlias: '@postJson' });
|
2018-10-11 17:13:04 -04:00
|
|
|
|
|
|
|
cy.get('[data-test=short-link-button]').click();
|
2018-10-18 13:40:30 -04:00
|
|
|
|
|
|
|
// explicitly wait for the url response
|
|
|
|
cy.wait('@getShortUrl');
|
|
|
|
|
2019-11-27 17:02:48 -05:00
|
|
|
cy.get('#shorturl-popover [data-test="short-url"]')
|
|
|
|
.invoke('text')
|
|
|
|
.then(text => {
|
2018-10-18 13:40:30 -04:00
|
|
|
cy.visit(text);
|
2018-10-11 17:13:04 -04:00
|
|
|
});
|
Fix control validation handling (#7231)
Fixes a series of unexpected things around control validation.
* when a chart opens in a state where a control is invalid, it still
runs the query, and sometimes gets stuck in what appears to be a 'running'
state. After this change, no query is run, and a warning is displayed
in the chart panel body, just like any other error would
* validation used to be done in the <Control> component and alter the
redux store as it went. Clearly this is not the right approach, now
validation occurs on loading the initial redux state, as well as in
the reducer when controls are changed
* currently, when going from a invalid control state to a valid one
(user addresses what is needed), it auto-triggers a query which can be
unexpected. After this change, the error message disappears, and the
"Run Query" overlay gets displayed
* when changing viz type, it's common to get new validation
errors, and currently when that occurs it will still go ahead and run
a query with invalid inputs, which often results in errors
that are not well handled, since much of the logic
assumes control-validated input.
* prettier control validation messages
(cherry picked from commit a3212eba5df95bca834d8d6d98c11d522d9172f3)
2019-04-18 14:36:38 -04:00
|
|
|
cy.verifySliceSuccess({ waitAlias: '@postJson' });
|
2018-10-11 17:13:04 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
it('Test iframe link', () => {
|
|
|
|
cy.visitChartByName('Growth Rate');
|
Fix control validation handling (#7231)
Fixes a series of unexpected things around control validation.
* when a chart opens in a state where a control is invalid, it still
runs the query, and sometimes gets stuck in what appears to be a 'running'
state. After this change, no query is run, and a warning is displayed
in the chart panel body, just like any other error would
* validation used to be done in the <Control> component and alter the
redux store as it went. Clearly this is not the right approach, now
validation occurs on loading the initial redux state, as well as in
the reducer when controls are changed
* currently, when going from a invalid control state to a valid one
(user addresses what is needed), it auto-triggers a query which can be
unexpected. After this change, the error message disappears, and the
"Run Query" overlay gets displayed
* when changing viz type, it's common to get new validation
errors, and currently when that occurs it will still go ahead and run
a query with invalid inputs, which often results in errors
that are not well handled, since much of the logic
assumes control-validated input.
* prettier control validation messages
(cherry picked from commit a3212eba5df95bca834d8d6d98c11d522d9172f3)
2019-04-18 14:36:38 -04:00
|
|
|
cy.verifySliceSuccess({ waitAlias: '@postJson' });
|
2018-10-11 17:13:04 -04:00
|
|
|
|
|
|
|
cy.get('[data-test=embed-code-button]').click();
|
|
|
|
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', () => {
|
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
|
|
|
|
|
|
|
cy.visitChartByParams(JSON.stringify(formData));
|
2019-04-03 15:11:08 -04:00
|
|
|
cy.verifySliceSuccess({ waitAlias: '@postJson' });
|
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();
|
Fix control validation handling (#7231)
Fixes a series of unexpected things around control validation.
* when a chart opens in a state where a control is invalid, it still
runs the query, and sometimes gets stuck in what appears to be a 'running'
state. After this change, no query is run, and a warning is displayed
in the chart panel body, just like any other error would
* validation used to be done in the <Control> component and alter the
redux store as it went. Clearly this is not the right approach, now
validation occurs on loading the initial redux state, as well as in
the reducer when controls are changed
* currently, when going from a invalid control state to a valid one
(user addresses what is needed), it auto-triggers a query which can be
unexpected. After this change, the error message disappears, and the
"Run Query" overlay gets displayed
* when changing viz type, it's common to get new validation
errors, and currently when that occurs it will still go ahead and run
a query with invalid inputs, which often results in errors
that are not well handled, since much of the logic
assumes control-validated input.
* prettier control validation messages
(cherry picked from commit a3212eba5df95bca834d8d6d98c11d522d9172f3)
2019-04-18 14:36:38 -04:00
|
|
|
cy.verifySliceSuccess({ waitAlias: '@postJson' });
|
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();
|
2020-07-23 03:26:29 -04:00
|
|
|
cy.verifySliceSuccess({ waitAlias: '@postJson' });
|
|
|
|
const query = {
|
|
|
|
filters: [
|
|
|
|
{
|
|
|
|
col: 'slice_name',
|
|
|
|
opr: 'eq',
|
|
|
|
value: newChartName,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
|
|
|
cy.request(apiURL('/api/v1/chart/', query)).then(response => {
|
|
|
|
expect(response.body.count).equals(1);
|
|
|
|
cy.request('DELETE', `/api/v1/chart/${response.body.ids[0]}`);
|
|
|
|
});
|
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);
|
Fix control validation handling (#7231)
Fixes a series of unexpected things around control validation.
* when a chart opens in a state where a control is invalid, it still
runs the query, and sometimes gets stuck in what appears to be a 'running'
state. After this change, no query is run, and a warning is displayed
in the chart panel body, just like any other error would
* validation used to be done in the <Control> component and alter the
redux store as it went. Clearly this is not the right approach, now
validation occurs on loading the initial redux state, as well as in
the reducer when controls are changed
* currently, when going from a invalid control state to a valid one
(user addresses what is needed), it auto-triggers a query which can be
unexpected. After this change, the error message disappears, and the
"Run Query" overlay gets displayed
* when changing viz type, it's common to get new validation
errors, and currently when that occurs it will still go ahead and run
a query with invalid inputs, which often results in errors
that are not well handled, since much of the logic
assumes control-validated input.
* prettier control validation messages
(cherry picked from commit a3212eba5df95bca834d8d6d98c11d522d9172f3)
2019-04-18 14:36:38 -04:00
|
|
|
cy.verifySliceSuccess({ waitAlias: '@postJson' });
|
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"]')
|
|
|
|
.find('#dashboard-creatable-select')
|
|
|
|
.type(`${dashboardTitle}{enter}{enter}`);
|
|
|
|
|
|
|
|
cy.get('[data-test="btn-modal-save"]').click();
|
Fix control validation handling (#7231)
Fixes a series of unexpected things around control validation.
* when a chart opens in a state where a control is invalid, it still
runs the query, and sometimes gets stuck in what appears to be a 'running'
state. After this change, no query is run, and a warning is displayed
in the chart panel body, just like any other error would
* validation used to be done in the <Control> component and alter the
redux store as it went. Clearly this is not the right approach, now
validation occurs on loading the initial redux state, as well as in
the reducer when controls are changed
* currently, when going from a invalid control state to a valid one
(user addresses what is needed), it auto-triggers a query which can be
unexpected. After this change, the error message disappears, and the
"Run Query" overlay gets displayed
* when changing viz type, it's common to get new validation
errors, and currently when that occurs it will still go ahead and run
a query with invalid inputs, which often results in errors
that are not well handled, since much of the logic
assumes control-validated input.
* prettier control validation messages
(cherry picked from commit a3212eba5df95bca834d8d6d98c11d522d9172f3)
2019-04-18 14:36:38 -04:00
|
|
|
cy.verifySliceSuccess({ waitAlias: '@postJson' });
|
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);
|
Fix control validation handling (#7231)
Fixes a series of unexpected things around control validation.
* when a chart opens in a state where a control is invalid, it still
runs the query, and sometimes gets stuck in what appears to be a 'running'
state. After this change, no query is run, and a warning is displayed
in the chart panel body, just like any other error would
* validation used to be done in the <Control> component and alter the
redux store as it went. Clearly this is not the right approach, now
validation occurs on loading the initial redux state, as well as in
the reducer when controls are changed
* currently, when going from a invalid control state to a valid one
(user addresses what is needed), it auto-triggers a query which can be
unexpected. After this change, the error message disappears, and the
"Run Query" overlay gets displayed
* when changing viz type, it's common to get new validation
errors, and currently when that occurs it will still go ahead and run
a query with invalid inputs, which often results in errors
that are not well handled, since much of the logic
assumes control-validated input.
* prettier control validation messages
(cherry picked from commit a3212eba5df95bca834d8d6d98c11d522d9172f3)
2019-04-18 14:36:38 -04:00
|
|
|
cy.verifySliceSuccess({ waitAlias: '@postJson' });
|
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"]')
|
|
|
|
.find('#dashboard-creatable-select')
|
|
|
|
.type(`${dashboardTitle}{enter}{enter}`);
|
|
|
|
|
|
|
|
cy.get('[data-test="btn-modal-save"]').click();
|
Fix control validation handling (#7231)
Fixes a series of unexpected things around control validation.
* when a chart opens in a state where a control is invalid, it still
runs the query, and sometimes gets stuck in what appears to be a 'running'
state. After this change, no query is run, and a warning is displayed
in the chart panel body, just like any other error would
* validation used to be done in the <Control> component and alter the
redux store as it went. Clearly this is not the right approach, now
validation occurs on loading the initial redux state, as well as in
the reducer when controls are changed
* currently, when going from a invalid control state to a valid one
(user addresses what is needed), it auto-triggers a query which can be
unexpected. After this change, the error message disappears, and the
"Run Query" overlay gets displayed
* when changing viz type, it's common to get new validation
errors, and currently when that occurs it will still go ahead and run
a query with invalid inputs, which often results in errors
that are not well handled, since much of the logic
assumes control-validated input.
* prettier control validation messages
(cherry picked from commit a3212eba5df95bca834d8d6d98c11d522d9172f3)
2019-04-18 14:36:38 -04:00
|
|
|
cy.verifySliceSuccess({ waitAlias: '@postJson' });
|
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
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|