codeant-ai-for-open-source[bot] commented on code in PR #40679:
URL: https://github.com/apache/superset/pull/40679#discussion_r3799953316
##########
superset-frontend/src/dashboard/components/SliceHeader/SliceHeader.test.tsx:
##########
@@ -940,3 +940,63 @@ test('Should NOT show row count warning for table chart
with server pagination w
mockUseUiConfig.mockRestore();
});
+
+const mockDefaultUiConfig = () => {
+ (useUiConfig as jest.Mock).mockReturnValue({
+ hideTitle: false,
+ hideTab: false,
+ hideNav: false,
+ hideChartControls: false,
+ emitDataMasks: false,
+ showRowLimitWarning: false,
+ });
+};
+
+test('Should display the localized name when not in edit mode', () => {
+ mockDefaultUiConfig();
+ const props = createProps({
+ editMode: false,
+ sliceName: 'Sales',
+ localizedName: 'Ventes',
+ });
+ render(<SliceHeader {...props} />, {
+ useRedux: true,
+ useRouter: true,
+ initialState,
+ });
+ expect(screen.getByText('Ventes')).toBeInTheDocument();
+ expect(screen.queryByText('Sales')).not.toBeInTheDocument();
+});
+
+test('Should display the canonical name in edit mode so edits target it', ()
=> {
+ mockDefaultUiConfig();
+ const props = createProps({
+ editMode: true,
+ sliceName: 'Sales',
+ localizedName: 'Ventes',
+ });
+ render(<SliceHeader {...props} />, {
+ useRedux: true,
+ useRouter: true,
+ initialState,
+ });
+ // In edit mode the editable field must show the canonical name, otherwise a
+ // save would round-trip the translation into slice_name.
+ expect(screen.getByText('Sales')).toBeInTheDocument();
Review Comment:
**Suggestion:** In edit mode `EditableTitle` renders an Ant Design
`Input.TextArea`, so `Sales` is stored in the element's `value` property rather
than as text content. `getByText('Sales')` will not find it and this test will
fail; assert the input with `getByDisplayValue('Sales')` instead. [logic error]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ❌ SliceHeader localization test fails deterministically.
- ⚠️ CI cannot pass the affected frontend test suite.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=0ace5ecb0a034f818fb39fe49d5eafa6&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=0ace5ecb0a034f818fb39fe49d5eafa6&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:**
superset-frontend/src/dashboard/components/SliceHeader/SliceHeader.test.tsx
**Line:** 985:985
**Comment:**
*Logic Error: In edit mode `EditableTitle` renders an Ant Design
`Input.TextArea`, so `Sales` is stored in the element's `value` property rather
than as text content. `getByText('Sales')` will not find it and this test will
fail; assert the input with `getByDisplayValue('Sales')` instead.
Validate the correctness of the flagged issue. If correct, How can I resolve
this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask
user if the user wants to fix the rest of the comments as well. if said yes,
then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40679&comment_hash=007bc62792db0ae52d4221f7faa6cfabac75a7910746492a62b00391211c848c&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40679&comment_hash=007bc62792db0ae52d4221f7faa6cfabac75a7910746492a62b00391211c848c&reaction=dislike'>👎</a>
##########
superset-frontend/src/pages/DashboardList/index.tsx:
##########
@@ -391,28 +395,32 @@ function DashboardList(props: DashboardListProps) {
row: {
original: {
url,
- dashboard_title: dashboardTitle,
+ dashboard_title: canonicalTitle,
+ localized_title: localizedTitle,
certified_by: certifiedBy,
certification_details: certificationDetails,
description,
},
},
- }: any) => (
- <FlexRowContainer>
- <Link to={url} title={dashboardTitle}>
- {certifiedBy && (
- <>
- <CertifiedBadge
- certifiedBy={certifiedBy}
- details={certificationDetails}
- />{' '}
- </>
- )}
- {dashboardTitle}
- </Link>
- {description && <InfoTooltip tooltip={description} />}
- </FlexRowContainer>
- ),
+ }: any) => {
+ const dashboardTitle = localizedTitle ?? canonicalTitle;
Review Comment:
**Suggestion:** The localized title is retained from the previous list item
after an edit. `handleDashboardEdit` updates `dashboard_title` but neither
refreshes nor clears/recomputes `localized_title`, so this expression continues
displaying a translation for the old canonical title until the list is
reloaded. Update the localized field from the response or invalidate it when
the canonical title changes. [stale reference]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ⚠️ Dashboard list shows stale localized titles after edits.
- ⚠️ Viewer sees a translation for the previous dashboard name.
- ⚠️ Correct display returns only after list refresh.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=06946e8401cd408496dfdf7079046ef7&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=06946e8401cd408496dfdf7079046ef7&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset-frontend/src/pages/DashboardList/index.tsx
**Line:** 406:406
**Comment:**
*Stale Reference: The localized title is retained from the previous
list item after an edit. `handleDashboardEdit` updates `dashboard_title` but
neither refreshes nor clears/recomputes `localized_title`, so this expression
continues displaying a translation for the old canonical title until the list
is reloaded. Update the localized field from the response or invalidate it when
the canonical title changes.
Validate the correctness of the flagged issue. If correct, How can I resolve
this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask
user if the user wants to fix the rest of the comments as well. if said yes,
then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40679&comment_hash=e3ba3684e01d9aa69cf1959516e6bcbe7c28bbb6fe6ea8cb5815ed2ed4430bc8&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40679&comment_hash=e3ba3684e01d9aa69cf1959516e6bcbe7c28bbb6fe6ea8cb5815ed2ed4430bc8&reaction=dislike'>👎</a>
##########
tests/integration_tests/log_api_tests.py:
##########
@@ -207,6 +207,57 @@ def test_get_recent_activity(self):
]
}
+ @with_feature_flags(ENABLE_I18N_ASSET_TRANSLATIONS=True)
+ def test_get_recent_activity_localized_title(self):
+ """
+ Log API: recent activity localizes item_title via TRANSLATION_HOOK
+ when asset-metadata translation is enabled and a non-default locale
+ is active. The canonical title is preserved as the translation source.
+ """
+ admin_user = self.get_user("admin")
+ self.login(ADMIN_USERNAME)
+ dash = create_dashboard("loc_slug", "Sales Dashboard", "{}", [])
+ log1 = self.insert_log(
+ "log",
+ admin_user,
+ dashboard_id=dash.id,
+ json='{"event_name": "mount_dashboard"}',
+ )
+
+ def _hook(default_text, locale, **kwargs):
+ if locale == "mi" and default_text == "Sales Dashboard":
+ return "Papatohu Hokohoko"
+ return None
+
+ languages = {
+ "en": {"flag": "us", "name": "English"},
+ "mi": {"flag": "nz", "name": "Māori"},
+ }
+ with (
+ patch.dict(
+ app.config,
+ {"LANGUAGES": languages, "TRANSLATION_HOOK": _hook},
+ ),
+ patch("superset.utils.i18n.get_locale", return_value="mi"),
+ ):
+ rv = self.client.get("api/v1/log/recent_activity/")
+ assert rv.status_code == 200
+ response = json.loads(rv.data.decode("utf-8"))
+
+ db.session.delete(log1)
+ db.session.delete(dash)
+ db.session.commit()
Review Comment:
**Suggestion:** The test creates persistent dashboard and log rows but
performs cleanup only after the request and assertions succeed. If the request,
JSON decoding, or any assertion fails, those rows remain in the shared
integration database and can affect later tests. Move the deletion and commit
into a fixture or a `finally` block so cleanup happens on failure as well.
[missing cleanup]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ❌ Failed localization tests can strand dashboard and log rows.
- ⚠️ Later recent-activity tests may receive contaminated database results.
- ⚠️ Shared integration runs can report cascading unrelated failures.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=e2e3aa7dcf1d49cd99af195907f52984&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=e2e3aa7dcf1d49cd99af195907f52984&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** tests/integration_tests/log_api_tests.py
**Line:** 247:249
**Comment:**
*Missing Cleanup: The test creates persistent dashboard and log rows
but performs cleanup only after the request and assertions succeed. If the
request, JSON decoding, or any assertion fails, those rows remain in the shared
integration database and can affect later tests. Move the deletion and commit
into a fixture or a `finally` block so cleanup happens on failure as well.
Validate the correctness of the flagged issue. If correct, How can I resolve
this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask
user if the user wants to fix the rest of the comments as well. if said yes,
then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40679&comment_hash=66d4e694712f21acfff2cc4d232c2bb56d2b0a80b30c284eb1de1e13b72f1b29&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40679&comment_hash=66d4e694712f21acfff2cc4d232c2bb56d2b0a80b30c284eb1de1e13b72f1b29&reaction=dislike'>👎</a>
--
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]