From 1a9e6c29b2f66944cefb1b8331f82a13764df00f Mon Sep 17 00:00:00 2001 From: Mark Bouslog Date: Fri, 14 Jun 2024 13:10:28 -0500 Subject: [PATCH] lib-user: Refactor link urls for internal testing (#6131) * Refactor link urls for internal testing * Add BASE_URL const to getHeaderItems --- .../GroupStats/helpers/getHeaderItems.js | 16 +++++++++------- .../GroupStats/helpers/getHeaderItems.spec.js | 8 ++++---- .../src/components/MyGroups/MyGroupsContainer.js | 6 ++---- .../src/components/UserStats/UserStats.js | 4 ++-- .../shared/ContentBox/ContentBox.stories.js | 6 +----- .../shared/HeaderToast/HeaderToast.stories.js | 4 ++-- .../components/shared/TopProjects/TopProjects.js | 2 -- .../shared/TopProjects/TopProjects.spec.js | 4 +++- 8 files changed, 23 insertions(+), 27 deletions(-) diff --git a/packages/lib-user/src/components/GroupStats/helpers/getHeaderItems.js b/packages/lib-user/src/components/GroupStats/helpers/getHeaderItems.js index fc731b5522..e1074b3abe 100644 --- a/packages/lib-user/src/components/GroupStats/helpers/getHeaderItems.js +++ b/packages/lib-user/src/components/GroupStats/helpers/getHeaderItems.js @@ -11,6 +11,8 @@ import { HeaderToast } from '@components/shared' +const BASE_URL = 'https://fe-root.preview.zooniverse.org' + async function handleLeaveGroup({ login, membershipId @@ -21,7 +23,7 @@ async function handleLeaveGroup({ const deleteMembershipResponse = await deletePanoptesMembership({ membershipId }) if (!deleteMembershipResponse.ok) return - window.location.href = `https://www.zooniverse.org/users/${login}` + window.location.href = '/' } function getHeaderItems({ @@ -46,14 +48,14 @@ function getHeaderItems({ label='Share Group' message='Group Link Copied!' primaryItem={true} - textToCopy={`https://www.zooniverse.org/groups/${group.id}`} + textToCopy={`${BASE_URL}/groups/${group.id}`} /> ) } else { headerItems.PrimaryHeaderItem = ( ) @@ -74,7 +76,7 @@ function getHeaderItems({ icon={} label='Share Group' message='Group Link Copied!' - textToCopy={`https://www.zooniverse.org/groups/${group.id}`} + textToCopy={`${BASE_URL}/groups/${group.id}`} /> ) } @@ -86,14 +88,14 @@ function getHeaderItems({ icon={} label='Copy Join Link' message='Join Link Copied!' - textToCopy={`https://www.zooniverse.org/groups/${group.id}?join_token=${group.join_token}`} + textToCopy={`${BASE_URL}/groups/${group.id}?join_token=${group.join_token}`} />, } label='Share Group' message='Group Link Copied!' - textToCopy={`https://www.zooniverse.org/groups/${group.id}`} + textToCopy={`${BASE_URL}/groups/${group.id}`} />, GroupStats > getHeaderItems', function () { describe('with group member', function () { it('should return a link to the user profile', function () { const result = getHeaderItems({ authUser, group: privateAggOnly, membership: groupMember }) - expect(result.PrimaryHeaderItem.props.label).to.equal('back to profile') + expect(result.PrimaryHeaderItem.props.label).to.equal('all my groups') }) it('should return a leave group button', function () { @@ -37,7 +37,7 @@ describe('components > GroupStats > getHeaderItems', function () { describe('with group admin', function () { it('should return a link to the user profile', function () { const result = getHeaderItems({ authUser, group: privateAggOnly, membership: groupAdmin }) - expect(result.PrimaryHeaderItem.props.label).to.equal('back to profile') + expect(result.PrimaryHeaderItem.props.label).to.equal('all my groups') }) it('should return a copy join link toast', function () { @@ -71,7 +71,7 @@ describe('components > GroupStats > getHeaderItems', function () { describe('with group member', function () { it('should return a link to the user profile', function () { const result = getHeaderItems({ authUser, group: publicShowAll, membership: groupMember }) - expect(result.PrimaryHeaderItem.props.label).to.equal('back to profile') + expect(result.PrimaryHeaderItem.props.label).to.equal('all my groups') }) it('should return a leave group button', function () { @@ -88,7 +88,7 @@ describe('components > GroupStats > getHeaderItems', function () { describe('with group admin', function () { it('should return a link to the user profile', function () { const result = getHeaderItems({ authUser, group: publicShowAll, membership: groupAdmin }) - expect(result.PrimaryHeaderItem.props.label).to.equal('back to profile') + expect(result.PrimaryHeaderItem.props.label).to.equal('all my groups') }) it('should return a copy join link toast', function () { diff --git a/packages/lib-user/src/components/MyGroups/MyGroupsContainer.js b/packages/lib-user/src/components/MyGroups/MyGroupsContainer.js index e9555ca22d..ea890ae7d6 100644 --- a/packages/lib-user/src/components/MyGroups/MyGroupsContainer.js +++ b/packages/lib-user/src/components/MyGroups/MyGroupsContainer.js @@ -64,15 +64,13 @@ function MyGroupsContainer({ } > diff --git a/packages/lib-user/src/components/UserStats/UserStats.js b/packages/lib-user/src/components/UserStats/UserStats.js index 4d04d663b1..ed997cb678 100644 --- a/packages/lib-user/src/components/UserStats/UserStats.js +++ b/packages/lib-user/src/components/UserStats/UserStats.js @@ -43,8 +43,8 @@ function UserStats({ } diff --git a/packages/lib-user/src/components/shared/ContentBox/ContentBox.stories.js b/packages/lib-user/src/components/shared/ContentBox/ContentBox.stories.js index 36fe737cec..cb2be615a1 100644 --- a/packages/lib-user/src/components/shared/ContentBox/ContentBox.stories.js +++ b/packages/lib-user/src/components/shared/ContentBox/ContentBox.stories.js @@ -82,8 +82,6 @@ export const TopProjectsFull = { export const TopProjectsFullWithFewerProjects = { render: () => ( ( @@ -123,7 +119,7 @@ export const TopContributors = { render: () => ( diff --git a/packages/lib-user/src/components/shared/HeaderToast/HeaderToast.stories.js b/packages/lib-user/src/components/shared/HeaderToast/HeaderToast.stories.js index 67ab9c2249..61c26ef10f 100644 --- a/packages/lib-user/src/components/shared/HeaderToast/HeaderToast.stories.js +++ b/packages/lib-user/src/components/shared/HeaderToast/HeaderToast.stories.js @@ -33,7 +33,7 @@ export const CopyJoinLink = { icon: , label: 'Copy Join Link', message: 'Join Link Copied!', - textToCopy: 'groups/1234?join_token=56789' + textToCopy: 'https://www.zooniverse.org/groups/1234?join_token=56789' } } @@ -42,6 +42,6 @@ export const ShareGroup = { icon: , label: 'Share Group', message: 'Group Link Copied!', - textToCopy: 'zooniverse.org/groups/1234' + textToCopy: 'https://www.zooniverse.org/groups/1234' } } diff --git a/packages/lib-user/src/components/shared/TopProjects/TopProjects.js b/packages/lib-user/src/components/shared/TopProjects/TopProjects.js index 47ab0335cc..08a85292ab 100644 --- a/packages/lib-user/src/components/shared/TopProjects/TopProjects.js +++ b/packages/lib-user/src/components/shared/TopProjects/TopProjects.js @@ -70,8 +70,6 @@ function TopProjects({ return ( diff --git a/packages/lib-user/src/components/shared/TopProjects/TopProjects.spec.js b/packages/lib-user/src/components/shared/TopProjects/TopProjects.spec.js index 15c22c417c..1f2c69e2a7 100644 --- a/packages/lib-user/src/components/shared/TopProjects/TopProjects.spec.js +++ b/packages/lib-user/src/components/shared/TopProjects/TopProjects.spec.js @@ -14,7 +14,9 @@ describe('components > shared > TopProjects', function () { expect(screen.getByText('Top Projects')).to.be.ok() }) - it('should show a "see more" link', function () { + // temporarily skipping until the new All Projects page is created + // once the All Projects page is created the "see more" to that page will be added and this test can be enabled + it.skip('should show a "see more" link', function () { render() expect(screen.getByRole('link', { name: 'See more' })).to.be.ok()