mirror of
https://github.com/apache/superset.git
synced 2026-04-23 10:04:45 +00:00
172 lines
5.6 KiB
TypeScript
172 lines
5.6 KiB
TypeScript
/**
|
|
* 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 { CHART_LIST } from 'cypress/utils/urls';
|
|
import { setGridMode, toggleBulkSelect } from 'cypress/utils';
|
|
import {
|
|
setFilter,
|
|
interceptBulkDelete,
|
|
interceptUpdate,
|
|
interceptDelete,
|
|
interceptFiltering,
|
|
interceptFavoriteStatus,
|
|
} from '../explore/utils';
|
|
|
|
function orderAlphabetical() {
|
|
setFilter('Sort', 'Alphabetical');
|
|
}
|
|
|
|
function openProperties() {
|
|
cy.get('[aria-label="more"]').eq(0).click();
|
|
cy.getBySel('chart-list-edit-option').click();
|
|
}
|
|
|
|
function openMenu() {
|
|
cy.get('[aria-label="more"]').eq(0).click();
|
|
}
|
|
|
|
function confirmDelete() {
|
|
cy.getBySel('delete-modal-input').type('DELETE');
|
|
cy.getBySel('modal-confirm-button').click();
|
|
}
|
|
|
|
function visitChartList() {
|
|
interceptFiltering();
|
|
interceptFavoriteStatus();
|
|
cy.visit(CHART_LIST);
|
|
cy.wait('@filtering');
|
|
cy.wait('@favoriteStatus');
|
|
}
|
|
|
|
describe('Charts list', () => {
|
|
describe('common actions', () => {
|
|
beforeEach(() => {
|
|
visitChartList();
|
|
});
|
|
|
|
it('should bulk delete correctly', () => {
|
|
cy.createSampleCharts([0, 1, 2, 3]);
|
|
|
|
interceptBulkDelete();
|
|
toggleBulkSelect();
|
|
|
|
// bulk deletes in card-view
|
|
setGridMode('card');
|
|
orderAlphabetical();
|
|
|
|
cy.getBySel('skeleton-card').should('not.exist');
|
|
cy.getBySel('styled-card').contains('1 - Sample chart').click();
|
|
cy.getBySel('styled-card').contains('2 - Sample chart').click();
|
|
cy.getBySel('bulk-select-action').contains('Delete').click();
|
|
confirmDelete();
|
|
cy.wait('@bulkDelete');
|
|
cy.getBySel('styled-card')
|
|
.eq(1)
|
|
.should('not.contain', '1 - Sample chart');
|
|
cy.getBySel('styled-card')
|
|
.eq(2)
|
|
.should('not.contain', '2 - Sample chart');
|
|
|
|
// bulk deletes in list-view
|
|
setGridMode('list');
|
|
cy.get('.loading').should('not.exist');
|
|
cy.getBySel('table-row').contains('3 - Sample chart').should('exist');
|
|
cy.getBySel('table-row').contains('4 - Sample chart').should('exist');
|
|
cy.get('[data-test="table-row"] input[type="checkbox"]').eq(0).click();
|
|
cy.get('[data-test="table-row"] input[type="checkbox"]').eq(1).click();
|
|
cy.getBySel('bulk-select-action').eq(0).contains('Delete').click();
|
|
confirmDelete();
|
|
cy.wait('@bulkDelete');
|
|
cy.get('.loading').should('exist');
|
|
cy.get('.loading').should('not.exist');
|
|
cy.getBySel('table-row').eq(0).should('not.contain', '3 - Sample chart');
|
|
cy.getBySel('table-row').eq(1).should('not.contain', '4 - Sample chart');
|
|
});
|
|
|
|
it('should delete correctly in card mode', () => {
|
|
cy.createSampleCharts([0, 1]);
|
|
interceptDelete();
|
|
|
|
// deletes in card-view
|
|
setGridMode('card');
|
|
orderAlphabetical();
|
|
|
|
cy.getBySel('styled-card').contains('1 - Sample chart');
|
|
openMenu();
|
|
cy.getBySel('chart-list-delete-option').click();
|
|
confirmDelete();
|
|
cy.wait('@delete');
|
|
cy.getBySel('styled-card')
|
|
.contains('1 - Sample chart')
|
|
.should('not.exist');
|
|
});
|
|
|
|
it('should delete correctly in list mode', () => {
|
|
cy.createSampleCharts([2, 3]);
|
|
interceptDelete();
|
|
cy.getBySel('sort-header').contains('Name').click();
|
|
|
|
// Modal closes immediately without this
|
|
cy.wait(2000);
|
|
|
|
cy.getBySel('table-row').eq(0).contains('3 - Sample chart');
|
|
cy.getBySel('delete').eq(0).click();
|
|
confirmDelete();
|
|
cy.wait('@delete');
|
|
cy.get('.loading').should('exist');
|
|
cy.get('.loading').should('not.exist');
|
|
cy.getBySel('table-row').eq(0).should('not.contain', '3 - Sample chart');
|
|
});
|
|
|
|
it('should edit correctly', () => {
|
|
cy.createSampleCharts([0]);
|
|
interceptUpdate();
|
|
|
|
// edits in card-view
|
|
setGridMode('card');
|
|
orderAlphabetical();
|
|
cy.getBySel('skeleton-card').should('not.exist');
|
|
cy.getBySel('styled-card').eq(0).contains('1 - Sample chart');
|
|
|
|
// change title
|
|
openProperties();
|
|
cy.getBySel('properties-modal-name-input').type(' | EDITED');
|
|
cy.get('button:contains("Save")').click();
|
|
cy.wait('@update');
|
|
cy.getBySel('styled-card').eq(0).contains('1 - Sample chart | EDITED');
|
|
|
|
// edits in list-view
|
|
setGridMode('list');
|
|
// Wait for list view to fully render after mode change
|
|
cy.get('.loading').should('not.exist');
|
|
cy.getBySel('table-row').should('be.visible');
|
|
// Target the specific row by chart title to avoid flakiness from row ordering
|
|
cy.getBySel('table-row')
|
|
.contains('1 - Sample chart | EDITED')
|
|
.parents('[data-test="table-row"]')
|
|
.find('[data-test="edit-alt"]')
|
|
.click();
|
|
cy.getBySel('properties-modal-name-input').clear();
|
|
cy.getBySel('properties-modal-name-input').type('1 - Sample chart');
|
|
cy.get('button:contains("Save")').click();
|
|
cy.wait('@update');
|
|
cy.getBySel('table-row').contains('1 - Sample chart').should('exist');
|
|
});
|
|
});
|
|
});
|