Skip to content

Commit

Permalink
lib-user: Refactor link urls for internal testing (#6131)
Browse files Browse the repository at this point in the history
* Refactor link urls for internal testing

* Add BASE_URL const to getHeaderItems
  • Loading branch information
mcbouslog authored Jun 14, 2024
1 parent cdd1c1c commit 1a9e6c2
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import {
HeaderToast
} from '@components/shared'

const BASE_URL = 'https://fe-root.preview.zooniverse.org'

async function handleLeaveGroup({
login,
membershipId
Expand All @@ -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({
Expand All @@ -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 = (
<HeaderLink
href={`https://www.zooniverse.org/users/${authUser?.login}`}
label='back to profile'
href={`/users/${authUser?.login}/groups`}
label='all my groups'
primaryItem={true}
/>
)
Expand All @@ -74,7 +76,7 @@ function getHeaderItems({
icon={<Layer color='white' size='small' />}
label='Share Group'
message='Group Link Copied!'
textToCopy={`https://www.zooniverse.org/groups/${group.id}`}
textToCopy={`${BASE_URL}/groups/${group.id}`}
/>
)
}
Expand All @@ -86,14 +88,14 @@ function getHeaderItems({
icon={<Link color='white' size='small' />}
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}`}
/>,
<HeaderToast
key='share-group-toast'
icon={<Layer color='white' size='small' />}
label='Share Group'
message='Group Link Copied!'
textToCopy={`https://www.zooniverse.org/groups/${group.id}`}
textToCopy={`${BASE_URL}/groups/${group.id}`}
/>,
<HeaderButton
key='manage-group-button'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,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: 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 () {
Expand All @@ -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 () {
Expand Down Expand Up @@ -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 () {
Expand All @@ -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 () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,13 @@ function MyGroupsContainer({
<Layout
primaryHeaderItem={
<HeaderLink
href={`https://www.zooniverse.org/users/${login}`}
label='back to profile'
href='/'
label='back'
primaryItem={true}
/>
}
>
<ContentBox
linkLabel='Learn more about Groups'
linkProps={{ href: '/groups' }}
title='My Groups'
pad={{ horizontal: '60px', vertical: '30px' }}
>
Expand Down
4 changes: 2 additions & 2 deletions packages/lib-user/src/components/UserStats/UserStats.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ function UserStats({
<Layout
primaryHeaderItem={
<HeaderLink
href={`https://www.zooniverse.org/users/${user?.login}`}
label='back to profile'
href='/'
label='back'
primaryItem={true}
/>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ export const TopProjectsFull = {
export const TopProjectsFullWithFewerProjects = {
render: () => (
<ContentBox
linkLabel='See more'
linkProps={{ href: 'https://www.zooniverse.org/projects' }}
title='Top Projects'
>
<Box
Expand All @@ -103,8 +101,6 @@ export const TopProjectsFullWithFewerProjects = {
export const TopProjectsGrid = {
render: () => (
<ContentBox
linkLabel='See more'
linkProps={{ href: 'https://www.zooniverse.org/projects' }}
title='Top Projects'
width='625px'
>
Expand All @@ -123,7 +119,7 @@ export const TopContributors = {
render: () => (
<ContentBox
linkLabel='See all contributors and detailed stats'
linkProps={{ href: 'https://www.zooniverse.org/groups/12345/contributors' }}
linkProps={{ href: '/groups/12345/contributors' }}
title='Top Contributors'
width='625px'
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const CopyJoinLink = {
icon: <Link color='white' size='small' />,
label: 'Copy Join Link',
message: 'Join Link Copied!',
textToCopy: 'groups/1234?join_token=56789'
textToCopy: 'https://www.zooniverse.org/groups/1234?join_token=56789'
}
}

Expand All @@ -42,6 +42,6 @@ export const ShareGroup = {
icon: <Layer color='white' size='small' />,
label: 'Share Group',
message: 'Group Link Copied!',
textToCopy: 'zooniverse.org/groups/1234'
textToCopy: 'https://www.zooniverse.org/groups/1234'
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ function TopProjects({

return (
<ContentBox
linkLabel='See more'
linkProps={{ href: 'https://www.zooniverse.org/projects' }}
title='Top Projects'
>
<Container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(<DefaultStory />)

expect(screen.getByRole('link', { name: 'See more' })).to.be.ok()
Expand Down

0 comments on commit 1a9e6c2

Please sign in to comment.