Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,12 @@ describe("HCATableProjectsComponent", () => {
const INDEX_TABLE_ROW_NULL_VALUES = 5;

// Column titles
const COLUMN_TITLE_DONORCOUNT = "Donor Count";
const COLUMN_TITLE_TOTALCELLS = "Cell Count Estimate";
const COLUMN_TITLE_WORKFLOW = "Analysis Protocol";

// Column names
const COLUMN_NAME_DONORCOUNT = "donorCount";
const COLUMN_NAME_TOTALCELLS = "totalCells";
const COLUMN_NAME_WORKFLOW = "workflow";

Expand Down Expand Up @@ -457,6 +459,36 @@ describe("HCATableProjectsComponent", () => {
expect(findColumnCellComponent(INDEX_TABLE_ROW_SINGLE_VALUES, COLUMN_NAME_WORKFLOW, COMPONENT_NAME_HCA_CONTENT_UNSPECIFIED_DASH)).toBe(null);
});

/**
* Confirm donorCount column labeled as "Donor Count" is displayed.
*/
it(`should display column "Donor Count"`, () => {

testStore.pipe
.and.returnValues(
of(PROJECTS_TABLE_MODEL.data),
of(PROJECTS_TABLE_MODEL.data),
of(PROJECTS_TABLE_MODEL.loading),
of(PROJECTS_TABLE_MODEL.pagination),
of(PROJECTS_TABLE_MODEL.termCountsByFacetName),
of(DEFAULT_FILE_SUMMARY),
of(new Map()), // project matrix URLs
of({
status: ProjectTSVUrlRequestStatus.NOT_STARTED // selectProjectTSVUrlsByProjectId inside ProjectTSVDownloadComponent
})
);

component.selectedProjectIds = [];

// Trigger change detection so template updates accordingly
fixture.detectChanges();

const columnHeaderDE = findHeader(COLUMN_NAME_DONORCOUNT);

// Confirm column title is displayed
expect(columnHeaderDE.nativeElement.innerText).toEqual(COLUMN_TITLE_DONORCOUNT);
});

/**
* Confirm totalCells column labeled as "Cell Count Estimate" is displayed.
*/
Expand Down
86 changes: 47 additions & 39 deletions spa/src/app/files/hca-table-projects/project-row-mapper.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,23 +99,24 @@ export const PROJECT_ROW_SINGLE_VALUES =
"cellLines": [],
"donorOrganisms": [
{
"id": [
"420508"
"biologicalSex": [
"male"
],
"disease": [
"x"
],
"donorCount": 15,
"genusSpecies": [
"Mus musculus"
],
"id": [
"420508"
],
"organismAge": [
"56"
],
"organismAgeUnit": [
"day"
],
"biologicalSex": [
"male"
],
"disease": [
"x"
]
}
],
Expand Down Expand Up @@ -283,24 +284,28 @@ export const PROJECT_ROW_MULTIPLE_VALUES_SINGLE_OBJECT =
"cellLines": [],
"donorOrganisms": [
{
"biologicalSex": [
"male",
"female"
],
"disease": ["H syndrome", "normal"],
"donorCount": 12,
"genusSpecies": [
"Mus musculus",
"Homo sapiens"
],
"id": [
"420508",
"123456"
],
"genusSpecies": [
"Mus musculus"
],
"organismAge": [
"56"
"56",
"44"
],
"organismAgeUnit": [
"day",
"week"
],
"biologicalSex": [
"male"
],
"disease": null
]
}
],
"organoids": [],
Expand Down Expand Up @@ -524,46 +529,47 @@ export const PROJECT_ROW_VALUES_ACROSS_MULTIPLE_OBJECTS =
"cellLines": [],
"donorOrganisms": [
{
"id": [
"420508"
"biologicalSex": [
"male"
],
"disease": ["normal"],
"donorCount": 8,
"genusSpecies": [
"Mus musculus"
],
"id": [
"420508"
],
"organismAge": [
"56"
],
"organismAgeUnit": [
"day",
"week"
],
"biologicalSex": [
"male"
],
"disease": null
"day"
]
},
{
"id": [
"biologicalSex": [
"x",
"y"
],
"genusSpecies": [
"disease": [
"x",
"y"
],
"organismAge": [
"donorCount": 3,
"genusSpecies": [
"x",
"y"
],
"organismAgeUnit": [
"id": [
"x",
"y"
],
"biologicalSex": [
"organismAge": [
"x",
"y"
],
"disease": [
"organismAgeUnit": [
"x",
"y"
]
Expand Down Expand Up @@ -679,12 +685,13 @@ export const PROJECT_ROW_EMPTY_ARRAY_VALUES =
"cellLines": [],
"donorOrganisms": [
{
"id": [],
"biologicalSex": [],
"disease": [],
"genusSpecies": [],
"donorCount": 1,
"id": [],
"organismAge": [],
"organismAgeUnit": [],
"biologicalSex": [],
"disease": []
"organismAgeUnit": []
}
],
"organoids": [],
Expand Down Expand Up @@ -757,12 +764,13 @@ export const PROJECT_ROW_NULL_VALUES =
],
"donorOrganisms": [
{
"id": null,
"biologicalSex": null,
"disease": null,
"donorCount": null,
"genusSpecies": null,
"id": null,
"organismAge": null,
"organismAgeUnit": null,
"biologicalSex": null,
"disease": null
}
],
"organoids": null,
Expand Down
98 changes: 50 additions & 48 deletions spa/src/app/files/hca-table-projects/project-row-mapper.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,49 +67,6 @@ describe("ProjectRowMapper:", () => {
})
});

/**
* A null project summary should map donor count to "Unspecified".
*/
it(`should map donor count of null project summary to "Unspecified"`, (done: DoneFn) => {

dataSource = new EntitiesDataSource<ProjectRowMapper>(of([PROJECT_ROW_NULL_VALUES]), ProjectRowMapper);
dataSource.connect().subscribe((rows) => {

const mappedProject = rows[0];
expect(mappedProject.donorCount).toEqual(0);
done();
})
});

/**
* Donor count, when specified, should be mapped
*/
it("should map donor count", (done: DoneFn) => {

const projectToMap = PROJECT_ROW_SINGLE_VALUES;
dataSource = new EntitiesDataSource<ProjectRowMapper>(of([projectToMap]), ProjectRowMapper);
dataSource.connect().subscribe((rows) => {

const mappedProject = rows[0];
expect(mappedProject.donorCount).toEqual(projectToMap.donorOrganisms[0].id.length);
done();
})
});

/**
* A null donor count should be mapped to "Unspecified"
*/
it(`should map null donor count to "Unspecified"`, (done: DoneFn) => {

dataSource = new EntitiesDataSource<ProjectRowMapper>(of([PROJECT_ROW_NULL_VALUES]), ProjectRowMapper);
dataSource.connect().subscribe((rows) => {

const mappedProject = rows[0];
expect(mappedProject.donorCount).toEqual(0);
done();
})
});

/**
* Entry ID should be mapped
*/
Expand Down Expand Up @@ -230,11 +187,11 @@ describe("ProjectRowMapper:", () => {
});

/**
* An age unit value that is an empty array should be mapped to "Unspecified"
* A null project short name should be mapped to "Unspecified"
*/
it(`should map an empty age unit array to "Unspecified"`, (done: DoneFn) => {
it(`should map null project short name to "Unspecified"`, (done: DoneFn) => {

dataSource = new EntitiesDataSource<ProjectRowMapper>(of([PROJECT_ROW_EMPTY_ARRAY_VALUES]), ProjectRowMapper);
dataSource = new EntitiesDataSource<ProjectRowMapper>(of([PROJECT_ROW_NULL_VALUES]), ProjectRowMapper);
dataSource.connect().subscribe((rows) => {

const mappedProject = rows[0];
Expand All @@ -244,11 +201,56 @@ describe("ProjectRowMapper:", () => {
});

/**
* A null project short name should be mapped to "Unspecified"
* Donor count, when specified, should be included in mapping.
*/
it(`should map null project short name to "Unspecified"`, (done: DoneFn) => {
it("should map donor count", (done: DoneFn) => {

const projectToMap = PROJECT_ROW_SINGLE_VALUES;
dataSource = new EntitiesDataSource<ProjectRowMapper>(of([projectToMap]), ProjectRowMapper);
dataSource.connect().subscribe((rows) => {

const mappedProject = rows[0];
expect(mappedProject.donorCount).toEqual(projectToMap.donorOrganisms[0].donorCount);
done();
})
});

/**
* Donor count across multiple projects should be rolled up and mapped
*/
it("should roll up and map donor count values across multiple projects", (done: DoneFn) => {

const projectToMap = PROJECT_ROW_VALUES_ACROSS_MULTIPLE_OBJECTS;
dataSource = new EntitiesDataSource<ProjectRowMapper>(of([projectToMap]), ProjectRowMapper);
dataSource.connect().subscribe((rows) => {

const mappedProject = rows[0];
const expectedValue = mapMultipleValues(projectToMap.donorOrganisms, "donorCount");
expect(mappedProject.donorCount).toEqual(expectedValue);
done();
})
});

/**
* A null donor count should be mapped to "Unspecified"
*/
it(`should map null donor count to "Unspecified"`, (done: DoneFn) => {

dataSource = new EntitiesDataSource<ProjectRowMapper>(of([PROJECT_ROW_NULL_VALUES]), ProjectRowMapper);
dataSource.connect().subscribe((rows) => {

const mappedProject = rows[0];
expect(mappedProject.donorCount).toEqual("Unspecified");
done();
})
});

/**
* An age unit value that is an empty array should be mapped to "Unspecified"
*/
it(`should map an empty age unit array to "Unspecified"`, (done: DoneFn) => {

dataSource = new EntitiesDataSource<ProjectRowMapper>(of([PROJECT_ROW_EMPTY_ARRAY_VALUES]), ProjectRowMapper);
dataSource.connect().subscribe((rows) => {

const mappedProject = rows[0];
Expand Down
1 change: 0 additions & 1 deletion spa/src/app/files/hca-table-projects/project-row-mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export class ProjectRowMapper extends FileTypeSummariesRowMapper {
public mapRow(): EntityRow {

return Object.assign({}, super.mapRow(), {
donorCount: (((this.row.donorOrganisms || [])[0] || {}).id || []).length, // Donor count is the number of IDs in the id field of donor organisms
entryId: this.row.entryId,
projectShortname: getUnspecifiedIfNullValue(this.projects.projectShortname)
});
Expand Down
1 change: 0 additions & 1 deletion spa/src/app/files/hca-table-projects/project-row.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { EntityRow } from "../table/entity-row.model";
import { FileTypeSummariesRow } from "../table/file-type-summaries-row.model";

export interface ProjectRow extends EntityRow, FileTypeSummariesRow {
donorCount: number;
entryId: string;
projectShortname: string;
}
Loading