rusackas commented on code in PR #44031:
URL: https://github.com/apache/superset/pull/44031#discussion_r3984628078
##########
superset-frontend/src/utils/downloadAsPivotExcel.test.ts:
##########
@@ -124,12 +128,27 @@ test('leaves date-shaped strings as text rather than
reinterpreting them as date
expect(sheet.C1).toMatchObject({ t: 's', v: 'not-a-date' });
});
-test('should log an error and return early when table element is not found',
() => {
+test('logs an error, warns the user via the bound toast callback, and returns
early when table element is not found', () => {
jest.spyOn(document, 'querySelector').mockReturnValue(null);
+ const addWarningToast = jest.fn();
- exportPivotExcel('.non-existent-selector', 'test-file');
+ exportPivotExcel('.non-existent-selector', 'test-file', addWarningToast);
expect(logging.error as jest.Mock).toHaveBeenCalledWith(
'[exportPivotExcel] No element found for selector:
".non-existent-selector"',
);
+ // Passed in already bound to dispatch (e.g. via `useToasts()`), so calling
+ // it directly is what actually renders the toast -- unlike the raw action
+ // creator, which only builds a Redux action object.
+ expect(addWarningToast).toHaveBeenCalledWith(
Review Comment:
Will investigate on the follow-up PR.
--
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]