-
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.
feat: write test for all pages under admin plugin #302
- Loading branch information
1 parent
37275a9
commit a69f4a4
Showing
11 changed files
with
338 additions
and
24 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
40 changes: 40 additions & 0 deletions
40
plugins/admin/components/Configuration/LicenseDetailsPage.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,40 @@ | ||
import React from 'react' | ||
import { render, screen } from '@testing-library/react' | ||
import LicenseDetailsPage from './LicenseDetailsPage' | ||
import { createStore, combineReducers } from 'redux' | ||
import { Provider } from 'react-redux' | ||
import i18n from '../../../../app/i18n' | ||
import { I18nextProvider } from 'react-i18next' | ||
import license from "./license" | ||
|
||
const permissions = [ | ||
'https://jans.io/oauth/config/attributes.readonly', | ||
'https://jans.io/oauth/config/attributes.write', | ||
'https://jans.io/oauth/config/attributes.delete', | ||
] | ||
const INIT_LICENSE_DETAIL_STATE = { | ||
item: license, | ||
loading: false, | ||
} | ||
const store = createStore( | ||
combineReducers({ | ||
licenseDetailsReducer: (state = INIT_LICENSE_DETAIL_STATE) => state, | ||
noReducer: (state = {}) => state, | ||
}), | ||
) | ||
|
||
const Wrapper = ({ children }) => ( | ||
<I18nextProvider i18n={i18n}> | ||
<Provider store={store}>{children}</Provider> | ||
</I18nextProvider> | ||
) | ||
|
||
it('Should render the Custom Script add page properly', () => { | ||
render(<LicenseDetailsPage />, { wrapper: Wrapper }) | ||
const key = license.licenseKey | ||
screen.getByText(/Product Name/) | ||
screen.getByText(/Product Code/) | ||
screen.getByText(/License Type/) | ||
screen.getByText(/License Key/) | ||
screen.getByText(key) | ||
}) |
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,17 +1,15 @@ | ||
export const license = [ | ||
{ | ||
companyName: "Gluu", | ||
customerEmail: "arnab@gluu.org", | ||
customerFirstName: "Arnab", | ||
customerLastName: "Dutta", | ||
licenseActive: true, | ||
licenseEnable: true, | ||
licenseKey: "GFXJ-AB8B-YDJK-L4AD", | ||
licenseType: "TIME_LIMITED", | ||
maxActivations: 14, | ||
productCode: "adminui001", | ||
productName: "Gluu Admin UI", | ||
validityPeriod: "2022-10-01T00:00Z", | ||
} | ||
] | ||
export const license = { | ||
companyName: "Gluu", | ||
customerEmail: "arnab@gluu.org", | ||
customerFirstName: "Arnab", | ||
customerLastName: "Dutta", | ||
licenseActive: true, | ||
licenseEnable: true, | ||
licenseKey: "GFXJ-AB8B-YDJK-L4AD", | ||
licenseType: "TIME_LIMITED", | ||
maxActivations: 14, | ||
productCode: "adminui001", | ||
productName: "Gluu Admin UI", | ||
validityPeriod: "2022-10-01T00:00Z", | ||
} | ||
export default license |
42 changes: 42 additions & 0 deletions
42
plugins/admin/components/CustomScripts/CustomScriptAddPage.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,42 @@ | ||
import React from 'react' | ||
import { render, screen } from '@testing-library/react' | ||
import CustomScriptAddPage from './CustomScriptAddPage' | ||
import { createStore, combineReducers } from 'redux' | ||
import { Provider } from 'react-redux' | ||
import i18n from '../../../../app/i18n' | ||
import { I18nextProvider } from 'react-i18next' | ||
import item from "./item" | ||
|
||
const permissions = [ | ||
'https://jans.io/oauth/config/attributes.readonly', | ||
'https://jans.io/oauth/config/attributes.write', | ||
'https://jans.io/oauth/config/attributes.delete', | ||
] | ||
const INIT_STATE = { | ||
permissions: permissions, | ||
} | ||
const INIT_CUSTOM_SCRIPT_STATE = { | ||
items: [ | ||
item, | ||
], | ||
loading: false, | ||
} | ||
const store = createStore( | ||
combineReducers({ | ||
authReducer: (state = INIT_STATE) => state, | ||
customScriptReducer: (state = INIT_CUSTOM_SCRIPT_STATE) => state, | ||
noReducer: (state = {}) => state, | ||
}), | ||
) | ||
|
||
const Wrapper = ({ children }) => ( | ||
<I18nextProvider i18n={i18n}> | ||
<Provider store={store}>{children}</Provider> | ||
</I18nextProvider> | ||
) | ||
|
||
it('Should render the Custom Script add page properly', () => { | ||
render(<CustomScriptAddPage />, { wrapper: Wrapper }) | ||
screen.getByText(/Name/) | ||
screen.getByText(/Description/) | ||
}) |
46 changes: 46 additions & 0 deletions
46
plugins/admin/components/CustomScripts/CustomScriptEditPage.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,46 @@ | ||
import React from 'react' | ||
import { render, screen } from '@testing-library/react' | ||
import CustomScriptEditPage from './CustomScriptEditPage' | ||
import { createStore, combineReducers } from 'redux' | ||
import { Provider } from 'react-redux' | ||
import i18n from '../../../../app/i18n' | ||
import { I18nextProvider } from 'react-i18next' | ||
import item from "./item" | ||
import script from "./script" | ||
|
||
const permissions = [ | ||
'https://jans.io/oauth/config/attributes.readonly', | ||
'https://jans.io/oauth/config/attributes.write', | ||
'https://jans.io/oauth/config/attributes.delete', | ||
] | ||
const INIT_STATE = { | ||
permissions: permissions, | ||
} | ||
const INIT_CUSTOM_SCRIPT_STATE = { | ||
items: [ | ||
script, | ||
], | ||
item: item, | ||
loading: false, | ||
} | ||
const store = createStore( | ||
combineReducers({ | ||
authReducer: (state = INIT_STATE) => state, | ||
customScriptReducer: (state = INIT_CUSTOM_SCRIPT_STATE) => state, | ||
noReducer: (state = {}) => state, | ||
}), | ||
) | ||
|
||
const Wrapper = ({ children }) => ( | ||
<I18nextProvider i18n={i18n}> | ||
<Provider store={store}>{children}</Provider> | ||
</I18nextProvider> | ||
) | ||
|
||
it('Should render the Custom Script edit page properly', () => { | ||
render(<CustomScriptEditPage />, { wrapper: Wrapper }) | ||
screen.getByText(/Name/) | ||
screen.getByText(/Description/) | ||
screen.getByText(/Select SAML ACRS/) | ||
screen.getByText(/Script Type/) | ||
}) |
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
111 changes: 111 additions & 0 deletions
111
plugins/admin/components/MonthlyActiveUsersPage.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,111 @@ | ||
import React from 'react' | ||
import { render, screen } from '@testing-library/react' | ||
import MonthlyActiveUsersPage from './MonthlyActiveUsersPage' | ||
import { createStore, combineReducers } from 'redux' | ||
import { Provider } from 'react-redux' | ||
import i18n from '../../../app/i18n' | ||
import { I18nextProvider } from 'react-i18next' | ||
|
||
const stat = [ | ||
{ | ||
"month": 202108, | ||
"monthly_active_users": 5, | ||
"token_count_per_granttype": { | ||
"client_credentials": { | ||
"access_token": 107 | ||
}, | ||
"authorization_code": { | ||
"access_token": 623, | ||
"id_token": 622 | ||
} | ||
} | ||
}, | ||
{ | ||
"month": 202109, | ||
"monthly_active_users": 1, | ||
"token_count_per_granttype": { | ||
"client_credentials": { | ||
"access_token": 957 | ||
}, | ||
"authorization_code": { | ||
"access_token": 2387, | ||
"id_token": 2387 | ||
} | ||
} | ||
}, | ||
{ | ||
"month": 202110, | ||
"monthly_active_users": 1, | ||
"token_count_per_granttype": { | ||
"client_credentials": { | ||
"access_token": 89 | ||
}, | ||
"authorization_code": { | ||
"access_token": 350, | ||
"id_token": 350 | ||
} | ||
} | ||
}, | ||
{ | ||
"month": 202111, | ||
"monthly_active_users": 1, | ||
"token_count_per_granttype": { | ||
"client_credentials": { | ||
"access_token": 1036 | ||
}, | ||
"password": { | ||
"access_token": 2 | ||
}, | ||
"authorization_code": { | ||
"access_token": 347, | ||
"id_token": 347 | ||
} | ||
} | ||
}, | ||
{ | ||
"month": 202112, | ||
"monthly_active_users": 1, | ||
"token_count_per_granttype": { | ||
"client_credentials": { | ||
"access_token": 411 | ||
}, | ||
"authorization_code": { | ||
"access_token": 132, | ||
"id_token": 132 | ||
} | ||
} | ||
} | ||
] | ||
|
||
const permissions = [ | ||
'https://jans.io/oauth/config/attributes.readonly', | ||
'https://jans.io/oauth/config/attributes.write', | ||
'https://jans.io/oauth/config/attributes.delete', | ||
] | ||
const INIT_STATE = { | ||
permissions: permissions, | ||
} | ||
const INIT_MAU_STATE = { | ||
stat: stat, | ||
} | ||
const INIT_OIDC_STATE = { | ||
loading: false, | ||
} | ||
const store = createStore( | ||
combineReducers({ | ||
authReducer: (state = INIT_STATE) => state, | ||
mauReducer: (state = INIT_MAU_STATE) => state, | ||
oidcReducer: (state = INIT_OIDC_STATE) => state, | ||
noReducer: (state = {}) => state, | ||
}), | ||
) | ||
|
||
const Wrapper = ({ children }) => ( | ||
<I18nextProvider i18n={i18n}> | ||
<Provider store={store}>{children}</Provider> | ||
</I18nextProvider> | ||
) | ||
|
||
it('Should render the api role list page properly', () => { | ||
render(<MonthlyActiveUsersPage />, { wrapper: Wrapper }) | ||
}) |
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,25 @@ | ||
import React from 'react' | ||
import { render, screen } from '@testing-library/react' | ||
import UiRoleDetailPage from './UiRoleDetailPage' | ||
import roles from "./roles" | ||
import i18n from '../../../../app/i18n' | ||
import { I18nextProvider } from 'react-i18next' | ||
|
||
const Wrapper = ({ children }) => ( | ||
<I18nextProvider i18n={i18n}>{children}</I18nextProvider> | ||
) | ||
const permissions = [ | ||
'https://jans.io/oauth/config/attributes.readonly', | ||
'https://jans.io/oauth/config/attributes.write', | ||
'https://jans.io/oauth/config/attributes.delete', | ||
] | ||
const row = roles[0] | ||
it('Should render the license detail page properly', () => { | ||
render(<UiRoleDetailPage row={row} permissions={permissions} />, { | ||
wrapper: Wrapper, | ||
}) | ||
const name = row.name | ||
screen.getByText(/Name/) | ||
screen.getByText(/Description/) | ||
screen.getByText(name) | ||
}) |
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,39 @@ | ||
import React from 'react' | ||
import { render, screen } from '@testing-library/react' | ||
import UiRoleListPage from './UiRoleListPage' | ||
import { createStore, combineReducers } from 'redux' | ||
import { Provider } from 'react-redux' | ||
import i18n from '../../../../app/i18n' | ||
import { I18nextProvider } from 'react-i18next' | ||
import roles from "./roles" | ||
|
||
const permissions = [ | ||
'https://jans.io/oauth/config/attributes.readonly', | ||
'https://jans.io/oauth/config/attributes.write', | ||
'https://jans.io/oauth/config/attributes.delete', | ||
] | ||
const INIT_STATE = { | ||
permissions: permissions, | ||
} | ||
const INIT_API_ROLE_STATE = { | ||
items: roles, | ||
loading: false, | ||
} | ||
const store = createStore( | ||
combineReducers({ | ||
authReducer: (state = INIT_STATE) => state, | ||
apiRoleReducer: (state = INIT_API_ROLE_STATE) => state, | ||
noReducer: (state = {}) => state, | ||
}), | ||
) | ||
|
||
const Wrapper = ({ children }) => ( | ||
<I18nextProvider i18n={i18n}> | ||
<Provider store={store}>{children}</Provider> | ||
</I18nextProvider> | ||
) | ||
|
||
it('Should render the api role list page properly', () => { | ||
render(<UiRoleListPage />, { wrapper: Wrapper }) | ||
|
||
}) |
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,18 @@ | ||
import React from 'react' | ||
import { render, screen } from '@testing-library/react' | ||
import SettingsPage from './SettingsPage' | ||
import i18n from '../../../../app/i18n' | ||
import { I18nextProvider } from 'react-i18next' | ||
|
||
const Wrapper = ({ children }) => ( | ||
<I18nextProvider i18n={i18n}>{children}</I18nextProvider> | ||
) | ||
|
||
it('Should render the license detail page properly', () => { | ||
render(<SettingsPage />, { | ||
wrapper: Wrapper, | ||
}) | ||
screen.getByText(/List paging size/) | ||
screen.getByText(/Dark Mode/) | ||
screen.getByText(/Config API URL/) | ||
}) |