diff --git a/app/components/identity/blocked.hbs b/app/components/identity/blocked.hbs new file mode 100644 index 00000000..1a3d68fe --- /dev/null +++ b/app/components/identity/blocked.hbs @@ -0,0 +1,8 @@ +
Status Blocked
+
The system failed to link + your profile service with the Identity service, + Please try again!
+ \ No newline at end of file diff --git a/app/components/identity/get-started.hbs b/app/components/identity/get-started.hbs new file mode 100644 index 00000000..03877160 --- /dev/null +++ b/app/components/identity/get-started.hbs @@ -0,0 +1,16 @@ +
Qualification + Criteria
+
+ To update your profile details, link your profile service URL with + RealDevSquad Service.
+ Profile Service Template: + https://github.com/Real-Dev-Squad/sample-profile-service +
+ \ No newline at end of file diff --git a/app/components/identity/reload.hbs b/app/components/identity/reload.hbs new file mode 100644 index 00000000..373bbab0 --- /dev/null +++ b/app/components/identity/reload.hbs @@ -0,0 +1,6 @@ +
Status Pending
+
Reload to complete and + verify the link between Profile Service and RealDevSquad Service.
+ \ No newline at end of file diff --git a/app/components/identity/reload.js b/app/components/identity/reload.js new file mode 100644 index 00000000..e94bba78 --- /dev/null +++ b/app/components/identity/reload.js @@ -0,0 +1,9 @@ +import Component from '@glimmer/component'; +import { action } from '@ember/object'; + +export default class ReloadComponent extends Component { + @action async handleReload(e) { + e.preventDefault(); + window.location.reload(); + } +} diff --git a/app/components/identity/step1.hbs b/app/components/identity/step1.hbs new file mode 100644 index 00000000..a7256e09 --- /dev/null +++ b/app/components/identity/step1.hbs @@ -0,0 +1,45 @@ +
Step 1: Chaincode + Generation
+
A private key that you need + to use in your profile service URL and deploy for validation that you’re the + source of URL.
+{{#if this.isChaincodeGenerated}} +
+
+ {{if this.isChaincodeVisible this.chaincode '********************'}} + {{if
+
+ copy +
Copy
+
+
+{{else}} + +{{/if}} +{{#if this.isChaincodeGenerated}} + +{{/if}} \ No newline at end of file diff --git a/app/components/identity/step1.js b/app/components/identity/step1.js new file mode 100644 index 00000000..894bc228 --- /dev/null +++ b/app/components/identity/step1.js @@ -0,0 +1,79 @@ +import Component from '@glimmer/component'; +import { action } from '@ember/object'; +import { tracked } from '@glimmer/tracking'; +import { inject as service } from '@ember/service'; +import { toastNotificationTimeoutOptions } from '../../constants/toast-notification'; +import ENV from 'website-my/config/environment'; + +const BASE_URL = ENV.BASE_API_URL; + +export default class Step1Component extends Component { + @tracked isChaincodeGenerated = false; + @tracked isGeneratingChaincode = false; + @tracked chaincode = 'asxjdDZVNTfuDMQJiunJ'; + @tracked isChaincodeVisible = false; + @service toast; + + @action handleNext() { + if ( + confirm( + 'Make sure you copied the chaincode as you are not able to see it again. If not, click `Cancel` and copy it.' + ) + ) { + this.args.setState('step2'); + } + } + + @action handleEyeClick() { + this.isChaincodeVisible = !this.isChaincodeVisible; + } + + @action handleCopy() { + navigator.clipboard.writeText(this.chaincode); + this.toast.info('Chaincode Copied!!', '', toastNotificationTimeoutOptions); + } + + @action async handleGenerateChaincode(e) { + e.preventDefault(); + if (this.isGeneratingChaincode === false) { + this.isGeneratingChaincode = true; + try { + const response = await fetch(`${BASE_URL}/users/chaincode`, { + method: 'GET', + headers: { + 'Content-Type': 'application/json', + }, + credentials: 'include', + }); + + const { chaincode } = await response.json(); + + if (response.ok) { + this.chaincode = chaincode; + this.isChaincodeGenerated = true; + this.toast.info( + 'Generated New Chaincode!!', + '', + toastNotificationTimeoutOptions + ); + } else { + console.log(response); + this.toast.error( + 'Something went wrong. Please check console errors.', + '', + toastNotificationTimeoutOptions + ); + } + } catch (error) { + console.log('error', error); + this.toast.error( + 'Something went wrong. Please check console errors.', + '', + toastNotificationTimeoutOptions + ); + } finally { + this.isGeneratingChaincode = false; + } + } + } +} diff --git a/app/components/identity/step2.hbs b/app/components/identity/step2.hbs new file mode 100644 index 00000000..a04959a7 --- /dev/null +++ b/app/components/identity/step2.hbs @@ -0,0 +1,19 @@ +
Step 2: Profile + Service URL
+
Set the chaincode on your + profile service, deploy it and enter your profile service URL.
+ +{{#if this.profileURL}} + +{{/if}} \ No newline at end of file diff --git a/app/components/identity/step2.js b/app/components/identity/step2.js new file mode 100644 index 00000000..dbfc40b1 --- /dev/null +++ b/app/components/identity/step2.js @@ -0,0 +1,73 @@ +import Component from '@glimmer/component'; +import { action } from '@ember/object'; +import { tracked } from '@glimmer/tracking'; +import { inject as service } from '@ember/service'; +import { toastNotificationTimeoutOptions } from '../../constants/toast-notification'; +import ENV from 'website-my/config/environment'; + +const BASE_URL = ENV.BASE_API_URL; + +export default class Step2Component extends Component { + @tracked profileURL = this.args.profileURL || ''; + @tracked savingURL = false; + @service toast; + + @action async handleNext() { + const isValidUrl = (str) => { + try { + const newUrl = new URL(str); + return newUrl.protocol === 'https:'; + } catch (err) { + return false; + } + }; + if (this.profileURL) { + if (isValidUrl(this.profileURL)) { + if (this.savingURL === false) { + if (this.profileURL === this.args.profileURL) { + this.args.setState('step3'); + return; + } + this.savingURL = true; + try { + const response = await fetch(`${BASE_URL}/users/profileURL`, { + method: 'PATCH', + body: JSON.stringify({ profileURL: this.profileURL }), + headers: { + 'Content-Type': 'application/json', + }, + credentials: 'include', + }); + if (response.ok) { + this.toast.info( + 'Updated profile URL!!', + '', + toastNotificationTimeoutOptions + ); + this.args.setState('step3'); + } else { + this.toast.error( + 'Something went wrong. Please check console errors.', + '', + toastNotificationTimeoutOptions + ); + } + } catch (error) { + console.error(error); + this.toast.error( + 'Something went wrong. Please check console errors.', + '', + toastNotificationTimeoutOptions + ); + } finally { + this.savingURL = false; + } + } + } else { + alert( + 'Invalid URL! Make sure you entered the correct https profile URL.' + ); + } + } + } +} diff --git a/app/components/identity/step3.hbs b/app/components/identity/step3.hbs new file mode 100644 index 00000000..0e05a08c --- /dev/null +++ b/app/components/identity/step3.hbs @@ -0,0 +1,13 @@ +
Step 3: Link Profile + Service
+
Ensure that you have + deployed your profile service URL and after that link with the RealDevSquad + service.
+ \ No newline at end of file diff --git a/app/components/identity/step3.js b/app/components/identity/step3.js new file mode 100644 index 00000000..abec8d41 --- /dev/null +++ b/app/components/identity/step3.js @@ -0,0 +1,57 @@ +import Component from '@glimmer/component'; +import { action } from '@ember/object'; +import { tracked } from '@glimmer/tracking'; +import { inject as service } from '@ember/service'; +import { toastNotificationTimeoutOptions } from '../../constants/toast-notification'; +import ENV from 'website-my/config/environment'; + +const BASE_URL = ENV.BASE_API_URL; + +export default class Step3Component extends Component { + @tracked linking = false; + @service toast; + + @action async handleLink(e) { + e.preventDefault(); + if ( + this.linking === false && + confirm( + 'Make sure to set the chaincode and re-deploy your profile service before linking.' + ) + ) { + this.linking = true; + try { + const response = await fetch(`${BASE_URL}/users/verify`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + credentials: 'include', + }); + + if (response.ok) { + this.toast.info( + 'Your linking request has been queued successfully', + '', + toastNotificationTimeoutOptions + ); + this.args.setState('reload'); + } 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.linking = false; + } + } + } +} diff --git a/app/components/identity/verified.hbs b/app/components/identity/verified.hbs new file mode 100644 index 00000000..ebad1442 --- /dev/null +++ b/app/components/identity/verified.hbs @@ -0,0 +1,6 @@ +
Verified
+
Congratulations!!! + You did it, go ahead and tell in the community that you verified your profile + service.
\ No newline at end of file diff --git a/app/controllers/identity.js b/app/controllers/identity.js index a78c9335..7af80206 100644 --- a/app/controllers/identity.js +++ b/app/controllers/identity.js @@ -11,6 +11,7 @@ const BASE_URL = ENV.BASE_API_URL; export default class IdentityController extends Controller { @service toast; + @service router; @tracked isEditClicked = false; @tracked isGenerateChaincodeClicked = false; @tracked isChecked = false; @@ -25,6 +26,30 @@ export default class IdentityController extends Controller { this.generateChainCodeDisabled || this.model.chaincode === undefined; @tracked identityError = ''; + get intialState() { + if (this.model.profileStatus === 'PENDING') { + return 'reload'; + } else if (this.model.profileStatus === 'VERIFIED') { + return 'verified'; + } else if (this.model.profileStatus === 'BLOCKED') { + return 'blocked'; + } + return 'getStarted'; + } + + get isDev() { + if (this.router.currentRoute) { + return this.router.currentRoute.queryParams.dev; + } + return false; + } + + @tracked state = this.intialState; + + @action setState(value) { + this.state = value; + } + @action async handleRefresh() { window.location.reload(); } diff --git a/app/router.js b/app/router.js index 93be6472..258e72a8 100644 --- a/app/router.js +++ b/app/router.js @@ -13,6 +13,7 @@ Router.map(function () { this.route('tasks'); this.route('profile'); this.route('identity'); + this.route('new-identity'); this.route('404', { path: '/*' }); this.route('discord'); this.route('mobile'); diff --git a/app/styles/identity.css b/app/styles/identity.css index e7fb3487..aac5d77b 100644 --- a/app/styles/identity.css +++ b/app/styles/identity.css @@ -1,3 +1,5 @@ +@import url('https://fonts.googleapis.com/css2?family=Hanuman:wght@700&family=Inter:wght@400;700&display=swap'); + .identity-heading { margin-top: 25px; text-align: center; @@ -154,3 +156,299 @@ width: 100%; } } + +/* New CSS */ + +.identity-page { + height: 91.5vh; + position: relative; + display: flex; + flex-direction: column; + /* justify-content: center; */ + align-items: center; +} + +.identity-hero { + position: absolute; + left: 0; + bottom: 0; + z-index: 1; +} + +.identity-heading { + font-family: 'Hanuman', serif; + color: #000; + text-align: center; + font-size: 28px; + font-style: normal; + font-weight: 700; + line-height: normal; +} + +.identity-box { + position: relative; + height: 252px; + width: 656px; + max-width: 90%; + margin-top: 24px; + border-radius: 47px; + border: 1px solid rgba(0, 0, 0, 0.25); + background: #fff; + box-shadow: 3px 3px 3px 0px rgba(0, 0, 0, 0.25); + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + padding: 20px; +} + +.identity-box-desc-bold { + color: #000; + font-family: 'Inter', sans-serif; + font-size: 17px; + font-style: normal; + font-weight: 700; + line-height: normal; +} + +.identity-box-desc-a { + color: #0000af; + font-family: 'Inter', sans-serif; + font-size: 15px; + font-style: normal; + font-weight: 400; + line-height: normal; +} + +.identity-box-heading { + color: #1d1283; + text-align: center; + font-family: 'Inter', sans-serif; + font-size: 26px; + font-style: normal; + font-weight: 700; + line-height: normal; + margin-bottom: 12px; +} + +.identity-box-desc { + color: #000; + font-family: 'Inter', sans-serif; + font-size: 21px; + font-style: normal; + font-weight: 400; + line-height: normal; + text-align: center; +} + +.identity-rds-logo { + margin-top: 4%; +} + +.identity-header-hero { + position: absolute; + right: 22px; + top: 32px; +} + +.identity-header { + position: absolute; + top: -32px; + z-index: 0; +} + +.identity-footer { + bottom: 0; + position: absolute; +} + +.identity-chaincode-box { + display: flex; + position: relative; + align-items: center; + margin-top: 16px; + border: 1px solid rgba(0, 0, 0, 0.5); + background: #fff; + width: 90%; + height: 36px; + padding-left: 16px; + color: #000; + font-family: 'Inter', sans-serif; + font-size: 16px; + font-style: normal; + font-weight: 500; + line-height: normal; +} + +.identity-box-eye-margin { + margin-right: 8px; +} + +.identity-box-eye { + position: absolute; + right: 4px; + cursor: pointer; +} + +.identity-chaincode-copy-box { + display: flex; + width: 60%; +} + +.identity-copy-box { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + margin-top: 12px; + margin-left: 12px; + cursor: pointer; +} + +.identity-next-button { + border-radius: 15px; + background: #1d1283; + box-shadow: 0px 4px 8px 0px rgba(0, 0, 0, 0.25); + padding: 12px 24px; + color: #fff; + text-align: center; + font-family: 'Inter', sans-serif; + font-size: 18px; + font-style: normal; + font-weight: 700; + line-height: normal; + position: absolute; + right: 4%; + bottom: 8%; +} + +.identity-box-input { + border: 1px solid rgba(0, 0, 0, 0.5); + background: #fff; + width: 50%; + margin-top: 16px; + padding: 8px; + color: #0000af; + font-family: 'Inter', sans-serif; + font-size: 16px; + font-style: normal; + font-weight: 500; + line-height: normal; +} + +.identity-box-input::placeholder { + color: #808080; + font-family: 'Inter', sans-serif; + font-size: 14px; + font-style: normal; + font-weight: 400; + line-height: normal; +} + +.identity-box-button { + padding: 12px; + border-radius: 15px; + background: #1d1283; + color: #fff; + text-align: center; + font-family: 'Inter', sans-serif; + font-size: 18px; + font-style: normal; + font-weight: 700; + line-height: normal; + margin-top: 20px; +} + +.loader { + border: 4px solid #f3f3f3; + border-top: 4px solid black; + border-radius: 50%; + width: 18px; + height: 18px; + animation: spin 2s linear infinite; +} + +@keyframes spin { + 0% { + transform: rotate(0deg); + } + 100% { + transform: rotate(360deg); + } +} + +@media (max-width: 460px) { + .identity-box-input { + width: 90%; + } + + .identity-chaincode-box { + font-size: 12px; + } + + .identity-chaincode-copy-box { + width: 90%; + } + + .identity-box-button { + font-size: 12px; + padding: 8px; + border-radius: 8px; + } + + .identity-next-button { + font-size: 12px; + padding: 8px 16px; + border-radius: 8px; + bottom: 4%; + } + + .identity-hero { + width: 50%; + } + + .identity-box { + border-radius: 25px; + } + + .identity-heading { + font-size: 16px; + max-width: 90%; + line-height: normal; + } + + .identity-rds-logo { + margin-top: 5%; + margin-bottom: 0px; + height: 100px; + width: 100px; + } + + .identity-header-hero { + position: absolute; + width: 20%; + right: 12px; + top: 8px; + } + + .identity-box-heading { + font-size: 16px; + } + + .identity-box-desc { + font-size: 12px; + } + + .identity-heading { + font-size: 16px; + margin-top: 8px; + } + + .identity-box-desc-bold { + font-size: 12px; + } + + .identity-box-desc-a { + font-size: 12px; + } +} diff --git a/app/styles/navbar.css b/app/styles/navbar.css index 16704a84..fba17c94 100644 --- a/app/styles/navbar.css +++ b/app/styles/navbar.css @@ -7,6 +7,7 @@ nav { font: 'Roboto', sans-serif; font-weight: 700; background-color: var(--nav--bg); + z-index: 1; } nav li a { diff --git a/app/templates/identity.hbs b/app/templates/identity.hbs index f50df200..547418c8 100644 --- a/app/templates/identity.hbs +++ b/app/templates/identity.hbs @@ -1,99 +1,140 @@ {{page-title 'Identity'}} -

- Identity Service Verification -

-
- {{#if (eq @model.profileStatus 'PENDING')}} -

Verification process is Pending!

- - {{else if (eq @model.profileStatus 'VERIFIED')}} -

Verification Done!

- {{else}} - {{#if (eq @model.profileStatus 'BLOCKED')}} -

Your previous chaincode is blocked for some reason. Please generate a - new chaincode.

+{{#if this.isDev}} +
+ header + hero + + {{#if (eq this.state 'getStarted')}} +
Connect your Profile Service with Identity + Service
{{/if}} -
-
+{{else}} +

+ Identity Service Verification +

+
+ {{#if (eq @model.profileStatus 'PENDING')}} +

Verification process is Pending!

+ + {{else if (eq @model.profileStatus 'VERIFIED')}} +

Verification Done!

+ {{else}} + {{#if (eq @model.profileStatus 'BLOCKED')}} +

Your previous chaincode is blocked for some reason. Please generate a + new chaincode.

+ {{/if}} +
+ -
-
-
- - + +
+ {{/if}} + +
+ +
+
+ + -
-
- + /> +
+
+ +
-
- + -

{{this.identityError}}

- {{/if}} -
\ No newline at end of file + > + {{#if this.isVerifyClicked}} + + {{/if}} + Link Chaincode + +

{{this.identityError}}

+ {{/if}} +
+{{/if}} \ No newline at end of file diff --git a/public/identity/closeeye.svg b/public/identity/closeeye.svg new file mode 100644 index 00000000..bc669422 --- /dev/null +++ b/public/identity/closeeye.svg @@ -0,0 +1,4 @@ + + + + diff --git a/public/identity/copy.svg b/public/identity/copy.svg new file mode 100644 index 00000000..57829ce6 --- /dev/null +++ b/public/identity/copy.svg @@ -0,0 +1,3 @@ + + + diff --git a/public/identity/footer.svg b/public/identity/footer.svg new file mode 100644 index 00000000..4db6119c --- /dev/null +++ b/public/identity/footer.svg @@ -0,0 +1,3 @@ + + + diff --git a/public/identity/header-hero.svg b/public/identity/header-hero.svg new file mode 100644 index 00000000..17888ed0 --- /dev/null +++ b/public/identity/header-hero.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/public/identity/header.svg b/public/identity/header.svg new file mode 100644 index 00000000..4890d550 --- /dev/null +++ b/public/identity/header.svg @@ -0,0 +1,3 @@ + + + diff --git a/public/identity/hero.svg b/public/identity/hero.svg new file mode 100644 index 00000000..62cace42 --- /dev/null +++ b/public/identity/hero.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/public/identity/logo.svg b/public/identity/logo.svg new file mode 100644 index 00000000..6d03df9a --- /dev/null +++ b/public/identity/logo.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/public/identity/openeye.svg b/public/identity/openeye.svg new file mode 100644 index 00000000..40220d51 --- /dev/null +++ b/public/identity/openeye.svg @@ -0,0 +1,3 @@ + + + diff --git a/tests/acceptance/mobile-test.js b/tests/acceptance/mobile-test.js index d58457ea..ba9fd984 100644 --- a/tests/acceptance/mobile-test.js +++ b/tests/acceptance/mobile-test.js @@ -38,7 +38,7 @@ module('Acceptance | login', function (hooks) { // eslint-disable-next-line ember/no-pause-test await pauseTest(); assert.equal(currentURL(), '/mobile'); - + stub.restore(); server.shutdown(); }); diff --git a/tests/integration/components/identity/blocked-test.js b/tests/integration/components/identity/blocked-test.js new file mode 100644 index 00000000..97f7615c --- /dev/null +++ b/tests/integration/components/identity/blocked-test.js @@ -0,0 +1,25 @@ +import { module, test } from 'qunit'; +import { setupRenderingTest } from 'ember-qunit'; +import { render, click } from '@ember/test-helpers'; +import { hbs } from 'ember-cli-htmlbars'; + +module('Integration | Component | identity/blocked', function (hooks) { + setupRenderingTest(hooks); + + test('it renders the identity blocked component', async function (assert) { + this.set('setState', (val) => { + assert.step(val); + }); + + await render(hbs``); + + assert.dom('[data-test-blocked-heading]').exists(); + assert.dom('[data-test-blocked-heading]').hasText('Status Blocked'); + + assert.dom('[data-test-blocked-desc]').exists(); + + await click('[data-test-blocked-button]'); + + assert.verifySteps(['step1']); + }); +}); diff --git a/tests/integration/components/identity/get-started-test.js b/tests/integration/components/identity/get-started-test.js new file mode 100644 index 00000000..7fe5edb4 --- /dev/null +++ b/tests/integration/components/identity/get-started-test.js @@ -0,0 +1,27 @@ +import { module, test } from 'qunit'; +import { setupRenderingTest } from 'ember-qunit'; +import { render, click } from '@ember/test-helpers'; +import { hbs } from 'ember-cli-htmlbars'; + +module('Integration | Component | identity/get-started', function (hooks) { + setupRenderingTest(hooks); + + test('it renders the identity get-started component', async function (assert) { + this.set('setState', (val) => { + assert.step(val); + }); + + await render(hbs``); + + assert.dom('[data-test-getStarted-heading]').exists(); + assert + .dom('[data-test-getStarted-heading]') + .hasText('Qualification Criteria'); + + assert.dom('[data-test-getStarted-desc]').exists(); + + await click('[data-test-getStarted-button]'); + + assert.verifySteps(['step1']); + }); +}); diff --git a/tests/integration/components/identity/reload-test.js b/tests/integration/components/identity/reload-test.js new file mode 100644 index 00000000..1f3530af --- /dev/null +++ b/tests/integration/components/identity/reload-test.js @@ -0,0 +1,17 @@ +import { module, test } from 'qunit'; +import { setupRenderingTest } from 'ember-qunit'; +import { render } from '@ember/test-helpers'; +import { hbs } from 'ember-cli-htmlbars'; + +module('Integration | Component | identity/reload', function (hooks) { + setupRenderingTest(hooks); + + test('it renders the identity reload component', async function (assert) { + await render(hbs``); + + assert.dom('[data-test-reload-heading]').exists(); + assert.dom('[data-test-reload-heading]').hasText('Status Pending'); + + assert.dom('[data-test-reload-desc]').exists(); + }); +}); diff --git a/tests/integration/components/identity/step1-test.js b/tests/integration/components/identity/step1-test.js new file mode 100644 index 00000000..7675672e --- /dev/null +++ b/tests/integration/components/identity/step1-test.js @@ -0,0 +1,80 @@ +import { module, test } from 'qunit'; +import { setupRenderingTest } from 'ember-qunit'; +import { render, click } from '@ember/test-helpers'; +import { hbs } from 'ember-cli-htmlbars'; +import { Server } from 'ember-cli-mirage'; +import ENV from 'website-my/config/environment'; +import sinon from 'sinon'; + +module('Integration | Component | identity/step1', function (hooks) { + setupRenderingTest(hooks); + + test('it renders the identity step1 component', async function (assert) { + this.set('setState', (val) => { + assert.step(val); + }); + + await render(hbs``); + + assert.dom('[data-test-step1-heading]').exists(); + assert + .dom('[data-test-step1-heading]') + .hasText('Step 1: Chaincode Generation'); + + assert.dom('[data-test-step1-desc]').exists(); + assert.dom('[data-test-step1-button]').exists(); + }); + + test('it generates the chaincode', async function (assert) { + let stub = sinon.stub(window, 'confirm'); + stub.returns(true); + + let server = new Server({ + models: {}, + routes() { + this.namespace = ENV.BASE_API_URL; + + this.get('/users/chaincode', { chaincode: 'abcdefghijklmnopqrs' }); + }, + }); + + this.set('setState', (val) => { + assert.step(val); + }); + + await render(hbs``); + + assert.dom('[data-test-step1-heading]').exists(); + assert + .dom('[data-test-step1-heading]') + .hasText('Step 1: Chaincode Generation'); + + assert.dom('[data-test-step1-desc]').exists(); + assert.dom('[data-test-step1-button]').exists(); + + await click('[data-test-step1-button]'); + + setTimeout(() => { + this.resumeTest(); + }, 500); + // eslint-disable-next-line ember/no-pause-test + await this.pauseTest(); + + assert + .dom('[data-test-step1-chaincode]') + .exists() + .hasText('********************'); + + await click('[data-test-step1-eye]'); + assert + .dom('[data-test-step1-chaincode]') + .exists() + .hasText('abcdefghijklmnopqrs'); + + await click('[data-test-step1-next-button]'); + + assert.verifySteps(['step2']); + stub.restore(); + server.shutdown(); + }); +}); diff --git a/tests/integration/components/identity/step2-test.js b/tests/integration/components/identity/step2-test.js new file mode 100644 index 00000000..2ed4a7ea --- /dev/null +++ b/tests/integration/components/identity/step2-test.js @@ -0,0 +1,63 @@ +import { module, test } from 'qunit'; +import { setupRenderingTest } from 'ember-qunit'; +import { render, click } from '@ember/test-helpers'; +import { hbs } from 'ember-cli-htmlbars'; +import { Server } from 'ember-cli-mirage'; +import ENV from 'website-my/config/environment'; + +module('Integration | Component | identity/step2', function (hooks) { + setupRenderingTest(hooks); + + test('it renders the identity step2 component without next button', async function (assert) { + this.set('setState', (val) => { + assert.step(val); + }); + + await render( + hbs`` + ); + + assert.dom('[data-test-step2-heading]').exists(); + assert + .dom('[data-test-step2-heading]') + .hasText('Step 2: Profile Service URL'); + + assert.dom('[data-test-step2-desc]').exists(); + assert.dom('[data-test-step2-input]').exists().hasNoText(); + assert.dom('[data-test-step2-next-button]').doesNotExist(); + }); + + test('it renders the identity step2 component without next button', async function (assert) { + let server = new Server({ + models: {}, + routes() { + this.namespace = ENV.BASE_API_URL; + + this.patch('/users/profileURL', {}); + }, + }); + + this.set('setState', (val) => { + assert.step(val); + }); + + await render( + hbs`` + ); + + assert.dom('[data-test-step2-heading]').exists(); + assert + .dom('[data-test-step2-heading]') + .hasText('Step 2: Profile Service URL'); + + assert.dom('[data-test-step2-input]').exists().hasNoText(); + assert.dom('[data-test-step2-input]').exists().hasNoText(); + assert.dom('[data-test-step2-next-button]').exists(); + + await click('[data-test-step2-next-button]'); + + assert.verifySteps(['step3']); + + server.shutdown(); + }); +}); diff --git a/tests/integration/components/identity/step3-test.js b/tests/integration/components/identity/step3-test.js new file mode 100644 index 00000000..f5aa10e5 --- /dev/null +++ b/tests/integration/components/identity/step3-test.js @@ -0,0 +1,43 @@ +import { module, test } from 'qunit'; +import { setupRenderingTest } from 'ember-qunit'; +import { render, click } from '@ember/test-helpers'; +import { hbs } from 'ember-cli-htmlbars'; +import sinon from 'sinon'; +import { Server } from 'ember-cli-mirage'; +import ENV from 'website-my/config/environment'; + +module('Integration | Component | identity/step3', function (hooks) { + setupRenderingTest(hooks); + + test('it renders the identity step3 component', async function (assert) { + let stub = sinon.stub(window, 'confirm'); + stub.returns(true); + + this.set('setState', (val) => { + assert.step(val); + }); + + let server = new Server({ + models: {}, + routes() { + this.namespace = ENV.BASE_API_URL; + + this.post('/users/verify', {}); + }, + }); + + await render(hbs``); + + assert.dom('[data-test-step3-heading]').exists(); + assert + .dom('[data-test-step3-heading]') + .hasText('Step 3: Link Profile Service'); + + assert.dom('[data-test-step3-desc]').exists(); + + await click('[data-test-step3-button]'); + + stub.restore(); + server.shutdown(); + }); +}); diff --git a/tests/integration/components/identity/verified-test.js b/tests/integration/components/identity/verified-test.js new file mode 100644 index 00000000..9390d535 --- /dev/null +++ b/tests/integration/components/identity/verified-test.js @@ -0,0 +1,17 @@ +import { module, test } from 'qunit'; +import { setupRenderingTest } from 'ember-qunit'; +import { render } from '@ember/test-helpers'; +import { hbs } from 'ember-cli-htmlbars'; + +module('Integration | Component | identity/verified', function (hooks) { + setupRenderingTest(hooks); + + test('it renders the identity verified component', async function (assert) { + await render(hbs``); + + assert.dom('[data-test-verified-heading]').exists(); + assert.dom('[data-test-verified-heading]').hasText('Verified'); + + assert.dom('[data-test-verified-desc]').exists(); + }); +});