Skip to content
Merged
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
40 changes: 20 additions & 20 deletions superset-frontend/src/hooks/useThemeMenuItems.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ describe('useThemeMenuItems', () => {
test('renders Light and Dark theme options by default', async () => {
renderThemeMenu();

userEvent.hover(await screen.findByRole('menuitem'));
await userEvent.hover(await screen.findByRole('menuitem'));
const menu = await findMenuWithText('Light');

expect(within(menu!).getByText('Light')).toBeInTheDocument();
Expand All @@ -79,7 +79,7 @@ describe('useThemeMenuItems', () => {

test('does not render Match system option when allowOSPreference is false', async () => {
renderThemeMenu({ ...defaultProps, allowOSPreference: false });
userEvent.hover(await screen.findByRole('menuitem'));
await userEvent.hover(await screen.findByRole('menuitem'));

await waitFor(() => {
expect(screen.queryByText('Match system')).not.toBeInTheDocument();
Expand All @@ -89,7 +89,7 @@ describe('useThemeMenuItems', () => {
test('renders with allowOSPreference as true by default', async () => {
renderThemeMenu();

userEvent.hover(await screen.findByRole('menuitem'));
await userEvent.hover(await screen.findByRole('menuitem'));
const menu = await findMenuWithText('Match system');

expect(within(menu).getByText('Match system')).toBeInTheDocument();
Expand All @@ -103,7 +103,7 @@ describe('useThemeMenuItems', () => {
onClearLocalSettings: mockClear,
});

userEvent.hover(await screen.findByRole('menuitem'));
await userEvent.hover(await screen.findByRole('menuitem'));
const menu = await findMenuWithText('Clear local theme');

expect(within(menu).getByText('Clear local theme')).toBeInTheDocument();
Expand All @@ -117,7 +117,7 @@ describe('useThemeMenuItems', () => {
onClearLocalSettings: mockClear,
});

userEvent.hover(await screen.findByRole('menuitem'));
await userEvent.hover(await screen.findByRole('menuitem'));

await waitFor(() => {
expect(screen.queryByText('Clear local theme')).not.toBeInTheDocument();
Expand All @@ -128,9 +128,9 @@ describe('useThemeMenuItems', () => {
const mockSet = jest.fn();
renderThemeMenu({ ...defaultProps, setThemeMode: mockSet });

userEvent.hover(await screen.findByRole('menuitem'));
await userEvent.hover(await screen.findByRole('menuitem'));
const menu = await findMenuWithText('Light');
userEvent.click(within(menu).getByText('Light'));
await userEvent.click(within(menu).getByText('Light'));

expect(mockSet).toHaveBeenCalledWith(ThemeMode.DEFAULT);
});
Expand All @@ -139,9 +139,9 @@ describe('useThemeMenuItems', () => {
const mockSet = jest.fn();
renderThemeMenu({ ...defaultProps, setThemeMode: mockSet });

userEvent.hover(await screen.findByRole('menuitem'));
await userEvent.hover(await screen.findByRole('menuitem'));
const menu = await findMenuWithText('Dark');
userEvent.click(within(menu).getByText('Dark'));
await userEvent.click(within(menu).getByText('Dark'));

expect(mockSet).toHaveBeenCalledWith(ThemeMode.DARK);
});
Expand All @@ -150,9 +150,9 @@ describe('useThemeMenuItems', () => {
const mockSet = jest.fn();
renderThemeMenu({ ...defaultProps, setThemeMode: mockSet });

userEvent.hover(await screen.findByRole('menuitem'));
await userEvent.hover(await screen.findByRole('menuitem'));
const menu = await findMenuWithText('Match system');
userEvent.click(within(menu).getByText('Match system'));
await userEvent.click(within(menu).getByText('Match system'));

expect(mockSet).toHaveBeenCalledWith(ThemeMode.SYSTEM);
});
Expand All @@ -165,9 +165,9 @@ describe('useThemeMenuItems', () => {
onClearLocalSettings: mockClear,
});

userEvent.hover(await screen.findByRole('menuitem'));
await userEvent.hover(await screen.findByRole('menuitem'));
const menu = await findMenuWithText('Clear local theme');
userEvent.click(within(menu).getByText('Clear local theme'));
await userEvent.click(within(menu).getByText('Clear local theme'));

expect(mockClear).toHaveBeenCalledTimes(1);
});
Expand Down Expand Up @@ -195,7 +195,7 @@ describe('useThemeMenuItems', () => {
test('renders Theme group header', async () => {
renderThemeMenu();

userEvent.hover(await screen.findByRole('menuitem'));
await userEvent.hover(await screen.findByRole('menuitem'));
const menu = await findMenuWithText('Theme');

expect(within(menu).getByText('Theme')).toBeInTheDocument();
Expand All @@ -204,7 +204,7 @@ describe('useThemeMenuItems', () => {
test('renders sun icon for Light theme option', async () => {
renderThemeMenu();

userEvent.hover(await screen.findByRole('menuitem'));
await userEvent.hover(await screen.findByRole('menuitem'));
const menu = await findMenuWithText('Light');
const lightOption = within(menu).getByText('Light').closest('li');

Expand All @@ -214,7 +214,7 @@ describe('useThemeMenuItems', () => {
test('renders moon icon for Dark theme option', async () => {
renderThemeMenu();

userEvent.hover(await screen.findByRole('menuitem'));
await userEvent.hover(await screen.findByRole('menuitem'));
const menu = await findMenuWithText('Dark');
const darkOption = within(menu).getByText('Dark').closest('li');

Expand All @@ -224,7 +224,7 @@ describe('useThemeMenuItems', () => {
test('renders format-painter icon for Match system option', async () => {
renderThemeMenu({ ...defaultProps, allowOSPreference: true });

userEvent.hover(await screen.findByRole('menuitem'));
await userEvent.hover(await screen.findByRole('menuitem'));
const menu = await findMenuWithText('Match system');
const matchOption = within(menu).getByText('Match system').closest('li');

Expand All @@ -240,7 +240,7 @@ describe('useThemeMenuItems', () => {
onClearLocalSettings: jest.fn(),
});

userEvent.hover(await screen.findByRole('menuitem'));
await userEvent.hover(await screen.findByRole('menuitem'));
const menu = await findMenuWithText('Clear local theme');
const clearOption = within(menu)
.getByText('Clear local theme')
Expand All @@ -256,7 +256,7 @@ describe('useThemeMenuItems', () => {
onClearLocalSettings: jest.fn(),
});

userEvent.hover(await screen.findByRole('menuitem'));
await userEvent.hover(await screen.findByRole('menuitem'));

const menu = await findMenuWithText('Clear local theme');
const divider = within(menu).queryByRole('separator');
Expand All @@ -267,7 +267,7 @@ describe('useThemeMenuItems', () => {
test('does not render divider when clear option is not present', async () => {
renderThemeMenu({ ...defaultProps });

userEvent.hover(await screen.findByRole('menuitem'));
await userEvent.hover(await screen.findByRole('menuitem'));
const divider = document.querySelector('.ant-menu-item-divider');

expect(divider).toBeNull();
Expand Down
Loading