Revert "admin lastname defaults to undefined"

This commit is contained in:
Gustav Hansen 2023-07-26 17:52:28 +02:00 committed by Marc-Roig
parent f36e9256a2
commit dbcf405f67
No known key found for this signature in database
GPG Key ID: FB4E2C43A0BEE249
2 changed files with 0 additions and 59 deletions

View File

@ -98,10 +98,6 @@ const Register = ({ authType, fieldsToDisable, noSignin, onSubmit, schema }) =>
if (!['password', 'confirmPassword'].includes(key) && typeof value === 'string') {
normalizedvalue = normalizedvalue.trim();
if (key === 'lastname') {
normalizedvalue = normalizedvalue || null;
}
}
acc[key] = normalizedvalue;

View File

@ -136,61 +136,6 @@ describe('ADMIN | PAGES | AUTH | Register', () => {
);
});
it('Validates optional Lastname value to be null', async () => {
const spy = jest.fn();
const { getByRole, getByLabelText, user } = setup({ onSubmit: spy });
await user.type(getByLabelText(/Firstname/i), 'First name');
await user.type(getByLabelText(/Email/i), 'test@strapi.io');
await user.type(getByLabelText(/^Password/i), 'secret');
await user.type(getByLabelText(/Confirm Password/i), 'secret');
fireEvent.click(getByRole('button', { name: /let's start/i }));
await waitFor(() =>
expect(spy).toHaveBeenCalledWith(
{
firstname: 'First name',
lastname: null,
email: 'test@strapi.io',
news: false,
registrationToken: undefined,
confirmPassword: 'secret',
password: 'secret',
},
expect.any(Object)
)
);
});
it('Validates optional Lastname value to be empty space', async () => {
const spy = jest.fn();
const { getByRole, getByLabelText, user } = setup({ onSubmit: spy });
await user.type(getByLabelText(/Firstname/i), 'First name');
await user.type(getByLabelText(/Lastname/i), ' ');
await user.type(getByLabelText(/Email/i), 'test@strapi.io');
await user.type(getByLabelText(/^Password/i), 'secret');
await user.type(getByLabelText(/Confirm Password/i), 'secret');
fireEvent.click(getByRole('button', { name: /let's start/i }));
await waitFor(() =>
expect(spy).toHaveBeenCalledWith(
{
firstname: 'First name',
lastname: null,
email: 'test@strapi.io',
news: false,
registrationToken: undefined,
confirmPassword: 'secret',
password: 'secret',
},
expect.any(Object)
)
);
});
it('Disable fields', () => {
const { getByLabelText } = setup({
fieldsToDisable: ['email', 'firstname'],