Skip to content

Commit

Permalink
Merge pull request #1489 from kianamcc/PORTALS-3305
Browse files Browse the repository at this point in the history
PORTALS-3305: New Featured Research ("What's New") component
  • Loading branch information
kianamcc authored Jan 10, 2025
2 parents 8a66702 + 88be7be commit 8cb66b4
Show file tree
Hide file tree
Showing 8 changed files with 598 additions and 1 deletion.
2 changes: 2 additions & 0 deletions apps/portals/elportal/src/config/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export const cohortBuilderFilesSql = 'SELECT * FROM syn52234677'
export const partnersSql =
'SELECT * FROM syn62661043 order by organizationName desc'
export const whatWeDoSql = 'SELECT * FROM syn64130706'
export const featuredResearchSql =
'SELECT * FROM syn64542019 ORDER BY order ASC'

export const defaultSearchConfiguration = {
fullTextSearchHelpURL: 'https://help.eliteportal.org/help/search-tips',
Expand Down
8 changes: 7 additions & 1 deletion apps/portals/elportal/src/pages/HomePageV2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@ import {
RecentPublicationsGrid,
ImageCardGridWithLinks,
PortalFeatureHighlights,
FeaturedResearch,
} from 'synapse-react-client'
import ELContributeYourData from '@sage-bionetworks/synapse-portal-framework/components/elportal/ELContributeYourData'
import ELGettingStarted from '@sage-bionetworks/synapse-portal-framework/components/elportal/ELGettingStarted'
import { topPublicationsSql, whatWeDoSql } from '../config/resources'
import {
topPublicationsSql,
whatWeDoSql,
featuredResearchSql,
} from '../config/resources'
import { Link, Typography } from '@mui/material'
import analyzetheclouds from '../assets/analyzetheclouds.png'
import computationaltools from '../assets/computationaltools.png'
Expand Down Expand Up @@ -45,6 +50,7 @@ export default function HomePage() {
title="What We Do"
summaryText="We provide multi-omic datasets, software tools, and publications that empower researchers to discover the latest health-promoting therapeutics."
/>
<FeaturedResearch sql={featuredResearchSql} />
{/* Commented out for release (see EC-485) */}
{/*<div className={'home-bg-dark'}>*/}
{/*<SectionLayout*/}
Expand Down
5 changes: 5 additions & 0 deletions apps/portals/elportal/src/themes/HomePageThemeProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ export function HomePageThemeProvider({ children }: React.PropsWithChildren) {
},
},
},
MuiStack: {
defaultProps: {
useFlexGap: true,
},
},
},
}
const mergedTheme = deepmerge(theme, homePageOverrides)
Expand Down
30 changes: 30 additions & 0 deletions packages/synapse-react-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,33 @@ This project can be built as a umd bundle. It produces four files
- `synapse-react-client.development.css`.
> Note - this script is run automatically as part of the build command.
## Testing Synapse React Client (SRC) in Synapse Web Client (SWC)
This guide explains how to test changes made in the Synapse React Client (SRC) on the Synapse Web Client (SWC) using **Chrome DevTools**.
1. Make Your Changes in SRC
Edit the code in the `synapse-react-client` package as needed.
2. Build the UMD Files
Run the following command to build the UMD files for SRC:
```bash
pnpm build:umd
```
3. Go to https://www.synapse.org in Chrome and open the **Developer Tools**.
4. Locate the synapse-react-client.production.min.js file in the Network tab and right click on the file and select **Override Content**.
5. Go to the **Sources** tab in Developer Tools and go to the **Overrides** section. Make sure **Enabled Local Overrides** is checked.
6. Right-click cdn-www.synapse.org/generated or synapse-react-client.production.min.js and select **Open Folder** or **Open Containing Folder** respectively
7. In your file explore, navigate to packages/synapse-react-client/dist/umd/ and find the updated synapse-react-client.production.min.js file. Drag and drop this file to the generated folder to replace the old synapse-react-client.production.min.js file.
8. Refresh https://www.synapse.org and the site should now be using your override file.
9. Repeat steps above for any SRC changes you want to see in https://www.synapse.org.
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
import FeaturedResearch, { FeaturedResearchProps } from './FeaturedResearch'
import { screen, render, waitFor } from '@testing-library/react'
import { createWrapper } from '../../testutils/TestingLibraryUtils'
import useGetQueryResultBundle from '../../synapse-queries/entity/useGetQueryResultBundle'
import {
BatchFileResult,
ColumnTypeEnum,
QueryResultBundle,
} from '@sage-bionetworks/synapse-types'
import { getUseQuerySuccessMock } from '../../testutils/ReactQueryMockUtils'
import { SynapseClient } from '../../index'

jest.mock('../../synapse-queries/entity/useGetQueryResultBundle')
const mockUseGetQueryResultBundle = jest.mocked(useGetQueryResultBundle)

describe('FeaturedResearch Tests', () => {
const mockProps: FeaturedResearchProps = {
sql: 'SELECT * FROM syn64542019',
}

const mockQueryResult: QueryResultBundle = {
concreteType: 'org.sagebionetworks.repo.model.table.QueryResultBundle',
queryResult: {
concreteType: 'org.sagebionetworks.repo.model.table.QueryResult',
queryResults: {
concreteType: 'org.sagebionetworks.repo.model.table.RowSet',
tableId: 'syn64542019',
etag: 'DEFAULT',
headers: [
{
name: 'title',
columnType: ColumnTypeEnum.STRING,
id: '1',
},
{
name: 'description',
columnType: ColumnTypeEnum.STRING,
id: '2',
},
{
name: 'publicationDate',
columnType: ColumnTypeEnum.DATE,
id: '3',
},
{
name: 'tags',
columnType: ColumnTypeEnum.STRING_LIST,
id: '4',
},
{
name: 'affiliation',
columnType: ColumnTypeEnum.STRING,
id: '5',
},
{
name: 'image',
columnType: ColumnTypeEnum.FILEHANDLEID,
id: '6',
},
{ name: 'link', columnType: ColumnTypeEnum.LINK, id: '7' },
{ name: 'order', columnType: ColumnTypeEnum.INTEGER, id: '8' },
],
rows: [
{
rowId: 1,
values: [
'Title 1',
'Description 1',
'1726164997000',
'["tag1_1", "tag1_2"]',
'affiliation 1',
'151525812',
'https://mockurl.com/data-release-1',
'2',
],
},
{
rowId: 2,
values: [
'Title 2',
'Description 2',
'1726164997000',
'["tag2_1"]',
'affiliation 2',
'151468828',
'https://mockurl.com/data-release-2',
'2',
],
},
],
},
},
selectColumns: [
{
name: 'title',
columnType: ColumnTypeEnum.STRING,
id: '1',
},
{
name: 'description',
columnType: ColumnTypeEnum.STRING,
id: '2',
},
{
name: 'publicationDate',
columnType: ColumnTypeEnum.DATE,
id: '3',
},
{
name: 'tags',
columnType: ColumnTypeEnum.STRING_LIST,
id: '4',
},
{
name: 'affiliation',
columnType: ColumnTypeEnum.STRING,
id: '5',
},
{
name: 'image',
columnType: ColumnTypeEnum.FILEHANDLEID,
id: '6',
},
{ name: 'link', columnType: ColumnTypeEnum.LINK, id: '7' },
{ name: 'order', columnType: ColumnTypeEnum.INTEGER, id: '8' },
],
}

const mockFileResult = [
{
fileHandleId: '151525812',
preSignedURL: 'https://mockurl.com/cat1.jpeg',
},
{
fileHandleId: '151468828',
preSignedURL: 'https://mockurl.com/cat2.jpeg',
},
]

const mockBatchFileResult: BatchFileResult = {
requestedFiles: mockFileResult,
}

beforeEach(() => {
jest.clearAllMocks()
jest.spyOn(SynapseClient, 'getFiles').mockResolvedValue(mockBatchFileResult)
mockUseGetQueryResultBundle.mockReturnValue(
getUseQuerySuccessMock(mockQueryResult),
)
})

function renderComponent(props: FeaturedResearchProps) {
return render(<FeaturedResearch {...props} />, {
wrapper: createWrapper(),
})
}

it('fetches and displays research cards', async () => {
mockUseGetQueryResultBundle.mockReturnValue(
getUseQuerySuccessMock(mockQueryResult),
)
renderComponent(mockProps)

await waitFor(() =>
expect(mockUseGetQueryResultBundle).toHaveBeenCalledTimes(1),
)

expect(screen.getByText('Featured Research')).toBeInTheDocument()
expect(screen.getByText('Read more')).toBeInTheDocument()
expect(screen.getByText('Title 1')).toBeInTheDocument()
expect(screen.getByText('Description 1')).toBeInTheDocument()
expect(screen.getByText('tag1_1')).toBeInTheDocument()
expect(screen.getByText('affiliation 1')).toBeInTheDocument()

expect(screen.getByText('Title 2')).toBeInTheDocument()
expect(screen.getByText('tag2_1')).toBeInTheDocument()
expect(screen.getByText('affiliation 2')).toBeInTheDocument()
expect(screen.getByText('September, 2024')).toBeInTheDocument()

await waitFor(() => {
const images = document.querySelectorAll('.MuiCardMedia-root')
expect(images).toHaveLength(2)
})
})
})
Loading

0 comments on commit 8cb66b4

Please sign in to comment.