From 3fc6a7a191a3b018e330c1bc068c66381c6815ac Mon Sep 17 00:00:00 2001 From: khemchand <84411728+khemchand-twt11@users.noreply.github.com> Date: Tue, 10 Oct 2023 02:05:21 +0530 Subject: [PATCH] Fix: Add user profile with dropdown after sign in through github (#535) * user profile with dropdown after sign in through github * changes done and test case added * Update home.test.js syntax error fixed in home.test.js * changes map to forEach * change map to forEach * condition to check whether dropdown open or not --- __tests__/home/home.test.js | 51 ++++++++++++++++++ constants.js | 1 - index.html | 9 +++- mock-data/users/index.js | 4 ++ script.js | 100 ++++++++++++++++++++++++++++++++++++ style.css | 79 ++++++++++++++++++++++++++++ utils.js | 26 ++++++++-- 7 files changed, 263 insertions(+), 7 deletions(-) diff --git a/__tests__/home/home.test.js b/__tests__/home/home.test.js index 6252da33..28713064 100644 --- a/__tests__/home/home.test.js +++ b/__tests__/home/home.test.js @@ -387,6 +387,57 @@ describe('Home Page', () => { expect(repoLinkStyle).toBeTruthy(); }); + it('Check user profile with dropdown options', async () => { + const DROPDOWN_OPTIONS = [ + { + name: 'Home', + link: 'https://dashboard.realdevsquad.com/', + }, + { + name: 'Status', + link: 'https://my.realdevsquad.com/', + }, + { + name: 'Profile', + link: 'https://my.realdevsquad.com/profile', + }, + { + name: 'Tasks', + link: 'https://my.realdevsquad.com/tasks', + }, + { + name: 'Identity', + link: 'https://my.realdevsquad.com/identity', + }, + ]; + + const userName = await page.$eval( + '#user-name', + (element) => element.textContent, + ); + const userImage = await page.$eval('#user-img', (element) => element.src); + expect(userName).toContain(superUserData.first_name); + expect(userImage).toEqual(superUserData.picture.url); + + const userInfoButton = await page.$('.user-info'); + await userInfoButton.click(); + + const hrefs = await page.$$eval( + '.dropdown-list .dropdown-item a', + (elements) => elements.map((element) => element.getAttribute('href')), + ); + + const expectedHrefs = DROPDOWN_OPTIONS.map((option) => option.link); + + expect(hrefs).toEqual(expectedHrefs); + + const signoutButton = await page.$('#signout-option'); + await signoutButton.click(); + const signinButton = await page.$('.sign-in-btn'); + + expect(signinButton).toBeTruthy(); + }); + it('should display the Sync Onboarding 31d+ button', async () => { const syncOnboarding31dPlusUsersButton = await page.$( '#sync-onboarding-31d-plus-users', diff --git a/constants.js b/constants.js index c705a139..e1a94da4 100644 --- a/constants.js +++ b/constants.js @@ -26,7 +26,6 @@ const DISABLED = 'disabled'; const STATUS_BASE_URL_PROD = 'https://status.realdevsquad.com'; const STATUS_BASE_URL_STAGING = 'https://staging-status.realdevsquad.com'; const STATUS_BASE_URL = STATUS_BASE_URL_PROD; - const dummyPicture = 'https://dashboard.realdevsquad.com/images/avatar.png'; const USER_MANAGEMENT_URL = 'https://dashboard.realdevsquad.com/users/details/?username='; diff --git a/index.html b/index.html index 985abe5b..d695df0c 100644 --- a/index.html +++ b/index.html @@ -37,9 +37,16 @@ Sign In With GitHub - + +
+