2020-06-25 18:24:23 -04: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.
|
|
|
|
*/
|
|
|
|
import readResponseBlob from '../../utils/readResponseBlob';
|
|
|
|
import { WORLD_HEALTH_DASHBOARD } from './dashboard.helper';
|
|
|
|
|
|
|
|
describe('Dashboard save action', () => {
|
|
|
|
let dashboardId;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
cy.server();
|
|
|
|
cy.login();
|
|
|
|
cy.visit(WORLD_HEALTH_DASHBOARD);
|
|
|
|
|
|
|
|
cy.get('#app').then(data => {
|
|
|
|
const bootstrapData = JSON.parse(data[0].dataset.bootstrap);
|
|
|
|
const dashboard = bootstrapData.dashboard_data;
|
|
|
|
dashboardId = dashboard.id;
|
|
|
|
cy.route('POST', `/superset/copy_dash/${dashboardId}/`).as('copyRequest');
|
|
|
|
});
|
|
|
|
|
2020-10-20 00:36:20 -04:00
|
|
|
cy.get('[data-test="more-horiz"]').trigger('click', { force: true });
|
|
|
|
cy.get('[data-test="save-as-menu-item"]').trigger('click', { force: true });
|
|
|
|
cy.get('[data-test="modal-save-dashboard-button"]').trigger('click', {
|
|
|
|
force: true,
|
|
|
|
});
|
2020-06-25 18:24:23 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should save as new dashboard', () => {
|
|
|
|
cy.wait('@copyRequest').then(xhr => {
|
|
|
|
expect(xhr.status).to.eq(200);
|
|
|
|
readResponseBlob(xhr.response.body).then(json => {
|
|
|
|
expect(json.id).to.be.gt(dashboardId);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should save/overwrite dashboard', () => {
|
|
|
|
// should have box_plot chart
|
2020-10-20 00:36:20 -04:00
|
|
|
cy.get('[data-test="grid-row-background--transparent"]').within(() => {
|
|
|
|
cy.get('.box_plot', { timeout: 10000 }).should('be.visible');
|
|
|
|
});
|
2020-06-25 18:24:23 -04:00
|
|
|
|
|
|
|
// remove box_plot chart from dashboard
|
2020-10-20 00:36:20 -04:00
|
|
|
cy.get('[data-test="edit-alt"]').click({ timeout: 5000 });
|
|
|
|
cy.get('[data-test="dashboard-delete-component-button"]')
|
|
|
|
.should('be.visible', { timeout: 10000 })
|
|
|
|
.last()
|
|
|
|
.trigger('click');
|
|
|
|
cy.get('[data-test="grid-container"]')
|
|
|
|
.find('.box_plot')
|
|
|
|
.should('not.be.visible');
|
2020-06-25 18:24:23 -04:00
|
|
|
|
|
|
|
cy.route('POST', '/superset/save_dash/**/').as('saveRequest');
|
2020-10-20 00:36:20 -04:00
|
|
|
cy.get('[data-test="dashboard-header"]')
|
|
|
|
.find('[data-test="header-save-button"]')
|
2020-08-05 21:53:53 -04:00
|
|
|
.contains('Save')
|
2020-06-25 18:24:23 -04:00
|
|
|
.trigger('click', { force: true });
|
|
|
|
// go back to view mode
|
|
|
|
cy.wait('@saveRequest');
|
2020-10-20 00:36:20 -04:00
|
|
|
cy.get('[data-test="dashboard-header"]')
|
|
|
|
.find('[data-test="edit-alt"]')
|
|
|
|
.click();
|
|
|
|
cy.get('[data-test="grid-container"]')
|
|
|
|
.find('.box_plot', { timeout: 20000 })
|
|
|
|
.should('not.be.visible');
|
2020-06-25 18:24:23 -04:00
|
|
|
});
|
|
|
|
});
|