-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat/gwas unified flow outcome card (#1201)
* feat(gwasUnifiedFlowOutcomeCard): initial commit * feat(gwasUnifiedFlowOutcomeCard): Added unit test for CovariatesCard.js * feat(gwasUnifiedFlowOutcomeCard): Updated test to use ValidInitialState data for outcome and updated CovariatesCardList keys to use covariate obj * feat(gwasUnifiedFlowOutcomeCard): Cleaned up code formatting for CovariatesCardList.test.jsx * feat(gwasUnifiedFlowStyleSidebars): Wrote storybook for CovariatesCardsList * feat(gwasUnifiedFlowStyleSidebars): Changed outcome card title to Outcome Phenotype to match design * feat(gwasUnifiedFlowOutcomeCard): Changed all instances of InitialValidState to ValidState * feat(gwasUnifiedFlowOutcomeCard): Updated CovariatesCardList test to use Valid state objs instead of hard coded values; updated ref to Valid state in JobInputModal; Updated ValidState to use correct data * feat(gwasUnifiedFlowOutcomeCard): Ran ESLINT-new
- Loading branch information
1 parent
707c5ec
commit 297b3b7
Showing
12 changed files
with
165 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/Analysis/GWASV2/Components/Covariates/CovariatesCardList.stories.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React, { useState } from 'react'; | ||
import CovariatesCardsList from './CovariatesCardsList'; | ||
import ValidState from '../../TestData/States/ValidState'; | ||
import './Covariates.css'; | ||
import '../../Steps/SelectCovariates/SelectCovariates.css'; | ||
import '../../GWASV2.css'; | ||
|
||
export default { | ||
title: 'Tests3/GWASV2/CovariatesCardsList', | ||
component: CovariatesCardsList, | ||
}; | ||
|
||
const Template = (args) => ( | ||
<div className='GWASV2'> | ||
<div className='GWASUI-row'> | ||
<div className='GWASUI-double-column'></div> | ||
<div className='GWASUI-column GWASUI-card-column'> | ||
<CovariatesCardsList | ||
{...args} | ||
deleteCovariate={(chosenCovariate) => | ||
alert('called deleteCovariate Method') | ||
} | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
|
||
export const SuccessState = Template.bind({}); | ||
SuccessState.args = ValidState; |
80 changes: 80 additions & 0 deletions
80
src/Analysis/GWASV2/Components/Covariates/CovariatesCardList.test.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import React from 'react'; | ||
import { mount } from 'enzyme'; | ||
import { DeleteOutlined } from '@ant-design/icons'; | ||
import CovariatesCardsList from './CovariatesCardsList'; | ||
import ValidState from '../../TestData/States/ValidState'; | ||
|
||
describe('CovariatesCardsList component', () => { | ||
let wrapper; | ||
const mockDeleteCovariate = jest.fn(); | ||
|
||
const outcomeText = ValidState.outcome.concept_name; | ||
const lastCovariateObj = ValidState.covariates.at(-1); | ||
const lastContinousCovariateText = lastCovariateObj.concept_name; | ||
const dichotomousObj = ValidState.covariates.filter( | ||
(obj) => obj.variable_type === 'custom_dichotomous', | ||
)[0]; | ||
const dichotomousText = dichotomousObj.provided_name; | ||
|
||
beforeEach(() => { | ||
const mockProps = { | ||
outcome: ValidState.outcome, | ||
covariates: ValidState.covariates, | ||
deleteCovariate: mockDeleteCovariate, | ||
}; | ||
wrapper = mount(<CovariatesCardsList {...mockProps} />); | ||
}); | ||
|
||
it('should render an outcome card', () => { | ||
expect(wrapper.find('.outcome-card').exists()).toBe(true); | ||
expect(wrapper.find('.outcome-card .ant-card-meta-title').text()).toBe( | ||
'Outcome Phenotype', | ||
); | ||
expect( | ||
wrapper.find('.outcome-card .ant-card-meta-description').text(), | ||
).toBe(outcomeText); | ||
}); | ||
|
||
it('should render covariate cards', () => { | ||
expect(wrapper.find('.dichotomous-card').exists()).toBe(true); | ||
expect( | ||
wrapper | ||
.find('.dichotomous-card .ant-card-meta-title') | ||
.last() | ||
.text(), | ||
).toBe('Dichotomous Covariate'); | ||
expect( | ||
wrapper | ||
.find('.dichotomous-card .ant-card-meta-description') | ||
.last() | ||
.text(), | ||
).toBe(dichotomousText); | ||
|
||
expect(wrapper.find('.continuous-card').exists()).toBe(true); | ||
expect( | ||
wrapper | ||
.find('.continuous-card .ant-card-meta-title') | ||
.last() | ||
.text(), | ||
).toBe('Continuous Covariate'); | ||
expect( | ||
wrapper | ||
.find('.continuous-card .ant-card-meta-description') | ||
.last() | ||
.text(), | ||
).toBe(lastContinousCovariateText); | ||
}); | ||
|
||
it('should call deleteCovariate when the delete icon is clicked', () => { | ||
wrapper | ||
.find(DeleteOutlined) | ||
.first() | ||
.simulate('click'); | ||
expect(mockDeleteCovariate).toHaveBeenCalledWith(dichotomousObj); | ||
wrapper | ||
.find(DeleteOutlined) | ||
.last() | ||
.simulate('click'); | ||
expect(mockDeleteCovariate).toHaveBeenCalledWith(lastCovariateObj); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters