Skip to content

Commit

Permalink
Dev to Main Sync (#630)
Browse files Browse the repository at this point in the history
* Merge pull request #627 from Hariom01010/fix/update-users-self-api-endpoint

Updated deprecated API endpoint from /users/self to /users?profile=true

* dev flag removed for update profile picture button (#626)

* dev flag removed for update profile picture button

* added test for profile-edit-button

---------

Co-authored-by: Achintya Chatterjee <55826451+Achintya-Chatterjee@users.noreply.github.com>

* Fix/update users self api endpoint (#629)

* Updated deprecated API endpoint from /users/self to /users?profile=true

* Fix: Remove the updates where patch route was updated by mistake

---------

Co-authored-by: Prakash Choudhary <34452139+prakashchoudhary07@users.noreply.github.com>

---------

Co-authored-by: Hariom Vashista <rishivashista4@gmail.com>
Co-authored-by: Javed Ansari <javedans2003@gmail.com>
Co-authored-by: Prakash Choudhary <34452139+prakashchoudhary07@users.noreply.github.com>
Co-authored-by: Amit Prakash <34869115+iamitprakash@users.noreply.github.com>
4 people authored Jan 29, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents 4a19a23 + b457ff4 commit 38d517e
Showing 12 changed files with 35 additions and 88 deletions.
2 changes: 1 addition & 1 deletion app/routes/application.js
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ export default class ApplicationRoute extends Route {
const defaultPicture = 'dummyProfilePicture.png';

try {
const response = await fetch(`${API_BASE_URL}/users/self`, {
const response = await fetch(`${API_BASE_URL}/users?profile=true`, {
credentials: 'include',
});
const userData = await response.json();
9 changes: 6 additions & 3 deletions app/routes/discord.js
Original file line number Diff line number Diff line change
@@ -22,9 +22,12 @@ export default class DiscordRoute extends Route {
}
);

const userResponse = await fetch(`${ENV.BASE_API_URL}/users/self`, {
credentials: 'include',
});
const userResponse = await fetch(
`${ENV.BASE_API_URL}/users?profile=true`,
{
credentials: 'include',
}
);

const externalAccountData = await externalAccountResponse.json();
const userData = await userResponse.json();
2 changes: 1 addition & 1 deletion app/routes/identity.js
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ export default class IdentityRoute extends Route {
@service toast;
async model() {
try {
const response = await fetch(`${ENV.BASE_API_URL}/users/self`, {
const response = await fetch(`${ENV.BASE_API_URL}/users?profile=true`, {
credentials: 'include',
});
const userData = await response.json();
2 changes: 1 addition & 1 deletion app/routes/mobile.js
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ export default class MobileRoute extends Route {

model = async () => {
try {
const response = await fetch(`${API_BASE_URL}/users/self`, {
const response = await fetch(`${API_BASE_URL}/users?profile=true`, {
credentials: 'include',
});
const userData = await response.json();
2 changes: 1 addition & 1 deletion app/routes/new-signup.js
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ export default class NewSignupRoute extends Route {
async model() {
try {
this.analytics.trackEvent(SIGNUP.PAGE_LOADED);
const response = await fetch(`${ENV.BASE_API_URL}/users/self`, {
const response = await fetch(`${ENV.BASE_API_URL}/users?profile=true`, {
credentials: 'include',
});
const userData = await response.json();
2 changes: 1 addition & 1 deletion app/routes/profile.js
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ export default class ProfileRoute extends Route {
credentials: 'include',
});
const { developerRoleExistsOnUser } = await res.json();
const response = await fetch(`${ENV.BASE_API_URL}/users/self`, {
const response = await fetch(`${ENV.BASE_API_URL}/users?profile=true`, {
credentials: 'include',
});
const userData = await response.json();
2 changes: 1 addition & 1 deletion app/routes/signup.js
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ export default class SignupRoute extends Route {
async model() {
try {
this.analytics.trackEvent(SIGNUP.PAGE_LOADED);
const response = await fetch(`${ENV.BASE_API_URL}/users/self`, {
const response = await fetch(`${ENV.BASE_API_URL}/users?profile=true`, {
credentials: 'include',
});
const userData = await response.json();
9 changes: 0 additions & 9 deletions app/templates/profile.hbs
Original file line number Diff line number Diff line change
@@ -12,20 +12,11 @@
alt='user profile'
/>
{{/if}}

{{#if this.isDev}}
<Button @onClick={{this.handleShowEditProfilePictureModal}}
@class='profile-edit-button '
@data-test-btn='edit'>
<FaIcon @icon="edit" />
</Button>
{{else}}
<Button @onClick={{this.handleShowEditProfilePictureModal}}
@class='edit-btn btn'
@data-test-btn='edit'>
Update Picture
</Button>
{{/if}}
</div>
<div class='profile-form-grid'>
{{#if (get @model 'isDeveloper')}}
2 changes: 1 addition & 1 deletion app/utils/register-api.js
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ const registerUser = (user) =>
});

const newRegisterUser = async (signupDetails, roles) => {
const getResponse = await fetch(`${BASE_API_URL}/users/self`, {
const getResponse = await fetch(`${BASE_API_URL}/users?profile=true`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
57 changes: 0 additions & 57 deletions tests/integration/components/profile-test.js

This file was deleted.

22 changes: 22 additions & 0 deletions tests/unit/components/profile-edit-button-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';

module('Unit | Component | profile-edit-button', function (hooks) {
setupRenderingTest(hooks);

test('profile-edit-button renders and triggers action on click', async function (assert) {
this.set('mockAction', () => {
assert.ok(true, 'Action was called');
});

await render(
hbs`<Button @onClick={{this.mockAction}} @class='profile-edit-button' @data-test-btn='edit'>
<FaIcon @icon="edit" />
</Button>`
);

assert.dom('[data-test-btn="edit"]').exists('Edit button is rendered');
});
});
12 changes: 0 additions & 12 deletions tests/unit/routes/profile-test.js
Original file line number Diff line number Diff line change
@@ -20,16 +20,4 @@ module('Unit | Route | profile', function (hooks) {
assert.dom('[data-test-modal="image-upload"]').exists();
assert.dom('[data-test-btn="browse"]').exists();
});
test('button appearance based on dev query param', async (assert) => {
await visit('/profile?dev=true');

assert.dom('[data-test-btn="edit"]').exists();
assert.dom('[data-test-btn="edit"]').hasClass('profile-edit-button');

await visit('/profile?dev=false');

assert.dom('[data-test-btn="edit"]').exists();
assert.dom('[data-test-btn="edit"]').hasClass('edit-btn');
assert.dom('[data-test-btn="edit"]').hasText('Update Picture');
});
});

0 comments on commit 38d517e

Please sign in to comment.