Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DT-530: Add conditional rendering around apply for access #2718

Merged
merged 6 commits into from
Nov 12, 2024
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
138 changes: 138 additions & 0 deletions cypress/component/Dataset/dataset.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
{
"datasetId": 1975,
"name": "ExteranlAccessTestJL1",
"datasetName": "ExteranlAccessTestJL1",
"createDate": "Nov 2, 2023",
"createUserId": 3396,
"updateDate": 1730999135936,
"updateUserId": 3351,
"alias": 682,
"datasetIdentifier": "DUOS-000682",
"dataUse": {
"generalUse": true,
"hmbResearch": false,
"diseaseRestrictions": [],
"populationOriginsAncestry": false,
"ethicsApprovalRequired": false,
"collaboratorRequired": true,
"geneticStudiesOnly": true,
"publicationResults": true,
"controls": false,
"population": false
},
"deletable": false,
"properties": [
{
"propertyId": 9311,
"datasetId": 1975,
"propertyName": "Data Location",
"propertyValue": "Not Determined",
"schemaProperty": "dataLocation",
"propertyType": "String"
},
{
"propertyId": 9312,
"datasetId": 1975,
"propertyName": "# of participants",
"propertyValue": 1,
"schemaProperty": "numberOfParticipants",
"propertyType": "Number"
},
{
"propertyId": 9313,
"datasetId": 1975,
"propertyName": "File Types",
"propertyValue": [
{}
],
"schemaProperty": "fileTypes",
"propertyType": "Json"
}
],
"createUser": {
"userId": 3396,
"email": "jlawson@broadinstitute.org",
"displayName": "Jonathan Lawson (Admin \u0026 DAC Member)",
"createDate": 1526056488000,
"emailPreference": false,
"institutionId": 150,
"eraCommonsId": "a"
},
"study": {
"studyId": 5854,
"name": "ExternalAccessTestJL1",
"description": "ExternalAccessTestJL1",
"publicVisibility": true,
"piName": "Dr. Make",
"dataTypes": [
"Hybrid Capture"
],
"datasetIds": [
1975,
1976,
1977
],
"properties": [
{
"studyPropertyId": 5860,
"studyId": 5854,
"key": "collaboratingSites",
"type": "Json",
"value": []
},
{
"studyPropertyId": 5855,
"studyId": 5854,
"key": "species",
"type": "String",
"value": "ExternalAccessTestJL1"
},
{
"studyPropertyId": 5857,
"studyId": 5854,
"key": "dataCustodianEmail",
"type": "Json",
"value": [
"geraldg@spurs.bb"
]
},
{
"studyPropertyId": 5858,
"studyId": 5854,
"key": "nihAnvilUse",
"type": "String",
"value": "I am not NHGRI funded and do not plan to store data in AnVIL"
},
{
"studyPropertyId": 5854,
"studyId": 5854,
"key": "phenotypeIndication",
"type": "String",
"value": "ExternalAccessTestJL1"
},
{
"studyPropertyId": 5859,
"studyId": 5854,
"key": "nihICsSupportingStudy",
"type": "Json",
"value": []
},
{
"studyPropertyId": 5853,
"studyId": 5854,
"key": "studyType",
"type": "String",
"value": "Observational"
},
{
"studyPropertyId": 5861,
"studyId": 5854,
"key": "alternativeDataSharingPlanReasons",
"type": "Json",
"value": []
}
],
"createDate": 1698897809861,
"createUserId": 3396
}
}
167 changes: 167 additions & 0 deletions cypress/component/Dataset/datasetStatistics.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
/* eslint-disable no-undef,no-console */

import React from 'react';
import {mount} from 'cypress/react';
import DatasetStatistics from '../../../src/pages/DatasetStatistics';
import dataset from './dataset.json';
import {DataSet} from '../../../src/libs/ajax/DataSet';
import {DatasetMetrics} from '../../../src/libs/ajax/DatasetMetrics';

const externalProp = {
'propertyId': 9314,
'datasetId': 1975,
'propertyName': 'Access Management',
'propertyValue': 'external',
'schemaProperty': 'accessManagement',
'propertyType': 'String'
};

const openProp = {
'propertyId': 9314,
'datasetId': 1975,
'propertyName': 'Access Management',
'propertyValue': 'open',
'schemaProperty': 'accessManagement',
'propertyType': 'String'
};

const controlledProp = {
'propertyId': 9314,
'datasetId': 1975,
'propertyName': 'Access Management',
'propertyValue': 'controlled',
'schemaProperty': 'accessManagement',
'propertyType': 'String'
};

const location = {
'propertyId': 12657,
'datasetId': 1975,
'propertyName': 'URL',
'propertyValue': 'https://duos.org',
'schemaProperty': 'url',
'propertyType': 'String'
};

describe('Dataset Statistics Tests', () => {

it('Displays Controlled Access Dataset Apply Button', () => {
const controlled = Object.assign(dataset, {properties: [controlledProp]});
cy.viewport(600, 800);
cy.stub(DataSet, 'getDatasetByDatasetIdentifier').returns(Promise.resolve(controlled));
cy.stub(DataSet, 'getDataSetsByDatasetId').returns(Promise.resolve(controlled));
cy.stub(DatasetMetrics, 'getDatasetStats').returns(Promise.resolve({}));

const props = {
match: {
params: {
datasetIdentifier: controlled.datasetIdentifier
}
},
history: {
push() {
}
}
};
mount(<DatasetStatistics {...props}/>);
cy.contains(controlled.datasetIdentifier).should('exist');
cy.contains('Apply for Access').should('exist');
});

it('Displays External Access Language With Location', () => {
const external = Object.assign(dataset, {properties: [externalProp, location]});
cy.viewport(600, 800);
cy.stub(DataSet, 'getDatasetByDatasetIdentifier').returns(Promise.resolve(external));
cy.stub(DataSet, 'getDataSetsByDatasetId').returns(Promise.resolve(external));
cy.stub(DatasetMetrics, 'getDatasetStats').returns(Promise.resolve({}));

const props = {
match: {
params: {
datasetIdentifier: external.datasetIdentifier
}
},
history: {
push() {
}
}
};
mount(<DatasetStatistics {...props}/>);
cy.contains(external.datasetIdentifier).should('exist');
cy.contains('This dataset is externally managed').should('exist');
cy.contains('Requests cannot be made via DUOS, but must be made directly').should('exist');
});

it('Displays External Access Language Without Location', () => {
const external = Object.assign(dataset, {properties: [externalProp]});
cy.viewport(600, 800);
cy.stub(DataSet, 'getDatasetByDatasetIdentifier').returns(Promise.resolve(external));
cy.stub(DataSet, 'getDataSetsByDatasetId').returns(Promise.resolve(external));
cy.stub(DatasetMetrics, 'getDatasetStats').returns(Promise.resolve({}));

const props = {
match: {
params: {
datasetIdentifier: external.datasetIdentifier
}
},
history: {
push() {
}
}
};
mount(<DatasetStatistics {...props}/>);
cy.contains(external.datasetIdentifier).should('exist');
cy.contains('This dataset is externally managed').should('exist');
cy.contains('Requests cannot be made via DUOS, but must be made directly').should('not.exist');
});

it('Displays Open Access Language With Location', () => {
const open = Object.assign(dataset, {properties: [openProp, location]});
cy.viewport(600, 800);
cy.stub(DataSet, 'getDatasetByDatasetIdentifier').returns(Promise.resolve(open));
cy.stub(DataSet, 'getDataSetsByDatasetId').returns(Promise.resolve(open));
cy.stub(DatasetMetrics, 'getDatasetStats').returns(Promise.resolve({}));

const props = {
match: {
params: {
datasetIdentifier: open.datasetIdentifier
}
},
history: {
push() {
}
}
};
mount(<DatasetStatistics {...props}/>);
cy.contains(open.datasetIdentifier).should('exist');
cy.contains('This dataset is open access, does not require an access request').should('exist');
cy.contains('and can be accessed directly').should('exist');
});

it('Displays Open Access Language Without Location', () => {
const open = Object.assign(dataset, {properties: [openProp]});
cy.viewport(600, 800);
cy.stub(DataSet, 'getDatasetByDatasetIdentifier').returns(Promise.resolve(open));
cy.stub(DataSet, 'getDataSetsByDatasetId').returns(Promise.resolve(open));
cy.stub(DatasetMetrics, 'getDatasetStats').returns(Promise.resolve({}));

const props = {
match: {
params: {
datasetIdentifier: open.datasetIdentifier
}
},
history: {
push() {
}
}
};
mount(<DatasetStatistics {...props}/>);
cy.contains(open.datasetIdentifier).should('exist');
cy.contains('This dataset is open access, does not require an access request').should('exist');
cy.contains('and can be accessed directly').should('not.exist');
});

});
6 changes: 6 additions & 0 deletions src/libs/Models.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

export enum AccessManagement {
OPEN = 'open',
CONTROLLED = 'controlled',
EXTERNAL = 'external'
}
Loading
Loading