mirror of
https://github.com/strapi/strapi.git
synced 2025-08-13 19:27:34 +00:00
Fix username field
Signed-off-by: soupette <cyril.lpz@gmail.com>
This commit is contained in:
parent
f73d4fc226
commit
d4833d3767
@ -27,6 +27,8 @@ const reducer = (state, action) =>
|
||||
case 'ON_CHANGE': {
|
||||
if (action.inputType === 'password' && !action.value) {
|
||||
unset(draftState.modifiedData, action.keys.split('.'));
|
||||
} else if (action.keys.includes('username')) {
|
||||
set(draftState.modifiedData, action.keys.split('.'), null);
|
||||
} else {
|
||||
set(draftState.modifiedData, action.keys.split('.'), action.value);
|
||||
}
|
||||
|
@ -151,6 +151,31 @@ describe('ADMIN | CONTAINERS | ProfilePage | reducer', () => {
|
||||
|
||||
expect(reducer(initialState, action)).toEqual(expected);
|
||||
});
|
||||
|
||||
it('should set the username value to null if the value is empty', () => {
|
||||
const initialState = {
|
||||
modifiedData: {
|
||||
email: 'john@strapi.io',
|
||||
password: 'pwd123',
|
||||
username: 'test',
|
||||
},
|
||||
};
|
||||
const action = {
|
||||
type: 'ON_CHANGE',
|
||||
keys: 'username',
|
||||
inputType: 'text',
|
||||
value: '',
|
||||
};
|
||||
const expected = {
|
||||
modifiedData: {
|
||||
email: 'john@strapi.io',
|
||||
password: 'pwd123',
|
||||
username: null,
|
||||
},
|
||||
};
|
||||
|
||||
expect(reducer(initialState, action)).toEqual(expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe('ON_SUBMIT', () => {
|
||||
|
@ -8,7 +8,7 @@ const schema = yup.object().shape({
|
||||
.string()
|
||||
.email(translatedErrors.email)
|
||||
.required(translatedErrors.required),
|
||||
username: yup.string(),
|
||||
username: yup.string().nullable(),
|
||||
password: yup
|
||||
.string()
|
||||
.min(8, translatedErrors.minLength)
|
||||
|
Loading…
x
Reference in New Issue
Block a user