bito-code-review[bot] commented on code in PR #40817: URL: https://github.com/apache/superset/pull/40817#discussion_r3365973429
########## superset-frontend/playwright/tests/chart/handlebars-format-date.spec.ts: ########## @@ -0,0 +1,103 @@ +/** + * 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. + */ + +/** + * Regression for #32960: the `formatDate` Handlebars helper (provided by + * just-handlebars-helpers) stopped working after 4.1.2, rendering + * "i is not a function" (minified) / "moment is not a function" (dev) instead + * of the formatted date. The helper resolves `moment` lazily via + * `global.moment` / `require('moment/min/moment-with-locales')`, which the + * bundled HandlebarsViewer no longer satisfies (it switched to dayjs). + * + * This is a TDD validation test. It creates a Handlebars chart whose template + * uses `{{formatDate 'DD.MM.YYYY' ds}}` and asserts the chart renders a real + * formatted date rather than the helper error. + * + * CI green => formatDate works again; merging closes #32960. + * CI red => the bug is still live; the fix belongs in the Handlebars plugin + * (superset-frontend/plugins/plugin-chart-handlebars), e.g. by + * providing a moment-free formatDate or making moment resolvable. + */ +import { testWithAssets, expect } from '../../helpers/fixtures'; +import { apiPost } from '../../helpers/api/requests'; + +const DATASET_NAME = 'birth_names'; + +async function findDatasetIdByName(page: any, name: string): Promise<number> { Review Comment: <div> <div id="suggestion"> <div id="issue"><b>TypeScript any type violation</b></div> <div id="fix"> The `findDatasetIdByName` function uses `page: any` which violates the project's TypeScript standard prohibiting `any` types. Use the properly typed `Page` from `@playwright/test` instead. </div> <details> <summary> <b>Code suggestion</b> </summary> <blockquote>Check the AI-generated fix before applying</blockquote> <div id="code"> ``` --- superset-frontend/playwright/tests/chart/handlebars-format-date.spec.ts +++ superset-frontend/playwright/tests/chart/handlebars-format-date.spec.ts @@ -35,6 +35,7 @@ import { testWithAssets, expect } from '../../helpers/fixtures'; import { apiPost } from '../../helpers/api/requests'; +import type { Page } from '@playwright/test'; const DATASET_NAME = 'birth_names'; @@ -39,7 +40,7 @@ const DATASET_NAME = 'birth_names'; const DATASET_NAME = 'birth_names'; async function findDatasetIdByName( - page: any, + page: Page, name: string ): Promise<number> { ``` </div> </details> </div> <details> <summary><b>Citations</b></summary> <ul> <li> Rule Violated: <a href="https://github.com/apache/superset/blob/51555ab/.cursor/rules/dev-standard.mdc#L16">dev-standard.mdc:16</a> </li> <li> Rule Violated: <a href="https://github.com/apache/superset/blob/51555ab/AGENTS.md#L31">AGENTS.md:31</a> </li> </ul> </details> <small><i>Code Review Run #430de0</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]
