Validate special chars when creating a team (#209)
* Add validation for team account names - Prevent creating teams with reserved names like 'billing' and 'settings' - Add regex validation to block team names with special characters - Update localization for new error messages - Extend E2E tests to cover various invalid team name scenarios * Enhance team account name validation and slug generation - Add comprehensive tests for account slug generation in Supabase - Improve team name validation schema to handle special characters - Add form validation message display in update team account name form - Refine slug generation to handle various edge cases like special characters, non-ASCII text, and mixed case
This commit is contained in:
committed by
GitHub
parent
b265f596da
commit
bd723dccce
@@ -51,6 +51,78 @@ select throws_ok(
|
||||
'duplicate key value violates unique constraint "accounts_slug_key"'
|
||||
);
|
||||
|
||||
-- Test special characters in the slug
|
||||
update public.accounts set slug = 'test-5' where slug = 'test-4[';
|
||||
|
||||
select row_eq(
|
||||
$$ select slug from public.accounts where name = 'Test 4' $$,
|
||||
row('test-4'::text),
|
||||
'Updating the name of a team account should update the slug'
|
||||
);
|
||||
|
||||
-- Test various special characters
|
||||
update public.accounts set name = 'Test@Special#Chars$' where slug = 'test-4';
|
||||
|
||||
select row_eq(
|
||||
$$ select slug from public.accounts where name = 'Test@Special#Chars$' $$,
|
||||
row('test-special-chars'::text),
|
||||
'Special characters should be removed from slug'
|
||||
);
|
||||
|
||||
-- Test multiple consecutive special characters
|
||||
update public.accounts set name = 'Test!!Multiple---Special$$$Chars' where slug = 'test-special-chars';
|
||||
|
||||
select row_eq(
|
||||
$a$ select slug from public.accounts where name = 'Test!!Multiple---Special$$$Chars' $a$,
|
||||
row('test-multiple-special-chars'::text),
|
||||
'Multiple consecutive special characters should be replaced with single hyphen'
|
||||
);
|
||||
|
||||
-- Test leading and trailing special characters
|
||||
update public.accounts set name = '!!!LeadingAndTrailing###' where slug = 'test-multiple-special-chars';
|
||||
|
||||
select row_eq(
|
||||
$$ select slug from public.accounts where name = '!!!LeadingAndTrailing###' $$,
|
||||
row('leadingandtrailing'::text),
|
||||
'Leading and trailing special characters should be removed'
|
||||
);
|
||||
|
||||
-- Test non-ASCII characters
|
||||
update public.accounts set name = 'Testéñ中文Русский' where slug = 'leadingandtrailing';
|
||||
|
||||
select row_eq(
|
||||
$$ select slug from public.accounts where name = 'Testéñ中文Русский' $$,
|
||||
row('testen'::text),
|
||||
'Non-ASCII characters should be transliterated or removed'
|
||||
);
|
||||
|
||||
-- Test mixed case with special characters
|
||||
update public.accounts set name = 'Test Mixed CASE With Special@Chars!' where slug = 'testen';
|
||||
|
||||
select row_eq(
|
||||
$$ select slug from public.accounts where name = 'Test Mixed CASE With Special@Chars!' $$,
|
||||
row('test-mixed-case-with-special-chars'::text),
|
||||
'Mixed case should be converted to lowercase and special chars handled'
|
||||
);
|
||||
|
||||
-- Test using parentheses
|
||||
update public.accounts set name = 'Test (Parentheses)' where slug = 'test-mixed-case-with-special-chars';
|
||||
|
||||
select row_eq(
|
||||
$$ select slug from public.accounts where name = 'Test (Parentheses)' $$,
|
||||
row('test-parentheses'::text),
|
||||
'Parentheses should be removed from slug'
|
||||
);
|
||||
|
||||
-- Test using asterisk
|
||||
update public.accounts set name = 'Test * Asterisk' where slug = 'test-parentheses';
|
||||
|
||||
select row_eq(
|
||||
$$ select slug from public.accounts where name = 'Test * Asterisk' $$,
|
||||
row('test-asterisk'::text),
|
||||
'Asterisk should be removed from slug'
|
||||
);
|
||||
|
||||
select * from finish();
|
||||
|
||||
ROLLBACK;
|
||||
Reference in New Issue
Block a user