-
Notifications
You must be signed in to change notification settings - Fork 0
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
Feature: #22 TopMenu #60
base: development
Are you sure you want to change the base?
Conversation
7014fe2
to
c56ba3b
Compare
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.
This file will be changed in the test PRs, So it doesn't need to be reviewed.
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.
Please move this component to the shared/components/TopMenu
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.
Done.
src/components/Dropdown/DropdownDivider/DropdownDivider.spec.tsx
Outdated
Show resolved
Hide resolved
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.
This file will be changed in the test PRs, So it doesn't need to be reviewed.
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.
This file will be changed in the test PRs, So it doesn't need to be reviewed.
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.
Property 'pic' does not exist on type '{ address: string; } & { name?: string | null | undefined; email?: string | null | undefined; image?: string | null | undefined; }'.
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.
And what kind of name is TopMenuUserMenu? two times menu?!
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.
This test failed. 4 fails! Also, you did it wrongly. You should make a mock instance and then run mockReturnValue or reset or clear it. You can run: useSession.mockReturnValue({ data: null }); directly because you didn't mock it!
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.
Thank you, All of the above-mentioned items have been done except the item regarding tests which I will solve in the test issue.
src/styles/fonts.test.ts
Outdated
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.
Here I changed the Roboto font to Roboto_Flex font because the Nextjs document recommended using variable fonts because of performance. So I replaced Roboto with Roboto_Flex which is a variable font in the main fonts file and continuously in its test file
src/styles/fonts.ts
Outdated
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.
Here I changed the Roboto font to Roboto_Flex font because the Nextjs document recommended using variable fonts because of performance. So I replaced Roboto with Roboto_Flex which is a variable font in the main fonts file
src/utils/i18n/client.js
Outdated
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.
I tried to fix the i18next problem. So, these are not complete please don't review them. I should work on it in the future
src/utils/i18n/i18n.js
Outdated
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.
I tried to fix the i18next problem. So, these are not complete please don't review them. I should work on it in the future.
src/utils/i18n/index.js
Outdated
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.
These changes are because of my vscode so I think this file doesn't need review.
@@ -23,7 +23,7 @@ const NavbarToggle = forwardRef<any, NavbarToggleProps>( | |||
id={id} | |||
className={className} | |||
data-testid={testId} | |||
onClick={onClick} | |||
// onClick={onClick} |
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.
Why did you do this?
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.
Because, The Navbar Toggle flowbite component has a hidden onClick function, and there is no way to override it. So adding onClick will deactivate the default onClick. Finally, it will not work as a toggle in the navbar.
66a5488
to
99326ff
Compare
9024fa9
to
cb1491c
Compare
99326ff
to
076779d
Compare
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.
There are some problems here:
When we switch to persian and then english, some data are still in Persian and vice versa.
In the persian the top menu home link is stuck to the next item.
When we are switching from a language to another one the login/register button is still on the prior language.
|
||
describe('TopMenuUserMenu', () => { | ||
afterEach(() => { | ||
jest.clearAllMocks(); // Clear mock calls after each test |
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.
You have to make an instance and then reset it here:
useSessionMock.clearMock()
|
||
// Mock the useSession hook | ||
jest.mock('next-auth/react', () => ({ | ||
useSession: jest.fn(), |
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.
const useSessionMock = jest.fn();
useSession: useSessionMock
....
Do the same thing also for login and logout methods.
|
||
describe('TopMenuUserMenu', () => { | ||
afterEach(() => { | ||
jest.clearAllMocks(); // Clear mock calls after each test |
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.
This comment is not clearing anything here.
}); | ||
|
||
it('renders login button when user is not authenticated', () => { | ||
useSession.mockReturnValue({ data: null }); // Mock unauthenticated session |
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.
This is not a real mock and is running the real implementation of the method because you didn't mock it so this reset is not working here.
|
||
it('renders user menu when user is authenticated', () => { | ||
const mockUser = { | ||
name: 'Bonnie Green', |
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.
mockUser should be public and then it could be used also in other tests.
label={ | ||
<Avatar | ||
alt={`${session.user.name} profile picture`} | ||
placeholderInitials={session.user.name |
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.
You shouldn't do this kind of things in the JSX.
const { getByText } = render(<TopUserMenu />); | ||
fireEvent.click(getByText('Sign Out')); | ||
await waitFor(() => { | ||
expect(signOut).toHaveBeenCalled(); |
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.
How many times? With which data?!
useSession.mockReturnValue({ data: null }); // Mock unauthenticated session | ||
const { getByText } = render(<TopUserMenu />); | ||
fireEvent.click(getByText('Login / Register')); | ||
expect(signIn).toHaveBeenCalled(); |
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.
How many times? With which data?!
email: '[email protected]', | ||
pic: 'https://flowbite.com/docs/images/people/profile-picture-5.jpg', | ||
}; | ||
useSession.mockReturnValue({ data: { user: mockUser } }); // Mock authenticated session |
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.
Remove ChatGPT comments.
}); | ||
|
||
it('renders user menu when user is authenticated', () => { | ||
const mockUser = { |
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.
Declare the mock user as a public user when use are using it in some test with the same data.
No description provided.