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.server();
|
|
|
|
cy.login();
|
|
|
|
cy.visit(WORLD_HEALTH_DASHBOARD);
|
2020-09-25 17:49:30 -04:00
|
|
|
cy.get('.dashboard-header [data-test=edit-alt]').click();
|
2020-06-25 18:24:23 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
it('remove, and add chart flow', () => {
|
|
|
|
// wait for box plot to appear
|
|
|
|
cy.get('.grid-container .box_plot');
|
|
|
|
|
|
|
|
cy.get('.fa.fa-trash')
|
|
|
|
.last()
|
|
|
|
.then($el => {
|
|
|
|
cy.wrap($el).invoke('show').click();
|
|
|
|
// box plot should be gone
|
|
|
|
cy.get('.grid-container .box_plot').should('not.exist');
|
|
|
|
});
|
|
|
|
|
2020-08-05 21:53:53 -04:00
|
|
|
cy.get('.tabs-components .nav-tabs li a').contains('Charts').click();
|
2020-06-25 18:24:23 -04:00
|
|
|
|
|
|
|
// find box plot is available from list
|
2020-08-05 21:53:53 -04:00
|
|
|
cy.get('.tabs-components')
|
|
|
|
.find('.chart-card-container')
|
|
|
|
.contains('Box plot');
|
2020-06-25 18:24:23 -04:00
|
|
|
|
2020-09-15 17:12:06 -04:00
|
|
|
drag('.chart-card', 'Box plot').to(
|
|
|
|
'.grid-row.background--transparent:last',
|
|
|
|
);
|
2020-06-25 18:24:23 -04:00
|
|
|
|
|
|
|
// add back to dashboard
|
|
|
|
cy.get('.grid-container .box_plot').should('be.exist');
|
|
|
|
|
|
|
|
// should show Save changes button
|
2020-08-05 21:53:53 -04:00
|
|
|
cy.get('.dashboard-header .button-container').contains('Save');
|
2020-06-25 18:24:23 -04:00
|
|
|
|
|
|
|
// undo 2 steps
|
|
|
|
cy.get('.dashboard-header .undo-action').click().click();
|
|
|
|
|
|
|
|
// no changes, can switch to view mode
|
|
|
|
cy.get('.dashboard-header .button-container')
|
2020-08-05 21:53:53 -04:00
|
|
|
.contains('Discard Changes')
|
2020-06-25 18:24:23 -04:00
|
|
|
.click();
|
|
|
|
});
|
|
|
|
});
|