sadpandajoe commented on code in PR #44358:
URL: https://github.com/apache/superset/pull/44358#discussion_r4130349898
##########
tests/unit_tests/commands/chart/create_test.py:
##########
@@ -269,3 +270,114 @@ def
test_create_chart_query_context_without_datasource_is_allowed(
_mock_table_datasource(mocker)
CreateChartCommand(_create_payload(query_context)).validate()
+
+
+def test_create_chart_updates_dashboard_changed_on(mocker: MockerFixture) ->
None:
+ """Issue #44305: Creating a chart linked to dashboards must touch audit
metadata."""
+ _mock_table_datasource(mocker)
+ user = MagicMock()
+ g.user = user
+
+ dashboard = MagicMock(is_managed_externally=False, changed_on=None,
changed_by=None)
+ mocker.patch(
+ "superset.commands.chart.create.DashboardDAO.find_by_ids",
+ return_value=[dashboard],
+ )
+ mocker.patch(
+ "superset.commands.chart.create.security_manager.is_editor",
+ return_value=True,
+ )
+ mocker.patch(
+ "superset.commands.chart.create.ChartDAO.create",
+ return_value=MagicMock(),
+ )
+
+ cmd = CreateChartCommand(
+ {
+ "datasource_id": 42,
+ "datasource_type": "table",
+ "slice_name": "New Chart",
+ "viz_type": "table",
+ "dashboards": [101],
+ }
+ )
+ cmd.run()
+
+ assert dashboard.changed_on is not None
Review Comment:
These new regression tests only assert `changed_on`/`changed_by` are not
`None`, so a future bug that stamps a stale or fixed timestamp instead of the
current time would still pass every test here while the dashboard's "Last
modified" display stayed wrong. Could the assertions also check that
`changed_on` actually advances from a seeded prior value, rather than just
checking non-null?
--
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]