rusackas commented on code in PR #42910: URL: https://github.com/apache/superset/pull/42910#discussion_r4119026002
########## superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberPeriodOverPeriod/PopKPI.test.tsx: ########## @@ -0,0 +1,106 @@ +/** + * 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 { render, screen } from 'spec/helpers/testing-library'; +import PopKPI from './PopKPI'; +import { PopKPIProps } from './types'; + +const baseProps: PopKPIProps = { + height: 200, + width: 400, + data: [], + metrics: [], + metricName: 'Sales', + showMetricName: true, + headerText: '', + boldText: true, + bigNumber: '120', + prevNumber: '100', + valueDifference: '20', + percentDifferenceFormattedString: '20%', + compType: 'r', + percentDifferenceNumber: 0.2, + subtitleFontSize: 0.15, + shift: '', + headerFontSize: 'l', + subheaderFontSize: 'm', + comparisonColorEnabled: true, +}; + +test('renders the up arrow and metric values when the metric increased', () => { + render(<PopKPI {...baseProps} />); + + expect(screen.getByText('↑')).toBeInTheDocument(); + expect(screen.getByText('120')).toBeInTheDocument(); + expect(screen.getByText('Sales')).toBeInTheDocument(); +}); + +test('renders the down arrow when the metric decreased', () => { + render( + <PopKPI + {...baseProps} + percentDifferenceNumber={-0.2} + valueDifference="-20" + />, + ); + + expect(screen.getByText('↓')).toBeInTheDocument(); +}); Review Comment: Good catch, fixed. Added the assertion on the -20 value text next to the arrow. ########## superset-frontend/src/explore/components/controls/BulletRangeColorsControl/index.tsx: ########## @@ -0,0 +1,114 @@ +/** + * 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 { t } from '@apache-superset/core/translation'; +import { styled } from '@apache-superset/core/theme'; +import { Button } from '@superset-ui/core/components'; +import ControlHeader from '../../ControlHeader'; +import ColorPickerControl from '../ColorPickerControl'; +import type { ColorPickerValue } from '../ColorPickerControl'; +import { BulletRangeColorsControlProps } from './types'; + +const RangeRow = styled.div` + display: flex; + align-items: center; + gap: ${({ theme }) => theme.sizeUnit * 2}px; + margin-bottom: ${({ theme }) => theme.sizeUnit}px; +`; + +const RangeLabel = styled.span` + min-width: 90px; + color: ${({ theme }) => theme.colorTextSecondary}; + font-size: ${({ theme }) => theme.fontSizeSM}px; +`; + +const parseRanges = (ranges?: string): number[] => + (ranges ?? '') + .split(',') + .map(part => part.trim()) + .filter(part => part !== '') + .map(Number) + .filter(range => Number.isFinite(range)); Review Comment: Agreed, this one's the exact class of bug we already found once in this PR (the Infinity-vs-NaN mismatch). Dropped parseRanges and imported tokenizeToNumericArray from Bullet/utils.ts directly (newly exported from the plugin's public barrel) so there's one tokenizer, not two to keep in sync. -- 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]
