codeant-ai-for-open-source[bot] commented on code in PR #41031: URL: https://github.com/apache/superset/pull/41031#discussion_r3533032662
########## superset-frontend/src/SqlLab/components/ResultSet/buildResultsGridThemeOverrides.test.ts: ########## @@ -0,0 +1,94 @@ +/** + * 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 type { SupersetTheme } from '@apache-superset/core/theme'; +import { buildResultsGridThemeOverrides } from './buildResultsGridThemeOverrides'; + +test('returns undefined when no resultsGrid tokens are set', () => { + const theme = {} as SupersetTheme; + expect(buildResultsGridThemeOverrides(theme)).toBeUndefined(); +}); + +test('maps resultsGridHeaderFontSize to headerFontSize', () => { + const theme = { resultsGridHeaderFontSize: 14 } as SupersetTheme; + expect(buildResultsGridThemeOverrides(theme)).toEqual({ + headerFontSize: 14, + }); +}); + +test('maps resultsGridHeaderFontWeight to headerFontWeight', () => { + const theme = { resultsGridHeaderFontWeight: 700 } as SupersetTheme; + expect(buildResultsGridThemeOverrides(theme)).toEqual({ + headerFontWeight: 700, + }); +}); + +test('maps resultsGridRowHeight to both rowHeight and headerHeight', () => { + const theme = { resultsGridRowHeight: 40 } as SupersetTheme; + expect(buildResultsGridThemeOverrides(theme)).toEqual({ + rowHeight: 40, + headerHeight: 40, + }); +}); + +test('maps resultsGridBorderRadius to both borderRadius and wrapperBorderRadius', () => { + const theme = { resultsGridBorderRadius: 8 } as SupersetTheme; + expect(buildResultsGridThemeOverrides(theme)).toEqual({ + borderRadius: 8, + wrapperBorderRadius: 8, + }); +}); + +test('maps resultsGridNoStriping to oddRowBackgroundColor transparent', () => { + const theme = { resultsGridNoStriping: true } as SupersetTheme; + expect(buildResultsGridThemeOverrides(theme)).toEqual({ + oddRowBackgroundColor: 'transparent', + }); +}); + +test('does not map resultsGridNoStriping when false', () => { + const theme = { resultsGridNoStriping: false } as SupersetTheme; + expect(buildResultsGridThemeOverrides(theme)).toBeUndefined(); +}); + +test('maps all tokens together when all are set', () => { + const theme = { + resultsGridHeaderFontSize: 12, + resultsGridHeaderFontWeight: 600, + resultsGridRowHeight: 36, + resultsGridBorderRadius: 4, + resultsGridNoStriping: true, + } as SupersetTheme; + expect(buildResultsGridThemeOverrides(theme)).toEqual({ + headerFontSize: 12, + headerFontWeight: 600, + rowHeight: 36, + headerHeight: 36, + borderRadius: 4, + wrapperBorderRadius: 4, + oddRowBackgroundColor: 'transparent', + }); +}); + +test('ignores non-number values for numeric tokens', () => { + const theme = { + resultsGridRowHeight: '40' as any, Review Comment: **Suggestion:** Replace the `any` cast with a concrete incompatible type (for example a string-typed field definition) so the test still validates non-numeric input without using `any`. [custom_rule] **Severity Level:** Minor ⚠️ <details> <summary><b>Why it matters? 🤔 </b></summary> The new TypeScript test code uses `as any`, which is directly prohibited by the rule requiring concrete types instead of `any`. The snippet is in the final file state, so this is a real violation. </details> [](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=a03386e479784ec9b32e15e30b619bce&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=a03386e479784ec9b32e15e30b619bce&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) *(Use Cmd/Ctrl + Click for best experience)* <details> <summary><b>Prompt for AI Agent 🤖 </b></summary> ```mdx This is a comment left during a code review. **Path:** superset-frontend/src/SqlLab/components/ResultSet/buildResultsGridThemeOverrides.test.ts **Line:** 90:90 **Comment:** *Custom Rule: Replace the `any` cast with a concrete incompatible type (for example a string-typed field definition) so the test still validates non-numeric input without using `any`. 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%2F41031&comment_hash=297610c80d77b62bef537efdeee76b7b1c45556810c1679df236066e3efa1080&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41031&comment_hash=297610c80d77b62bef537efdeee76b7b1c45556810c1679df236066e3efa1080&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]
