forked from binary-com/deriv-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mahdiyeh/ Refactor: Reports monorepo package (binary-com#5620)
* add initial config of reports monorepo * add config to core * fix event-source-polyfil version * resolve build errors * move validator to utils * fix trader files * delete reports, change imports * fix root_store error * fix chunkName * fix direcory path * fix jest errors * fix directory * make separate emptyPrtfolioMessage in trader * fix aliases * add translation * fix code smell * reload tests * fix empty-portfolio-message conflicts * remove unnecessary css files and functions * remove deriv-charts package and unnecessary related files * fix import from trader in reports * remove duplicated files * change BinaryLink to NavLink * rerun tests * fix circular dependency * fix EHOIST_PKG_VERSION error * fix test * remove position-drawer-card from trader * remove duplicated scss * remove bottom-widget * fix reports loader * add contract, portfolio and chartbarrier stores to the core * use core portfolio and contract store in trader and reports * move markers component, helpers and constants to the core * remove all duplicated files from trader and reports * remove contract store from core exports * update reports packages version * remove commented imports * add getContactValidationRules to contact core * move duration test to shared * fix active_symbols store * fix moduleLoader in routes.config error * fix stores constructor * move contract-type file to trader * move validation-rules to trading * remove serverTime from shared * remove .js from imports * remove all commented lines * fix error when the trade_store in localStorage in not existd yet * clean the code * fix is_multiplier error issue using it from portfolio store * add props type to open-positions and position-drawer * change portfolio file name * add action for updating contract_type observable in portfolio store * update with latest master * remove comments * add shared to translation scripts/add deriv/reports to the build * remove redundant comment in contract-replay.jsx * remove connectionWithContractUpdate from reports * fix openPositions default tab issue * fix to not remove closed contracts when navigating from reporst to trader * prevent unmounting the portfolio component when redirecting to reports packge * fix performance issue on profit_loss input * fix circular dependancy Co-authored-by: Carol Sachdeva <58209918+carol-binary@users.noreply.github.com>
- Loading branch information
1 parent
d68f87f
commit 5fadc00
Showing
220 changed files
with
8,372 additions
and
985 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
Validating CODEOWNERS rules …
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
52 changes: 52 additions & 0 deletions
52
packages/core/src/Components/markers/__tests__/marker-spot-label.spec.js
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,52 @@ | ||
import React from 'react'; | ||
import { expect } from 'chai'; | ||
import { configure, shallow, mount } from 'enzyme'; | ||
import Adapter from 'enzyme-adapter-react-16'; | ||
import MarkerSpotLabel from '../marker-spot-label.jsx'; | ||
|
||
configure({ adapter: new Adapter() }); | ||
|
||
describe('MarkerSpotLabel', () => { | ||
it('should render one <MarkerSpotLabel /> component', () => { | ||
const wrapper = shallow(<MarkerSpotLabel />); | ||
expect(wrapper).to.have.length(1); | ||
}); | ||
it('should have class .chart-spot-label__time-value-container--top if align_label top is passed in props', () => { | ||
const wrapper = shallow(<MarkerSpotLabel align_label={'top'} />); | ||
expect(wrapper.find('.chart-spot-label__time-value-container--top').exists()).to.be.true; | ||
}); | ||
it('should have class .chart-spot-label__time-value-container--bottom if align_label bottom is passed in props', () => { | ||
const wrapper = shallow(<MarkerSpotLabel align_label={'bottom'} />); | ||
expect(wrapper.find('.chart-spot-label__time-value-container--bottom').exists()).to.be.true; | ||
}); | ||
it('should have class .chart-spot-label__time-value-container--top if no align_label is passed in props', () => { | ||
const wrapper = shallow(<MarkerSpotLabel />); | ||
expect(wrapper.find('.chart-spot-label__time-value-container--top').exists()).to.be.true; | ||
expect(wrapper.find('.chart-spot-label__time-value-container--bottom').exists()).to.be.false; | ||
}); | ||
it('should toggle label on hover if has_hover_toggle is passed in props', async () => { | ||
const wrapper = mount(<MarkerSpotLabel has_hover_toggle={true} />); | ||
expect(wrapper.find('.chart-spot-label__info-container').exists()).to.be.false; | ||
|
||
wrapper.find('.marker-hover-container').simulate('mouseenter'); | ||
wrapper.update(); | ||
expect(wrapper.find('.chart-spot-label__info-container').exists()).to.be.true; | ||
|
||
wrapper.find('.marker-hover-container').simulate('mouseleave'); | ||
wrapper.update(); | ||
expect(wrapper.find('.chart-spot-label__info-container').exists()).to.be.false; | ||
}); | ||
it('should not toggle label on hover if has_label_toggle is not passed in props', () => { | ||
const wrapper = shallow(<MarkerSpotLabel />); | ||
expect(wrapper.find('.chart-spot-label__info-container').exists()).to.be.true; | ||
expect(wrapper.find('.marker-hover-container').exists()).to.equal(false); | ||
}); | ||
it('should have class .chart-spot-label__value-container--won if status won is passed in props', () => { | ||
const wrapper = shallow(<MarkerSpotLabel status={'won'} />); | ||
expect(wrapper.find('.chart-spot-label__value-container--won').exists()).to.be.true; | ||
}); | ||
it('should have class .chart-spot-label__value-container--lost if status lost is passed in props', () => { | ||
const wrapper = shallow(<MarkerSpotLabel status={'lost'} />); | ||
expect(wrapper.find('.chart-spot-label__value-container--lost').exists()).to.be.true; | ||
}); | ||
}); |
20 changes: 20 additions & 0 deletions
20
packages/core/src/Components/markers/__tests__/marker-spot.spec.js
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,20 @@ | ||
import React from 'react'; | ||
import { expect } from 'chai'; | ||
import { configure, shallow } from 'enzyme'; | ||
import Adapter from 'enzyme-adapter-react-16'; | ||
import MarkerSpot from '../marker-spot.jsx'; | ||
|
||
configure({ adapter: new Adapter() }); | ||
|
||
describe('MarkerSpot', () => { | ||
it('should render one <MarkerSpot /> component', () => { | ||
const wrapper = shallow(<MarkerSpot />); | ||
expect(wrapper).to.have.length(1); | ||
}); | ||
it('should not have class .chart-spot__spot--lost or .chart-spot__spot--won if no status is passed in props', () => { | ||
const wrapper = shallow(<MarkerSpot />); | ||
expect(wrapper.find('.chart-spot__spot--lost').exists()).to.be.false; | ||
expect(wrapper.find('.chart-spot__spot--lost').exists()).to.be.false; | ||
expect(wrapper.find('.chart-spot').exists()).to.be.true; | ||
}); | ||
}); |
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,38 @@ | ||
import classNames from 'classnames'; | ||
import { observer } from 'mobx-react'; | ||
import PropTypes from 'prop-types'; | ||
import React from 'react'; | ||
import { Icon } from '@deriv/components'; | ||
|
||
const MarkerLine = ({ label, line_style, marker_config, status }) => { | ||
// TODO: Find a more elegant solution | ||
if (!marker_config) return <div />; | ||
return ( | ||
<div className={classNames('chart-marker-line__wrapper', `chart-marker-line--${line_style}`)}> | ||
{label === marker_config.LINE_END.content_config.label && ( | ||
<Icon | ||
icon='IcContractExitTimeCircle' | ||
className='chart-marker-line__icon' | ||
color={status === 'lost' ? 'red' : 'green'} | ||
size={24} | ||
/> | ||
)} | ||
{label === marker_config.LINE_START.content_config.label && ( | ||
<Icon | ||
icon='IcContractStartTimeCircle' | ||
className='chart-marker-line__icon chart-marker-line__icon--time' | ||
color='secondary' | ||
size={24} | ||
/> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
MarkerLine.propTypes = { | ||
label: PropTypes.string, | ||
line_style: PropTypes.string, | ||
marker_config: PropTypes.object, | ||
status: PropTypes.oneOf(['won', 'lost']), | ||
}; | ||
export default observer(MarkerLine); |
Oops, something went wrong.