-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
140 additions
and
67 deletions.
There are no files selected for viewing
This file contains 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 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 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,66 @@ | ||
import { screen } from '@testing-library/react'; | ||
import AppRouter from './AppRouter'; | ||
import { componentRender } from '@/shared/lib/tests/componentRender/componentRender'; | ||
import { getRouteAbout, getRouteAdminPanel, getRouteProfile } from '@/shared/const/router'; | ||
import { UserRole } from '@/entities/User'; | ||
|
||
describe('AppRouter', () => { | ||
test('Test render', async () => { | ||
componentRender(<AppRouter />, { | ||
route: getRouteAbout(), | ||
}); | ||
const page = await screen.findByTestId('AboutPage'); | ||
expect(page).toBeInTheDocument(); | ||
}); | ||
test('no page foundN', async () => { | ||
componentRender(<AppRouter />, { | ||
route: '/dadsdsad', | ||
}); | ||
const page = await screen.findByTestId('NotFoundPage'); | ||
expect(page).toBeInTheDocument(); | ||
}); | ||
test('redirect no auth to main page', async () => { | ||
componentRender(<AppRouter />, { | ||
route: getRouteProfile('1'), | ||
}); | ||
|
||
const page = await screen.findByTestId('MainPage'); | ||
expect(page).toBeInTheDocument(); | ||
}); | ||
|
||
test('access to profile', async () => { | ||
componentRender(<AppRouter />, { | ||
route: getRouteProfile('1'), | ||
initialState: { | ||
user: { _inited: true, authData: {} }, | ||
}, | ||
}); | ||
|
||
const page = await screen.findByTestId('ProfilePage'); | ||
expect(page).toBeInTheDocument(); | ||
}); | ||
|
||
test('access denied (no roles)', async () => { | ||
componentRender(<AppRouter />, { | ||
route: getRouteAdminPanel(), | ||
initialState: { | ||
user: { _inited: true, authData: {} }, | ||
}, | ||
}); | ||
|
||
const page = await screen.findByTestId('ForbiddenPage'); | ||
expect(page).toBeInTheDocument(); | ||
}); | ||
|
||
test('access granted (have roles)', async () => { | ||
componentRender(<AppRouter />, { | ||
route: getRouteAdminPanel(), | ||
initialState: { | ||
user: { _inited: true, authData: { roles: [UserRole.ADMIN] } }, | ||
}, | ||
}); | ||
|
||
const page = await screen.findByTestId('AdminPanelPage'); | ||
expect(page).toBeInTheDocument(); | ||
}); | ||
}); |
This file contains 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 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 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 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 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 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 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 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
2 changes: 1 addition & 1 deletion
2
src/pages/ArticlesPage/model/services/initArticlesPage/initArticlesPage.ts
This file contains 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 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 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 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 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 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 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 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.