sadpandajoe commented on code in PR #37866: URL: https://github.com/apache/superset/pull/37866#discussion_r2790836545
########## superset-frontend/playwright/tests/experimental/chart/chart-list.spec.ts: ########## @@ -0,0 +1,297 @@ +/** + * 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 { + test as testWithAssets, + expect, +} from '../../../helpers/fixtures/testAssets'; +import { ChartListPage } from '../../../pages/ChartListPage'; +import { ChartPropertiesModal } from '../../../components/modals/ChartPropertiesModal'; +import { DeleteConfirmationModal } from '../../../components/modals/DeleteConfirmationModal'; +import { Toast } from '../../../components/core/Toast'; +import { apiGetChart, ENDPOINTS } from '../../../helpers/api/chart'; +import { createTestChart } from './chart-test-helpers'; +import { waitForGet } from '../../../helpers/api/intercepts'; +import { + expectStatusOneOf, + expectValidExportZip, +} from '../../../helpers/api/assertions'; + +/** + * Extend testWithAssets with chartListPage navigation (beforeEach equivalent). + */ +const test = testWithAssets.extend<{ chartListPage: ChartListPage }>({ + chartListPage: async ({ page }, use) => { + const chartListPage = new ChartListPage(page); + await chartListPage.goto(); + await chartListPage.waitForTableLoad(); + await use(chartListPage); + }, +}); + +test('should delete a chart with confirmation', async ({ + page, + chartListPage, + testAssets, +}) => { + // Create throwaway chart for deletion + const { id: chartId, name: chartName } = await createTestChart( + page, + testAssets, + test.info(), + { prefix: 'test_delete' }, + ); + + // Refresh to see the new chart (created via API) + await chartListPage.goto(); + await chartListPage.waitForTableLoad(); + + // Verify chart is visible in list + await expect(chartListPage.getChartRow(chartName)).toBeVisible(); + + // Click delete action button + await chartListPage.clickDeleteAction(chartName); + + // Delete confirmation modal should appear + const deleteModal = new DeleteConfirmationModal(page); + await deleteModal.waitForVisible(); + + // Type "DELETE" to confirm + await deleteModal.fillConfirmationInput('DELETE'); + + // Click the Delete button + await deleteModal.clickDelete(); + + // Modal should close + await deleteModal.waitForHidden(); + + // Verify success toast appears + const toast = new Toast(page); + await expect(toast.getSuccess()).toBeVisible(); + + // Verify chart is removed from list + await expect(chartListPage.getChartRow(chartName)).not.toBeVisible(); + + // Backend verification: API returns 404 + await expect + .poll( + async () => { + const response = await apiGetChart(page, chartId, { + failOnStatusCode: false, + }); + return response.status(); + }, + { timeout: 10000, message: `Chart ${chartId} should return 404` }, + ) + .toBe(404); +}); + +test('should edit chart name via properties modal', async ({ + page, + chartListPage, + testAssets, +}) => { + // Create throwaway chart for editing + const { id: chartId, name: chartName } = await createTestChart( + page, + testAssets, + test.info(), + { prefix: 'test_edit' }, + ); + + // Refresh to see the new chart + await chartListPage.goto(); + await chartListPage.waitForTableLoad(); + + // Verify chart is visible in list + await expect(chartListPage.getChartRow(chartName)).toBeVisible(); + + // Click edit action to open properties modal + await chartListPage.clickEditAction(chartName); + + // Wait for properties modal to be ready + const propertiesModal = new ChartPropertiesModal(page); + await propertiesModal.waitForReady(); + + // Edit the chart name + const newName = `renamed_${Date.now()}_${test.info().parallelIndex}`; + await propertiesModal.fillName(newName); + + // Click Save button + await propertiesModal.clickSave(); + + // Modal should close + await propertiesModal.waitForHidden(); + + // Verify success toast appears + const toast = new Toast(page); + await expect(toast.getSuccess()).toBeVisible(); + + // Backend verification: API returns updated name + const response = await apiGetChart(page, chartId); + const chart = (await response.json()).result; + expect(chart.slice_name).toBe(newName); Review Comment: Addressed in 4e129fd — added `waitForPut` + `expectStatusOneOf` before the `apiGetChart` assertion, matching the dataset edit test pattern. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
