Skip to content

Commit

Permalink
fix(admin-ui): resolve all bugs displayed for admin-ui #308
Browse files Browse the repository at this point in the history
  • Loading branch information
syntrydy committed Nov 14, 2021
1 parent 877188c commit 510f19e
Show file tree
Hide file tree
Showing 22 changed files with 50 additions and 179 deletions.
7 changes: 4 additions & 3 deletions __tests__/setup.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
jest.spyOn(global.console, 'log').mockImplementation(jest.fn());
jest.spyOn(global.console, 'warn').mockImplementation(jest.fn());
jest.spyOn(global.console, 'log').mockImplementation(jest.fn())
jest.spyOn(global.console, 'warn').mockImplementation(jest.fn())
import '@testing-library/jest-dom'

it('Jans-admin UI test setup', () => {
})
expect(true).toBeTruthy()
})
4 changes: 2 additions & 2 deletions app/components/Accordion/Accordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export class Accordion extends React.Component {
};

if (props.open !== 'undefined' && props.onToggle === 'undefined') {
throw "Accordion: props.open has to be used combined with props.onToggle " +
"use props.initialOpen to create an uncontrolled Accordion.";
throw new Error("Accordion: props.open has to be used combined with props.onToggle " +
"use props.initialOpen to create an uncontrolled Accordion.");
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
<div class="initial-loader-wrap">
<div class="initial-loader">
<div class="initial-loader__row">
<img src="https://i.ibb.co/9HdXTNb/logo.png" width="130px" height="51px" />
<img src="https://i.ibb.co/9HdXTNb/logo.png" alt="application logo" width="130px" height="51px" />
<svg
version="1.1"
id="loader-circle"
Expand Down
16 changes: 5 additions & 11 deletions app/redux/store/index.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
/**
* Redux Store
*/
import { createStore, applyMiddleware, compose } from 'redux'
import { createStore, applyMiddleware, compose, combineReducers } from 'redux'
import createSagaMiddleware from 'redux-saga'
import appReducers from '../reducers'
import RootSaga from '../sagas'
import { persistStore, persistReducer } from 'redux-persist'
import storage from 'redux-persist/lib/storage'
import hardSet from 'redux-persist/lib/stateReconciler/hardSet'
import reducerRegistry from '../reducers/ReducerRegistry'
import { combineReducers } from 'redux'
import process from '../../../plugins/PluginReducersResolver'
// create the saga middleware
const sagaMiddleware = createSagaMiddleware()

const middlewares = [sagaMiddleware]

const composeEnhancer = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose

const persistConfig = {
Expand All @@ -25,14 +19,14 @@ const persistConfig = {
}

// Preserve initial state for not-yet-loaded reducers
const combine = (reducers) => {
const reducerNames = Object.keys(reducers)
const combine = (reducersObjects) => {
const reducerNames = Object.keys(reducersObjects)
Object.keys(appReducers).forEach((item) => {
if (reducerNames.indexOf(item) === -1) {
reducers[item] = (state = null) => state
reducersObjects[item] = (state = null) => state
}
})
return combineReducers(reducers)
return combineReducers(reducersObjects)
}

const reducers = combine(reducerRegistry.getReducers())
Expand Down
6 changes: 4 additions & 2 deletions app/routes/Apps/Gluu/Tests/GluuFormDetailRow.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import { render, screen, fireEvent } from '@testing-library/react'
import { render, screen} from '@testing-library/react'
import GluuFormDetailRow from '../GluuFormDetailRow'
import i18n from '../../../../i18n'
import { I18nextProvider } from 'react-i18next'
Expand All @@ -8,7 +8,9 @@ let NAME = 'application_type'
let VALUE = 'openid'

it('Should render one label and a badge', () => {
function handler() {}
function handler() {
console.log("========");
}
render(
<I18nextProvider i18n={i18n}>
<GluuFormDetailRow
Expand Down
4 changes: 3 additions & 1 deletion app/routes/Apps/Gluu/Tests/GluuInlineInput.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ let NAME = 'application_type'
let VALUE = true

it('Should render a boolean select box', () => {
function handler() {}
function handler() {
console.log("========");
}
render(
<I18nextProvider i18n={i18n}>
<GluuInlineInput
Expand Down
1 change: 1 addition & 0 deletions app/routes/Apps/Gluu/Tests/GluuInputRow.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ it('Should show the input with proper text', () => {
const NAME = 'application_type'
const VALUE = 'Public'
function handler(){
console.log("========");
}
render(
<I18nextProvider i18n={i18n}>
Expand Down
11 changes: 7 additions & 4 deletions app/routes/Apps/Gluu/Tests/GluuInumInput.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ import GluuInumInput from '../GluuInumInput'
import i18n from '../../../../i18n'
import { I18nextProvider } from 'react-i18next'

const LABEL = 'fields.application_type'
const NAME = 'application_type'
const VALUE = 'Public'

it('Should show the disabled input with proper text wit sa', () => {
const LABEL = 'fields.application_type'
const NAME = 'application_type'
const VALUE = 'Public'
function handler() {}
function handler() {
console.log("========");
}
render(
<I18nextProvider i18n={i18n}>
<GluuInumInput
Expand Down
2 changes: 1 addition & 1 deletion app/routes/Apps/Gluu/Tests/GluuTypeAhead.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import i18n from '../../../../i18n'
import { I18nextProvider } from 'react-i18next'

const LABEL = 'fields.application_type'
let NAME = 'applicationType'
const NAME = 'applicationType'
const VALUE = ['Monday']
const OPTIONS = ['Monday', 'Tuesday']

Expand Down
2 changes: 1 addition & 1 deletion app/routes/Apps/Gluu/Tests/GluuTypeAheadWithAdd.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import GluuTypeAheadWithAdd from '../GluuTypeAheadWithAdd'
import { render, screen, fireEvent } from '@testing-library/react'
import { render, screen} from '@testing-library/react'
import i18n from '../../../../i18n'
import { I18nextProvider } from 'react-i18next'

Expand Down
4 changes: 0 additions & 4 deletions app/routes/Dashboards/Reports/Reports.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import React, { useEffect } from 'react'
import {
hasPermission,
buildPayload,
CLIENT_WRITE,
CLIENT_READ,
CLIENT_DELETE,
} from '../../../../app/utils/PermChecker'
import {
Container,
Expand Down
4 changes: 0 additions & 4 deletions app/styles/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@
padding: 0.05rem;
text-overflow: ellipsis;
white-space: nowrap;
*white-space: nowrap;
overflow: hidden;
-webkit-font-smoothing: antialiased;
-webkit-text-stroke-width: 0.2px;
Expand Down Expand Up @@ -195,7 +194,6 @@
background-color: rgba(238, 238, 238, 0.9); } }
.month-picker > .rmp-container .rmp-popup.light .rmp-pad .rmp-btn {
cursor: pointer;
moz-user-select: -moz-none;
-moz-user-select: none;
-o-user-select: none;
-khtml-user-select: none;
Expand Down Expand Up @@ -227,7 +225,6 @@
background-color: rgba(70, 70, 70, 0.9); } }
.month-picker > .rmp-container .rmp-popup.dark .rmp-pad .rmp-btn {
cursor: pointer;
moz-user-select: -moz-none;
-moz-user-select: none;
-o-user-select: none;
-khtml-user-select: none;
Expand Down Expand Up @@ -276,7 +273,6 @@
.month-picker .tab.btn {
font-size: 0; }
.month-picker .tab.btn:before {
speak: none;
font-style: normal;
font-weight: normal;
font-family: "icomoon";
Expand Down
24 changes: 2 additions & 22 deletions plugins/auth-server/components/Clients/ClientAddPage.test.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,21 @@
import React from 'react'
import { render, screen } from '@testing-library/react'
import ClientAddPage from './ClientAddPage'
import { combineReducers } from 'redux'
import { BrowserRouter as Router } from 'react-router-dom'
import { createStore } from 'redux'
import { createStore, combineReducers } from 'redux'
import { Provider } from 'react-redux'
import i18n from '../../../../app/i18n'
import { I18nextProvider } from 'react-i18next'
import authReducer from '../../../../app/redux/reducers/AuthReducer'
import initReducer from '../../../../app/redux/reducers/InitReducer'
import oidcDiscoveryReducer from '../../../../app/redux/reducers/OidcDiscoveryReducer'
import oidcReducer from '../../redux/reducers/OIDCReducer'
import scopeReducer from '../../redux/reducers/ScopeReducer'
const scopes = []
const permissions = [
'https://jans.io/oauth/config/openid/clients.readonly',
'https://jans.io/oauth/config/openid/clients.write',
'https://jans.io/oauth/config/openid/clients.delete',
]
const INIT_STATE = {
isAuthenticated: false,
userinfo: null,
userinfo_jwt: null,
token: null,
issuer: null,
permissions: permissions,
location: {},
config: {},
backendIsUp: true,
}
const INIT_SCPOPES_STATE = {
items: [
Expand Down Expand Up @@ -65,17 +53,9 @@ const Wrapper = ({ children }) => (
</Provider>
</I18nextProvider>
)
const emptyArray = []

it('Should render client add page properly', () => {
render(
<ClientAddPage
scopes={scopes}
permissions={permissions}
scopes={emptyArray}
/>,
{ wrapper: Wrapper },
)
render(<ClientAddPage />, { wrapper: Wrapper })
screen.getByText(/Basic/)
screen.getByText(/Advanced/)
screen.getByText('Encryption/Signing')
Expand Down
23 changes: 2 additions & 21 deletions plugins/auth-server/components/Clients/ClientEditPage.test.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,22 @@
import React from 'react'
import { render, screen } from '@testing-library/react'
import ClientEditPage from './ClientEditPage'
import { combineReducers } from 'redux'
import { BrowserRouter as Router } from 'react-router-dom'
import { createStore } from 'redux'
import { createStore, combineReducers } from 'redux'
import { Provider } from 'react-redux'
import clients from './clients'
import i18n from '../../../../app/i18n'
import { I18nextProvider } from 'react-i18next'
import authReducer from '../../../../app/redux/reducers/AuthReducer'
import initReducer from '../../../../app/redux/reducers/InitReducer'
import oidcDiscoveryReducer from '../../../../app/redux/reducers/OidcDiscoveryReducer'
import oidcReducer from '../../redux/reducers/OIDCReducer'
import scopeReducer from '../../redux/reducers/ScopeReducer'
const scopes = []
const permissions = [
'https://jans.io/oauth/config/openid/clients.readonly',
'https://jans.io/oauth/config/openid/clients.write',
'https://jans.io/oauth/config/openid/clients.delete',
]
const INIT_STATE = {
isAuthenticated: false,
userinfo: null,
userinfo_jwt: null,
token: null,
issuer: null,
permissions: permissions,
location: {},
config: {},
backendIsUp: true,
}

const INIT_CLIENTS_STATE = {
Expand Down Expand Up @@ -56,14 +44,7 @@ const Wrapper = ({ children }) => (
const emptyArray = []

it('Should the client edit page properly', () => {
render(
<ClientEditPage
scopes={scopes}
permissions={permissions}
scopes={emptyArray}
/>,
{ wrapper: Wrapper },
)
render(<ClientEditPage />, { wrapper: Wrapper })
screen.getByText(/Basic/)
screen.getByText(/Advanced/)
screen.getByText('Encryption/Signing')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import React from 'react'
import { Col, Container, FormGroup, Input } from '../../../../app/components'
import GluuLabel from '../../../../app/routes/Apps/Gluu/GluuLabel'
import { Col, Container, FormGroup} from '../../../../app/components'
import GluuInputRow from '../../../../app/routes/Apps/Gluu/GluuInputRow'
import GluuSelectRow from '../../../../app/routes/Apps/Gluu/GluuSelectRow'
import { useTranslation } from 'react-i18next'
const DOC_CATEGORY = 'openid_client'

function ClientEncryptionPanel({ client, formik, oidcConfiguration }) {
const { t } = useTranslation()
const accessTokenSigningAlg = !!oidcConfiguration.tokenEndpointAuthSigningAlgValuesSupported
? oidcConfiguration.tokenEndpointAuthSigningAlgValuesSupported
: []
Expand Down
25 changes: 3 additions & 22 deletions plugins/auth-server/components/Clients/ClientListPage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,14 @@ import { Provider } from 'react-redux'
import i18n from '../../../../app/i18n'
import clients from './clients'
import { I18nextProvider } from 'react-i18next'
import authReducer from '../../../../app/redux/reducers/AuthReducer'
import oidcReducer from '../../redux/reducers/OIDCReducer'
import scopeReducer from '../../redux/reducers/ScopeReducer'

const permissions = [
'https://jans.io/oauth/config/openid/clients.readonly',
'https://jans.io/oauth/config/openid/clients.write',
'https://jans.io/oauth/config/openid/clients.delete',
]
const INIT_STATE = {
isAuthenticated: false,
userinfo: null,
userinfo_jwt: null,
token: null,
issuer: null,
permissions: permissions,
location: {},
config: {},
backendIsUp: true,
}

const INIT_CLIENTS_STATE = {
Expand Down Expand Up @@ -57,8 +46,8 @@ const INIT_SCPOPES_STATE = {
const store = createStore(
combineReducers({
authReducer: (state = INIT_STATE) => state,
oidcReducer: (state = INIT_SCPOPES_STATE) => state,
scopeReducer,
oidcReducer: (state = INIT_CLIENTS_STATE) => state,
scopeReducer: (state = INIT_SCPOPES_STATE) => state,
noReducer: (state = {}) => state,
}),
)
Expand All @@ -70,17 +59,9 @@ const Wrapper = ({ children }) => (
</Provider>
</I18nextProvider>
)
const emptyArray = []

it('Should show the sidebar properly', () => {
render(
<ClientListPage
clients={emptyArray}
permissions={permissions}
scopes={emptyArray}
/>,
{ wrapper: Wrapper },
)
render(<ClientListPage />, { wrapper: Wrapper })
screen.getByText(/OIDC Clients/)
screen.getByTitle('Add Client')
screen.getByText(/refresh/)
Expand Down
Loading

0 comments on commit 510f19e

Please sign in to comment.