bito-code-review[bot] commented on code in PR #44554:
URL: https://github.com/apache/superset/pull/44554#discussion_r4097699137
##########
superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberViz.test.tsx:
##########
@@ -117,3 +117,70 @@ describe('BigNumberViz context menu', () => {
expect(ancestorHandler).not.toHaveBeenCalled();
});
});
+
+describe('BigNumberViz alignment', () => {
+ test('defaults to left alignment', () => {
+ const { container } = render(
+ <BigNumberVis
+ width={200}
+ height={100}
+ bigNumber={42}
+ headerFormatter={getNumberFormatter()}
+ headerFontSize={0.3}
+ subheaderFontSize={0.125}
+ subtitleFontSize={0.125}
+ subtitle=""
+ refs={{}}
+ />,
+ );
+
+ const textContainer = container.querySelector('.text-container');
+ expect(textContainer).toHaveStyle({ alignItems: 'flex-start' });
+ const headerLine = container.querySelector('.header-line');
+ expect(headerLine).toHaveStyle({ justifyContent: 'flex-start' });
+ });
+
+ test('centers content when headerAlignment is "center"', () => {
+ const { container } = render(
+ <BigNumberVis
+ width={200}
+ height={100}
+ bigNumber={42}
+ headerFormatter={getNumberFormatter()}
+ headerFontSize={0.3}
+ subheaderFontSize={0.125}
+ subtitleFontSize={0.125}
+ subtitle=""
+ refs={{}}
+ headerAlignment="center"
+ />,
+ );
+
+ const textContainer = container.querySelector('.text-container');
+ expect(textContainer).toHaveStyle({ alignItems: 'center' });
+ const headerLine = container.querySelector('.header-line');
+ expect(headerLine).toHaveStyle({ justifyContent: 'center' });
+ });
+
+ test('right-aligns content when headerAlignment is "right"', () => {
+ const { container } = render(
+ <BigNumberVis
+ width={200}
+ height={100}
+ bigNumber={42}
+ headerFormatter={getNumberFormatter()}
+ headerFontSize={0.3}
+ subheaderFontSize={0.125}
+ subtitleFontSize={0.125}
+ subtitle=""
+ refs={{}}
+ headerAlignment="right"
+ />,
+ );
+
+ const textContainer = container.querySelector('.text-container');
+ expect(textContainer).toHaveStyle({ alignItems: 'flex-end' });
+ const headerLine = container.querySelector('.header-line');
+ expect(headerLine).toHaveStyle({ justifyContent: 'flex-end' });
+ });
+});
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Duplicated test setup</b></div>
<div id="fix">
The three new tests duplicate the same ~13-prop `<BigNumberVis>` render,
differing only in `headerAlignment`. Extract a `renderViz(headerAlignment)`
helper so the props stay in one place and the tests only assert the alignment
mapping. Reduces divergence risk if a prop changes.
</div>
</div>
<small><i>Code Review Run #cd18eb</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]