-
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.
STCOR-864 correctly evaluate typeof stripes.okapi (#1498)
Stripes should render `<ModuleContainer>` either when discovery is complete or when okapi isn't present at all, i.e. when `stripes.config.js` doesn't even contain an `okapi` entry. What's most amazing about this bug is not the bug, which is a relatively simple typo, but that it didn't bite us for more than six years. BTOG init never conducted discovery, but _did_ pass an okapi object during application setup, which is another way of saying that our application didn't have anything that relied on the presence of this bug, but our test suite did. :| Ignore the "new" AuthnLogin test file; those tests were previously stashed in `RootWithIntl.test.js` for some reason and have just been relocated. Refs STCOR-864
- Loading branch information
Showing
6 changed files
with
148 additions
and
61 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 |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* shhhh, eslint, it's ok. we need "unused" imports for mocks */ | ||
/* eslint-disable no-unused-vars */ | ||
|
||
import { render, screen } from '@folio/jest-config-stripes/testing-library/react'; | ||
|
||
import { Redirect as InternalRedirect } from 'react-router-dom'; | ||
import Redirect from '../Redirect'; | ||
import Login from '../Login'; | ||
import PreLoginLanding from '../PreLoginLanding'; | ||
|
||
import AuthnLogin from './AuthnLogin'; | ||
|
||
jest.mock('react-router-dom', () => ({ | ||
Redirect: () => '<internalredirect>', | ||
withRouter: (Component) => Component, | ||
})); | ||
jest.mock('../Redirect', () => () => '<redirect>'); | ||
jest.mock('../Login', () => () => '<login>'); | ||
jest.mock('../PreLoginLanding', () => () => '<preloginlanding>'); | ||
|
||
const store = { | ||
getState: () => ({ | ||
okapi: { | ||
token: '123', | ||
}, | ||
}), | ||
dispatch: () => {}, | ||
subscribe: () => {}, | ||
replaceReducer: () => {}, | ||
}; | ||
|
||
describe('RootWithIntl', () => { | ||
describe('AuthnLogin', () => { | ||
it('handles legacy login', () => { | ||
const stripes = { okapi: {}, config: {}, store }; | ||
render(<AuthnLogin stripes={stripes} />); | ||
|
||
expect(screen.getByText(/<login>/)).toBeInTheDocument(); | ||
}); | ||
|
||
describe('handles third-party login', () => { | ||
it('handles single-tenant', () => { | ||
const stripes = { | ||
okapi: { authnUrl: 'https://barbie.com' }, | ||
config: { | ||
isSingleTenant: true, | ||
tenantOptions: { | ||
diku: { name: 'diku', clientId: 'diku-application' } | ||
} | ||
}, | ||
store | ||
}; | ||
render(<AuthnLogin stripes={stripes} />); | ||
|
||
expect(screen.getByText(/<redirect>/)).toBeInTheDocument(); | ||
}); | ||
|
||
it('handles multi-tenant', () => { | ||
const stripes = { | ||
okapi: { authnUrl: 'https://oppie.com' }, | ||
config: { | ||
isSingleTenant: false, | ||
tenantOptions: { | ||
diku: { name: 'diku', clientId: 'diku-application' }, | ||
diku2: { name: 'diku2', clientId: 'diku2-application' } | ||
} | ||
}, | ||
store | ||
}; | ||
render(<AuthnLogin stripes={stripes} />); | ||
|
||
expect(screen.getByText(/<preloginlanding>/)).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