fix(trading): set trading view as default (#5632)
This commit is contained in:
parent
0da20b750f
commit
bb826c88f0
@ -1,9 +1,5 @@
|
|||||||
import { render, waitFor } from '@testing-library/react';
|
import { render, waitFor } from '@testing-library/react';
|
||||||
import {
|
import { NestedDataList, sortNestedDataByChildren } from './nested-data-list';
|
||||||
BORDER_COLOURS,
|
|
||||||
NestedDataList,
|
|
||||||
sortNestedDataByChildren,
|
|
||||||
} from './nested-data-list';
|
|
||||||
import userEvent from '@testing-library/user-event';
|
import userEvent from '@testing-library/user-event';
|
||||||
|
|
||||||
const mockData = {
|
const mockData = {
|
||||||
@ -61,38 +57,6 @@ describe('NestedDataList', () => {
|
|||||||
expect(parent[0].querySelector('li')).toHaveClass('pl-4 border-l-4 pt-2');
|
expect(parent[0].querySelector('li')).toHaveClass('pl-4 border-l-4 pt-2');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should repeat the border colours in the correct order', () => {
|
|
||||||
const colourMockData = {
|
|
||||||
t0: {
|
|
||||||
t1: {
|
|
||||||
t2: {
|
|
||||||
t3: {
|
|
||||||
t4: {
|
|
||||||
t5: {
|
|
||||||
t6: {
|
|
||||||
t7: {
|
|
||||||
t8: {
|
|
||||||
hello: 'world',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
const tree = render(<NestedDataList data={colourMockData} />);
|
|
||||||
const { getByTestId } = tree;
|
|
||||||
|
|
||||||
for (let i = 0; i < 8; i++) {
|
|
||||||
const item = getByTestId(`T${i}`);
|
|
||||||
const expected = BORDER_COLOURS.light[i % 5];
|
|
||||||
expect(item.style.borderColor.toUpperCase()).toBe(expected);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should sort the data by values with children', () => {
|
it('should sort the data by values with children', () => {
|
||||||
const mockData = {
|
const mockData = {
|
||||||
nonce: '5980890939790185837',
|
nonce: '5980890939790185837',
|
||||||
|
@ -27,11 +27,11 @@ describe('ChartMenu', () => {
|
|||||||
|
|
||||||
render(<ChartMenu />);
|
render(<ChartMenu />);
|
||||||
|
|
||||||
await userEvent.click(screen.getByRole('button', { name: 'TradingView' }));
|
|
||||||
expect(useChartSettingsStore.getState().chartlib).toEqual('tradingview');
|
|
||||||
|
|
||||||
await userEvent.click(screen.getByRole('button', { name: 'Vega chart' }));
|
await userEvent.click(screen.getByRole('button', { name: 'Vega chart' }));
|
||||||
expect(useChartSettingsStore.getState().chartlib).toEqual('pennant');
|
expect(useChartSettingsStore.getState().chartlib).toEqual('pennant');
|
||||||
|
|
||||||
|
await userEvent.click(screen.getByRole('button', { name: 'TradingView' }));
|
||||||
|
expect(useChartSettingsStore.getState().chartlib).toEqual('tradingview');
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('tradingview', () => {
|
describe('tradingview', () => {
|
||||||
|
@ -30,7 +30,7 @@ const STUDY_ORDER: Study[] = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
export const DEFAULT_CHART_SETTINGS = {
|
export const DEFAULT_CHART_SETTINGS = {
|
||||||
chartlib: 'pennant' as const,
|
chartlib: 'tradingview' as const,
|
||||||
interval: Interval.INTERVAL_I15M,
|
interval: Interval.INTERVAL_I15M,
|
||||||
type: ChartType.CANDLE,
|
type: ChartType.CANDLE,
|
||||||
overlays: [Overlay.MOVING_AVERAGE],
|
overlays: [Overlay.MOVING_AVERAGE],
|
||||||
|
@ -162,6 +162,8 @@ const NavbarMenu = ({ onClick }: { onClick: () => void }) => {
|
|||||||
const envNameMapping = useEnvNameMapping();
|
const envNameMapping = useEnvNameMapping();
|
||||||
const { VEGA_ENV, VEGA_NETWORKS, GITHUB_FEEDBACK_URL } = useEnvironment();
|
const { VEGA_ENV, VEGA_NETWORKS, GITHUB_FEEDBACK_URL } = useEnvironment();
|
||||||
const marketId = useGlobalStore((store) => store.marketId);
|
const marketId = useGlobalStore((store) => store.marketId);
|
||||||
|
const GOVERNANCE_LINK = useLinks(DApp.Governance)();
|
||||||
|
const EXPLORER_LINK = useLinks(DApp.Explorer)();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="gap-3 lg:flex lg:h-full">
|
<div className="gap-3 lg:flex lg:h-full">
|
||||||
@ -220,7 +222,7 @@ const NavbarMenu = ({ onClick }: { onClick: () => void }) => {
|
|||||||
</NavbarLink>
|
</NavbarLink>
|
||||||
</NavbarItem>
|
</NavbarItem>
|
||||||
<NavbarItem>
|
<NavbarItem>
|
||||||
<NavbarLinkExternal to={useLinks(DApp.Governance)()}>
|
<NavbarLinkExternal to={GOVERNANCE_LINK}>
|
||||||
{t('Governance')}
|
{t('Governance')}
|
||||||
</NavbarLinkExternal>
|
</NavbarLinkExternal>
|
||||||
</NavbarItem>
|
</NavbarItem>
|
||||||
@ -228,6 +230,13 @@ const NavbarMenu = ({ onClick }: { onClick: () => void }) => {
|
|||||||
<NavbarTrigger>{t('Resources')}</NavbarTrigger>
|
<NavbarTrigger>{t('Resources')}</NavbarTrigger>
|
||||||
<NavbarContent data-testid="navbar-content-resources">
|
<NavbarContent data-testid="navbar-content-resources">
|
||||||
<ul className="lg:p-4">
|
<ul className="lg:p-4">
|
||||||
|
{EXPLORER_LINK && (
|
||||||
|
<NavbarSubItem>
|
||||||
|
<NavbarLinkExternal to={EXPLORER_LINK}>
|
||||||
|
{t('Explorer')}
|
||||||
|
</NavbarLinkExternal>
|
||||||
|
</NavbarSubItem>
|
||||||
|
)}
|
||||||
{DocsLinks?.NEW_TO_VEGA && (
|
{DocsLinks?.NEW_TO_VEGA && (
|
||||||
<NavbarSubItem>
|
<NavbarSubItem>
|
||||||
<NavbarLinkExternal to={DocsLinks?.NEW_TO_VEGA}>
|
<NavbarLinkExternal to={DocsLinks?.NEW_TO_VEGA}>
|
||||||
|
@ -100,12 +100,12 @@ export const TradingView = ({
|
|||||||
},
|
},
|
||||||
|
|
||||||
// No theme in deps to avoid full chart reload when the theme changes
|
// No theme in deps to avoid full chart reload when the theme changes
|
||||||
// Instead the theme is changed programmitcally in a separate useEffect
|
// Instead the theme is changed programmatically in a separate useEffect
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
[datafeed, marketId, language, libraryPath, isMobile]
|
[datafeed, marketId, language, libraryPath, isMobile]
|
||||||
);
|
);
|
||||||
|
|
||||||
// Update the trading view theme every time the app theme updates, doen separately
|
// Update the trading view theme every time the app theme updates, done separately
|
||||||
// to avoid full chart reload
|
// to avoid full chart reload
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!widgetRef.current || !widgetRef.current._ready) return;
|
if (!widgetRef.current || !widgetRef.current._ready) return;
|
||||||
|
Loading…
Reference in New Issue
Block a user