closes https://github.com/twentyhq/twenty/issues/6041 - enabled removing all dropdown items including the primary one - primary one can be removed even when it is not the last remaining one from the list, this will set the next item on the list as the new primary one (_idk if it was expected to implement this_) https://github.com/twentyhq/twenty/assets/19856731/405a055d-13de-43f4-b3e8-d6a199bfdf24 --------- Co-authored-by: Félix Malfait <felix.malfait@gmail.com>
34 lines
1.2 KiB
TypeScript
34 lines
1.2 KiB
TypeScript
import { absoluteUrlSchema } from '~/utils/validation-schemas/absoluteUrlSchema';
|
|
|
|
describe('absoluteUrlSchema', () => {
|
|
it('validates an absolute url', () => {
|
|
expect(absoluteUrlSchema.parse('https://www.example.com')).toBe(
|
|
'https://www.example.com',
|
|
);
|
|
expect(absoluteUrlSchema.parse('http://subdomain.example.com')).toBe(
|
|
'http://subdomain.example.com',
|
|
);
|
|
expect(absoluteUrlSchema.parse('https://www.example.com/path')).toBe(
|
|
'https://www.example.com/path',
|
|
);
|
|
expect(absoluteUrlSchema.parse('https://www.example.com?query=123')).toBe(
|
|
'https://www.example.com?query=123',
|
|
);
|
|
expect(absoluteUrlSchema.parse('http://localhost:3000')).toBe(
|
|
'http://localhost:3000',
|
|
);
|
|
});
|
|
|
|
it('transforms a non-absolute URL to an absolute URL', () => {
|
|
expect(absoluteUrlSchema.parse('example.com')).toBe('https://example.com');
|
|
expect(absoluteUrlSchema.parse('www.subdomain.example.com')).toBe(
|
|
'https://www.subdomain.example.com',
|
|
);
|
|
});
|
|
|
|
it('fails for invalid urls', () => {
|
|
expect(absoluteUrlSchema.safeParse('?o').success).toBe(false);
|
|
expect(absoluteUrlSchema.safeParse('\\').success).toBe(false);
|
|
});
|
|
});
|