diff --git a/app/components/new-signup/checkbox.hbs b/app/components/new-signup/checkbox.hbs
index dd74fb320..ceca4cd90 100644
--- a/app/components/new-signup/checkbox.hbs
+++ b/app/components/new-signup/checkbox.hbs
@@ -3,24 +3,25 @@
{{this.label}}
-
- {{#each this.checkboxData as |data|}}
-
- {{/each}}
-
+
+ {{#each this.checkboxData as |data|}}
+
+ {{/each}}
+
{
return `${APPS.DASHBOARD}/applications/?id=${id}`;
};
+export const SELF_USERS_URL = (userId, devFlag) => {
+ return `${APPS.API_BACKEND}/users/${userId}?profile=true&dev=${devFlag}`;
+};
+
export const GENERATE_USERNAME_URL = (
sanitizedFirstname,
sanitizedLastname,
@@ -29,8 +33,6 @@ export const CHECK_USERNAME_AVAILABILITY = (userName) => {
return `${APPS.API_BACKEND}/users/isUsernameAvailable/${userName}`;
};
-export const SELF_USERS_URL = `${APPS.API_BACKEND}/users/self`;
-
export const SELF_USER_STATUS_URL = `${APPS.API_BACKEND}/users/status/self`;
export const UPDATE_USER_STATUS = `${APPS.API_BACKEND}/users/status/self?userStatusFlag=true`;
diff --git a/app/constants/new-signup.js b/app/constants/new-signup.js
index b157553a5..65aa2405a 100644
--- a/app/constants/new-signup.js
+++ b/app/constants/new-signup.js
@@ -1,7 +1,6 @@
const GET_STARTED = 'get-started';
const FIRST_NAME = 'firstName';
const LAST_NAME = 'lastName';
-const USERNAME = 'username';
const ROLE = 'role';
const THANK_YOU = 'thank-you';
@@ -9,7 +8,6 @@ export const NEW_SIGNUP_STEPS = [
GET_STARTED,
FIRST_NAME,
LAST_NAME,
- USERNAME,
ROLE,
THANK_YOU,
];
@@ -44,9 +42,21 @@ export const CHECK_BOX_DATA = [
label: 'Maven',
name: 'maven',
},
+ {
+ label: 'Social Media',
+ name: 'social_media',
+ },
{
label: 'Product Manager',
- name: 'productmanager',
+ name: 'product_manager',
+ },
+ {
+ label: 'QA',
+ name: 'qa',
+ },
+ {
+ label: 'Project Manager',
+ name: 'project_manager',
},
];
diff --git a/app/controllers/new-signup.js b/app/controllers/new-signup.js
index c358e7a81..fc510a278 100644
--- a/app/controllers/new-signup.js
+++ b/app/controllers/new-signup.js
@@ -31,14 +31,12 @@ export default class NewSignupController extends Controller {
SECOND_STEP = NEW_SIGNUP_STEPS[1];
THIRD_STEP = NEW_SIGNUP_STEPS[2];
FOURTH_STEP = NEW_SIGNUP_STEPS[3];
- FIFTH_STEP = NEW_SIGNUP_STEPS[4];
- LAST_STEP = NEW_SIGNUP_STEPS[5];
+ LAST_STEP = NEW_SIGNUP_STEPS[4];
@tracked signupDetails = {
firstName: '',
lastName: '',
- username: '',
- roles: {},
+ role: '',
};
get isDevMode() {
@@ -82,22 +80,11 @@ export default class NewSignupController extends Controller {
}
}
- async registerUser(user) {
- return await apiRequest(SELF_USERS_URL, 'PATCH', user);
- }
-
- async newRegisterUser(signupDetails, roles) {
+ async registerUser(signupDetails, devFlag) {
const getResponse = await apiRequest(SELF_USER_PROFILE_URL);
const userData = await getResponse.json();
-
- const res = await this.registerUser({
- ...signupDetails,
- roles: {
- ...userData.roles,
- ...roles,
- },
- });
-
+ const url = SELF_USERS_URL(userData?.id, devFlag);
+ const res = await apiRequest(url, 'PATCH', signupDetails);
if (!res) {
throw new Error(SIGNUP_ERROR_MESSAGES.others);
}
@@ -134,48 +121,40 @@ export default class NewSignupController extends Controller {
else this.isButtonDisabled = true;
}
- @action handleCheckboxInputChange(key, value) {
- set(this.signupDetails.roles, key, value);
- if (Object.values(this.signupDetails.roles).includes(true)) {
- this.isButtonDisabled = false;
- } else {
- this.isButtonDisabled = true;
- }
+ @action handleCheckboxInputChange(selectedRole) {
+ this.signupDetails.role = selectedRole;
+ this.isButtonDisabled = !selectedRole;
}
@action async signup() {
try {
let username;
+ const { firstName, lastName, role } = this.signupDetails;
this.isLoading = true;
- if (!this.isDevMode)
- username = await this.generateUsername(
- this.signupDetails.firstName,
- this.signupDetails.lastName,
- );
- const signupDetails = {
- first_name: this.signupDetails.firstName,
- last_name: this.signupDetails.lastName,
- username: this.isDevMode ? this.signupDetails.username : username,
- };
- const roles = {};
- Object.entries(this.signupDetails.roles).forEach(([key, value]) => {
- if (value === true) {
- roles[key] = value;
- }
- });
- const isUsernameAvailable = await this.checkUserName(
- signupDetails.username,
- );
- if (!isUsernameAvailable) {
- this.isLoading = false;
- this.isButtonDisabled = false;
- return (this.error = SIGNUP_ERROR_MESSAGES.userName);
+ if (!this.isDevMode) {
+ username = await this.generateUsername(firstName, lastName);
+
+ const isUsernameAvailable = await this.checkUserName(username);
+
+ if (!isUsernameAvailable) {
+ this.isLoading = false;
+ this.isButtonDisabled = false;
+ return (this.error = SIGNUP_ERROR_MESSAGES.userName);
+ }
}
- const res = this.isDevMode
- ? await this.newRegisterUser(signupDetails, roles)
- : await this.registerUser(signupDetails);
+ const basePayload = {
+ first_name: firstName,
+ last_name: lastName,
+ };
+
+ const signupDetails = this.isDevMode
+ ? { ...basePayload, role }
+ : { ...basePayload, username };
+
+ const res = await this.registerUser(signupDetails, this.isDevMode);
+
if (res?.status === 204) {
this.currentStep = this.LAST_STEP;
} else {
diff --git a/app/styles/new-signup.module.css b/app/styles/new-signup.module.css
index 9cbc1eeb5..d8f5991b2 100644
--- a/app/styles/new-signup.module.css
+++ b/app/styles/new-signup.module.css
@@ -1,6 +1,7 @@
.user-details__container {
margin: 0;
padding: 0;
+ padding-top: 1rem;
display: flex;
flex-direction: column;
width: 100%;
diff --git a/app/templates/new-signup.hbs b/app/templates/new-signup.hbs
index 1d5d6d61e..c13b14482 100644
--- a/app/templates/new-signup.hbs
+++ b/app/templates/new-signup.hbs
@@ -30,16 +30,6 @@
@error={{this.error}}
/>
{{else if (and this.isDevMode (eq step this.FOURTH_STEP))}}
-
- {{else if (and this.isDevMode (eq step this.FIFTH_STEP))}}
`);
- assert.dom('[data-test-checkbox-label]').exists({ count: 4 });
- assert.dom('[data-test-checkbox-input]').exists({ count: 4 });
+ assert.dom('[data-test-checkbox-label]').exists({ count: 7 });
+ assert.dom('[data-test-checkbox-input]').exists({ count: 7 });
assert.dom('[data-test-checkbox-input="developer"]').isNotChecked();
assert.dom('[data-test-checkbox-input="designer"]').isNotChecked();
+ assert.dom('[data-test-checkbox-input="project_manager"]').isNotChecked();
assert.dom('[data-test-checkbox-input="maven"]').isNotChecked();
- assert.dom('[data-test-checkbox-input="productmanager"]').isNotChecked();
+ assert.dom('[data-test-checkbox-input="product_manager"]').isNotChecked();
+ assert.dom('[data-test-checkbox-input="qa"]').isNotChecked();
+ assert.dom('[data-test-checkbox-input="social_media"]').isNotChecked();
assert.dom('[data-test-checkbox-label="developer"]').hasText('Developer');
assert.dom('[data-test-checkbox-label="designer"]').hasText('Designer');
assert.dom('[data-test-checkbox-label="maven"]').hasText('Maven');
assert
- .dom('[data-test-checkbox-label="productmanager"]')
+ .dom('[data-test-checkbox-label="product_manager"]')
.hasText('Product Manager');
+ assert
+ .dom('[data-test-checkbox-label="project_manager"]')
+ .hasText('Project Manager');
+ assert.dom('[data-test-checkbox-label="qa"]').hasText('QA');
+ assert
+ .dom('[data-test-checkbox-label="social_media"]')
+ .hasText('Social Media');
});
test('checkbox is checked after the click (under dev flag)', async function (assert) {
@@ -88,15 +98,15 @@ module('Integration | Component | new-signup/checkbox', function (hooks) {
this.setProperties({
onClick: function () {
- this.currentStep = NEW_SIGNUP_STEPS[5];
+ this.currentStep = NEW_SIGNUP_STEPS[3];
},
currentStep: 'role',
isDevMode: true,
});
- this.set('onChange', function (roleKey, value) {
+ this.set('onChange', function (selectedRole, value) {
assert.strictEqual(
- roleKey,
+ selectedRole,
'developer',
'onChange action called with correct roleKey',
);
diff --git a/tests/integration/components/profile/upload-image-test.js b/tests/integration/components/profile/upload-image-test.js
index 387fb291f..bf574bb6f 100644
--- a/tests/integration/components/profile/upload-image-test.js
+++ b/tests/integration/components/profile/upload-image-test.js
@@ -77,12 +77,9 @@ module('Integration | Component | image uploader', function (hooks) {
dataTransfer,
});
await waitFor('p.message-text__failure');
-
assert
.dom('p.message-text__failure')
- .hasText(
- 'Error occured, please try again and if the issue still exists contact administrator and create a issue on the repo with logs',
- );
+ .exists('Error message is shown for invalid file type');
});
test('it renders crop UI when an image is selected', async function (assert) {
diff --git a/tests/unit/controllers/new-signup-test.js b/tests/unit/controllers/new-signup-test.js
index a3a74b35c..0a199e948 100644
--- a/tests/unit/controllers/new-signup-test.js
+++ b/tests/unit/controllers/new-signup-test.js
@@ -90,22 +90,34 @@ module('Unit | Controller | new-signup', function (hooks) {
);
});
- test('handleCheckboxInputChange updates roles and toggles button state', function (assert) {
- controller.send('handleCheckboxInputChange', 'developer', true);
- assert.true(controller.signupDetails.roles.developer, 'Developer role set');
+ test('handleCheckboxInputChange updates role and toggles button state', function (assert) {
+ controller.send('handleCheckboxInputChange', 'developer');
+ assert.strictEqual(controller.signupDetails.role, 'developer');
assert.false(
controller.isButtonDisabled,
'Button enabled when one role is selected',
);
- controller.send('handleCheckboxInputChange', 'developer', false);
+ controller.send('handleCheckboxInputChange', 'developer');
+ assert.strictEqual(
+ controller.signupDetails.role,
+ 'developer',
+ 'Role remains selected when same role is chosen again',
+ );
assert.false(
- controller.signupDetails.roles.developer,
- 'Developer role unset',
+ controller.isButtonDisabled,
+ 'Button remains enabled when role is selected',
+ );
+
+ controller.send('handleCheckboxInputChange', '');
+ assert.strictEqual(
+ controller.signupDetails.role,
+ '',
+ 'Role is unset when empty value is passed',
);
assert.true(
controller.isButtonDisabled,
- 'Button disabled when no roles selected',
+ 'Button disabled when no role selected',
);
});
@@ -158,7 +170,6 @@ module('Unit | Controller | new-signup', function (hooks) {
controller.signupDetails = {
firstName: fakeUserData.first_name,
lastName: fakeUserData.last_name,
- roles: { developer: true },
};
sinon.stub(controller, 'generateUsername').resolves(fakeUserData.username);
@@ -179,7 +190,6 @@ module('Unit | Controller | new-signup', function (hooks) {
controller.signupDetails = {
firstName: fakeUserData.first_name,
lastName: fakeUserData.last_name,
- roles: { developer: true },
};
sinon.stub(controller, 'generateUsername').resolves(fakeUserData.username);
@@ -204,13 +214,12 @@ module('Unit | Controller | new-signup', function (hooks) {
controller.signupDetails = {
firstName: fakeUserData.first_name,
lastName: fakeUserData.last_name,
- username: 'mock-username',
- roles: { developer: true },
+ roles: 'developer',
};
sinon.stub(controller, 'checkUserName').resolves(true);
sinon
- .stub(controller, 'newRegisterUser')
+ .stub(controller, 'registerUser')
.throws(new Error(SIGNUP_ERROR_MESSAGES.others));
await controller.signup();
diff --git a/tests/unit/services/onboarding-test.js b/tests/unit/services/onboarding-test.js
index 2dbefd047..ef53a3ffb 100644
--- a/tests/unit/services/onboarding-test.js
+++ b/tests/unit/services/onboarding-test.js
@@ -67,7 +67,7 @@ module('Unit | Service | onboarding', function (hooks) {
});
test('signup method for non-Developer role', async function (assert) {
- assert.expect(2);
+ assert.expect(4);
let service = this.owner.lookup('service:onboarding');
let store = this.owner.lookup('service:store');
@@ -94,14 +94,16 @@ module('Unit | Service | onboarding', function (hooks) {
let dataToUpdate = {
username: 'testuser',
- roles: {
- maven: true,
- },
+ role: 'maven',
};
await service.signup(dataToUpdate);
- assert.verifySteps(['store.createRecord called']);
+ assert.verifySteps([
+ 'store.createRecord called',
+ 'setProperties called',
+ 'save called',
+ ]);
});
test('discordInvite method', async function (assert) {