bito-code-review[bot] commented on code in PR #28008:
URL: https://github.com/apache/superset/pull/28008#discussion_r3393096774


##########
tests/integration_tests/dashboards/commands_tests.py:
##########
@@ -507,6 +507,29 @@ def test_export_dashboard_command_no_related(self, 
mock_g1, mock_g2):
         }
         assert expected_paths == set(contents.keys())
 
+    @pytest.mark.usefixtures("load_world_bank_dashboard_with_slices")
+    @patch("superset.security.manager.g")
+    @patch("superset.views.base.g")
+    def test_export_dashboard_command_unicode_chars(self, mock_g1, mock_g2):
+        mock_g1.user = security_manager.find_user("admin")
+        mock_g2.user = security_manager.find_user("admin")
+        db.session.query(Dashboard).filter_by(slug="world_health").update(
+            {"dashboard_title": "中文"},
+        )
+        example_dashboard = (
+            db.session.query(Dashboard).filter_by(dashboard_title="中文").one()
+        )
+
+        command = ExportDashboardsCommand([example_dashboard.id])
+        contents = dict(command.run())
+
+        path = f"dashboards/{example_dashboard.id}.yaml"
+        assert path in set(contents.keys())
+        yaml_content = contents[path]()
+        metadata = yaml.safe_load(yaml_content)
+        assert metadata["dashboard_title"] == "中文"
+        assert "dashboard_title: 中文" in yaml_content

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Test isolation failure</b></div>
   <div id="fix">
   
   This test modifies shared fixture data (dashboard_title changed from "World 
Bank's Data" to "中文") without restoring it. The fixture cleanup deletes by ID, 
not by title, so the modification persists. If 
`test_export_dashboard_command_no_related` runs after this test, it will fail 
at line 506 because the exported filename will be `dashboards/{id}.yaml` 
instead of `dashboards/World_Banks_Data_{id}.yaml`.
   </div>
   
   
   <details>
   <summary>
   <b>Code suggestion</b>
   </summary>
   <blockquote>Check the AI-generated fix before applying</blockquote>
   <div id="code">
   
   
   ```
    --- tests/integration_tests/dashboards/commands_tests.py (lines 528-531) ---
    528:         yaml_content = contents[path]()
    529:         metadata = yaml.safe_load(yaml_content)
    530:         assert metadata["dashboard_title"] == "中文"
    531:         assert "dashboard_title: 中文" in yaml_content
    +        # Restore original dashboard title for test isolation
    +        db.session.query(Dashboard).filter_by(slug="world_health").update(
    +            {"dashboard_title": "World Bank's Data"},
    +        )
    +        db.session.commit()
   ```
   
   </div>
   </details>
   
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #e26422</i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



-- 
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]

Reply via email to