mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-04-14 19:47:03 +00:00
* Updated userItemsNotEnough string * Added a variable to be passed to the deleteSocialAccountText string. This variable name is `magic_word` and is set as DELETE where used * modified incorrectDeletePhrase to use a variable rather than translatable string for the word DELETE. Updated the DELETE-user test and the user api * Changed noSudoAccess from translatable string to static * Changed enterprisePlansEmailSubject from a translatable string to a static string within groupPlans.vue * Fixed test problems with translation fixes * Added no sudo access string to api messages * changed plain string to apiMessage for no sudo access messages
39 lines
1.2 KiB
JavaScript
39 lines
1.2 KiB
JavaScript
import {
|
|
generateUser,
|
|
resetHabiticaDB,
|
|
} from '../../../../helpers/api-v3-integration.helper';
|
|
import apiMessages from '../../../../../website/server/libs/apiMessages';
|
|
|
|
describe('GET /coupons/', () => {
|
|
let user;
|
|
before(async () => {
|
|
await resetHabiticaDB();
|
|
});
|
|
|
|
beforeEach(async () => {
|
|
user = await generateUser();
|
|
});
|
|
|
|
it('returns an error if user has no sudo permission', async () => {
|
|
await user.get('/user'); // needed so the request after this will authenticate with the correct cookie session
|
|
await expect(user.get('/coupons')).to.eventually.be.rejected.and.eql({
|
|
code: 401,
|
|
error: 'NotAuthorized',
|
|
message: apiMessages('noSudoAccess'),
|
|
});
|
|
});
|
|
|
|
it('should return the coupons in CSV format ordered by creation date', async () => {
|
|
await user.update({
|
|
'contributor.sudo': true,
|
|
});
|
|
|
|
let coupons = await user.post('/coupons/generate/wondercon?count=11');
|
|
let res = await user.get('/coupons');
|
|
let splitRes = res.split('\n');
|
|
|
|
expect(splitRes.length).to.equal(13);
|
|
expect(splitRes[0]).to.equal('code,event,date,user');
|
|
expect(splitRes[6].split(',')[1]).to.equal(coupons[5].event);
|
|
});
|
|
});
|