-
Notifications
You must be signed in to change notification settings - Fork 7
Add subitem support to MobileNavigation #1071
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
IhGori
wants to merge
1
commit into
main
Choose a base branch
from
feature/mobile-navigation-subitems-12015175150653333810
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| import { describe, test, expect } from 'vitest'; | ||
| import MobileNavigation from '../components/MobileNavigation.vue'; | ||
| import { mount } from '@vue/test-utils'; | ||
|
|
||
| const mockedData = [ | ||
| { | ||
| label: 'Início', | ||
| icon: 'home-outline', | ||
| route: { | ||
| path: '/home', | ||
| name: 'home' | ||
| }, | ||
| }, | ||
| { | ||
| label: 'Agendamentos', | ||
| icon: 'calendar-outline', | ||
| items: [ | ||
| { | ||
| label: 'Categorias', | ||
| route: { | ||
| path: '/categories', | ||
| name: 'index-categories', | ||
| }, | ||
| }, | ||
| ], | ||
| }, | ||
| ]; | ||
|
|
||
| describe('MobileNavigation subitems', () => { | ||
| test('renders items with subitems correctly', async () => { | ||
| const wrapper = mount(MobileNavigation, { | ||
| global: { | ||
| stubs: { | ||
| 'cds-icon': true, | ||
| 'cds-avatar': true, | ||
| 'router-link': { template: '<a><slot /></a>' }, | ||
| }, | ||
| }, | ||
| props: { | ||
| items: mockedData, | ||
| user: { | ||
| name: 'Joana Mendes', | ||
| role: 'Administradora', | ||
| } | ||
| }, | ||
| }); | ||
|
|
||
| // Check if the parent item is rendered | ||
| expect(wrapper.text()).toContain('Agendamentos'); | ||
|
|
||
| // Check if subitems are initially not rendered | ||
| expect(wrapper.text()).not.toContain('Categorias'); | ||
|
|
||
| // Find the parent item with subitems and click it to expand | ||
| const parentItem = wrapper.findAll('.mobile-navigation__sidebar-item').filter(w => w.text().includes('Agendamentos'))[0]; | ||
| await parentItem.trigger('click'); | ||
|
|
||
| // Check if subitems are now rendered | ||
| expect(wrapper.text()).toContain('Categorias'); | ||
|
|
||
| // Check if isActive correctly identifies active parent when subitem is active | ||
| const subitem = wrapper.find('.mobile-navigation__sidebar-subitem'); | ||
| // We can't easily test router-link active state here without a real router, | ||
| // but we can test the isActive logic if we mount with an activeItem that is a subitem. | ||
| }); | ||
|
|
||
| test('identifies active parent when subitem is active', async () => { | ||
| const subitem = mockedData[1].items[0]; | ||
| const wrapper = mount(MobileNavigation, { | ||
| global: { | ||
| stubs: { | ||
| 'cds-icon': true, | ||
| 'cds-avatar': true, | ||
| 'router-link': { template: '<a><slot /></a>' }, | ||
| }, | ||
| }, | ||
| props: { | ||
| items: mockedData, | ||
| activeItem: subitem, | ||
| user: { | ||
| name: 'Joana Mendes', | ||
| role: 'Administradora', | ||
| } | ||
| }, | ||
| }); | ||
|
|
||
| // The parent item "Agendamentos" should have the active class | ||
| const parentItem = wrapper.findAll('.mobile-navigation__sidebar-item').filter(w => w.text().includes('Agendamentos'))[0]; | ||
| expect(parentItem.classes()).toContain('mobile-navigation__sidebar-item--active'); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cursor: pointerausente no item pai (elementodiv)Antes desta PR, o item era renderizado como
<router-link>(que gera uma tag<a>), a qual possuicursor: pointerpor padrão. Agora que itens com subitems são renderizados como<div>, eles herdam o cursor padrão de texto (default), removendo a indicação visual de que o elemento é clicável.A classe
.mobile-navigation__sidebar-itemno CSS base não definecursor: pointerexplicitamente. O único elemento que define é__sidebar-logout.Sugestão: adicionar
cursor: pointerao bloco base de__sidebar-itemno SCSS: