Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev to Main sync #922

Merged
merged 9 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ A short introduction of this app could easily go here.
You will need the following things properly installed on your computer.

- [Git](https://git-scm.com/)
- [Node.js](https://nodejs.org/) (with npm)
- [Node.js](https://nodejs.org/) (with yarn)
- [Ember CLI](https://cli.emberjs.com/release/)
- [Google Chrome](https://google.com/chrome/)

## Installation

- `git clone <repository-url>` this repository
- `cd website-www`
- `npm install`
- `yarn install`

## Running / Development

Expand Down
10 changes: 10 additions & 0 deletions app/controllers/join.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ export default class JoinController extends Controller {
@service router;
@service login;
@service featureFlag;
@service onboarding;
@tracked chaincode = 'Generate chaincode';
@tracked isChaincodeClicked = false;
@tracked isLoading = false;

ANKUSH_TWITTER = ANKUSH_TWITTER;

queryParams = ['step', 'dev'];
Expand All @@ -20,6 +22,14 @@ export default class JoinController extends Controller {
return this.featureFlag.isDevMode;
}

get applicationData() {
return this.onboarding.applicationData;
}

get loading() {
return this.login.isLoading || this.onboarding.loadingApplicationData;
}

@action async handleGenerateChaincode(e) {
e.preventDefault();

Expand Down
5 changes: 5 additions & 0 deletions app/routes/intro.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ export default class IntroRoute extends Route {
});
userData = await userResponse.json();

if (!userData.roles.super_user) {
this.router.transitionTo('/join');
return;
}

const response = await fetch(APPLICATION_URL(userId), {
credentials: 'include',
});
Expand Down
3 changes: 3 additions & 0 deletions app/services/onboarding.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export default class OnboardingService extends Service {
@service store;
@service toast;
@tracked applicationData;
@tracked loadingApplicationData = true;

constructor() {
super(...arguments);
Expand Down Expand Up @@ -126,6 +127,8 @@ export default class OnboardingService extends Service {
const applicationData = await applicationResponse.json();

this.applicationData = applicationData?.applications?.[0];

this.loadingApplicationData = false;
} catch (err) {
console.error('Error: ', err);
this.toast.error('Some error occured', 'Error ocurred!', TOAST_OPTIONS);
Expand Down
26 changes: 17 additions & 9 deletions app/templates/join.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{page-title 'Join'}}
<section class='join__container'>
{{#if this.login.isLoading}}
{{#if this.loading}}
<div data-test-loading class='intro__loading'>
<Fa-Icon @size='2x' @icon='circle-notch' @spin={{true}} />
</div>
Expand Down Expand Up @@ -29,16 +29,24 @@
</div>
</OnboardingCard>
{{else}}
{{#if this.isDevMode}}
<StepperSignup
@chaincode={{this.chaincode}}
@isChaincodeClicked={{this.isChaincodeClicked}}
@isLoading={{this.isLoading}}
@handleGenerateChaincode={{this.handleGenerateChaincode}}
{{#if this.applicationData}}
<JoinSteps::StatusCard
@status={{this.applicationData.status}}
@feedback={{this.applicationData.feedback}}
@joinDiscord={{this.joinDiscordHandler}}
/>
{{else}}
<Stepper />
{{#if this.isDevMode}}
<StepperSignup
@chaincode={{this.chaincode}}
@isChaincodeClicked={{this.isChaincodeClicked}}
@isLoading={{this.isLoading}}
@handleGenerateChaincode={{this.handleGenerateChaincode}}
/>
{{else}}
<Stepper />
{{/if}}
{{/if}}
{{/if}}
{{/if}}
</section>
</section>
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
"ember-ref-bucket": "5.0.1",
"ember-resolver": "11.0.1",
"ember-set-helper": "2.0.1",
"ember-sinon-qunit": "^7.5.0",
"ember-source": "5.9.0",
"ember-template-lint": "5.13.0",
"ember-toastr": "3.0.1",
Expand All @@ -97,6 +98,7 @@
"prettier": "3.3.1",
"qunit": "2.21.0",
"qunit-dom": "2.0.0",
"sinon": "^18.0.0",
"stylelint": "15.11.0",
"stylelint-config-standard": "34.0.0",
"stylelint-prettier": "4.1.0",
Expand Down
14 changes: 13 additions & 1 deletion tests/integration/components/status-card-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ import { setupRenderingTest } from 'ember-qunit';
import { render, waitFor } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
import { ANKUSH_TWITTER } from '../../constants/urls';
import Service from '@ember/service';
import sinon from 'sinon';

class LoginStub extends Service {
userData = { id: 'fZ0itx5x2ltOSMzON9kb' };
}
class OnboardingStub extends Service {
getApplicationDetails = sinon.spy;
}

module('Integration | Component | status-card', function (hooks) {
setupRenderingTest(hooks);
Expand All @@ -12,9 +21,12 @@ module('Integration | Component | status-card', function (hooks) {
window.open = this.spy();
});
this.set('ANKUSH_TWITTER', ANKUSH_TWITTER);

this.owner.register('service:login', LoginStub);
this.owner.register('service:onboarding', OnboardingStub);
});

test.skip('it renders pending status', async function (assert) {
test('it renders pending status', async function (assert) {
this.set('status', 'pending');
this.set('feedback', 'Feedback for pending status');

Expand Down
10 changes: 4 additions & 6 deletions tests/integration/components/step-five-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ANKUSH_TWITTER } from '../../constants/urls';
module('Integration | Component | step-five', function (hooks) {
setupRenderingTest(hooks);

test.skip('it renders', async function (assert) {
test('it renders', async function (assert) {
assert.expect(12);

await render(hbs`<JoinSteps::StepFive />`);
Expand All @@ -18,16 +18,14 @@ module('Integration | Component | step-five', function (hooks) {
assert.dom('[data-test-copy-btn]').hasText('Copy');
assert.dom('[data-test-next-text]').hasText('Next Steps :');
assert.dom('[data-test-instructions]').hasTagName('ol');
assert.dom('[data-test-instone]').hasText('Copy the above link');
assert.dom('[data-test-instone]').hasText('Click on the copy button.');
assert
.dom('[data-test-insttwo]')
.hasText('Follow Ankush Dharkar on Twitter');
.hasText('Message copied link to Ankush Dharkar on Twitter');
assert.dom('[data-test-insttwo-link]').hasProperty('href', ANKUSH_TWITTER);
assert
.dom('[data-test-instthree]')
.hasText(
'Message this link to him with this Real Dev Squad verification link',
);
.hasText('Wait for him to verify the link');
assert
.dom('[data-test-instfour]')
.hasText('Wait for him to verify the link');
Expand Down
2 changes: 2 additions & 0 deletions tests/test-helper.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Application from 'website-www/app';
import config from 'website-www/config/environment';
import setupSinon from 'ember-sinon-qunit';
import * as QUnit from 'qunit';
import { setApplication } from '@ember/test-helpers';
import { setup } from 'qunit-dom';
Expand All @@ -8,5 +9,6 @@ import { start } from 'ember-qunit';
setApplication(Application.create(config.APP));

setup(QUnit.assert);
setupSinon();

start();
Loading
Loading