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.
|
|
|
|
*/
|
2020-09-15 17:12:06 -04:00
|
|
|
import { WORLD_HEALTH_DASHBOARD, drag } from './dashboard.helper';
|
2020-06-25 18:24:23 -04:00
|
|
|
|
|
|
|
describe('Dashboard edit mode', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
cy.login();
|
|
|
|
cy.visit(WORLD_HEALTH_DASHBOARD);
|
2020-10-20 00:36:20 -04:00
|
|
|
cy.get('[data-test="dashboard-header"]')
|
|
|
|
.find('[data-test=edit-alt]')
|
|
|
|
.click();
|
2020-06-25 18:24:23 -04:00
|
|
|
});
|
|
|
|
|
2020-10-20 00:36:20 -04:00
|
|
|
it('remove, and add chart flow', () => {
|
2020-06-25 18:24:23 -04:00
|
|
|
// wait for box plot to appear
|
2020-10-20 00:36:20 -04:00
|
|
|
cy.get('[data-test="grid-container"]').find('.box_plot', {
|
|
|
|
timeout: 10000,
|
|
|
|
});
|
|
|
|
const elementsCount = 10;
|
2020-06-25 18:24:23 -04:00
|
|
|
|
2020-10-20 00:36:20 -04:00
|
|
|
cy.get('[data-test="dashboard-component-chart-holder"]')
|
|
|
|
.find('[data-test="dashboard-delete-component-button"]')
|
2020-06-25 18:24:23 -04:00
|
|
|
.last()
|
|
|
|
.then($el => {
|
|
|
|
cy.wrap($el).invoke('show').click();
|
|
|
|
// box plot should be gone
|
2020-10-20 00:36:20 -04:00
|
|
|
cy.get('[data-test="grid-container"]')
|
|
|
|
.find('.box_plot')
|
2021-01-25 18:05:43 -05:00
|
|
|
.should('not.exist');
|
2020-06-25 18:24:23 -04:00
|
|
|
});
|
|
|
|
|
2020-10-20 00:36:20 -04:00
|
|
|
cy.get('[data-test="dashboard-builder-component-pane-tabs-navigation"]')
|
2020-11-10 18:51:47 -05:00
|
|
|
.find('.ant-tabs-tab')
|
|
|
|
.last()
|
2020-10-20 00:36:20 -04:00
|
|
|
.click();
|
2020-09-27 23:08:21 -04:00
|
|
|
|
2020-06-25 18:24:23 -04:00
|
|
|
// find box plot is available from list
|
2020-10-20 00:36:20 -04:00
|
|
|
cy.get('[data-test="dashboard-charts-filter-search-input"]').type(
|
|
|
|
'Box plot',
|
|
|
|
);
|
|
|
|
cy.get('[data-test="card-title"]').should('have.length', 1);
|
2020-06-25 18:24:23 -04:00
|
|
|
|
2020-10-20 00:36:20 -04:00
|
|
|
drag('[data-test="card-title"]', 'Box plot').to(
|
2020-09-15 17:12:06 -04:00
|
|
|
'.grid-row.background--transparent:last',
|
|
|
|
);
|
2020-06-25 18:24:23 -04:00
|
|
|
|
|
|
|
// add back to dashboard
|
2020-10-20 00:36:20 -04:00
|
|
|
cy.get('[data-test="grid-container"]')
|
|
|
|
.find('.box_plot')
|
|
|
|
.should('be.visible');
|
2020-06-25 18:24:23 -04:00
|
|
|
|
|
|
|
// should show Save changes button
|
2020-10-20 00:36:20 -04:00
|
|
|
cy.get('[data-test="header-save-button"]').should('be.visible');
|
|
|
|
|
|
|
|
// undo first step and expect deleted item
|
|
|
|
cy.get('[data-test="undo-action"]').click();
|
|
|
|
cy.get('[data-test="grid-container"]')
|
|
|
|
.find('[data-test="chart-container"]')
|
|
|
|
.should('have.length', elementsCount - 1);
|
|
|
|
|
|
|
|
// Box plot chart should be gone
|
|
|
|
cy.get('[data-test="grid-container"]')
|
|
|
|
.find('.box_plot')
|
2021-01-25 18:05:43 -05:00
|
|
|
.should('not.exist');
|
2020-10-20 00:36:20 -04:00
|
|
|
|
|
|
|
// undo second step and expect initial items count
|
|
|
|
cy.get('[data-test="undo-action"]').click();
|
|
|
|
cy.get('[data-test="grid-container"]')
|
|
|
|
.find('[data-test="chart-container"]')
|
|
|
|
.should('have.length', elementsCount);
|
|
|
|
cy.get('[data-test="card-title"]').contains('Box plot', { timeout: 5000 });
|
2020-06-25 18:24:23 -04:00
|
|
|
|
2020-10-20 00:36:20 -04:00
|
|
|
// save changes button should be disabled
|
|
|
|
cy.get('[data-test="header-save-button"]').should('be.disabled');
|
2020-06-25 18:24:23 -04:00
|
|
|
|
|
|
|
// no changes, can switch to view mode
|
2020-10-20 00:36:20 -04:00
|
|
|
cy.get('[data-test="dashboard-edit-actions"]')
|
|
|
|
.find('[data-test="discard-changes-button"]')
|
|
|
|
.should('be.visible')
|
2020-06-25 18:24:23 -04:00
|
|
|
.click();
|
2020-10-20 00:36:20 -04:00
|
|
|
cy.get('[data-test="dashboard-header"]').within(() => {
|
|
|
|
cy.get('[data-test="dashboard-edit-actions"]').should('not.be.visible');
|
|
|
|
cy.get('[data-test="edit-alt"]').should('be.visible');
|
|
|
|
});
|
2020-06-25 18:24:23 -04:00
|
|
|
});
|
|
|
|
});
|