Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import React from 'react';
import { renderWithReduxStore } from '../mocks';
import { SettingsMenu } from './settings_menu';
import { screen, waitFor } from '@testing-library/react';
import { screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';

describe('settings menu', () => {
Expand Down Expand Up @@ -41,17 +41,6 @@ describe('settings menu', () => {
};
};

afterEach(() => {
onCloseMock.mockClear();
});

it('should call onClose when popover closes after toggling', async () => {
const { toggleAutoApply } = renderSettingsMenu();
await toggleAutoApply();

await waitFor(() => expect(onCloseMock).toHaveBeenCalledTimes(1));
});

it('should toggle auto-apply', async () => {
const { toggleAutoApply, isAutoApplyOn } = renderSettingsMenu();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,13 @@ export function SettingsMenu({
const dispatch = useLensDispatch();

const toggleAutoApply = useCallback(() => {
onClose();
writeToStorage(
new Storage(localStorage),
AUTO_APPLY_DISABLED_STORAGE_KEY,
String(autoApplyEnabled)
);
dispatch(autoApplyEnabled ? disableAutoApply() : enableAutoApply());
}, [dispatch, autoApplyEnabled, onClose]);
}, [dispatch, autoApplyEnabled]);

return (
<EuiWrappingPopover
Expand Down