-
Notifications
You must be signed in to change notification settings - Fork 9
[OSDEV-1747] Check auth for SLC pages. #523
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
Merged
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
b9933a2
added auth to Contribute PL,PL Info, Search by name & address res, Se…
19255b1
added task description
4fc075d
fixed old and added new auth tests for ContributeProductionLocation.test
149d831
fixed old and added new auth tests for SearchByOsIdResult.test
5f9fe63
moved AuthLogInFromRoute to separate component
ada1ca7
added AuthLogInFromRoute.test
e83ac48
added prop types
c7e719d
removed duplicate of Settings.jsx
0f5216b
added chek to Dashboard and removed from DashboardApiBlock because is…
5f441cd
added userHasSignedIn to propTypes for Dashboard
14262b8
merged main
a81e227
corrected tests, removed const
359da3d
removed extra space
412adac
Merge branch 'main' into OSDEV-1747-check-auth-for-slc-pages
Innavin369 f889503
fixed linter
cdba2f6
reuse one import
b9779e3
linter
77a7a64
Merge branch 'main' into OSDEV-1747-check-auth-for-slc-pages
3ce9ff5
import order
47a4786
Merge branch 'main' into OSDEV-1747-check-auth-for-slc-pages
Innavin369 f378803
merged main
02c7c4b
reamed component from AuthLogInFromRoute to RequireAuthNotice
1db4e28
updated link texts
3e89a17
resolved conflict
b1902ce
removed duplication
f8dde92
added test for loader, removed comma, moved Contribute to const
7370a7a
fixed auth in ProductionLocationInfo.test
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
52 changes: 52 additions & 0 deletions
52
src/react/src/__tests__/components/RequireAuthNotice.test.js
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,52 @@ | ||
| import React from 'react'; | ||
| import { Router } from "react-router-dom"; | ||
| import { fireEvent } from '@testing-library/react'; | ||
| import history from '../../util/history'; | ||
| import renderWithProviders from '../../util/testUtils/renderWithProviders'; | ||
| import { | ||
| authLoginFormRoute, | ||
| } from '../../util/constants'; | ||
| import RequireAuthNotice from '../../components/RequireAuthNotice'; | ||
|
|
||
| describe('RequireAuthNotice component', () => { | ||
| const renderComponent = (preloadedState = {}) => | ||
| renderWithProviders( | ||
| <Router history={history}> | ||
| <RequireAuthNotice {...preloadedState}/> | ||
| </Router> | ||
| ); | ||
|
|
||
| beforeEach(() => { | ||
| jest.clearAllMocks(); | ||
| }); | ||
|
|
||
| test("renders component with default params", () => { | ||
| const defaultTitle = 'Unauthorized Access'; | ||
| const defaultText = 'Log in to contribute to Open Supply Hub'; | ||
|
|
||
| const { getByText, getByRole } = renderComponent(); | ||
| const titleEl = getByRole("heading", { level: 2 }); | ||
| const titleText = titleEl.textContent.trim(); | ||
| const linkEl = getByRole("link", { name: defaultText }); | ||
|
|
||
| expect(titleEl).toBeInTheDocument(); | ||
| expect(defaultTitle).toBe(titleText); | ||
| expect(getByText(defaultText)).toBeInTheDocument(); | ||
|
|
||
| fireEvent.click(linkEl); | ||
| expect(history.location.pathname).toBe(authLoginFormRoute); | ||
| }); | ||
|
|
||
| test("renders component with set params", () => { | ||
| const expectedTitle = "Test title"; | ||
| const expectedText = "Test text"; | ||
| const preloadedState = { | ||
| title: expectedTitle, | ||
| text: expectedText, | ||
| } | ||
| const { getByText } = renderComponent(preloadedState); | ||
|
|
||
| expect(getByText(expectedTitle)).toBeInTheDocument(); | ||
| expect(getByText(expectedText)).toBeInTheDocument(); | ||
| }); | ||
| }) |
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
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.
Uh oh!
There was an error while loading. Please reload this page.