allow an empty space description to be provided (#24168) (#24183)

This commit is contained in:
Larry Gregory 2018-10-18 06:17:29 -04:00 committed by GitHub
parent f190954b06
commit e42ecd794f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 1 deletions

View file

@ -10,7 +10,7 @@ import { MAX_SPACE_INITIALS } from '../../common/constants';
export const spaceSchema = Joi.object({
id: Joi.string().regex(/[a-z0-9_\-]*/, `lower case, a-z, 0-9, "_", and "-" are allowed`),
name: Joi.string().required(),
description: Joi.string(),
description: Joi.string().allow(''),
initials: Joi.string().max(MAX_SPACE_INITIALS),
color: Joi.string().regex(/^#[a-z0-9]{6}$/, `6 digit hex color, starting with a #`),
_reserved: Joi.boolean(),

View file

@ -64,6 +64,31 @@ describe('Spaces Public API', () => {
});
});
test('PUT /space should allow an empty description', async () => {
const payload = {
id: 'a-space',
name: 'my updated space',
description: '',
};
const { mockSavedObjectsRepository, response } = await request(
'PUT',
'/api/spaces/space/a-space',
{
payload,
}
);
const { statusCode } = response;
expect(statusCode).toEqual(200);
expect(mockSavedObjectsRepository.update).toHaveBeenCalledTimes(1);
expect(mockSavedObjectsRepository.update).toHaveBeenCalledWith('space', 'a-space', {
name: 'my updated space',
description: '',
});
});
test(`returns result of routePreCheckLicense`, async () => {
const payload = {
id: 'a-space',