-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(admin-ui): write test for all pages under auth-server plugin #301
- Loading branch information
Showing
5 changed files
with
110 additions
and
2 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
48 changes: 48 additions & 0 deletions
48
plugins/auth-server/components/Configuration/Defaults/AcrsPage.test.js
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,48 @@ | ||
import React from 'react' | ||
import { render, screen } from '@testing-library/react' | ||
import AcrsPage from './AcrsPage' | ||
import { combineReducers, createStore } from 'redux' | ||
import { Provider } from 'react-redux' | ||
import i18n from '../../../../../app/i18n' | ||
import { I18nextProvider } from 'react-i18next' | ||
|
||
const permissions = [ | ||
'https://jans.io/oauth/config/acrs.readonly', | ||
'https://jans.io/oauth/config/acrs.write', | ||
'https://jans.io/oauth/config/acrs.delete', | ||
] | ||
const ACRS_STATE = { | ||
acrs: {}, | ||
scripts: [], | ||
loading: false, | ||
} | ||
|
||
const AUTH_STATE = { | ||
permissions: permissions, | ||
} | ||
const SCRIPT_STATE = { | ||
items: [], | ||
} | ||
|
||
const store = createStore( | ||
combineReducers({ | ||
authReducer: (state = AUTH_STATE) => state, | ||
acrReducer: (state = ACRS_STATE) => state, | ||
customScriptReducer: (state = SCRIPT_STATE) => state, | ||
noReducer: (state = {}) => state, | ||
}), | ||
) | ||
|
||
const Wrapper = ({ children }) => ( | ||
<I18nextProvider i18n={i18n}> | ||
<Provider store={store}>{children}</Provider> | ||
</I18nextProvider> | ||
) | ||
|
||
it('Should render Acr page properly', () => { | ||
render(<AcrsPage />, { | ||
wrapper: Wrapper, | ||
}) | ||
screen.getByText(/simple_password_auth/) | ||
expect(screen.getByTestId('defaultAcr')).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
57 changes: 57 additions & 0 deletions
57
plugins/auth-server/components/Configuration/Defaults/LoggingPage.test.js
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,57 @@ | ||
import React from 'react' | ||
import { render, screen } from '@testing-library/react' | ||
import LoggingPage from './LoggingPage' | ||
import { combineReducers, createStore } from 'redux' | ||
import { Provider } from 'react-redux' | ||
import i18n from '../../../../../app/i18n' | ||
import { I18nextProvider } from 'react-i18next' | ||
|
||
const permissions = [ | ||
'https://jans.io/oauth/config/logging.readonly', | ||
'https://jans.io/oauth/config/logging.write', | ||
'https://jans.io/oauth/config/logging.delete', | ||
] | ||
|
||
const AUTH_STATE = { | ||
permissions: permissions, | ||
} | ||
const logging = { | ||
loggingLevel: 'TRACE', | ||
loggingLayout: 'text', | ||
httpLoggingEnabled: true, | ||
disableJdkLogger: false, | ||
enabledOAuthAuditLogging: false, | ||
} | ||
const LOGGING_STATE = { | ||
logging: logging, | ||
loading: false, | ||
} | ||
|
||
const store = createStore( | ||
combineReducers({ | ||
authReducer: (state = AUTH_STATE) => state, | ||
loggingReducer: (state = LOGGING_STATE) => state, | ||
noReducer: (state = {}) => state, | ||
}), | ||
) | ||
|
||
const Wrapper = ({ children }) => ( | ||
<I18nextProvider i18n={i18n}> | ||
<Provider store={store}>{children}</Provider> | ||
</I18nextProvider> | ||
) | ||
|
||
it('Should render Acr page properly', () => { | ||
render(<LoggingPage />, { | ||
wrapper: Wrapper, | ||
}) | ||
expect(screen.getByTestId('loggingLayout')).toHaveDisplayValue( | ||
logging.loggingLayout, | ||
) | ||
expect(screen.getByTestId('loggingLevel')).toHaveDisplayValue( | ||
logging.loggingLevel, | ||
) | ||
expect(screen.getByTestId('httpLoggingEnabled')).toBeChecked() | ||
expect(screen.getByTestId('disableJdkLogger')).not.toBeChecked() | ||
expect(screen.getByTestId('enabledOAuthAuditLogging')).not.toBeChecked() | ||
}) |