Skip to content

Commit 98cabfd

Browse files
sadpandajoeclaude
andcommitted
test(navbar): assert down-chevron icon identity on navbar dropdowns
RightMenu.test.tsx and useThemeMenuItems.test.tsx passed regardless of whether the caret used Icons.DownOutlined or Icons.CaretDownOutlined, so the earlier regression (and this fix) went uncaught. Add a data-icon/anticon-down assertion for each of the four dropdown call sites (Menu, RightMenu x2, useThemeMenuItems, LanguagePicker) so a future icon swap fails the suite instead of only being caught visually. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 065d11f commit 98cabfd

4 files changed

Lines changed: 62 additions & 0 deletions

File tree

superset-frontend/src/features/home/LanguagePicker.test.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,13 @@ test('should render the items', async () => {
6767
expect(await screen.findByText('English')).toBeInTheDocument();
6868
expect(await screen.findByText('Italian')).toBeInTheDocument();
6969
});
70+
71+
test('renders the down-chevron caret icon, not the caret glyph (regression #43531)', async () => {
72+
render(<TestLanguagePicker {...mockedProps} />, {
73+
useRouter: true,
74+
});
75+
const menuItem = await screen.findByRole('menuitem');
76+
const caret = menuItem.querySelector('.ant-menu-item-icon');
77+
expect(caret).toHaveClass('anticon-down');
78+
expect(caret?.querySelector('svg')).toHaveAttribute('data-icon', 'down');
79+
});

superset-frontend/src/features/home/Menu.test.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,20 @@ test('should render all the top navbar menu items', async () => {
387387
});
388388
});
389389

390+
test('renders the down-chevron caret icon on top-level category dropdowns, not the caret glyph (regression #43531)', async () => {
391+
useSelectorMock.mockReturnValue({ roles: user.roles });
392+
render(<Menu {...mockedProps} />, {
393+
useRedux: true,
394+
useQueryParams: true,
395+
useRouter: true,
396+
useTheme: true,
397+
});
398+
const sources = await screen.findByText('Sources');
399+
const caret = sources.closest('li')?.querySelector('.ant-menu-item-icon');
400+
expect(caret).toHaveClass('anticon-down');
401+
expect(caret?.querySelector('svg')).toHaveAttribute('data-icon', 'down');
402+
});
403+
390404
test('should render the top navbar child menu items', async () => {
391405
useSelectorMock.mockReturnValue({ roles: user.roles });
392406
const {

superset-frontend/src/features/home/RightMenu.test.tsx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,34 @@ test('If there is NOT a DB with allow_file_upload set as True the option should
384384
);
385385
});
386386

387+
test('renders the down-chevron caret icon on the "+" and Settings dropdowns, not the caret glyph (regression #43531)', async () => {
388+
const mockedProps = createProps();
389+
resetUseSelectorMock();
390+
render(<RightMenu {...mockedProps} />, {
391+
useRedux: true,
392+
useQueryParams: true,
393+
useRouter: true,
394+
useTheme: true,
395+
});
396+
397+
const newDropdownIcon = screen.getByTestId('new-dropdown-icon');
398+
const newCaret = newDropdownIcon
399+
.closest('li')
400+
?.querySelector('.ant-menu-item-icon');
401+
expect(newCaret).toHaveClass('anticon-down');
402+
expect(newCaret?.querySelector('svg')).toHaveAttribute('data-icon', 'down');
403+
404+
const settings = await screen.findByText(/Settings/i);
405+
const settingsCaret = settings
406+
.closest('li')
407+
?.querySelector('.ant-menu-item-icon');
408+
expect(settingsCaret).toHaveClass('anticon-down');
409+
expect(settingsCaret?.querySelector('svg')).toHaveAttribute(
410+
'data-icon',
411+
'down',
412+
);
413+
});
414+
387415
test('Logs out and clears local storage item redux', async () => {
388416
const mockedProps = createProps();
389417
resetUseSelectorMock();

superset-frontend/src/hooks/useThemeMenuItems.test.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,4 +271,14 @@ describe('useThemeMenuItems', () => {
271271

272272
expect(divider).toBeNull();
273273
});
274+
275+
test('renders the down-chevron caret icon, not the caret glyph (regression #43531)', async () => {
276+
renderThemeMenu();
277+
278+
const menuItem = await screen.findByRole('menuitem');
279+
const caret = menuItem.querySelector('.ant-menu-item-icon');
280+
281+
expect(caret).toHaveClass('anticon-down');
282+
expect(caret?.querySelector('svg')).toHaveAttribute('data-icon', 'down');
283+
});
274284
});

0 commit comments

Comments
 (0)