Skip to content

Commit

Permalink
Merge pull request #912 from research-software-directory/807-organisa…
Browse files Browse the repository at this point in the history
…tion-card

807 organisation card
  • Loading branch information
dmijatovic authored Jun 16, 2023
2 parents 9d10a97 + 1be8dca commit b20cffb
Show file tree
Hide file tree
Showing 20 changed files with 541 additions and 194 deletions.
4 changes: 2 additions & 2 deletions database/100-create-api-views.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
-- SPDX-FileCopyrightText: 2022 - 2023 Ewan Cahen (Netherlands eScience Center) <[email protected]>
-- SPDX-FileCopyrightText: 2022 - 2023 Helmholtz Centre Potsdam - GFZ German Research Centre for Geosciences
-- SPDX-FileCopyrightText: 2022 - 2023 Netherlands eScience Center
-- SPDX-FileCopyrightText: 2023 Christian Meeßen (GFZ) <[email protected]>
-- SPDX-FileCopyrightText: 2023 Helmholtz Centre Potsdam - GFZ German Research Centre for Geosciences
-- SPDX-FileCopyrightText: 2023 Dusan Mijatovic (Netherlands eScience Center)
--
-- SPDX-License-Identifier: Apache-2.0
Expand Down Expand Up @@ -434,6 +432,7 @@ CREATE FUNCTION organisations_overview(public BOOLEAN DEFAULT TRUE) RETURNS TABL
primary_maintainer UUID,
name VARCHAR,
short_description VARCHAR,
country VARCHAR,
ror_id VARCHAR,
website VARCHAR,
is_tenant BOOLEAN,
Expand All @@ -454,6 +453,7 @@ SELECT
organisation.primary_maintainer,
organisation.name,
organisation.short_description,
organisation.country,
organisation.ror_id,
organisation.website,
organisation.is_tenant,
Expand Down
10 changes: 4 additions & 6 deletions e2e/tests/project.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// SPDX-FileCopyrightText: 2022 - 2023 Dusan Mijatovic (dv4all)
// SPDX-FileCopyrightText: 2022 - 2023 Dusan Mijatovic (dv4all) (dv4all)
// SPDX-FileCopyrightText: 2022 - 2023 dv4all
// SPDX-FileCopyrightText: 2023 Dusan Mijatovic (Netherlands eScience Center)
// SPDX-FileCopyrightText: 2023 Netherlands eScience Center
//
// SPDX-License-Identifier: Apache-2.0

Expand Down Expand Up @@ -72,12 +74,8 @@ test.describe.serial('Project', async () => {
// publish project
await page.getByLabel('Published').check()

// take reference to view page button
const viewPage = page.getByRole('button', {
name: 'view page'
})
// just click on view page to close
await viewPage.click()
// open view page
await page.getByTestId('view-page-button').click()
})

test('Edit team members', async ({page}, {project}) => {
Expand Down
8 changes: 3 additions & 5 deletions e2e/tests/software.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// SPDX-FileCopyrightText: 2022 - 2023 Dusan Mijatovic (dv4all)
// SPDX-FileCopyrightText: 2022 - 2023 Dusan Mijatovic (dv4all) (dv4all)
// SPDX-FileCopyrightText: 2022 - 2023 dv4all
// SPDX-FileCopyrightText: 2023 Dusan Mijatovic (Netherlands eScience Center)
// SPDX-FileCopyrightText: 2023 Netherlands eScience Center
//
// SPDX-License-Identifier: Apache-2.0

Expand Down Expand Up @@ -70,12 +72,8 @@ test.describe.serial('Software', async()=> {
// publish the software
await page.getByLabel('Published').check()

// find view page button
const viewPage = page.getByRole('button', {
name: 'view page'
})
// open view page
await viewPage.click()
await page.getByTestId('view-page-button').click()
})

test('Edit contributors', async ({page}, {project}) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@

import {render, screen} from '@testing-library/react'

import OrganisationsOverviewPage, {getServerSideProps} from '../pages/organisations/index'
import {mockResolvedValue} from '../utils/jest/mockFetch'
import organisationsOverview from './__mocks__/organisationsOverview.json'
import {WrappedComponentWithProps} from '../utils/jest/WrappedComponents'

import OrganisationIndexPage,{getServerSideProps} from '../pages/organisations/index'
import {RsdUser} from '../auth'
import {WithAppContext} from '~/utils/jest/WithAppContext'
import organisationsOverview from './__mocks__/organisationsOverview.json'

const mockProps = {
count: 408,
page: 1,
rows: 12,
organisations: organisationsOverview as any
}

describe('pages/organisations/index.tsx', () => {
beforeEach(() => {
Expand Down Expand Up @@ -43,49 +48,40 @@ describe('pages/organisations/index.tsx', () => {
})
})

it('renders heading with the title Organisations', async() => {
render(WrappedComponentWithProps(
OrganisationIndexPage, {
props: {
count:200,
page:0,
rows:12,
organisations:organisationsOverview,
},
// user session
session:{
status: 'missing',
token: 'test-token',
user: {name:'Test user'} as RsdUser
}
}
))
it('renders heading with the title Organisations', async () => {
render(
<WithAppContext>
<OrganisationsOverviewPage {...mockProps} />
</WithAppContext>
)

const heading = await screen.findByRole('heading',{
name: 'Organisations'
})
expect(heading).toBeInTheDocument()
})

it('renders organisation name as card header h2', async() => {
render(WrappedComponentWithProps(
OrganisationIndexPage, {
props:{
count:3,
page:0,
rows:12,
organisations: organisationsOverview,
},
// user session
session:{
status: 'missing',
token: 'test-token',
user: {name:'Test user'} as RsdUser
}
}
))
it('renders (24) grid cards', async () => {
mockProps.rows = 24
render(
<WithAppContext>
<OrganisationsOverviewPage {...mockProps} />
</WithAppContext>
)
const cards = screen.getAllByTestId('organisation-card-link')
expect(cards.length).toEqual(mockProps.organisations.length)
})

it('renders first organisation name', async() => {
render(
<WithAppContext>
<OrganisationsOverviewPage {...mockProps} />
</WithAppContext>
)

const name = organisationsOverview[0].name
const card = await screen.findByText(name)
expect(card).toBeInTheDocument()
})

})
Loading

0 comments on commit b20cffb

Please sign in to comment.