Skip to content

Commit

Permalink
Support #35538 - Molecular Analysis Run view page bug and test coverage
Browse files Browse the repository at this point in the history
- Added the rest of the mock items.
- Completed the generic molecular analysis test. Added coverage to ensure everything is rendered on the page.
- Fixed an issue with a hook on the view page to improve stability.
  • Loading branch information
brandonandre committed Jan 15, 2025
1 parent aac4766 commit 8ae3c49
Show file tree
Hide file tree
Showing 3 changed files with 210 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,21 @@ export function useMolecularAnalysisRunView({
}: UseMolecularAnalysisRunViewProps) {
const { apiClient, bulkGet } = useApiClient();

const [columns, setColumns] = useState<any[]>([]);
const [loading, setLoading] = useState<boolean>(true);

const [usageType, setUsageType] = useState<string>(
MolecularAnalysisRunItemUsageType.GENERIC_MOLECULAR_ANALYSIS_ITEM
);

const columns = useMolecularAnalysisRunColumns({
type: usageType,
readOnly: true
});

// Run Items
const [sequencingRunItems, setSequencingRunItems] =
useState<SequencingRunItem[]>();

const [loading, setLoading] = useState<boolean>(true);

// Quality control items
const [qualityControls, setQualityControls] = useState<QualityControl[]>([]);

Expand Down Expand Up @@ -132,12 +139,7 @@ export function useMolecularAnalysisRunView({
)?.[0]?.usageType ??
MolecularAnalysisRunItemUsageType.GENERIC_MOLECULAR_ANALYSIS_ITEM;

setColumns(
useMolecularAnalysisRunColumns({
type: usageType,
readOnly: true
})
);
setUsageType(usageType);

if (usageType === MolecularAnalysisRunItemUsageType.SEQ_REACTION) {
let seqReactions = await fetchSeqReactions();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import { PersistedResource } from "kitsu";
import { MolecularAnalysisRun } from "../../../../types/seqdb-api/resources/molecular-analysis/MolecularAnalysisRun";
import { Metadata } from "../../../../types/objectstore-api";
import { Vocabulary } from "../../../../types/collection-api";
import {
MaterialSampleSummary,
Vocabulary
} from "../../../../types/collection-api";
import {
MolecularAnalysisRunItem,
MolecularAnalysisRunItemUsageType
} from "../../../../types/seqdb-api/resources/molecular-analysis/MolecularAnalysisRunItem";
import { GenericMolecularAnalysisItem } from "packages/dina-ui/types/seqdb-api/resources/GenericMolecularAnalysisItem";
import { GenericMolecularAnalysis } from "packages/dina-ui/types/seqdb-api/resources/GenericMolecularAnalysis";
import { StorageUnitUsage } from "packages/dina-ui/types/collection-api/resources/StorageUnitUsage";

export const TEST_MOLECULAR_ANALYSIS_RUN_ID =
"b4c78082-61a8-4784-a116-8601f76c85d7";
Expand All @@ -23,6 +29,100 @@ export const TEST_MOLECULAR_ANALYSIS_RUN: PersistedResource<MolecularAnalysisRun
]
};

export const TEST_MATERIAL_SAMPLE_SUMMARY: PersistedResource<MaterialSampleSummary>[] =
[
{
id: "01932b12-fa1a-74dc-b70c-453f55f42444",
type: "material-sample-summary",
materialSampleName: "Sample 1"
},
{
id: "1182ca20-d3df-47e1-b27f-2a9cd9b6074f",
type: "material-sample-summary",
materialSampleName: "Sample 2"
},
{
id: "239aaf35-9d02-409c-b099-987948cdcd63",
type: "material-sample-summary",
materialSampleName: "Sample 3"
}
];

export const STORAGE_UNIT_USAGE_1: StorageUnitUsage = {
id: "45ed6126-26b8-4ebd-a89f-1bbcf6c69d27",
type: "storage-unit-usage",
cellNumber: 1,
wellColumn: 1,
wellRow: "A",
storageUnit: {
id: "6f5f6d1c-69cc-49b1-b3ae-1675c18ef5b5",
type: "storage-unit",
group: "aafc",
name: "Storage Unit Name",
storageUnitType: {
id: "61909244-5af7-453c-bc57-99504ed4bec4",
type: "storage-unit-type",
group: "aafc",
name: "Storage Unit Type Name",
gridLayoutDefinition: {
fillDirection: "BY_ROW",
numberOfColumns: 5,
numberOfRows: 5
}
}
}
};

export const STORAGE_UNIT_USAGE_2: StorageUnitUsage = {
id: "437005b1-1221-4ab3-bd29-62eac0c6b2f9",
type: "storage-unit-usage",
cellNumber: 2,
wellColumn: 2,
wellRow: "A",
storageUnit: {
id: "6f5f6d1c-69cc-49b1-b3ae-1675c18ef5b5",
type: "storage-unit",
group: "aafc",
name: "Storage Unit Name",
storageUnitType: {
id: "61909244-5af7-453c-bc57-99504ed4bec4",
type: "storage-unit-type",
group: "aafc",
name: "Storage Unit Type Name",
gridLayoutDefinition: {
fillDirection: "BY_ROW",
numberOfColumns: 5,
numberOfRows: 5
}
}
}
};

export const STORAGE_UNIT_USAGE_3: StorageUnitUsage = {
id: "67b82b6f-1c16-49ff-995d-07ad7c760d5d",
type: "storage-unit-usage",
cellNumber: 3,
wellColumn: 3,
wellRow: "A",
storageUnit: {
id: "6f5f6d1c-69cc-49b1-b3ae-1675c18ef5b5",
type: "storage-unit",
group: "aafc",
name: "Storage Unit Name",
storageUnitType: {
id: "61909244-5af7-453c-bc57-99504ed4bec4",
type: "storage-unit-type",
group: "aafc",
name: "Storage Unit Type Name",
gridLayoutDefinition: {
fillDirection: "BY_ROW",
numberOfColumns: 5,
numberOfRows: 5
}
}
}
};

export const TEST_MOLECULAR_ANALYSIS_RUN_ITEMS_GENERIC: PersistedResource<MolecularAnalysisRunItem>[] =
[
{
Expand All @@ -44,7 +144,7 @@ export const TEST_MOLECULAR_ANALYSIS_RUN_ITEMS_GENERIC: PersistedResource<Molecu
MolecularAnalysisRunItemUsageType.GENERIC_MOLECULAR_ANALYSIS_ITEM
},
{
id: "c578c258-761e-4d36-b2d4-e895cbb7d6b0",
id: "834c44bb-7f0a-46d8-8054-6c1b6e37dad1",
type: "molecular-analysis-run-item",
createdBy: "dina-admin",
createdOn: "2024-12-11T20:52:48.43824Z",
Expand All @@ -54,6 +154,52 @@ export const TEST_MOLECULAR_ANALYSIS_RUN_ITEMS_GENERIC: PersistedResource<Molecu
}
];

export const TEST_MOLECULAR_ANALYSIS: PersistedResource<GenericMolecularAnalysis> =
{
id: "d1e4a8b0-c6d5-4e23-9b30-0ae8d8763f2b",
type: "generic-molecular-analysis",
name: "generic molecular analysis",
analysisType: "hrms",
group: "aafc"
};

export const TEST_GENERIC_MOLECULAR_ANALYSIS_ITEMS: PersistedResource<GenericMolecularAnalysisItem>[] =
[
{
id: "99ecc6fc-7378-4641-8914-1b9104e37b95",
type: "generic-molecular-analysis-item",
genericMolecularAnalysis: TEST_MOLECULAR_ANALYSIS,
materialSample: TEST_MATERIAL_SAMPLE_SUMMARY[0],
molecularAnalysisRunItem: TEST_MOLECULAR_ANALYSIS_RUN_ITEMS_GENERIC[0],
storageUnitUsage: {
id: STORAGE_UNIT_USAGE_1.id ?? "",
type: "storage-unit-usage"
}
},
{
id: "923001e4-d0fa-44eb-ac8d-8fc0cad89aa9",
type: "generic-molecular-analysis-item",
genericMolecularAnalysis: TEST_MOLECULAR_ANALYSIS,
materialSample: TEST_MATERIAL_SAMPLE_SUMMARY[1],
molecularAnalysisRunItem: TEST_MOLECULAR_ANALYSIS_RUN_ITEMS_GENERIC[1],
storageUnitUsage: {
id: STORAGE_UNIT_USAGE_2.id ?? "",
type: "storage-unit-usage"
}
},
{
id: "9228588a-8c1e-462a-a4d9-4656319dd63c",
type: "generic-molecular-analysis-item",
genericMolecularAnalysis: TEST_MOLECULAR_ANALYSIS,
materialSample: TEST_MATERIAL_SAMPLE_SUMMARY[2],
molecularAnalysisRunItem: TEST_MOLECULAR_ANALYSIS_RUN_ITEMS_GENERIC[2],
storageUnitUsage: {
id: STORAGE_UNIT_USAGE_3.id ?? "",
type: "storage-unit-usage"
}
}
];

export const TEST_QUALITY_CONTROL_TYPES: PersistedResource<Vocabulary> = {
id: "qualityControlType",
type: "vocabulary",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ import MolecularAnalysisRunViewPage from "../../../../pages/seqdb/molecular-anal
import "@testing-library/jest-dom";
import { waitForElementToBeRemoved } from "@testing-library/react";
import {
STORAGE_UNIT_USAGE_1,
STORAGE_UNIT_USAGE_2,
STORAGE_UNIT_USAGE_3,
TEST_GENERIC_MOLECULAR_ANALYSIS_ITEMS,
TEST_MATERIAL_SAMPLE_SUMMARY,
TEST_METADATA,
TEST_MOLECULAR_ANALYSIS_RUN,
TEST_MOLECULAR_ANALYSIS_RUN_ID,
Expand All @@ -29,6 +34,17 @@ const mockGet = jest.fn(async (path, params) => {
};
}

// Generic Molecular Analysis Items
case "seqdb-api/generic-molecular-analysis-item?include=storageUnitUsage,materialSample,molecularAnalysisRunItem&filter[rsql]=molecularAnalysisRunItem.uuid==" +
TEST_MOLECULAR_ANALYSIS_RUN_ITEMS_GENERIC[0].id:
return { data: [TEST_GENERIC_MOLECULAR_ANALYSIS_ITEMS[0]] };
case "seqdb-api/generic-molecular-analysis-item?include=storageUnitUsage,materialSample,molecularAnalysisRunItem&filter[rsql]=molecularAnalysisRunItem.uuid==" +
TEST_MOLECULAR_ANALYSIS_RUN_ITEMS_GENERIC[1].id:
return { data: [TEST_GENERIC_MOLECULAR_ANALYSIS_ITEMS[1]] };
case "seqdb-api/generic-molecular-analysis-item?include=storageUnitUsage,materialSample,molecularAnalysisRunItem&filter[rsql]=molecularAnalysisRunItem.uuid==" +
TEST_MOLECULAR_ANALYSIS_RUN_ITEMS_GENERIC[2].id:
return { data: [TEST_GENERIC_MOLECULAR_ANALYSIS_ITEMS[2]] };

// Attachments
case "objectstore-api/metadata":
case "seqdb-api/molecular-analysis-run/" +
Expand All @@ -50,6 +66,22 @@ const mockGet = jest.fn(async (path, params) => {
const mockBulkGet = jest.fn(async (paths) => {
return paths.map((path: string) => {
switch (path) {
// Material Sample Summary
case "/material-sample-summary/" + TEST_MATERIAL_SAMPLE_SUMMARY[0].id:
return TEST_MATERIAL_SAMPLE_SUMMARY[0];
case "/material-sample-summary/" + TEST_MATERIAL_SAMPLE_SUMMARY[1].id:
return TEST_MATERIAL_SAMPLE_SUMMARY[1];
case "/material-sample-summary/" + TEST_MATERIAL_SAMPLE_SUMMARY[2].id:
return TEST_MATERIAL_SAMPLE_SUMMARY[2];

// Storage Unit Usages
case "/storage-unit-usage/" + STORAGE_UNIT_USAGE_1.id:
return STORAGE_UNIT_USAGE_1;
case "/storage-unit-usage/" + STORAGE_UNIT_USAGE_2.id:
return STORAGE_UNIT_USAGE_2;
case "/storage-unit-usage/" + STORAGE_UNIT_USAGE_3.id:
return STORAGE_UNIT_USAGE_3;

// Attachments
case "metadata/7f3eccfa-3bc1-412f-9385-bb00e2319ac6?include=derivatives":
case "metadata/7f3eccfa-3bc1-412f-9385-bb00e2319ac6?include=acMetadataCreator,derivatives":
Expand Down Expand Up @@ -87,14 +119,26 @@ describe("Molecular Analysis Run View", () => {
// Ensure the title is displayed of the run.
expect(wrapper.getAllByText(/run name 1/i)[0]).toBeInTheDocument();

// Wait for the inner loading bar to be completed.
// await waitForElementToBeRemoved(wrapper.getByText(/loading\.\.\./i));
// Ensure Molecular Analysis Run Items are displayed:
expect(wrapper.getByRole("link", { name: "Sample 1" })).toBeInTheDocument();
expect(wrapper.getByRole("link", { name: "Sample 2" })).toBeInTheDocument();
expect(wrapper.getByRole("link", { name: "Sample 3" })).toBeInTheDocument();

// Ensure Run Item Names are displayed:
expect(wrapper.getByText("Run Item 1")).toBeInTheDocument();
expect(wrapper.getByText("Run Item 2")).toBeInTheDocument();
expect(wrapper.getByText("Run Item 3")).toBeInTheDocument();

// Ensure Well Coordinates are displayed:
expect(wrapper.getByText("A1")).toBeInTheDocument();
expect(wrapper.getByText("A2")).toBeInTheDocument();
expect(wrapper.getByText("A3")).toBeInTheDocument();

// Ensure the attachment appears.
// expect(
// wrapper.getByRole("heading", {
// name: /sequencing run attachments \(1\)/i
// })
// ).toBeInTheDocument();
expect(
wrapper.getByRole("heading", {
name: /sequencing run attachments \(1\)/i
})
).toBeInTheDocument();
});
});

0 comments on commit 8ae3c49

Please sign in to comment.