rusackas commented on code in PR #38584:
URL: https://github.com/apache/superset/pull/38584#discussion_r3662397989
##########
superset-frontend/src/explore/components/SaveModal.test.tsx:
##########
@@ -36,14 +36,29 @@ import SaveModal, {
import { CHART_WIDTH } from 'src/dashboard/constants';
import { GRID_COLUMN_COUNT } from 'src/dashboard/util/constants';
+// Captures the AsyncSelect `options` loader (SaveModal's loadDashboards) so
+// tests can invoke it directly and assert on the request it issues.
+let mockLoadDashboards:
+ | ((search: string, page: number, pageSize: number) => Promise<unknown>)
+ | undefined;
+
jest.mock('@superset-ui/core/components/Select', () => ({
...jest.requireActual('@superset-ui/core/components/Select/AsyncSelect'),
- AsyncSelect: ({ onChange }: { onChange: (val: any) => void }) => (
- <input
- data-test="mock-async-select"
- onChange={({ target: { value } }) => onChange({ label: value, value })}
- />
- ),
+ AsyncSelect: ({
+ onChange,
+ options,
+ }: {
+ onChange: (val: any) => void;
+ options?: (search: string, page: number, pageSize: number) => Promise<any>;
Review Comment:
Same fix, using `SelectOptionsPagePromise` now instead of `Promise<any>`.
##########
tests/integration_tests/charts/commands_tests.py:
##########
@@ -669,6 +716,45 @@ def test_update_chart_dashboard_security_admin_bypass(
db.session.delete(alpha_dashboard)
db.session.commit()
+ @patch("superset.commands.chart.update.g")
+ @patch("superset.utils.core.g")
+ @patch("superset.security.manager.g")
+ @pytest.mark.usefixtures("load_energy_table_with_slice")
+ def test_update_chart_rejects_new_externally_managed_dashboard(
+ self, mock_sm_g, mock_u_g, mock_c_g
+ ):
+ """Test that updating a chart to add an externally managed dashboard
fails"""
+ from superset.models.dashboard import Dashboard
+
+ admin = security_manager.find_user(username="admin")
+ mock_u_g.user = mock_c_g.user = mock_sm_g.user = admin
+
+ chart = db.session.query(Slice).first()
+ chart.owners = [admin]
Review Comment:
This matches the same pattern the other tests in this class already use,
mutating `Slice.first()`'s editors/owners without restoring. Not new to this
test, would rather clean up the whole class in one pass than just this one.
--
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]