diff --git a/web/src/components/users/FirstUserForm.jsx b/web/src/components/users/FirstUserForm.jsx index 4cecfa12d0..94c9c36220 100644 --- a/web/src/components/users/FirstUserForm.jsx +++ b/web/src/components/users/FirstUserForm.jsx @@ -222,7 +222,6 @@ export default function FirstUserForm() { className="first-username-wrapper" fieldId="userName" label={_("Username")} - isRequired > { + if (!fullName) return []; + // Cleaning the name. const cleanedName = fullName .normalize('NFD') diff --git a/web/src/components/users/utils.test.js b/web/src/components/users/utils.test.js index 1049e3b171..0c303e2803 100644 --- a/web/src/components/users/utils.test.js +++ b/web/src/components/users/utils.test.js @@ -24,6 +24,11 @@ import { suggestUsernames } from "./utils"; describe('suggestUsernames', () => { + test('returns empty collection if fullName not defined', () => { + expect(suggestUsernames(undefined)).toEqual([]); + expect(suggestUsernames(null)).toEqual([]); + }); + test('handles basic single name', () => { expect(suggestUsernames('John')).toEqual(expect.arrayContaining(['john'])); });