sadpandajoe commented on code in PR #35810:
URL: https://github.com/apache/superset/pull/35810#discussion_r2529074228
##########
superset-frontend/src/components/Datasource/components/DatasourceEditor/tests/DatasourceEditorCurrency.test.tsx:
##########
@@ -33,160 +37,191 @@ const fastRender = (renderProps: typeof props) =>
initialState: { common: { currencies: ['USD', 'GBP', 'EUR'] } },
});
-// eslint-disable-next-line no-restricted-globals -- TODO: Migrate from
describe blocks
-describe('DatasourceEditor Currency Tests', () => {
- beforeEach(() => {
- fetchMock.get(DATASOURCE_ENDPOINT, [], { overwriteRoutes: true });
- });
+// Factory function for currency props - returns fresh copy to prevent test
pollution
+const createPropsWithCurrency = () => ({
+ ...props,
+ datasource: {
+ ...props.datasource,
+ metrics: [
+ {
+ ...props.datasource.metrics[0],
+ currency: { symbol: 'USD', symbolPosition: 'prefix' },
+ },
+ ...props.datasource.metrics.slice(1).map(m => ({ ...m })),
Review Comment:
1. Gets a completely NEW currency object (not a reference) so this should
be safe.
2. Tests don't mutate these metrics
3. Tests only interact via React components (no direct mutations)
--
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]