aminghadersohi commented on code in PR #44096:
URL: https://github.com/apache/superset/pull/44096#discussion_r4020508121
##########
superset-frontend/src/components/MessageToasts/Toast.test.tsx:
##########
@@ -127,3 +127,34 @@ test('a link requested through the action creator survives
to the rendered toast
expect(link).not.toBeNull();
expect(link).toHaveAttribute('href', '/explore/?slice_id=1');
});
+
+test('an action button invokes its callback and dismisses the toast', async ()
=> {
+ const onClick = jest.fn();
+ const onCloseToast = jest.fn();
+ const { getByRole } = setup({
+ toast: { ...props.toast, action: { label: 'Undo', onClick } },
+ onCloseToast,
+ });
+ fireEvent.click(getByRole('button', { name: 'Undo' }));
+ expect(onClick).toHaveBeenCalledTimes(1);
+ await waitFor(() =>
+ expect(onCloseToast).toHaveBeenCalledWith(props.toast.id),
+ );
+});
+
+test('an actionable toast remains until it is explicitly dismissed', () => {
+ jest.useFakeTimers();
+ const onCloseToast = jest.fn();
+ setup({
+ toast: {
+ ...props.toast,
+ duration: 100,
+ action: { label: 'Undo', onClick: jest.fn() },
+ },
+ onCloseToast,
+ });
+
+ act(() => jest.advanceTimersByTime(1000));
+ expect(onCloseToast).not.toHaveBeenCalled();
Review Comment:
Good catch. Added the second 200ms timer advance in 4370ed773d, so the test
crosses both the original duration timer and the delayed close callback. This
makes the regression test fail against the pre-fix Toast implementation while
continuing to pass with persistent actionable toasts.
--
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]