How to use onboarding method in qawolf

Best JavaScript code snippet using qawolf

onboarding.js

Source:onboarding.js Github

copy

Full Screen

1'use strict';2let assert = require('chai').assert;3let sinon = require('sinon');4let Onboarding = require('../../app/lib/onboarding.coffee');5let Step = require('../../app/lib/onboarding.coffee').Step;6describe('Onboarding', () => {7 describe('#initialize', () => {8 it('should set `user` property', () => {9 // arrange10 let user = {11 name: 'Claude',12 lastname: 'Causi'13 };14 let steps = [{name: 'test'}];15 // act16 let onboarding = new Onboarding(user, steps);17 // assert18 assert.deepEqual(onboarding.user, user);19 });20 it('should set `steps` property', () => {21 // arrange22 let user = null;23 let steps = [{24 name: 'test',25 route: 'testroute',26 view: 'testview'27 }, {28 name: 'test2',29 route: 'testroute2',30 view: 'testview2'31 }];32 // act33 let onboarding = new Onboarding(user, steps);34 // assert35 assert.isDefined(onboarding.steps);36 assert.equal(2, onboarding.steps.length);37 });38 it('should map steps objects to Steps instances', () => {39 // arrange40 let user = null;41 let steps = [{42 name: 'test',43 route: 'testroute',44 view: 'testview'45 }, {46 name: 'test2',47 route: 'testroute2',48 view: 'testview2'49 }];50 // act51 let onboarding = new Onboarding(user, steps);52 // assert53 let step1 = onboarding.steps[0];54 assert('Step', step1.constructor.name);55 assert.equal('test', step1.name);56 assert.equal('testroute', step1.route);57 assert.equal('testview', step1.view);58 assert.isFunction(step1.onCompleted);59 assert.isFunction(step1.triggerCompleted);60 assert.isFunction(step1.submit);61 let step2 = onboarding.steps[1];62 assert('Step', step2.constructor.name);63 assert.equal('test2', step2.name);64 assert.equal('testroute2', step2.route);65 assert.equal('testview2', step2.view);66 assert.isFunction(step2.onCompleted);67 assert.isFunction(step2.triggerCompleted);68 assert.isFunction(step2.submit);69 });70 it('should throw error when `steps` parameter is missing', () => {71 // arrange72 let fn = () => {73 // act74 let onboarding = new Onboarding();75 }76 // assert77 assert.throw(fn, 'Missing mandatory `steps` parameter');78 });79 it('should not map inActive steps', () => {80 // arrange81 let user = null;82 let steps = [{83 name: 'test',84 route: 'testroute',85 view: 'testview'86 }, {87 name: 'test2',88 route: 'testroute2',89 view: 'testview2',90 isActive: () => false91 }];92 // act93 let onboarding = new Onboarding(user, steps);94 // assert95 assert.equal(1, onboarding.steps.length)96 let step1 = onboarding.steps[0];97 assert('Step', step1.constructor.name);98 assert.equal('test', step1.name);99 assert.equal('testroute', step1.route);100 assert.equal('testview', step1.view);101 });102 it('should set current step', () => {103 // arrange104 let user = null;105 let steps = [{106 name: 'test',107 route: 'testroute',108 view: 'testview'109 }, {110 name: 'test2',111 route: 'testroute2',112 view: 'testview2'113 }];114 let onboardedSteps = ['test']115 // act116 let onboarding = new Onboarding(user, steps, onboardedSteps);117 let step2 = onboarding.getStepByName('test2');118 // assert119 assert.deepEqual(step2, onboarding.currentStep)120 });121 it('should set first step as current step', () => {122 // arrange123 let user = null;124 let steps = [{125 name: 'test',126 route: 'testroute',127 view: 'testview'128 }, {129 name: 'test2',130 route: 'testroute2',131 view: 'testview2'132 }];133 let onboardedSteps = []134 // act135 let onboarding = new Onboarding(user, steps, onboardedSteps);136 let step1 = onboarding.getStepByName('test');137 // assert138 assert.deepEqual(step1, onboarding.currentStep)139 });140 it('should set first step as current step with bad onboardedSteps', () => {141 // arrange142 let user = null;143 let steps = [{144 name: 'test',145 route: 'testroute',146 view: 'testview'147 }, {148 name: 'test2',149 route: 'testroute2',150 view: 'testview2'151 }];152 let onboardedSteps = ['test3', 'test4', 'test5']153 // act154 let onboarding = new Onboarding(user, steps, onboardedSteps);155 let step1 = onboarding.getStepByName('test');156 // assert157 assert.deepEqual(step1, onboarding.currentStep)158 });159 it(160 'should set first step as current step with completed onboardedSteps',161 () => {162 // arrange163 let user = null;164 let steps = [{165 name: 'test',166 route: 'testroute',167 view: 'testview'168 }, {169 name: 'test2',170 route: 'testroute2',171 view: 'testview2'172 }];173 let onboardedSteps = ['test', 'test2']174 // act175 let onboarding = new Onboarding(user, steps, onboardedSteps);176 let step1 = onboarding.getStepByName('test');177 // assert178 assert.deepEqual(step1, onboarding.currentStep)179 });180 it('should throw an error if steps parameter is empty', () => {181 // arrange182 let user = null;183 let steps = [];184 let fn = () => {185 // act186 let onboarding = new Onboarding(user, steps);187 };188 // assert189 assert.throw(fn, '`steps` parameter is empty');190 });191 });192 describe('#onStepChanged', () => {193 it('should add given callback to step changed handlers', () => {194 // arrange195 let onboarding = new Onboarding(null, [{name: 'test'}]);196 let callback = (step) => {};197 // act198 onboarding.onStepChanged(callback);199 // assert200 assert.isDefined(onboarding.stepChangedHandlers);201 assert.equal(1, onboarding.stepChangedHandlers.length);202 assert.include(onboarding.stepChangedHandlers, callback);203 });204 it('should throw an error when callback is not a function', () => {205 // arrange206 let onboarding = new Onboarding(null, [{name: 'test'}]);207 let randomString = 'abc';208 let fn = () => {209 // act210 onboarding.onStepChanged(randomString);211 };212 assert.throws(fn, 'Callback parameter should be a function');213 });214 });215 describe('#onStepFailed', () => {216 it('should add given callback to step failed handlers', () => {217 // arrange218 let onboarding = new Onboarding(null, [{name: 'test'}]);219 let callback = (step) => {};220 // act221 onboarding.onStepFailed(callback);222 // assert223 assert.isDefined(onboarding.stepFailedHandlers);224 assert.equal(1, onboarding.stepFailedHandlers.length);225 assert.include(onboarding.stepFailedHandlers, callback);226 });227 it('should throw an error when callback is not a function', () => {228 // arrange229 let onboarding = new Onboarding(null, [{name: 'test'}]);230 let randomString = 'abc';231 let fn = () => {232 // act233 onboarding.onStepFailed(randomString);234 };235 assert.throws(fn, 'Callback parameter should be a function');236 });237 });238 describe('#onDone', () => {239 it('should add given callback to onDone handler', () => {240 // arrange241 let onboarding = new Onboarding(null, [{name: 'test'}]);242 let callback = (step) => {};243 // act244 onboarding.onDone(callback);245 // assert246 assert.isDefined(onboarding.onDoneHandler);247 assert.equal(1, onboarding.onDoneHandler.length);248 assert.include(onboarding.onDoneHandler, callback);249 });250 it('should throw an error when callback is not a function', () => {251 // arrange252 let onboarding = new Onboarding(null, [{name: 'test'}]);253 let randomString = 'abc';254 let fn = () => {255 // act256 onboarding.onDone(randomString);257 };258 assert.throws(fn, 'Callback parameter should be a function');259 });260 });261 describe('#handleStepCompleted', () => {262 it('should call Onboarding#goToNext', () => {263 // arrange264 let onboarding = new Onboarding(null, [{name: 'test'}]);265 onboarding.goToNext = sinon.spy();266 // act267 onboarding.handleStepCompleted(null);268 // assert269 assert(onboarding.goToNext.calledOnce);270 });271 });272 describe('#goToNext', () => {273 it('should call goToStep with second step', () => {274 // arrange275 let onboarding = new Onboarding(null, [276 {277 name: 'test',278 route: 'testroute',279 view: 'testview'280 }, {281 name: 'test2',282 route: 'testroute2',283 view: 'testview2'284 }285 ]);286 let secondStep = onboarding.steps[1];287 onboarding.goToStep = sinon.spy();288 // act289 onboarding.goToNext();290 // assert291 assert(onboarding.goToStep.calledOnce);292 assert(onboarding.goToStep.calledWith(secondStep));293 });294 it('should call goToStep with next step', () => {295 // arrange296 let onboarding = new Onboarding(null, [297 {298 name: 'test',299 route: 'testroute',300 view: 'testview'301 }, {302 name: 'test2',303 route: 'testroute2',304 view: 'testview2'305 }, {306 name: 'test3',307 route: 'testroute3',308 view: 'testview3'309 }310 ]);311 let secondStep = onboarding.steps[1];312 let thirdStep = onboarding.steps[2];313 onboarding.goToStep(secondStep);314 onboarding.goToStep = sinon.spy();315 // act316 onboarding.goToNext();317 // assert318 assert(onboarding.goToStep.calledOnce);319 assert(onboarding.goToStep.calledWith(thirdStep));320 });321 it('should call triggerDone when current step is the last one', () => {322 // arrange323 let onboarding = new Onboarding(null, [324 {325 name: 'test',326 route: 'testroute',327 view: 'testview'328 }, {329 name: 'test2',330 route: 'testroute2',331 view: 'testview2'332 }, {333 name: 'test3',334 route: 'testroute3',335 view: 'testview3'336 }337 ]);338 let thirdStep = onboarding.steps[2];339 onboarding.goToStep(thirdStep);340 onboarding.triggerDone = sinon.spy();341 // act342 onboarding.goToNext();343 // assert344 assert(onboarding.triggerDone.calledOnce);345 });346 });347 describe('#goToStep', () => {348 it('should set new current step', () => {349 // arrange350 let onboarding = new Onboarding(null, [351 {352 name: 'test',353 route: 'testroute',354 view: 'testview'355 }, {356 name: 'test2',357 route: 'testroute2',358 view: 'testview2'359 }360 ]);361 let firstStep = onboarding.steps[0];362 // act363 onboarding.goToStep(firstStep);364 // assert365 assert.equal(firstStep, onboarding.currentStep);366 });367 it('should call `step.fetchData`', () => {368 // arrange369 let onboarding = new Onboarding(null, [370 {371 name: 'test',372 route: 'testroute',373 view: 'testview'374 }, {375 name: 'test2',376 route: 'testroute2',377 view: 'testview2'378 }379 ]);380 let firstStep = onboarding.steps[0];381 sinon.stub(firstStep, 'fetchData', () => {382 return Promise.resolve()383 });384 // act385 onboarding.goToStep(firstStep);386 // assert387 assert(firstStep.fetchData.calledOnce);388 });389 it('should call `triggerStepChanged` on `fetchData` on success', (done) => {390 // arrange391 let onboarding = new Onboarding(null, [392 {393 name: 'test',394 route: 'testroute',395 view: 'testview'396 }, {397 name: 'test2',398 route: 'testroute2',399 view: 'testview2'400 }401 ]);402 let firstStep = onboarding.steps[0];403 sinon.stub(firstStep, 'fetchData', () => {404 return Promise.resolve(firstStep)405 });406 onboarding.triggerStepChanged = sinon.spy();407 // act408 onboarding.goToStep(firstStep);409 // Handle Promise asynchronicity410 setTimeout( () => {411 // assert412 assert(onboarding.triggerStepChanged.calledOnce);413 assert(onboarding.triggerStepChanged.calledWith(firstStep));414 done();415 }, 5);416 });417 });418 describe('#triggerStepChanged', () => {419 it('should not throw error when `stepChangedHandlers` is empty', () => {420 // arrange421 let onboarding = new Onboarding(null, [{422 name: 'test',423 route: 'testroute',424 view: 'testview'425 }, {426 name: 'test2',427 route: 'testroute2',428 view: 'testview2'429 }]);430 let stepToTrigger = onboarding.steps[0];431 let fn = () => {432 // act433 onboarding.triggerStepChanged(stepToTrigger);434 };435 // assert436 assert.doesNotThrow(fn);437 });438 it('should call registered callbacks', () => {439 // arrange440 let onboarding = new Onboarding(null, [{441 name: 'test',442 route: 'testroute',443 view: 'testview'444 }, {445 name: 'test2',446 route: 'testroute2',447 view: 'testview2'448 }]);449 let stepToTrigger = onboarding.steps[0];450 let callback1 = sinon.spy();451 let callback2 = sinon.spy();452 onboarding.onStepChanged(callback1);453 onboarding.onStepChanged(callback2);454 // act455 onboarding.triggerStepChanged(stepToTrigger);456 // assert457 assert(callback1.calledOnce);458 assert(callback2.calledOnce);459 assert(callback1.calledWith(stepToTrigger));460 assert(callback2.calledWith(stepToTrigger));461 });462 });463 describe('#handleStepError', () => {464 it('should set current step with current error', () => {465 // arrange466 let onboarding = new Onboarding(null, [467 {468 name: 'test',469 route: 'testroute',470 view: 'testview'471 }, {472 name: 'test2',473 route: 'testroute2',474 view: 'testview2'475 }476 ]);477 let firstStep = onboarding.steps[0];478 let errorObject = {error: 'step error occured'}479 // act480 onboarding.handleStepError(firstStep, errorObject);481 // assert482 assert.equal(firstStep, onboarding.currentStep);483 assert.equal(errorObject, onboarding.currentError);484 });485 it('should call `triggerStepErrors`', () => {486 // arrange487 let onboarding = new Onboarding(null, [488 {489 name: 'test',490 route: 'testroute',491 view: 'testview'492 }, {493 name: 'test2',494 route: 'testroute2',495 view: 'testview2'496 }497 ]);498 let firstStep = onboarding.steps[0];499 let errorObject = {error: 'step error occured'}500 onboarding.triggerStepErrors = sinon.spy();501 // act502 onboarding.handleStepError(firstStep, errorObject);503 // assert504 assert(onboarding.triggerStepErrors.calledOnce);505 assert(onboarding.triggerStepErrors.calledWith(506 firstStep,507 errorObject508 ));509 });510 });511 describe('#triggerStepErrors', () => {512 it('should not throw error when `stepFailedHandlers` is empty', () => {513 // arrange514 let onboarding = new Onboarding(null, [{515 name: 'test',516 route: 'testroute',517 view: 'testview'518 }, {519 name: 'test2',520 route: 'testroute2',521 view: 'testview2'522 }]);523 let stepToTrigger = onboarding.steps[0];524 let errorObject = {error: 'step error occured'};525 let fn = () => {526 // act527 onboarding.triggerStepErrors(stepToTrigger, errorObject);528 };529 // assert530 assert.doesNotThrow(fn);531 });532 it('should call registered callbacks', () => {533 // arrange534 let onboarding = new Onboarding(null, [{535 name: 'test',536 route: 'testroute',537 view: 'testview'538 }, {539 name: 'test2',540 route: 'testroute2',541 view: 'testview2'542 }]);543 let stepToTrigger = onboarding.steps[0];544 let errorObject = {error: 'step error occured'};545 let callback1 = sinon.spy();546 let callback2 = sinon.spy();547 onboarding.onStepFailed(callback1);548 onboarding.onStepFailed(callback2);549 // act550 onboarding.triggerStepErrors(stepToTrigger, errorObject);551 // assert552 assert(callback1.calledOnce);553 assert(callback2.calledOnce);554 assert(callback1.calledWith(stepToTrigger, errorObject));555 assert(callback2.calledWith(stepToTrigger, errorObject));556 });557 });558 describe('#triggerDone', () => {559 it('should not throw error when `onDoneHandler` is empty', () => {560 // arrange561 let onboarding = new Onboarding(null, [{562 name: 'test',563 route: 'testroute',564 view: 'testview'565 }, {566 name: 'test2',567 route: 'testroute2',568 view: 'testview2'569 }]);570 let stepToTrigger = onboarding.steps[0];571 let errorObject = null;572 let fn = () => {573 // act574 onboarding.triggerDone(errorObject);575 };576 // assert577 assert.doesNotThrow(fn);578 });579 it('should call registered callbacks', () => {580 // arrange581 let onboarding = new Onboarding(null, [{582 name: 'test',583 route: 'testroute',584 view: 'testview'585 }, {586 name: 'test2',587 route: 'testroute2',588 view: 'testview2'589 }]);590 let stepToTrigger = onboarding.steps[0];591 let errorObject = null;592 let callback1 = sinon.spy();593 let callback2 = sinon.spy();594 onboarding.onDone(callback1);595 onboarding.onDone(callback2);596 // act597 onboarding.triggerDone(errorObject);598 // assert599 assert(callback1.calledOnce);600 assert(callback2.calledOnce);601 assert(callback1.calledWith(errorObject));602 assert(callback2.calledWith(errorObject));603 });604 });605 describe('#getStepByName', () => {606 it('should retrieve step by its name', () => {607 // arrange608 let onboarding = new Onboarding(null, [609 {610 name: 'test',611 route: 'testroute',612 view: 'testview'613 }, {614 name: 'test2',615 route: 'testroute2',616 view: 'testview2'617 }, {618 name: 'test3',619 route: 'testroute3',620 view: 'testview3'621 }622 ]);623 let secondStep = onboarding.steps[1];624 // act625 let result = onboarding.getStepByName('test2');626 // assert627 assert.equal(secondStep, result);628 });629 it('should return undefined when the given name does not match', () => {630 // arrange631 let onboarding = new Onboarding(null, [632 {633 name: 'test',634 route: 'testroute',635 view: 'testview'636 }, {637 name: 'test2',638 route: 'testroute2',639 view: 'testview2'640 }, {641 name: 'test3',642 route: 'testroute3',643 view: 'testview3'644 }645 ]);646 // act647 let result = onboarding.getStepByName('notExisting');648 // assert649 assert.isUndefined(result);650 });651 });652 describe('#getProgression', () => {653 it('should return expected total', () => {654 // arrange655 let onboarding = new Onboarding(null, [656 {657 name: 'test',658 route: 'testroute',659 view: 'testview'660 }, {661 name: 'test2',662 route: 'testroute2',663 view: 'testview2'664 }, {665 name: 'test3',666 route: 'testroute3',667 view: 'testview3'668 }669 ]);670 let step = onboarding.getStepByName('test');671 // act672 let result = onboarding.getProgression(step);673 // assert674 assert.equal(3, result.total);675 });676 it('should return first step as current', () => {677 // arrange678 let onboarding = new Onboarding(null, [679 {680 name: 'test',681 route: 'testroute',682 view: 'testview'683 }, {684 name: 'test2',685 route: 'testroute2',686 view: 'testview2'687 }, {688 name: 'test3',689 route: 'testroute3',690 view: 'testview3'691 }692 ]);693 let step = onboarding.getStepByName('test');694 // act695 onboarding.goToStep(step);696 let result = onboarding.getProgression(step);697 // assert698 assert.equal(1, result.current);699 });700 it('should return expected current', () => {701 // arrange702 let onboarding = new Onboarding(null, [703 {704 name: 'test',705 route: 'testroute',706 view: 'testview'707 }, {708 name: 'test2',709 route: 'testroute2',710 view: 'testview2'711 }, {712 name: 'test3',713 route: 'testroute3',714 view: 'testview3'715 }716 ]);717 let step = onboarding.getStepByName('test2');718 // act719 onboarding.goToStep(step);720 let result = onboarding.getProgression(step);721 // assert722 assert.equal(2, result.current);723 });724 it('should return last step as current', () => {725 // arrange726 let onboarding = new Onboarding(null, [727 {728 name: 'test',729 route: 'testroute',730 view: 'testview'731 }, {732 name: 'test2',733 route: 'testroute2',734 view: 'testview2'735 }, {736 name: 'test3',737 route: 'testroute3',738 view: 'testview3'739 }740 ]);741 let step = onboarding.getStepByName('test3');742 // act743 onboarding.goToStep(step);744 let result = onboarding.getProgression(step);745 // assert746 assert.equal(3, result.current);747 });748 it('should return expected labels', () => {749 // arrange750 let onboarding = new Onboarding(null, [751 {752 name: 'test',753 route: 'testroute',754 view: 'testview'755 }, {756 name: 'test2',757 route: 'testroute2',758 view: 'testview2'759 }, {760 name: 'test3',761 route: 'testroute3',762 view: 'testview3'763 }764 ]);765 let step = onboarding.getStepByName('test');766 let expectedLabels = ['test', 'test2', 'test3'];767 // act768 let result = onboarding.getProgression(step);769 // assert770 assert.deepEqual(expectedLabels, result.labels);771 });772 });773 describe('#getNextStep', () => {774 it('should throw error when no step is given in parameter', () => {775 // arrange776 let onboarding = new Onboarding(null, [777 {778 name: 'test',779 route: 'testroute',780 view: 'testview'781 }, {782 name: 'test2',783 route: 'testroute2',784 view: 'testview2'785 }, {786 name: 'test3',787 route: 'testroute3',788 view: 'testview3'789 }790 ]);791 let fn = () => {792 // act793 let result = onboarding.getNextStep();794 };795 // assert796 assert.throw(fn, 'Mandatory parameter step is missing');797 });798 it('should throw error when given step is not in step list', () => {799 // arrange800 let onboarding = new Onboarding(null, [801 {802 name: 'test',803 route: 'testroute',804 view: 'testview'805 }, {806 name: 'test2',807 route: 'testroute2',808 view: 'testview2'809 }, {810 name: 'test3',811 route: 'testroute3',812 view: 'testview3'813 }814 ]);815 let otherStep = new Step({816 name: 'otherStep',817 route: 'otherRoute',818 view: 'otherView'819 });820 let fn = () => {821 // act822 let result = onboarding.getNextStep(otherStep);823 };824 // assert825 assert.throw(fn, 'Given step missing in onboarding step list');826 });827 it('should return next step', () => {828 // arrange829 let onboarding = new Onboarding(null, [830 {831 name: 'test',832 route: 'testroute',833 view: 'testview'834 }, {835 name: 'test2',836 route: 'testroute2',837 view: 'testview2'838 }, {839 name: 'test3',840 route: 'testroute3',841 view: 'testview3'842 }843 ]);844 let step1 = onboarding.getStepByName('test');845 let step2 = onboarding.getStepByName('test2');846 // act847 let result = onboarding.getNextStep(step1);848 // assert849 assert.equal(step2, result);850 });851 it('should return null when current step is last step', () => {852 // arrange853 let onboarding = new Onboarding(null, [854 {855 name: 'test',856 route: 'testroute',857 view: 'testview'858 }, {859 name: 'test2',860 route: 'testroute2',861 view: 'testview2'862 }, {863 name: 'test3',864 route: 'testroute3',865 view: 'testview3'866 }867 ]);868 let step3 = onboarding.getStepByName('test3');869 // act870 let result = onboarding.getNextStep(step3);871 // assert872 assert.isNull(result);873 });874 });875 describe('#getCurrentStep', () => {876 it('should return the current step even after goToNext', () => {877 // arrange878 let onboarding = new Onboarding(null, [879 {880 name: 'test',881 route: 'testroute',882 view: 'testview'883 }, {884 name: 'test2',885 route: 'testroute2',886 view: 'testview2'887 }888 ], 'test');889 // act890 let firstStep = onboarding.steps[0];891 let result = onboarding.getCurrentStep();892 // assert893 assert.equal(result.name, firstStep.name);894 assert.equal(result.route, firstStep.route);895 assert.equal(result.testview, firstStep.testview);896 // act again897 onboarding.goToNext(result);898 let secondStep = onboarding.steps[1];899 result = onboarding.getCurrentStep();900 // assert again901 assert.equal(result.name, secondStep.name);902 assert.equal(result.route, secondStep.route);903 assert.equal(result.testview, secondStep.testview);904 });905 });...

Full Screen

Full Screen

OnboardingMessageProvider.jsm

Source:OnboardingMessageProvider.jsm Github

copy

Full Screen

1/* This Source Code Form is subject to the terms of the Mozilla Public2 * License, v. 2.0. If a copy of the MPL was not distributed with this3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */4"use strict";5/* globals Localization */6ChromeUtils.defineModuleGetter(7 this,8 "AttributionCode",9 "resource:///modules/AttributionCode.jsm"10);11ChromeUtils.defineModuleGetter(12 this,13 "AddonRepository",14 "resource://gre/modules/addons/AddonRepository.jsm"15);16const { FX_MONITOR_OAUTH_CLIENT_ID } = ChromeUtils.import(17 "resource://gre/modules/FxAccountsCommon.js"18);19const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");20const L10N = new Localization([21 "branding/brand.ftl",22 "browser/branding/brandings.ftl",23 "browser/branding/sync-brand.ftl",24 "browser/newtab/onboarding.ftl",25]);26const TRAILHEAD_ONBOARDING_TEMPLATE = {27 trigger: { id: "firstRun" },28 template: "trailhead",29 includeBundle: {30 length: 3,31 template: "onboarding",32 trigger: { id: "showOnboarding" },33 },34};35const TRAILHEAD_FULL_PAGE_CONTENT = {36 title: { string_id: "onboarding-welcome-body" },37 learn: {38 text: { string_id: "onboarding-welcome-learn-more" },39 url: "https://www.mozilla.org/firefox/accounts/",40 },41 form: {42 title: { string_id: "onboarding-welcome-form-header" },43 text: { string_id: "onboarding-join-form-body" },44 email: { string_id: "onboarding-fullpage-form-email" },45 button: { string_id: "onboarding-join-form-continue" },46 },47};48const DEFAULT_WELCOME_CONTENT = {49 className: "welcomeCohort",50 benefits: ["sync", "monitor", "lockwise"].map(id => ({51 id,52 title: { string_id: `onboarding-benefit-${id}-title` },53 text: { string_id: `onboarding-benefit-${id}-text` },54 })),55 learn: {56 text: { string_id: "onboarding-welcome-modal-family-learn-more" },57 url: "https://www.mozilla.org/firefox/accounts/",58 },59 form: {60 title: { string_id: "onboarding-welcome-form-header" },61 text: { string_id: "onboarding-join-form-body" },62 email: { string_id: "onboarding-join-form-email" },63 button: { string_id: "onboarding-join-form-continue" },64 },65 skipButton: { string_id: "onboarding-start-browsing-button-label" },66};67const ONBOARDING_MESSAGES = () => [68 {69 id: "TRAILHEAD_1",70 utm_term: "trailhead-join",71 ...TRAILHEAD_ONBOARDING_TEMPLATE,72 content: {73 ...DEFAULT_WELCOME_CONTENT,74 title: { string_id: "onboarding-welcome-body" },75 },76 },77 {78 id: "TRAILHEAD_2",79 targeting: "trailheadInterrupt == 'sync'",80 utm_term: "trailhead-sync",81 ...TRAILHEAD_ONBOARDING_TEMPLATE,82 content: {83 className: "syncCohort",84 title: { string_id: "onboarding-sync-welcome-header" },85 subtitle: { string_id: "onboarding-sync-welcome-content" },86 benefits: [],87 learn: {88 text: { string_id: "onboarding-sync-welcome-learn-more-link" },89 url: "https://www.mozilla.org/firefox/accounts/",90 },91 form: {92 title: { string_id: "onboarding-sync-form-header" },93 text: { string_id: "onboarding-sync-form-sub-header" },94 email: { string_id: "onboarding-sync-form-input" },95 button: { string_id: "onboarding-sync-form-continue-button" },96 },97 skipButton: { string_id: "onboarding-sync-form-skip-login-button" },98 },99 },100 {101 id: "TRAILHEAD_3",102 targeting: "trailheadInterrupt == 'cards'",103 utm_term: "trailhead-cards",104 ...TRAILHEAD_ONBOARDING_TEMPLATE,105 },106 {107 id: "TRAILHEAD_4",108 template: "trailhead",109 targeting: "trailheadInterrupt == 'nofirstrun'",110 trigger: { id: "firstRun" },111 },112 {113 id: "TRAILHEAD_6",114 targeting: "trailheadInterrupt == 'modal_variant_a'",115 utm_term: "trailhead-modal_variant_a",116 ...TRAILHEAD_ONBOARDING_TEMPLATE,117 content: {118 ...DEFAULT_WELCOME_CONTENT,119 title: { string_id: "onboarding-welcome-modal-get-body" },120 },121 },122 {123 id: "TRAILHEAD_7",124 targeting: "trailheadInterrupt == 'modal_variant_b'",125 utm_term: "trailhead-modal_variant_b",126 ...TRAILHEAD_ONBOARDING_TEMPLATE,127 content: {128 ...DEFAULT_WELCOME_CONTENT,129 title: { string_id: "onboarding-welcome-modal-supercharge-body" },130 },131 },132 {133 id: "TRAILHEAD_8",134 targeting: "trailheadInterrupt == 'modal_variant_c'",135 utm_term: "trailhead-modal_variant_c",136 ...TRAILHEAD_ONBOARDING_TEMPLATE,137 content: {138 ...DEFAULT_WELCOME_CONTENT,139 title: { string_id: "onboarding-welcome-modal-privacy-body" },140 },141 },142 {143 id: "FULL_PAGE_1",144 targeting: "trailheadInterrupt == 'full_page_d'",145 utm_term: "trailhead-full_page_d",146 ...TRAILHEAD_ONBOARDING_TEMPLATE,147 content: {148 ...TRAILHEAD_FULL_PAGE_CONTENT,149 },150 template: "full_page_interrupt",151 },152 {153 id: "FULL_PAGE_2",154 targeting: "trailheadInterrupt == 'full_page_e'",155 utm_term: "trailhead-full_page_e",156 ...TRAILHEAD_ONBOARDING_TEMPLATE,157 content: {158 className: "fullPageCardsAtTop",159 ...TRAILHEAD_FULL_PAGE_CONTENT,160 },161 template: "full_page_interrupt",162 },163 {164 id: "EXTENDED_TRIPLETS_1",165 template: "extended_triplets",166 campaign: "firstrun_triplets",167 targeting:168 "trailheadTriplet && ((currentDate|date - profileAgeCreated) / 86400000) < 7",169 includeBundle: {170 length: 3,171 template: "onboarding",172 trigger: { id: "showOnboarding" },173 },174 frequency: { lifetime: 5 },175 utm_term: "trailhead-cards",176 },177 {178 id: "TRAILHEAD_CARD_1",179 template: "onboarding",180 bundled: 3,181 order: 3,182 content: {183 title: { string_id: "onboarding-tracking-protection-title2" },184 text: { string_id: "onboarding-tracking-protection-text2" },185 icon: "tracking",186 primary_button: {187 label: { string_id: "onboarding-tracking-protection-button2" },188 action:189 Services.locale.appLocaleAsBCP47.substr(0, 2) === "en"190 ? {191 type: "OPEN_URL",192 data: {193 args: "https://mzl.la/ETPdefault",194 where: "tabshifted",195 },196 }197 : {198 type: "OPEN_PREFERENCES_PAGE",199 data: { category: "privacy-trackingprotection" },200 },201 },202 },203 targeting: "trailheadTriplet == 'privacy'",204 trigger: { id: "showOnboarding" },205 },206 {207 id: "TRAILHEAD_CARD_2",208 template: "onboarding",209 bundled: 3,210 order: 1,211 content: {212 title: { string_id: "onboarding-data-sync-title" },213 text: { string_id: "onboarding-data-sync-text2" },214 icon: "devices",215 primary_button: {216 label: { string_id: "onboarding-data-sync-button2" },217 action: {218 type: "OPEN_URL",219 addFlowParams: true,220 data: {221 args:222 "https://accounts.firefox.com/?service=sync&action=email&context=fx_desktop_v3&entrypoint=activity-stream-firstrun&style=trailhead",223 where: "tabshifted",224 },225 },226 },227 },228 targeting:229 "(trailheadTriplet in ['supercharge', 'static'] || ( 'dynamic' in trailheadTriplet && usesFirefoxSync == false)) && isChinaRepack == false",230 trigger: { id: "showOnboarding" },231 },232 {233 id: "TRAILHEAD_CARD_3",234 template: "onboarding",235 bundled: 3,236 order: 2,237 content: {238 title: { string_id: "onboarding-firefox-monitor-title" },239 text: { string_id: "onboarding-firefox-monitor-text2" },240 icon: "ffmonitor",241 primary_button: {242 label: { string_id: "onboarding-firefox-monitor-button" },243 action: {244 type: "OPEN_URL",245 data: { args: "https://monitor.firefox.com/", where: "tabshifted" },246 },247 },248 },249 // Use service oauth client_id to identify 'Firefox Monitor' service attached to Firefox Account250 // https://docs.telemetry.mozilla.org/datasets/fxa_metrics/attribution.html#service-attribution251 targeting: `(trailheadTriplet in ['supercharge', 'static', 'privacy'] || ('dynamic' in trailheadTriplet && !("${FX_MONITOR_OAUTH_CLIENT_ID}" in attachedFxAOAuthClients|mapToProperty('id')))) && isChinaRepack == false`,252 trigger: { id: "showOnboarding" },253 },254 {255 id: "TRAILHEAD_CARD_4",256 template: "onboarding",257 bundled: 3,258 order: 3,259 content: {260 title: { string_id: "onboarding-browse-privately-title" },261 text: { string_id: "onboarding-browse-privately-text" },262 icon: "private",263 primary_button: {264 label: { string_id: "onboarding-browse-privately-button" },265 action: { type: "OPEN_PRIVATE_BROWSER_WINDOW" },266 },267 },268 targeting: "'dynamic' in trailheadTriplet",269 trigger: { id: "showOnboarding" },270 },271 {272 id: "TRAILHEAD_CARD_5",273 template: "onboarding",274 bundled: 3,275 order: 5,276 content: {277 title: { string_id: "onboarding-firefox-send-title" },278 text: { string_id: "onboarding-firefox-send-text2" },279 icon: "ffsend",280 primary_button: {281 label: { string_id: "onboarding-firefox-send-button" },282 action: {283 type: "OPEN_URL",284 data: { args: "https://send.firefox.com/", where: "tabshifted" },285 },286 },287 },288 targeting: "trailheadTriplet == 'payoff' && isChinaRepack == false",289 trigger: { id: "showOnboarding" },290 },291 {292 id: "TRAILHEAD_CARD_6",293 template: "onboarding",294 bundled: 3,295 order: 6,296 content: {297 title: { string_id: "onboarding-mobile-phone-title" },298 text: { string_id: "onboarding-mobile-phone-text" },299 icon: "mobile",300 primary_button: {301 label: { string_id: "onboarding-mobile-phone-button" },302 action: {303 type: "OPEN_URL",304 data: {305 args: "https://www.mozilla.org/firefox/mobile/",306 where: "tabshifted",307 },308 },309 },310 },311 targeting:312 "trailheadTriplet in ['supercharge', 'static'] || ('dynamic' in trailheadTriplet && sync.mobileDevices < 1)",313 trigger: { id: "showOnboarding" },314 },315 {316 id: "TRAILHEAD_CARD_7",317 template: "onboarding",318 bundled: 3,319 order: 4,320 content: {321 title: { string_id: "onboarding-send-tabs-title" },322 text: { string_id: "onboarding-send-tabs-text2" },323 icon: "sendtab",324 primary_button: {325 label: { string_id: "onboarding-send-tabs-button" },326 action: {327 type: "OPEN_URL",328 data: {329 args:330 "https://support.mozilla.org/kb/send-tab-firefox-desktop-other-devices",331 where: "tabshifted",332 },333 },334 },335 },336 targeting: "'dynamic' in trailheadTriplet",337 trigger: { id: "showOnboarding" },338 },339 {340 id: "TRAILHEAD_CARD_8",341 template: "onboarding",342 bundled: 3,343 order: 2,344 content: {345 title: { string_id: "onboarding-pocket-anywhere-title" },346 text: { string_id: "onboarding-pocket-anywhere-text2" },347 icon: "pocket",348 primary_button: {349 label: { string_id: "onboarding-pocket-anywhere-button" },350 action: {351 type: "OPEN_URL",352 data: {353 args: "https://getpocket.com/firefox_learnmore",354 where: "tabshifted",355 },356 },357 },358 },359 targeting: "trailheadTriplet == 'multidevice' && isChinaRepack == false",360 trigger: { id: "showOnboarding" },361 },362 {363 id: "TRAILHEAD_CARD_9",364 template: "onboarding",365 bundled: 3,366 order: 7,367 content: {368 title: { string_id: "onboarding-lockwise-strong-passwords-title" },369 text: { string_id: "onboarding-lockwise-strong-passwords-text" },370 icon: "lockwise",371 primary_button: {372 label: { string_id: "onboarding-lockwise-strong-passwords-button" },373 action: {374 type: "OPEN_ABOUT_PAGE",375 data: { args: "logins", where: "tabshifted" },376 },377 },378 },379 targeting: "'dynamic' in trailheadTriplet && isChinaRepack == false",380 trigger: { id: "showOnboarding" },381 },382 {383 id: "TRAILHEAD_CARD_10",384 template: "onboarding",385 bundled: 3,386 order: 4,387 content: {388 title: { string_id: "onboarding-facebook-container-title" },389 text: { string_id: "onboarding-facebook-container-text2" },390 icon: "fbcont",391 primary_button: {392 label: { string_id: "onboarding-facebook-container-button" },393 action: {394 type: "OPEN_URL",395 data: {396 args:397 "https://addons.mozilla.org/firefox/addon/facebook-container/",398 where: "tabshifted",399 },400 },401 },402 },403 targeting: "trailheadTriplet == 'payoff' && isChinaRepack == false",404 trigger: { id: "showOnboarding" },405 },406 {407 id: "TRAILHEAD_CARD_11",408 template: "onboarding",409 bundled: 3,410 order: 0,411 content: {412 title: { string_id: "onboarding-import-browser-settings-title" },413 text: { string_id: "onboarding-import-browser-settings-text" },414 icon: "import",415 primary_button: {416 label: { string_id: "onboarding-import-browser-settings-button" },417 action: { type: "SHOW_MIGRATION_WIZARD" },418 },419 },420 targeting: "trailheadTriplet == 'dynamic_chrome'",421 trigger: { id: "showOnboarding" },422 },423 {424 id: "TRAILHEAD_CARD_12",425 template: "onboarding",426 bundled: 3,427 order: 1,428 content: {429 title: { string_id: "onboarding-personal-data-promise-title" },430 text: { string_id: "onboarding-personal-data-promise-text" },431 icon: "pledge",432 primary_button: {433 label: { string_id: "onboarding-personal-data-promise-button" },434 action: {435 type: "OPEN_URL",436 data: {437 args: "https://www.mozilla.org/firefox/privacy/",438 where: "tabshifted",439 },440 },441 },442 },443 targeting: "trailheadTriplet == 'privacy'",444 trigger: { id: "showOnboarding" },445 },446 {447 id: "RETURN_TO_AMO_1",448 template: "return_to_amo_overlay",449 content: {450 header: { string_id: "onboarding-welcome-header" },451 title: { string_id: "return-to-amo-sub-header" },452 addon_icon: null,453 icon: "gift-extension",454 text: {455 string_id: "return-to-amo-addon-header",456 args: { "addon-name": null },457 },458 primary_button: {459 label: { string_id: "return-to-amo-extension-button" },460 action: {461 type: "INSTALL_ADDON_FROM_URL",462 data: { url: null, telemetrySource: "rtamo" },463 },464 },465 secondary_button: {466 label: { string_id: "return-to-amo-get-started-button" },467 },468 },469 includeBundle: {470 length: 3,471 template: "onboarding",472 trigger: { id: "showOnboarding" },473 },474 targeting:475 "attributionData.campaign == 'non-fx-button' && attributionData.source == 'addons.mozilla.org'",476 trigger: { id: "firstRun" },477 },478 {479 id: "FXA_ACCOUNTS_BADGE",480 template: "toolbar_badge",481 content: {482 delay: 10000, // delay for 10 seconds483 target: "fxa-toolbar-menu-button",484 },485 // Never accessed the FxA panel && doesn't use Firefox sync & has FxA enabled486 targeting: `!hasAccessedFxAPanel && !usesFirefoxSync && isFxAEnabled == true`,487 trigger: { id: "toolbarBadgeUpdate" },488 },489 {490 id: "PROTECTIONS_PANEL_1",491 template: "protections_panel",492 content: {493 title: { string_id: "cfr-protections-panel-header" },494 body: { string_id: "cfr-protections-panel-body" },495 link_text: { string_id: "cfr-protections-panel-link-text" },496 cta_url: `${Services.urlFormatter.formatURLPref(497 "app.support.baseURL"498 )}etp-promotions?as=u&utm_source=inproduct`,499 cta_type: "OPEN_URL",500 },501 trigger: { id: "protectionsPanelOpen" },502 },503];504const OnboardingMessageProvider = {505 async getExtraAttributes() {506 const [header, button_label] = await L10N.formatMessages([507 { id: "onboarding-welcome-header" },508 { id: "onboarding-start-browsing-button-label" },509 ]);510 return { header: header.value, button_label: button_label.value };511 },512 async getMessages() {513 const messages = await this.translateMessages(await ONBOARDING_MESSAGES());514 return messages;515 },516 async getUntranslatedMessages() {517 // This is helpful for jsonSchema testing - since we are localizing in the provider518 const messages = await ONBOARDING_MESSAGES();519 return messages;520 },521 async translateMessages(messages) {522 let translatedMessages = [];523 for (const msg of messages) {524 let translatedMessage = { ...msg };525 // If the message has no content, do not attempt to translate it526 if (!translatedMessage.content) {527 translatedMessages.push(translatedMessage);528 continue;529 }530 // We need some addon info if we are showing return to amo overlay, so fetch531 // that, and update the message accordingly532 if (msg.template === "return_to_amo_overlay") {533 try {534 const { name, iconURL, url } = await this.getAddonInfo();535 // If we do not have all the data from the AMO api to indicate to the user536 // what they are installing we don't want to show the message537 if (!name || !iconURL || !url) {538 continue;539 }540 msg.content.text.args["addon-name"] = name;541 msg.content.addon_icon = iconURL;542 msg.content.primary_button.action.data.url = url;543 } catch (e) {544 continue;545 }546 // We know we want to show this message, so translate message strings547 const [548 primary_button_string,549 title_string,550 text_string,551 ] = await L10N.formatMessages([552 { id: msg.content.primary_button.label.string_id },553 { id: msg.content.title.string_id },554 { id: msg.content.text.string_id, args: msg.content.text.args },555 ]);556 translatedMessage.content.primary_button.label =557 primary_button_string.value;558 translatedMessage.content.title = title_string.value;559 translatedMessage.content.text = text_string.value;560 }561 // Translate any secondary buttons separately562 if (msg.content.secondary_button) {563 const [secondary_button_string] = await L10N.formatMessages([564 { id: msg.content.secondary_button.label.string_id },565 ]);566 translatedMessage.content.secondary_button.label =567 secondary_button_string.value;568 }569 if (msg.content.header) {570 const [header_string] = await L10N.formatMessages([571 { id: msg.content.header.string_id },572 ]);573 translatedMessage.content.header = header_string.value;574 }575 translatedMessages.push(translatedMessage);576 }577 return translatedMessages;578 },579 async getAddonInfo() {580 try {581 let { content, source } = await AttributionCode.getAttrDataAsync();582 if (!content || source !== "addons.mozilla.org") {583 return null;584 }585 // Attribution data can be double encoded586 while (content.includes("%")) {587 try {588 const result = decodeURIComponent(content);589 if (result === content) {590 break;591 }592 content = result;593 } catch (e) {594 break;595 }596 }597 const [addon] = await AddonRepository.getAddonsByIDs([content]);598 if (addon.sourceURI.scheme !== "https") {599 return null;600 }601 return {602 name: addon.name,603 url: addon.sourceURI.spec,604 iconURL: addon.icons["64"] || addon.icons["32"],605 };606 } catch (e) {607 Cu.reportError(608 "Failed to get the latest add-on version for Return to AMO"609 );610 return null;611 }612 },613};614this.OnboardingMessageProvider = OnboardingMessageProvider;...

Full Screen

Full Screen

onboardingGroups.migrations.ts

Source:onboardingGroups.migrations.ts Github

copy

Full Screen

1import {2 getOnboardingGroups,3 insertOnboardingGroups,4 getOnboardingGroupTexts,5 insertOnboardingGroupTexts,6 getOnboardingList,7 insertOnboardingList,8} from "../queries/onboardingGroups.queries";9import {PoolClient} from "pg";10const migrateOnboardingGroups = async (11 applicationid: any,12 destApplicationId: any,13 contentIDsMap: any,14 flowsIDMap: any,15 sourceClient: PoolClient,16 destClient: PoolClient17) => {18 try {19 const onboardingGroupsIDMap = await migrateOnboardingGroupsTable(20 applicationid,21 destApplicationId,22 sourceClient,23 destClient,24 );25 if (typeof onboardingGroupsIDMap !== "object") return onboardingGroupsIDMap;26 const onboardingGroupTextsIDMap = await migrateOnboardingGroupTexts(27 applicationid,28 onboardingGroupsIDMap,29 sourceClient,30 destClient31 );32 const onboardingListsIDMap = await migrateOnbaordingLists(33 applicationid,34 onboardingGroupsIDMap,35 contentIDsMap,36 flowsIDMap,37 sourceClient,38 destClient39 );40 return [onboardingGroupsIDMap, onboardingGroupTextsIDMap, onboardingListsIDMap];41 } catch (error) {42 return error;43 }44};45const migrateOnboardingGroupsTable = async (46 applicationid: any,47 destApplicationId: any,48 sourceClient: PoolClient,49 destClient: PoolClient50) => {51 try {52 const onboardingGroupsIDMap: any = new Map(); // **Map for tracking the new and old Validation IDs**53 // **Querying for the results of on_boarding_groups table using the getOnboardingGroups query and a specific app number**54 const resultsOnboardingGroups = await sourceClient.query(getOnboardingGroups, [55 applicationid,56 ]);57 // **Making a starting map of the old IDs for onboardingGroups and initializing to null**58 // tslint:disable-next-line:prefer-for-of59 for (let i = 0; i < resultsOnboardingGroups.rows.length; i++) {60 const oldId = resultsOnboardingGroups.rows[i].id;61 // @ts-ignore62 onboardingGroupsIDMap[oldId] = null;63 resultsOnboardingGroups.rows[i].segments = []64 resultsOnboardingGroups.rows[i].app_id = destApplicationId65 }66 // **Inserting elements queried above and returning the IDs for onboardingGroups**67 const newOnboardingGroupsIds = await destClient.query(insertOnboardingGroups, [68 JSON.stringify(resultsOnboardingGroups.rows),69 ]);70 // **Finishing the map of onboardingGroup IDs using the new IDs returned by the insert query above**71 // tslint:disable-next-line:prefer-for-of72 for (let i = 0; i < resultsOnboardingGroups.rows.length; i++) {73 // @ts-ignore74 onboardingGroupsIDMap[resultsOnboardingGroups.rows[i].id] = newOnboardingGroupsIds.rows[i].id;75 }76 return onboardingGroupsIDMap;77 } catch (error) {78 return error.stack;79 }80};81const migrateOnboardingGroupTexts = async (82 applicationid: any,83 onboardingGroupsIDMap: any,84 sourceClient: PoolClient,85 destClient: PoolClient86) => {87 try {88 const onboardingGroupTextsIDMap: any = new Map(); // **Map for tracking the new and old GroupTexts IDs**89 // **Querying for the results of onboarding_group_texts using the getOnboardingGroupTexts query and a specific app number**90 const resultsOnboardingGroupTexts = await sourceClient.query(getOnboardingGroupTexts, [91 applicationid,92 ]);93 // **Mapping the old onboarding_group_id to the new ones using onboardingGroupsIDMap made earlier**94 // tslint:disable-next-line:prefer-for-of95 for (let i = 0; i < resultsOnboardingGroupTexts.rows.length; i++) {96 // @ts-ignore97 onboardingGroupTextsIDMap[resultsOnboardingGroupTexts.rows[i].id] = null98 resultsOnboardingGroupTexts.rows[i].onboarding_group_id = onboardingGroupsIDMap[resultsOnboardingGroupTexts.rows[i].onboarding_group_id];99 }100 // **Inserting elements queried above**101 const newOnboardingGroupTextsIDs = await destClient.query(insertOnboardingGroupTexts, [102 JSON.stringify(resultsOnboardingGroupTexts.rows),103 ]);104 // **Finishing the map of onboardingGroupTexts IDs using the new IDs returned by the insert query above**105 // tslint:disable-next-line:prefer-for-of106 for (let i = 0; i < resultsOnboardingGroupTexts.rows.length; i++) {107 // @ts-ignore108 onboardingGroupTextsIDMap[resultsOnboardingGroupTexts.rows[i].id] = newOnboardingGroupTextsIDs.rows[i].id;109 }110 return onboardingGroupTextsIDMap111 } catch (error) {112 return error.stack;113 }114};115const migrateOnbaordingLists = async (116 applicationid: any,117 onboardingGroupsIDMap: any,118 contentIDsMap: any,119 flowsIDMap: any,120 sourceClient: PoolClient,121 destClient: PoolClient122) => {123 try {124 const onboardingGroupListIDMap: any = new Map(); // **Map for tracking the new and old GroupTexts IDs**125 // **Querying for the results of on_boarding_lists using the getOnboardingList query and a specific app number**126 const resultsOnboardingList = await sourceClient.query(127 getOnboardingList,128 [applicationid]129 );130 // **Mapping the old item_id's to the new ones using contentIDsMap and flowsIDsMap made earlier, dependent on the "item_type" field for each item**131 // tslint:disable-next-line:prefer-for-of132 for (let i = 0; i < resultsOnboardingList.rows.length; i++) {133 resultsOnboardingList.rows[i].group_id = onboardingGroupsIDMap[resultsOnboardingList.rows[i].group_id]134 // @ts-ignore135 onboardingGroupListIDMap[resultsOnboardingList.rows[i].id] = null136 if (resultsOnboardingList.rows[i].item_type === 4) {137 resultsOnboardingList.rows[i].item_id = flowsIDMap[resultsOnboardingList.rows[i].item_id];138 } else if (resultsOnboardingList.rows[i].item_type === 5) {139 resultsOnboardingList.rows[i].item_id = contentIDsMap[resultsOnboardingList.rows[i].item_id];140 }141 }142 // **Inserting elements queried above and returning the IDs for Validators**143 const newOnboardingGroupListsIDMap = await destClient.query(144 insertOnboardingList,145 [JSON.stringify(resultsOnboardingList.rows)]146 );147 // **Finishing the map of onboardingList IDs using the new IDs returned by the insert query above**148 // tslint:disable-next-line:prefer-for-of149 for (let i = 0; i < resultsOnboardingList.rows.length; i++) {150 // @ts-ignore151 onboardingGroupListIDMap[resultsOnboardingList.rows[i].id] = newOnboardingGroupListsIDMap.rows[i].id;152 }153 return onboardingGroupListIDMap154 } catch (error) {155 return error.stack;156 }157};...

Full Screen

Full Screen

browser_devtools-onboarding.js

Source:browser_devtools-onboarding.js Github

copy

Full Screen

1/* This Source Code Form is subject to the terms of the Mozilla Public2 * License, v. 2.0. If a copy of the MPL was not distributed with this3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */4"use strict";5const ONBOARDING_PREF = "devtools.performance.new-panel-onboarding";6add_task(async function testWithOnboardingPreferenceFalse() {7 info("Test that the onboarding message is displayed as expected.");8 info("Test the onboarding message when the preference is false");9 await SpecialPowers.pushPrefEnv({10 set: [[ONBOARDING_PREF, false]],11 });12 await withDevToolsPanel(async document => {13 {14 // Wait for another UI element to be rendered before asserting the15 // onboarding message.16 await getActiveButtonFromText(document, "Start recording");17 ok(18 !isOnboardingDisplayed(document),19 "Onboarding message is not displayed"20 );21 }22 });23});24add_task(async function testWithOnboardingPreferenceTrue() {25 info("Test the onboarding message when the preference is true");26 await SpecialPowers.pushPrefEnv({27 set: [[ONBOARDING_PREF, true]],28 });29 await withDevToolsPanel(async document => {30 await waitUntil(31 () => isOnboardingDisplayed(document),32 "Waiting for the onboarding message to be displayed"33 );34 ok(true, "Onboarding message is displayed");35 await closeOnboardingMessage(document);36 });37 is(38 Services.prefs.getBoolPref(ONBOARDING_PREF),39 false,40 "onboarding preference should be false after closing the message"41 );42});43add_task(async function testWithOnboardingPreferenceNotSet() {44 info("Test the onboarding message when the preference is not set");45 await SpecialPowers.pushPrefEnv({46 clear: [[ONBOARDING_PREF]],47 });48 await withDevToolsPanel(async document => {49 await waitUntil(50 () => isOnboardingDisplayed(document),51 "Waiting for the onboarding message to be displayed"52 );53 ok(true, "Onboarding message is displayed");54 await closeOnboardingMessage(document);55 });56 is(57 Services.prefs.getBoolPref(ONBOARDING_PREF),58 false,59 "onboarding preference should be false after closing the message"60 );61});62/**63 * Helper to close the onboarding message by clicking on the close button.64 */65async function closeOnboardingMessage(document) {66 const closeButton = await getActiveButtonFromText(67 document,68 "Close the onboarding message"69 );70 info("Click the close button to hide the onboarding message.");71 closeButton.click();72 await waitUntil(73 () => !isOnboardingDisplayed(document),74 "Waiting for the onboarding message to disappear"75 );76}77function isOnboardingDisplayed(document) {78 return maybeGetElementFromDocumentByText(79 document,80 "Firefox Profiler is now integrated into Developer Tools"81 );...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const qawolf = require("qawolf");2const selectors = require("../selectors/test");3describe("test", () => {4 let browser;5 beforeAll(async () => {6 browser = await qawolf.launch();7 });8 afterAll(async () => {9 await qawolf.stopVideos();10 await browser.close();11 });12 it("test", async () => {13 await page.click(selecto

Full Screen

Using AI Code Generation

copy

Full Screen

1const { launch } = require('qawolf');2const selectors = require('./selectors/test.json');3describe('test', () => {4 let browser;5 beforeAll(async () => {6 browser = await launch();7 });8 afterAll(async () => {9 await browser.close();10 });11 it('test', async () => {12 const context = await browser.newContext();13 const page = await context.newPage();14 await page.click(selectors['input[name="q"]']);15 await page.fill(selectors['input[name="q"]'], 'qawolf');16 await page.press(selectors['input[name="q"]'], 'Enter');

Full Screen

Using AI Code Generation

copy

Full Screen

1const { launch } = require('qawolf');2const selectors = require('./selectors/test.json');3describe('test', () => {4 let browser;5 beforeAll(async () => {6 browser = await launch({7 });8 });9 afterAll(() => browser.close());10 it('test', async () => {11 await browser.type(selectors['input[name="q"]'], 'Hello World');12 await browser.press('Enter');13 });14});15{16 "input[name=\"q\"]": "#tsf > div:nth-child(2) > div > div.RNNXgb > div > div.a4bIc > input",17}18const { launch } = require('qawolf');19const selectors = require('./selectors/test.json');20describe('test', () => {21 let browser;22 beforeAll(async () => {23 browser = await launch({24 });25 });26 afterAll(() => browser.close());27 it('test', async () => {28 await browser.type(selectors['input[name="q"]'], 'Hello World');29 await browser.press('Enter');30 });31});32{33 "input[name=\"q\"]": "#tsf > div:nth-child(2) > div > div.RNNXgb > div > div.a4bIc > input",34}35const { launch } = require('qawolf');

Full Screen

Using AI Code Generation

copy

Full Screen

1const qawolf = require("qawolf");2const { chromium } = require("playwright");3const browser = await chromium.launch();4const context = await browser.newContext();5const onboarding = await qawolf.createOnboarding(context);6await onboarding.start();7const qawolf = require("qawolf");8const browser = await qawolf.launch();9const context = await browser.newContext();10const page = await context.newPage();11await qawolf.create(page, "test");12const qawolf = require("qawolf");13const browser = await qawolf.launch();14const context = await browser.newContext();15const page = await context.newPage();16await qawolf.create(page, "test");17const qawolf = require("qawolf");18const browser = await qawolf.launch();19const context = await browser.newContext();20const page = await context.newPage();21await qawolf.create(page, "test");22const qawolf = require("qawolf");23const browser = await qawolf.launch();24const context = await browser.newContext();25const page = await context.newPage();26await qawolf.create(page, "test");27const qawolf = require("qawolf");28const browser = await qawolf.launch();29const context = await browser.newContext();30const page = await context.newPage();31await qawolf.create(page, "test");32const qawolf = require("qawolf");33const browser = await qawolf.launch();

Full Screen

Using AI Code Generation

copy

Full Screen

1const qawolf = require('qawolf');2const { chromium } = require('playwright');3const { firefox } = require('playwright');4const { webkit } = require('playwright');5const browser = await chromium.launch({ headless: false });6const context = await browser.newContext();7const page = await context.newPage();8await page.click('input[name="q"]');9await page.fill('input[name="q"]', 'qawolf');10await page.press('input[name="q"]', 'Enter');11await qawolf.onboard(page, { name: 'test' });12await browser.close();13const qawolf = require('qawolf');14const { chromium } = require('playwright');15const { firefox } = require('playwright');16const { webkit } = require('playwright');17const browser = await chromium.launch({ headless: false });18const context = await browser.newContext();19const page = await context.newPage();20await page.click('input[name="q"]');21await page.fill('input[name="q"]', 'qawolf');22await page.press('input[name="q"]', 'Enter');23await qawolf.create(page, { name: 'test' });24await browser.close();25const qawolf = require('qawolf');26const { chromium } = require('playwright');27const { firefox } = require('playwright');28const { webkit } = require('playwright');29const browser = await chromium.launch({ headless: false });30const context = await browser.newContext();31const page = await context.newPage();32await page.click('input[name="q"]');33await page.fill('input[name="q"]', 'qawolf');34await page.press('input[name="q"]', 'Enter');35await qawolf.create(page, { name: 'test' });36await browser.close();37const qawolf = require('qawolf');38const { chromium } = require('playwright');39const { firefox } = require('playwright');40const { webkit } = require('playwright');

Full Screen

Using AI Code Generation

copy

Full Screen

1const { launch } = require('qawolf');2const selectors = require('./selectors/test.json');3const config = require('./config/test.json');4const onboarding = async () => {5 const browser = await launch();6 const page = await browser.newPage();7 await page.goto(config.url);8 await page.type(selectors.email, config.email);9 await page.type(selectors.password, config.password);10 await page.click(selectors.submit);11 await page.click(selectors.onboarding);12 await page.click(selectors.onboarding);13 await browser.close();14};15onboarding();16{17}18{

Full Screen

Using AI Code Generation

copy

Full Screen

1const { onboarding } = require("qawolf");2const { launch } = require("qawolf");3beforeAll(async () => {4 browser = await launch();5});6afterAll(() => browser.close());7test("onboarding", async () => {8 const context = await browser.newContext();9 const page = await context.newPage();10 await onboarding(page);11});12test("onboarding", async () => {13 const context = await browser.newContext();14 const page = await context.newPage();15 await onboarding(page);16});17test("onboarding", async () => {18 const context = await browser.newContext();19 const page = await context.newPage();20 await onboarding(page);21});22test("onboarding", async () => {23 const context = await browser.newContext();24 const page = await context.newPage();25 await onboarding(page);26});27test("onboarding", async () => {28 const context = await browser.newContext();29 const page = await context.newPage();30 await onboarding(page);31});32test("onboarding", async () => {33 const context = await browser.newContext();34 const page = await context.newPage();35 await onboarding(page);36});37test("onboarding", async () => {38 const context = await browser.newContext();39 const page = await context.newPage();40 await onboarding(page);41});42test("onboarding", async () => {43 const context = await browser.newContext();44 const page = await context.newPage();45 await onboarding(page);46});47test("onboarding", async () => {48 const context = await browser.newContext();49 const page = await context.newPage();50 await onboarding(page);51});52test("onboarding", async

Full Screen

Using AI Code Generation

copy

Full Screen

1const { onboarding } = require("qawolf");2const { launch } = require("qawolf");3(async () => {4 const browser = await launch();5 const page = await browser.newPage();6 const context = await browser.newContext();7 const page1 = await context.newPage();8 await onboarding(page1);9 await page1.click("text=Google apps");10 await page1.click("text=YouTube");11 await page1.click("text=Sign in");12 await page1.click("css=div > .gb_9a.gbii");13 await page1.click("text=Sign out");14 await onboarding(page1);15 await browser.close();16})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const qawolf = require("qawolf");2const browser = await qawolf.launch();3const context = await browser.newContext();4const page = await context.newPage();5await page.click("input[name='q']");6await page.fill("input[name='q']", "qawolf");7await page.press("input[name='q']", "Enter");8await page.click("text=GitHub - qawolf/qawolf: End-to-end testing for ...");9await qawolf.stopBrowser();10const qawolf = require("qawolf");11const browser = await qawolf.launch();12const context = await browser.newContext();13const page = await context.newPage();14await page.click("input[name='q']");15await page.fill("input[name='q']", "qawolf");16await page.press("input[name='q']", "Enter");17await page.click("text=GitHub - qawolf/qawolf: End-to-end testing for ...");18await qawolf.stopBrowser();19const qawolf = require("qawolf");20const browser = await qawolf.launch();21const context = await browser.newContext();22const page = await context.newPage();23await page.click("input[name='q']");

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run qawolf automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful