Copilot commented on code in PR #40758:
URL: https://github.com/apache/superset/pull/40758#discussion_r3364276624
##########
superset-frontend/src/dashboard/actions/dashboardState.certification.test.ts:
##########
@@ -0,0 +1,115 @@
+/**
Review Comment:
The PR description says these regression tests were added inside
`dashboardState.test.ts` under a new `describe('certification fields', ...)`
block, but this PR actually introduces a new file
(`dashboardState.certification.test.ts`). Please update the PR description (or
move the tests) so reviewers and release notes accurately reflect the change.
##########
superset-frontend/src/dashboard/actions/dashboardState.certification.test.ts:
##########
@@ -0,0 +1,115 @@
+/**
+ * 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 { SupersetClient } from '@superset-ui/core';
+import { waitFor } from 'spec/helpers/testing-library';
+import {
+ filterId,
+ sliceEntitiesForDashboard as sliceEntities,
+} from 'spec/fixtures/mockSliceEntities';
+import { emptyFilters } from 'spec/fixtures/mockDashboardFilters';
+import mockDashboardData from 'spec/fixtures/mockDashboardData';
+import { saveDashboardRequest } from 'src/dashboard/actions/dashboardState';
+import { SAVE_TYPE_OVERWRITE } from 'src/dashboard/util/constants';
+
+const mockState = {
+ dashboardState: { sliceIds: [filterId], hasUnsavedChanges: true },
+ dashboardInfo: { metadata: { color_scheme: 'supersetColors' } },
+ sliceEntities,
+ dashboardFilters: emptyFilters,
+ dashboardLayout: {
+ past: [],
+ present: mockDashboardData.positions,
+ future: {},
+ },
+ charts: {},
+};
+
+let putStub: jest.SpyInstance;
+
+beforeEach(() => {
+ jest.spyOn(SupersetClient, 'post').mockResolvedValue({} as any);
+ jest.spyOn(SupersetClient, 'get').mockResolvedValue({} as any);
+ putStub = jest.spyOn(SupersetClient, 'put').mockResolvedValue({
+ json: { result: mockDashboardData },
+ } as any);
+});
Review Comment:
These tests implicitly rely on `FeatureFlag.ConfirmDashboardDiff` being
disabled; if that flag is enabled via `window.featureFlags` in another test
file, `saveDashboardRequest` will take the overwrite-precheck path and the
`SupersetClient.get` stub here (currently resolving to `{}`) will cause a
runtime error or prevent the PUT call. To keep the tests deterministic and
isolated, explicitly disable `CONFIRM_DASHBOARD_DIFF` in `beforeEach` (or mock
`isFeatureEnabled`).
--
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]