diff --git a/CITATION.cff b/CITATION.cff index 810ca7a94..249fe0038 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -75,5 +75,5 @@ keywords: - Software Impact - Software Reuse license: Apache-2.0 -version: v1.27.0 -date-released: '2023-09-08' +version: v2.0.0 +date-released: '2023-09-29' diff --git a/database/118-backend-logs-views.sql b/database/118-backend-logs-views.sql new file mode 100644 index 000000000..8f9dfd24b --- /dev/null +++ b/database/118-backend-logs-views.sql @@ -0,0 +1,51 @@ +-- SPDX-FileCopyrightText: 2023 Dusan Mijatovic (Netherlands eScience Center) +-- SPDX-FileCopyrightText: 2023 Ewan Cahen (Netherlands eScience Center) +-- SPDX-FileCopyrightText: 2023 Netherlands eScience Center +-- +-- SPDX-License-Identifier: Apache-2.0 + +CREATE FUNCTION slug_from_log_reference( + table_name VARCHAR, + reference_id UUID +) +RETURNS TABLE ( + slug VARCHAR +) +LANGUAGE sql STABLE AS +$$ +SELECT CASE + WHEN table_name = 'repository_url' THEN ( + SELECT + CONCAT('/software/',slug,'/edit/information') as slug + FROM + software WHERE id = reference_id + ) + WHEN table_name = 'package_manager' THEN ( + SELECT + CONCAT('/software/',slug,'/edit/package-managers') as slug + FROM + software + WHERE id = (SELECT software FROM package_manager WHERE id = reference_id)) + END +$$; + +CREATE FUNCTION backend_log_view() RETURNS TABLE ( + id UUID, + service_name VARCHAR, + table_name VARCHAR, + reference_id UUID, + message VARCHAR, + stack_trace VARCHAR, + other_data JSONB, + created_at TIMESTAMPTZ, + updated_at TIMESTAMPTZ, + slug VARCHAR +) +LANGUAGE sql STABLE AS +$$ +SELECT + *, + slug_from_log_reference(backend_log.table_name, backend_log.reference_id) +FROM + backend_log +$$; diff --git a/e2e/helpers/utils.ts b/e2e/helpers/utils.ts index d0e4541e3..19c674ac1 100755 --- a/e2e/helpers/utils.ts +++ b/e2e/helpers/utils.ts @@ -103,104 +103,6 @@ export async function openEditSection(page:Page,name:string) { } -// TODO! REMOVE THIS FUNCTION LATER -// export async function addOrganisation(page, organisation: Organisation, apiUrl) { - -// // const findOrganisation = page.getByLabel('Find or add organisation') -// const findOrganisation = page.getByRole('combobox', {name: 'Find or add organisation'}) - -// // check if no organisation message is present -// const alert = await page.getByRole('alert') -// .filter({ -// hasText: /No participating organisations/ -// }).count() > 0 - -// // set breakpoint -// // console.log('alert...', alert) -// // await page.pause() - -// if (alert === false) { -// //check if organisation already present -// const organisations = page.getByTestId('organisation-list-item') -// const [count] = await Promise.all([ -// organisations.count(), -// page.waitForLoadState('networkidle') -// ]) - -// if (count > 0) { -// // check if organisation existis -// const found = await organisations -// .filter({hasText: RegExp(organisation.name)}) -// .count() -// // console.log('found...', found) -// // if already exists we return false -// if (found > 0) return false -// } -// } - -// // if not exists we search -// await Promise.all([ -// page.waitForResponse(/api.ror.org\/organizations/), -// page.waitForLoadState('networkidle'), -// findOrganisation.fill(organisation.name) -// ]) - -// const options = page.getByTestId('find-organisation-option') -// const option = await options -// .filter({ -// hasText:RegExp(organisation.name,'i') -// }) -// .first() - -// // get source information -// const source = await option.getByTestId('organisation-list-item').getAttribute('data-source') - -// if (source === 'RSD') { -// await Promise.all([ -// page.waitForResponse(RegExp(apiUrl)), -// option.click() -// ]) -// // if rsd we just add it to list (no modal popup) -// return true -// } -// if (source === 'ROR') { -// // for ROR we can upload logo -// // in the modal/dialog so -// // we wait on modal to appear -// await Promise.all([ -// page.waitForSelector('[role="dialog"]'), -// option.click() -// ]) - -// // console.log('logo...', organisation.logo) -// // upload logo if logo provided -// if (organisation.logo) { -// await uploadFile( -// page, '#upload-avatar-image', -// organisation.logo, -// 'img' -// ) -// } -// // save new organisation -// const saveBtn = page.getByRole('button', { -// name: 'Save' -// }) -// await Promise.all([ -// page.waitForResponse(/organisation/), -// page.waitForResponse(RegExp(apiUrl)), -// saveBtn.click() -// ]) -// } - -// // validate item is added to list -// const lastItem = await page.getByTestId('organisation-list-item').last() -// const lastText = await lastItem.getByTestId('organisation-list-item-text').textContent() -// // console.log('lastText...', lastText) -// expect(lastText).toContain(organisation.name) - -// return true -// } - export async function addRelatedSoftware(page: Page, waitForResponse:string) { const findSoftware = page .getByTestId('find-related-software') diff --git a/e2e/tests/project.spec.ts b/e2e/tests/project.spec.ts index dfa0f1a2e..7cc068b36 100755 --- a/e2e/tests/project.spec.ts +++ b/e2e/tests/project.spec.ts @@ -164,7 +164,7 @@ test.describe.serial('Project', async () => { expect(count).toBeGreaterThanOrEqual(organisations.length) }) - test('Related items', async ({page}, {project: {name}}) => { + test('Related projects', async ({page}, {project: {name}}) => { const project = mockProject[name] // directly open edit software page @@ -173,9 +173,21 @@ test.describe.serial('Project', async () => { // await page.pause() // navigate to organisations section - await openEditSection(page, 'Related topics') + await openEditSection(page, 'Related projects') await addRelatedProject(page, 'project_for_project') + }) + + test('Related software', async ({page}, {project: {name}}) => { + const project = mockProject[name] + + // directly open edit software page + const url = `/projects/${project.slug}` + await openEditPage(page, url, project.title) + + // await page.pause() + // navigate to organisations section + await openEditSection(page, 'Related software') // add related software only if not added const relatedSoftware = page.getByTestId('related-software-item') diff --git a/e2e/tests/software.spec.ts b/e2e/tests/software.spec.ts index a00567d8b..529cce26c 100755 --- a/e2e/tests/software.spec.ts +++ b/e2e/tests/software.spec.ts @@ -163,17 +163,26 @@ test.describe.serial('Software', async()=> { // We test related items as last because we // need some items to be created and published - test('Related items', async ({page}, {project}) => { + test('Related software', async ({page}, {project}) => { const software = mockSoftware[project.name] - // directly open edit software page const url = `/software/${software.slug}` await openEditPage(page, url, software.title) - // navigate to related topics section - await openEditSection(page, 'Related topics') + await openEditSection(page, 'Related software') // add some related software randomly await addRelatedSoftware(page, 'software_for_software') + }) + + // We test related items as last because we + // need some items to be created and published + test('Related projects', async ({page}, {project}) => { + const software = mockSoftware[project.name] + // directly open edit software page + const url = `/software/${software.slug}` + await openEditPage(page, url, software.title) + // navigate to related topics section + await openEditSection(page, 'Related projects') // add some related projects randomly await addRelatedProject(page, 'software_for_project') }) diff --git a/frontend/README.md b/frontend/README.md index 932eee8b3..73260f24f 100644 --- a/frontend/README.md +++ b/frontend/README.md @@ -187,7 +187,7 @@ yarn add @mui/material @mui/icons-material @emotion/react @emotion/server @emoti ```bash # react testing lib -yarn add -D @testing-library/react @testing-library/jest-dom jest jest-environment-jsdom @types/jest +yarn add -D @testing-library/react@latest @testing-library/jest-dom@latest jest@latest jest-environment-jsdom@latest @types/jest@latest ``` ### Others diff --git a/frontend/components/AppFooter/index.tsx b/frontend/components/AppFooter/index.tsx index d07eb1b8b..824c42eca 100644 --- a/frontend/components/AppFooter/index.tsx +++ b/frontend/components/AppFooter/index.tsx @@ -15,8 +15,7 @@ import OrganisationLogo from './OrganisationLogo' import ContactEmail from './ContactEmail' export default function AppFooter () { - const {pages,links,embedMode,host} = useRsdSettings() - if (embedMode === true) return null + const {pages,links,host} = useRsdSettings() return (