Skip to content

Commit

Permalink
feat: write test for the pages under admin plugin #302
Browse files Browse the repository at this point in the history
  • Loading branch information
fausto-gluu committed Dec 2, 2021
1 parent c88ca52 commit 37275a9
Show file tree
Hide file tree
Showing 6 changed files with 1,338 additions and 0 deletions.
24 changes: 24 additions & 0 deletions plugins/admin/components/Configuration/LicenseDetailsForm.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React from 'react'
import { render, screen } from '@testing-library/react'
import LicenseDetailsForm from './LicenseDetailsForm'
import license from "./license"
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 item = license[0]
it('Should render the license detail page properly', () => {
render(<LicenseDetailsForm item={item} permissions={permissions} />, {
wrapper: Wrapper,
})
screen.getByText(/License Valid Upto/)
screen.getByText(/Maximum Activations/)
screen.getByText(/Is License Active/)
})
17 changes: 17 additions & 0 deletions plugins/admin/components/Configuration/license.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React from 'react'
import { render, screen } from '@testing-library/react'
import CustomScriptDetailPage from './CustomScriptDetailPage'
import item from "./item"
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',
]

it('Should render the Custom Script detail page properly', () => {
render(<CustomScriptDetailPage row={item} permissions={permissions} />, {
wrapper: Wrapper,
})
const name = item.name
const script_type = item.scriptType
screen.getByText(/Inum/)
screen.getByText(/Location Type/)
screen.getByText(/Script Type/)
screen.getByText(name)
screen.getByText(script_type)
})
27 changes: 27 additions & 0 deletions plugins/admin/components/CustomScripts/CustomScriptForm.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from 'react'
import { render, screen } from '@testing-library/react'
import CustomScriptForm from './CustomScriptForm'
import item from "./item"
import script from "./script"
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',
]

it('Should render the Custom Script detail page properly', () => {
render(<CustomScriptForm item={item} scripts={script} permissions={permissions} />, {
wrapper: Wrapper,
})
const inum = item.inum
screen.getByText(/Inum/)
screen.getByText(/Name/)
screen.getByText(/Script/)
screen.getByText(inum)
})
28 changes: 28 additions & 0 deletions plugins/admin/components/CustomScripts/item.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
export const item = {
name: "basic",
script: "",
scriptType: "PERSON_AUTHENTICATION",
programmingLanguage: "PYTHON",
moduleProperties: [
{
value1: "usage_type",
value2: "interactive"
},
{
value1: "location_type",
value2: "ldap"
}
],
level: 10,
dn: "inum=A51E-76DA,ou=scripts,o=jans",
inum: "A51E-76DA",
description: "Sample authentication module",
revision: 1,
enabled: false,
modified: false,
internal: false,
tableData: {
id: 0
}
}
export default item
Loading

0 comments on commit 37275a9

Please sign in to comment.