mirror of
				https://github.com/HabitRPG/habitica.git
				synced 2025-10-30 20:52:29 +01:00 
			
		
		
		
	* WIP: report a bug api/ui * fix lint * add USER_USERNAME * extend sendTxn tests / checks + fix bug report email * fix lint * add more checks to sendTxn - fix bug-report variables * fix lint / ci * fix test: reset email config url * fix test stub * fix tests * refactor the variables checks * lint. * move bug-report page as a modal * send user_email to the email * show true/false instead 1/0 * fix issues * fix footer report bug email if not logged in * fix styles/margins * prefill user's email * show facebook email if local email not existing * bugReportSuccessModal.vue * add BROWSER_UA to mail properties * extract bugReportLogic to its own lib file for unit test * test api validators * fix lint
		
			
				
	
	
		
			58 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			58 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| /* eslint-disable global-require */
 | |
| import nconf from 'nconf';
 | |
| import { generateUser } from '../../../helpers/api-unit.helper';
 | |
| import * as emailLib from '../../../../website/server/libs/email';
 | |
| import { bugReportLogic } from '../../../../website/server/libs/bug-report';
 | |
| 
 | |
| describe('bug-report', () => {
 | |
|   beforeEach(() => {
 | |
|     sandbox.stub(emailLib, 'sendTxn').returns(Promise.resolve());
 | |
| 
 | |
|     const nconfGetStub = sandbox.stub(nconf, 'get');
 | |
|     nconfGetStub.withArgs('ADMIN_EMAIL').returns('true');
 | |
|   });
 | |
| 
 | |
|   afterEach(() => {
 | |
|     sandbox.restore();
 | |
|   });
 | |
| 
 | |
|   it('sends a mail using sendTxn', async () => {
 | |
|     const userId = '2b58daeb-bc50-4a83-b5d3-4ac52c7c0608';
 | |
|     const userMail = 'me@me.com';
 | |
|     const userMessage = 'The power is over 9000, please fix it';
 | |
|     const userAgent = 'The UserAgent with a bunch of weird browser engine levels';
 | |
| 
 | |
|     const user = generateUser({
 | |
|       _id: userId,
 | |
|     });
 | |
| 
 | |
|     const result = await bugReportLogic(
 | |
|       user, userMail, userMessage, userAgent,
 | |
|     );
 | |
| 
 | |
|     expect(emailLib.sendTxn).to.be.called;
 | |
|     expect(result).to.deep.equal({
 | |
|       sendMailResult: undefined,
 | |
|       emailData: {
 | |
|         BROWSER_UA: userAgent,
 | |
|         REPORT_MSG: userMessage,
 | |
|         USER_CLASS: 'warrior',
 | |
|         USER_CONSECUTIVE_MONTHS: 0,
 | |
|         USER_COSTUME: 'false',
 | |
|         USER_CUSTOMER_ID: undefined,
 | |
|         USER_CUSTOM_DAY: 0,
 | |
|         USER_DAILIES_PAUSED: 'false',
 | |
|         USER_EMAIL: userMail,
 | |
|         USER_HOURGLASSES: 0,
 | |
|         USER_ID: userId,
 | |
|         USER_LEVEL: 1,
 | |
|         USER_OFFSET_MONTHS: 0,
 | |
|         USER_PAYMENT_PLATFORM: undefined,
 | |
|         USER_SUBSCRIPTION: undefined,
 | |
|         USER_TIMEZONE_OFFSET: 0,
 | |
|         USER_USERNAME: undefined,
 | |
|       },
 | |
|     });
 | |
|   });
 | |
| });
 |