-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'keycloak-ramsons' into STCOR-875
- Loading branch information
Showing
42 changed files
with
1,166 additions
and
524 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
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 |
---|---|---|
@@ -1,36 +1,46 @@ | ||
import { render, screen } from '@folio/jest-config-stripes/testing-library/react'; | ||
import { userEvent } from '@folio/jest-config-stripes/testing-library/user-event'; | ||
|
||
import LogoutTimeout from './LogoutTimeout'; | ||
import { useStripes } from '../../StripesContext'; | ||
import { logout } from '../../loginServices'; | ||
|
||
|
||
import { getUnauthorizedPathFromSession, setUnauthorizedPathToSession } from '../../loginServices'; | ||
|
||
jest.mock('../OrganizationLogo'); | ||
jest.mock('../../StripesContext'); | ||
jest.mock('react-router', () => ({ | ||
Redirect: () => <div>Redirect</div>, | ||
})); | ||
|
||
jest.mock('../../loginServices', () => ({ | ||
logout: jest.fn(() => Promise.resolve()), | ||
})); | ||
|
||
describe('LogoutTimeout', () => { | ||
it('if not authenticated, renders a timeout message', async () => { | ||
const mockUseStripes = useStripes; | ||
mockUseStripes.mockReturnValue({ okapi: { isAuthenticated: false } }); | ||
describe('if not authenticated', () => { | ||
it('renders a timeout message', async () => { | ||
const mockUseStripes = useStripes; | ||
mockUseStripes.mockReturnValue({ okapi: { isAuthenticated: false } }); | ||
|
||
render(<LogoutTimeout />); | ||
screen.getByText('stripes-core.rtr.idleSession.sessionExpiredSoSad'); | ||
render(<LogoutTimeout />); | ||
screen.getByText('stripes-core.rtr.idleSession.sessionExpiredSoSad'); | ||
}); | ||
|
||
it('clears previous path from storage after clicking', async () => { | ||
const previousPath = '/monkey?bagel'; | ||
setUnauthorizedPathToSession(previousPath); | ||
const user = userEvent.setup(); | ||
const mockUseStripes = useStripes; | ||
mockUseStripes.mockReturnValue({ okapi: { isAuthenticated: false } }); | ||
|
||
render(<LogoutTimeout />); | ||
|
||
await user.click(screen.getByRole('button')); | ||
|
||
expect(getUnauthorizedPathFromSession()).toBe(null); | ||
}); | ||
}); | ||
|
||
it('if authenticated, calls logout then renders a timeout message', async () => { | ||
it('if authenticated, renders a redirect', async () => { | ||
const mockUseStripes = useStripes; | ||
mockUseStripes.mockReturnValue({ okapi: { isAuthenticated: true } }); | ||
|
||
render(<LogoutTimeout />); | ||
expect(logout).toHaveBeenCalled(); | ||
screen.getByText('stripes-core.rtr.idleSession.sessionExpiredSoSad'); | ||
screen.getByText('Redirect'); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import hideEmail from './hideEmail'; | ||
|
||
describe('hideEmail', () => { | ||
it('masks email addresses', () => { | ||
expect(hideEmail('[email protected]')).toEqual('te**@e******.***'); | ||
expect(hideEmail('[email protected]')).toEqual('mo****@b****.*****'); | ||
}); | ||
}); |
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.