Skip to content

Commit

Permalink
fix rendering failure for datasets that have not undergone in-depth c…
Browse files Browse the repository at this point in the history
…uration.
  • Loading branch information
apdavison committed Sep 24, 2024
1 parent f2b38b7 commit 04c7bbb
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 6 deletions.
84 changes: 83 additions & 1 deletion apps/nar-v3/__tests__/components/DatasetCard.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "@testing-library/jest-dom";
import DatasetCard from "../../src/components/DatasetCard";

describe("DatasetCard component", () => {
test("should render without errors", async () => {
test("should render a detailed dataset without errors", async () => {
const dataset = {
"@context": {
"@vocab": "https://schema.hbp.eu/myQuery/",
Expand Down Expand Up @@ -587,4 +587,86 @@ describe("DatasetCard component", () => {

expect(screen.getByText(/An example patch clamp dataset/i)).toBeInTheDocument();
});

test("should render a basic dataset without errors", async () => {
const dataset = {
"@context": {
"@vocab": "https://schema.hbp.eu/myQuery/",
},
fullName: "",
description: "",
id: "https://kg.ebrains.eu/api/instances/ff19f5db-e829-4b85-92eb-fc56991541f1",
author: [],
shortName: "An example patch clamp dataset",
custodian: [],
isVersionOf: {
author: [
{
givenName: "Stanley",
shortName: null,
familyName: "Laurel",
fullName: null,
type: ["https://openminds.ebrains.eu/core/Person"],
id: "https://kg.ebrains.eu/api/instances/a0993482-69dd-468b-a1d3-ff9589b485ae",
},
{
givenName: "Oliver",
shortName: null,
familyName: "Hardy",
fullName: null,
type: ["https://openminds.ebrains.eu/core/Person"],
id: "https://kg.ebrains.eu/api/instances/9fe3ffd5-bd56-4aee-979a-6ed15f65d235",
},
],
shortName: "An example patch clamp dataset",
custodian: [
{
givenName: "Stanley",
shortName: null,
familyName: "Laurel",
fullName: null,
type: ["https://openminds.ebrains.eu/core/Person"],
id: "https://kg.ebrains.eu/api/instances/a0993482-69dd-468b-a1d3-ff9589b485ae",
},
],
fullName: "An example patch clamp dataset, this is the long version of the name",
description:
"In this study we analyzed the intrinsic electrophysiological properties of foo in a mouse model of ...",
},
releaseDate: "2024-04-01",
license: "CC BY 4.0",
ethicsAssessment: "EU compliant, non sensitive",
versionIdentifier: "v1",
studiedSpecimen: [
{
species: {
species: null,
name: "Mus musculus",
},
lookupLabel: "sub-42",
studiedState: [
{
age: {
maxValue: 10,
minValue: 9,
maxValueUnit: "month",
value: null,
unit: null,
minValueUnit: "month",
},
ageCategory: "adult",
lookupLabel: "sub-42-state01",
pathology: [],
slicePreparation: []
},
],
biologicalSex: "male",
},
],
};

render(<DatasetCard dataset={dataset} />);

expect(screen.getByText(/An example patch clamp dataset/i)).toBeInTheDocument();
});
});
5 changes: 4 additions & 1 deletion apps/nar-v3/src/components/DataFileCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ import KeyValueTable from "./KeyValueTable";
import styles from "../styles";

function DataFileCard(props) {
const fileObj = props.fileObjects[props.index];
let fileObj = null;
if (props.fileObjects) {
fileObj = props.fileObjects[props.index];
}

if (fileObj) {
const data = {
Expand Down
11 changes: 8 additions & 3 deletions apps/nar-v3/src/components/DatasetCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,14 @@ function DatasetCard(props) {
};

const getDataFiles = (subjectIndex, sliceIndex, stimulationIndex) => {
const stimulationActivity = getStimulationActivities(subjectIndex, sliceIndex)[stimulationIndex];
if (stimulationActivity) {
return stimulationActivity.output;
const stimulationActivities = getStimulationActivities(subjectIndex, sliceIndex);
if (stimulationActivities) {
const stimulationActivity = stimulationActivities[stimulationIndex];
if (stimulationActivity) {
return stimulationActivity.output;
} else {
return null;
}
} else {
return null;
}
Expand Down
5 changes: 4 additions & 1 deletion apps/nar-v3/src/components/RecordingCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ import { formatQuant } from "../utility";

function RecordingCard(props) {
const recording = props.recording;
const stimulation = props.stimulations[props.index];
let stimulation = null;
if (props.stimulations) {
stimulation = props.stimulations[props.index];
}

if (recording) {
const recordingData = {
Expand Down

0 comments on commit 04c7bbb

Please sign in to comment.