-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for disableonEdit in oauth (#953)
* feat: add support for disableonEdit in oauth * feat: add tests for EntityModal disableonEdit * fix: removed placeholder for test data * fix: correct displayed text for test field * chore: review * fix: fix tests, wrap tabs in array * fix: make custom field optional * fix: add field to expected addon * fix: add rest field to expected addon * fix: remove fields from expected addon * fix: fix types in tests
- Loading branch information
1 parent
58ab2e0
commit d948128
Showing
15 changed files
with
343 additions
and
25 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
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
7 changes: 4 additions & 3 deletions
7
ui/src/components/EntityModal.stories.tsx → ...nents/EntityModal/EntityModal.stories.tsx
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,112 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import EntityModal, { EntityModalProps } from './EntityModal'; | ||
import { setUnifiedConfig } from '../../util/util'; | ||
import { getConfigBasicOauthDisableonEdit, getConfigOauthOauthDisableonEdit } from './TestConfig'; | ||
|
||
describe('EntityModal - Basic oauth', () => { | ||
const handleRequestClose = jest.fn(); | ||
|
||
const setUpConfigWithDisabedBasicOauth = () => { | ||
setUnifiedConfig(getConfigBasicOauthDisableonEdit()); | ||
}; | ||
|
||
const renderModalWithProps = (props: EntityModalProps) => { | ||
render(<EntityModal {...props} handleRequestClose={handleRequestClose} />); | ||
}; | ||
|
||
const getDisabledBasicField = () => | ||
document.getElementsByClassName('basic_oauth_text_jest_test')[1]; | ||
|
||
it('if oauth field not disabled with create after disableonEdit true', async () => { | ||
setUpConfigWithDisabedBasicOauth(); | ||
const props = { | ||
serviceName: 'account', | ||
mode: 'create', | ||
stanzaName: undefined, | ||
formLabel: 'formLabel', | ||
page: 'configuration', | ||
groupName: '', | ||
open: true, | ||
handleRequestClose: () => {}, | ||
} satisfies EntityModalProps; | ||
renderModalWithProps(props); | ||
const oauthTextBox = getDisabledBasicField(); | ||
expect(oauthTextBox).toBeInTheDocument(); | ||
expect(oauthTextBox?.getAttribute('disabled')).toBeNull(); | ||
}); | ||
|
||
it('test if oauth field disabled on edit after disableonEdit true', async () => { | ||
setUpConfigWithDisabedBasicOauth(); | ||
const props = { | ||
serviceName: 'account', | ||
mode: 'edit', | ||
stanzaName: undefined, | ||
formLabel: 'formLabel', | ||
page: 'configuration', | ||
groupName: '', | ||
open: true, | ||
handleRequestClose: () => {}, | ||
} satisfies EntityModalProps; | ||
|
||
renderModalWithProps(props); | ||
|
||
const oauthTextBox = getDisabledBasicField(); | ||
expect(oauthTextBox).toBeInTheDocument(); | ||
expect(oauthTextBox?.getAttribute('disabled')).toBe(''); | ||
}); | ||
}); | ||
|
||
describe('EntityModal - Oauth oauth', () => { | ||
const handleRequestClose = jest.fn(); | ||
|
||
const setUpConfigWithDisabedOauth = () => { | ||
const newConfig = getConfigOauthOauthDisableonEdit(); | ||
setUnifiedConfig(newConfig); | ||
}; | ||
|
||
const renderModalWithProps = (props: EntityModalProps) => { | ||
render(<EntityModal {...props} handleRequestClose={handleRequestClose} />); | ||
}; | ||
|
||
const getDisabledOauthField = () => | ||
document.getElementsByClassName('oauth_oauth_text_jest_test')[1]; | ||
|
||
it('Oauth Oauth - test if oauth field not disabled on create after disableonEdit', async () => { | ||
setUpConfigWithDisabedOauth(); | ||
const props = { | ||
serviceName: 'account', | ||
mode: 'create', | ||
stanzaName: undefined, | ||
formLabel: 'formLabel', | ||
page: 'configuration', | ||
groupName: '', | ||
open: true, | ||
handleRequestClose: () => {}, | ||
} satisfies EntityModalProps; | ||
renderModalWithProps(props); | ||
const oauthTextBox = getDisabledOauthField(); | ||
expect(oauthTextBox).toBeInTheDocument(); | ||
expect(oauthTextBox?.getAttribute('disabled')).toBeNull(); | ||
}); | ||
|
||
it('Oauth Oauth - test if oauth field disabled on edit after disableonEdit', async () => { | ||
setUpConfigWithDisabedOauth(); | ||
const props = { | ||
serviceName: 'account', | ||
mode: 'edit', | ||
stanzaName: undefined, | ||
formLabel: 'formLabel', | ||
page: 'configuration', | ||
groupName: '', | ||
open: true, | ||
handleRequestClose: () => {}, | ||
} satisfies EntityModalProps; | ||
|
||
renderModalWithProps(props); | ||
|
||
const oauthTextBox = getDisabledOauthField(); | ||
expect(oauthTextBox).toBeInTheDocument(); | ||
expect(oauthTextBox?.getAttribute('disabled')).toBe(''); | ||
}); | ||
}); |
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
Oops, something went wrong.