Skip to content

Commit 332bbf5

Browse files
committed
fix the tests
1 parent f371415 commit 332bbf5

File tree

4 files changed

+15
-17
lines changed

4 files changed

+15
-17
lines changed

src/ui/Router.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@ const ErrorBoundary: React.FC<ErrorBoundaryProps> = ({ children }) => {
201201

202202
export const Router: React.FC = () => {
203203
const { isLoggedIn } = useAuth();
204-
console.log(isLoggedIn);
205204
const router = isLoggedIn
206205
? authenticatedRouter
207206
: isLoggedIn === null

src/ui/components/AuthContext/AuthCallbackHandler.page.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,6 @@ export const AuthCallback: React.FC = () => {
3434
setTimeout(() => {
3535
handleCallback();
3636
}, 100);
37-
38-
// Cleanup function
39-
return () => {
40-
console.log('Callback component unmounting'); // Debug log 8
41-
};
4237
}, [instance, navigate]);
4338

4439
return <FullScreenLoader />;

src/ui/pages/profile/ManageProfileComponent.test.tsx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ describe('ManageProfileComponent tests', () => {
3838

3939
await renderComponent(getProfile, setProfile);
4040

41-
expect(screen.getByText(/Loading.../i)).toBeInTheDocument();
41+
expect(screen.getByTestId('profile-loading')).toBeInTheDocument();
4242
});
4343

4444
it('renders profile form after successfully fetching profile', async () => {
@@ -53,11 +53,11 @@ describe('ManageProfileComponent tests', () => {
5353

5454
await renderComponent(getProfile, setProfile);
5555

56-
expect(screen.getByLabelText('Display Name')).toHaveValue('John Doe');
57-
expect(screen.getByLabelText('First Name')).toHaveValue('John');
58-
expect(screen.getByLabelText('Last Name')).toHaveValue('Doe');
59-
expect(screen.getByLabelText('Email')).toHaveValue('[email protected]');
60-
expect(screen.getByLabelText('Discord Username')).toHaveValue('johndoe#1234');
56+
expect(screen.getByTestId('edit-displayName')).toHaveValue('John Doe');
57+
expect(screen.getByTestId('edit-firstName')).toHaveValue('John');
58+
expect(screen.getByTestId('edit-lastName')).toHaveValue('Doe');
59+
expect(screen.getByTestId('edit-email')).toHaveValue('[email protected]');
60+
expect(screen.getByTestId('edit-discordUsername')).toHaveValue('johndoe#1234');
6161
});
6262

6363
it('handles profile fetch failure gracefully', async () => {
@@ -67,7 +67,6 @@ describe('ManageProfileComponent tests', () => {
6767

6868
await renderComponent(getProfile, setProfile);
6969

70-
expect(screen.getByText(/Failed to load user profile/i)).toBeInTheDocument();
7170
expect(notificationsMock).toHaveBeenCalledWith(
7271
expect.objectContaining({
7372
message: 'Failed to load user profile',
@@ -94,9 +93,9 @@ describe('ManageProfileComponent tests', () => {
9493
const user = userEvent.setup();
9594

9695
// Edit fields
97-
await user.clear(screen.getByLabelText('Display Name'));
98-
await user.type(screen.getByLabelText('Display Name'), 'Jane Doe');
99-
await user.type(screen.getByLabelText('Discord Username'), 'janedoe#5678');
96+
await user.clear(screen.getByTestId('edit-displayName'));
97+
await user.type(screen.getByTestId('edit-displayName'), 'Jane Doe');
98+
await user.type(screen.getByTestId('edit-discordUsername'), 'janedoe#5678');
10099

101100
// Save changes
102101
const saveButton = screen.getByRole('button', { name: 'Save' });

src/ui/pages/profile/ManageProfileComponent.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export const ManageProfileComponent: React.FC<ManageProfileComponentProps> = ({
6262
};
6363

6464
if (userProfile === undefined) {
65-
return <LoadingOverlay visible={true} />;
65+
return <LoadingOverlay visible={true} data-testId="profile-loading" />;
6666
}
6767

6868
return (
@@ -91,6 +91,7 @@ export const ManageProfileComponent: React.FC<ManageProfileComponentProps> = ({
9191
}
9292
placeholder={userProfile?.displayName}
9393
required
94+
data-testId="edit-displayName"
9495
/>
9596
<TextInput
9697
label="First Name"
@@ -100,13 +101,15 @@ export const ManageProfileComponent: React.FC<ManageProfileComponentProps> = ({
100101
}
101102
placeholder={userProfile?.givenName}
102103
required
104+
data-testId="edit-firstName"
103105
/>
104106
<TextInput
105107
label="Last Name"
106108
value={userProfile?.surname || ''}
107109
onChange={(e) => setUserProfile((prev) => prev && { ...prev, surname: e.target.value })}
108110
placeholder={userProfile?.surname}
109111
required
112+
data-testId="edit-lastName"
110113
/>
111114
<TextInput
112115
label="Email"
@@ -115,6 +118,7 @@ export const ManageProfileComponent: React.FC<ManageProfileComponentProps> = ({
115118
placeholder={userProfile?.mail}
116119
required
117120
disabled
121+
data-testId="edit-email"
118122
/>
119123

120124
<TextInput
@@ -123,6 +127,7 @@ export const ManageProfileComponent: React.FC<ManageProfileComponentProps> = ({
123127
onChange={(e) =>
124128
setUserProfile((prev) => prev && { ...prev, discordUsername: e.target.value })
125129
}
130+
data-testId="edit-discordUsername"
126131
/>
127132

128133
<Group mt="md">

0 commit comments

Comments
 (0)