diff --git a/app/components/identity-steps/step-four.hbs b/app/components/identity-steps/step-four.hbs index e8a2d6c0..68775569 100644 --- a/app/components/identity-steps/step-four.hbs +++ b/app/components/identity-steps/step-four.hbs @@ -6,7 +6,7 @@ A private key that you need to use in your profile service URL and deploy for source that you're the source of the URL

- {{#if this.isChaincodeClicked}} + {{#if @isChaincodeClicked}}
{{else}} {{/if}} diff --git a/app/components/identity-steps/step-four.js b/app/components/identity-steps/step-four.js index 2b6b980c..9b98be77 100644 --- a/app/components/identity-steps/step-four.js +++ b/app/components/identity-steps/step-four.js @@ -3,58 +3,12 @@ import { tracked } from '@glimmer/tracking'; import { action } from '@ember/object'; import { inject as service } from '@ember/service'; import { toastNotificationTimeoutOptions } from '../../constants/toast-notification'; -import { APPS } from '../../constants/urls'; export default class IdentityStepsStepFourComponent extends Component { @service toast; - @tracked Chaincode = 'Generate Chaincode'; - @tracked isChaincodeClicked = false; @tracked hideChaincode = true; @tracked isCopyClicked = false; @tracked isChaincodePageButtonDisabled = true; - @tracked isLoading = false; - - @action async handleGenerateChaincode(e) { - e.preventDefault(); - - this.isLoading = true; - - try { - const response = await fetch(`${APPS.API_BACKEND}/users/chaincode`, { - method: 'GET', - headers: { - 'Content-Type': 'application/json', - }, - credentials: 'include', - }); - - const { chaincode } = await response.json(); - - if (response.ok) { - this.Chaincode = chaincode; - this.isChaincodeClicked = true; - this.toast.info( - 'Generated New Chaincode!!', - '', - toastNotificationTimeoutOptions - ); - } else { - this.toast.error( - 'Something went wrong. Please check console errors.', - '', - toastNotificationTimeoutOptions - ); - } - } catch (error) { - this.toast.error( - 'Something went wrong. Please check console errors.', - '', - toastNotificationTimeoutOptions - ); - } finally { - this.isLoading = false; - } - } @action toggleEye() { this.hideChaincode = !this.hideChaincode; diff --git a/app/components/stepper-signup.hbs b/app/components/stepper-signup.hbs index 487ff9be..9a658e32 100644 --- a/app/components/stepper-signup.hbs +++ b/app/components/stepper-signup.hbs @@ -56,7 +56,13 @@ {{else if (eq this.currentStep 9)}} {{else if (eq this.currentStep 10)}} - + {{else if (eq this.currentStep 11)}} {{else if (eq this.currentStep 12)}} diff --git a/app/controllers/join.js b/app/controllers/join.js index 1be5fb4f..766111a1 100644 --- a/app/controllers/join.js +++ b/app/controllers/join.js @@ -1,14 +1,62 @@ import Controller from '@ember/controller'; import { inject as service } from '@ember/service'; +import { APPS } from '../constants/urls'; +import { tracked } from '@glimmer/tracking'; +import { action } from '@ember/object'; +import { toastNotificationTimeoutOptions } from '../constants/toast-notification'; export default class JoinController extends Controller { @service router; @service login; @service featureFlag; + @tracked chaincode = 'Generate chaincode'; + @tracked isChaincodeClicked = false; + @tracked isLoading = false; queryParams = ['step', 'dev']; get isDevMode() { return this.featureFlag.isDevMode; } + + @action async handleGenerateChaincode(e) { + e.preventDefault(); + + this.isLoading = true; + + try { + const response = await fetch(`${APPS.API_BACKEND}/users/chaincode`, { + method: 'GET', + headers: { + 'Content-Type': 'application/json', + }, + credentials: 'include', + }); + + const { chaincode } = await response.json(); + + if (!response.ok) + return this.toast.error( + 'Something went wrong. Please check console errors.', + '', + toastNotificationTimeoutOptions + ); + + this.chaincode = chaincode; + this.isChaincodeClicked = true; + this.toast.info( + 'Generated New Chaincode!!', + '', + toastNotificationTimeoutOptions + ); + } catch (error) { + this.toast.error( + 'Something went wrong. Please check console errors.', + '', + toastNotificationTimeoutOptions + ); + } finally { + this.isLoading = false; + } + } } diff --git a/app/templates/join.hbs b/app/templates/join.hbs index 9b4c7063..f80734f3 100644 --- a/app/templates/join.hbs +++ b/app/templates/join.hbs @@ -11,7 +11,12 @@ {{else}} {{#if this.isDevMode}} - + {{else}} {{/if}} diff --git a/tests/integration/components/identity-steps/step-four-test.js b/tests/integration/components/identity-steps/step-four-test.js index 3024539d..80ba27bd 100644 --- a/tests/integration/components/identity-steps/step-four-test.js +++ b/tests/integration/components/identity-steps/step-four-test.js @@ -1,4 +1,4 @@ -import { module, skip, test } from 'qunit'; +import { module, test } from 'qunit'; import { setupRenderingTest } from 'website-www/tests/helpers'; import { render, click } from '@ember/test-helpers'; import { hbs } from 'ember-cli-htmlbars'; @@ -9,8 +9,12 @@ module('Integration | Component | identity-steps/step-four', function (hooks) { test('render main container div on generate chaincode page', async function (assert) { assert.expect(2); this.set('startHandler', () => {}); + this.set('handleGenerateChaincode', () => {}); await render( - hbs`` + hbs`` ); assert.dom('[data-test=chaincode]').exists(); @@ -20,8 +24,12 @@ module('Integration | Component | identity-steps/step-four', function (hooks) { test('render heading on generate chaincode page', async function (assert) { assert.expect(2); this.set('startHandler', () => {}); + this.set('handleGenerateChaincode', () => {}); await render( - hbs`` + hbs`` ); assert.dom('[data-test=heading]').hasClass('chaincode-page__heading'); assert.dom('[data-test=heading]').hasText('Chaincode Generation'); @@ -30,8 +38,12 @@ module('Integration | Component | identity-steps/step-four', function (hooks) { test('render description on generate chaincode page', async function (assert) { assert.expect(2); this.set('startHandler', () => {}); + this.set('handleGenerateChaincode', () => {}); await render( - hbs`` + hbs`` ); assert .dom('[data-test=description]') @@ -46,8 +58,16 @@ module('Integration | Component | identity-steps/step-four', function (hooks) { test('render Generation Chaincode button on chaincode page', async function (assert) { assert.expect(2); this.set('startHandler', () => {}); + this.set('handleGenerateChaincode', () => {}); + this.set('chaincode', 'Generate Chaincode'); + this.set('isChaincodeClicked', false); await render( - hbs`` + hbs`` ); assert.dom('[data-test-button=chaincode]').hasText('Generate Chaincode'); assert.dom('[data-test-button=chaincode]').hasProperty('type', 'button'); @@ -56,28 +76,40 @@ module('Integration | Component | identity-steps/step-four', function (hooks) { test('render disabled Next button on chaincode page', async function (assert) { assert.expect(2); this.set('startHandler', () => {}); + this.set('handleGenerateChaincode', () => {}); await render( - hbs`` + hbs`` ); assert.dom('[data-test-button=next]').hasText('Next'); assert.dom('[data-test-button=next]').hasProperty('disabled', true); }); - skip('Clicking "Generate Chaincode" button renders div with text and 2 button with icons on Chaincode page', async function (assert) { + test('Clicking "Generate Chaincode" button renders div with text and 2 button with icons on Chaincode page', async function (assert) { assert.expect(6); this.set('startHandler', () => {}); + this.set('handleGenerateChaincode', () => { + this.set('isChaincodeClicked', true); + }); + await render( - hbs`` + hbs`` ); await click('[data-test-button=chaincode]'); assert.dom('[data-test=chaincode-container]').exists(); assert .dom('[data-test=chaincode-container__value]') - .hasClass('chaincode-container__value'); + .hasClass('chaincode-container__value-invisible'); assert .dom('[data-test=chaincode-container__value]') - .hasText('**************'); + .hasText('********************'); assert .dom('[data-test=chaincode-container__action]') @@ -87,13 +119,20 @@ module('Integration | Component | identity-steps/step-four', function (hooks) { assert.dom('[data-test-button=copy-icon]').hasClass('chaicode-button-icon'); }); - skip('Clicking eye-icon button show generated code', async function (assert) { + test('Clicking eye-icon button show generated code', async function (assert) { assert.expect(1); this.set('startHandler', () => {}); + this.set('handleGenerateChaincode', () => {}); + this.set('isChaincodeClicked', true); + this.set('chaincode', 'hv2hz3xh1h'); await render( - hbs`` + hbs`` ); - await click('[data-test-button=chaincode]'); await click('[data-test-button=eye-icon]'); assert.dom('[data-test=chaincode-container__value]').hasText('hv2hz3xh1h');