2018-10-13 17:53:16 +00:00
|
|
|
import {
|
|
|
|
|
generateUser,
|
|
|
|
|
translate as t,
|
|
|
|
|
} from '../../../../helpers/api-integration/v4';
|
|
|
|
|
|
|
|
|
|
const ENDPOINT = '/user/auth/verify-display-name';
|
|
|
|
|
|
|
|
|
|
describe('POST /user/auth/verify-display-name', async () => {
|
|
|
|
|
let user;
|
|
|
|
|
|
|
|
|
|
beforeEach(async () => {
|
|
|
|
|
user = await generateUser();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('successfully verifies display name including funky characters', async () => {
|
2019-10-08 18:45:38 +00:00
|
|
|
const newDisplayName = 'Sabé 🤬';
|
|
|
|
|
const response = await user.post(ENDPOINT, {
|
2018-10-13 17:53:16 +00:00
|
|
|
displayName: newDisplayName,
|
|
|
|
|
});
|
|
|
|
|
expect(response).to.eql({ isUsable: true });
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
context('errors', async () => {
|
|
|
|
|
it('errors if display name is not provided', async () => {
|
|
|
|
|
await expect(user.post(ENDPOINT, {
|
|
|
|
|
})).to.eventually.be.rejected.and.eql({
|
|
|
|
|
code: 400,
|
|
|
|
|
error: 'BadRequest',
|
|
|
|
|
message: t('invalidReqParams'),
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('errors if display name is a slur', async () => {
|
|
|
|
|
await expect(user.post(ENDPOINT, {
|
2018-10-14 02:36:14 +00:00
|
|
|
displayName: 'TESTPLACEHOLDERSLURWORDHERE',
|
2021-04-30 20:47:39 +00:00
|
|
|
})).to.eventually.eql({ isUsable: false, issues: [t('bannedSlurUsedInProfile')] });
|
2018-10-13 17:53:16 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('errors if display name contains a slur', async () => {
|
|
|
|
|
await expect(user.post(ENDPOINT, {
|
2018-10-14 02:36:14 +00:00
|
|
|
displayName: 'TESTPLACEHOLDERSLURWORDHERE_otherword',
|
2021-04-30 20:47:39 +00:00
|
|
|
})).to.eventually.eql({
|
|
|
|
|
isUsable: false,
|
|
|
|
|
issues: [t('displaynameIssueLength'), t('bannedSlurUsedInProfile')],
|
|
|
|
|
});
|
2018-10-13 17:53:16 +00:00
|
|
|
await expect(user.post(ENDPOINT, {
|
2018-10-14 02:36:14 +00:00
|
|
|
displayName: 'something_TESTPLACEHOLDERSLURWORDHERE',
|
2021-04-30 20:47:39 +00:00
|
|
|
})).to.eventually.eql({
|
|
|
|
|
isUsable: false,
|
|
|
|
|
issues: [t('displaynameIssueLength'), t('bannedSlurUsedInProfile')],
|
|
|
|
|
});
|
2018-10-13 17:53:16 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('errors if display name has incorrect length', async () => {
|
|
|
|
|
await expect(user.post(ENDPOINT, {
|
2018-10-14 02:36:14 +00:00
|
|
|
displayName: 'this is a very long display name over 30 characters',
|
|
|
|
|
})).to.eventually.eql({ isUsable: false, issues: [t('displaynameIssueLength')] });
|
2018-10-13 17:53:16 +00:00
|
|
|
});
|
2020-07-18 20:41:19 +00:00
|
|
|
|
|
|
|
|
it('errors if display name contains a newline', async () => {
|
|
|
|
|
await expect(user.post(ENDPOINT, {
|
|
|
|
|
displayName: 'namecontainsnewline\n',
|
|
|
|
|
})).to.eventually.eql({ isUsable: false, issues: [t('displaynameIssueNewline')] });
|
|
|
|
|
});
|
2018-10-13 17:53:16 +00:00
|
|
|
});
|
|
|
|
|
});
|