feat(2036): add markets to the navbar (#2402)

* feat: add markets to the navbar

* feat: add markets to the navbar - adjust failing int test
This commit is contained in:
macqbat 2022-12-15 08:45:03 +01:00 committed by GitHub
parent 6b7a04176b
commit e653ad328f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 48 additions and 6 deletions

View File

@ -130,3 +130,33 @@ describe('ethereum wallet', { tags: '@smoke' }, () => {
cy.getByTestId(connectEthWalletBtn).should('exist'); cy.getByTestId(connectEthWalletBtn).should('exist');
}); });
}); });
describe('Navbar', { tags: '@smoke' }, () => {
beforeEach(() => {
cy.mockTradingPage();
cy.mockGQLSubscription();
cy.visit('/');
cy.getByTestId('dialog-close').click();
});
it('should be properly rendered', () => {
const links = ['Markets', 'Trading', 'Portfolio'];
const hashes = ['#/markets', '#/markets/market-0', '#/portfolio'];
let i = 0;
cy.getByTestId('navbar').within(() => {
cy.get('a[data-testid]', { log: true })
.should('have.length', 3)
.each((item) => {
cy.wrap(item).click();
cy.wrap(item).get('span.absolute.h-1.w-full').should('exist');
cy.location('hash').should('equal', hashes[i]);
cy.wrap(item).should('have.data', 'testid', links[i++]);
});
});
});
it('should look nicer on mobile', () => {
cy.viewport(560, 890);
cy.getByTestId('theme-switcher').scrollIntoView().click();
});
});

View File

@ -53,7 +53,7 @@ describe('markets table', { tags: '@smoke' }, () => {
.click(); .click();
cy.url().should('eq', Cypress.config('baseUrl') + '/#/markets'); cy.url().should('eq', Cypress.config('baseUrl') + '/#/markets');
cy.contains('AAPL.MF21').should('be.visible'); cy.contains('AAPL.MF21').should('be.visible');
cy.contains('Market').click(); // sort by market name cy.get('.ag-header-cell-label').contains('Market').click(); // sort by market name
for (let i = 0; i < ExpectedSortedMarkets.length; i++) { for (let i = 0; i < ExpectedSortedMarkets.length; i++) {
cy.get(`[row-index=${i}]`) cy.get(`[row-index=${i}]`)
.find('[col-id="tradableInstrument.instrument.code"]') .find('[col-id="tradableInstrument.instrument.code"]')

View File

@ -42,6 +42,12 @@ export const Navbar = ({
</Link> </Link>
} }
> >
<AppNavLink
name={t('Markets')}
path={Routes.MARKETS}
navbarTheme={navbarTheme}
end
/>
<AppNavLink <AppNavLink
name={t('Trading')} name={t('Trading')}
path={tradingPath} path={tradingPath}
@ -77,6 +83,7 @@ interface AppNavLinkProps {
navbarTheme: NavbarTheme; navbarTheme: NavbarTheme;
testId?: string; testId?: string;
target?: HTMLAttributeAnchorTarget; target?: HTMLAttributeAnchorTarget;
end?: boolean;
} }
const AppNavLink = ({ const AppNavLink = ({
@ -85,6 +92,7 @@ const AppNavLink = ({
navbarTheme, navbarTheme,
target, target,
testId = name, testId = name,
end,
}: AppNavLinkProps) => { }: AppNavLinkProps) => {
const borderClasses = classNames('absolute h-1 w-full bottom-[-1px] left-0', { const borderClasses = classNames('absolute h-1 w-full bottom-[-1px] left-0', {
'bg-black dark:bg-vega-yellow': navbarTheme !== 'yellow', 'bg-black dark:bg-vega-yellow': navbarTheme !== 'yellow',
@ -96,6 +104,7 @@ const AppNavLink = ({
to={{ pathname: path }} to={{ pathname: path }}
className={getNavLinkClassNames(navbarTheme)} className={getNavLinkClassNames(navbarTheme)}
target={target} target={target}
end={end}
> >
{({ isActive }) => { {({ isActive }) => {
return ( return (

View File

@ -40,13 +40,16 @@ export const Nav = ({
titleContent, titleContent,
title, title,
}: NavbarProps) => { }: NavbarProps) => {
const themeWrapperClasses = classNames('w-full', { const themeWrapperClasses = classNames(
dark: navbarTheme === 'dark', 'w-full overflow-y-hidden overflow-x-auto md:overflow-x-hidden',
}); {
dark: navbarTheme === 'dark',
}
);
const isYellow = navbarTheme === 'yellow'; const isYellow = navbarTheme === 'yellow';
const navbarClasses = classNames( const navbarClasses = classNames(
'flex items-stretch border-b px-4 border-default', 'min-w-max w-full flex items-stretch border-b px-4 border-default',
{ {
'dark:bg-black dark:text-white': !isYellow, 'dark:bg-black dark:text-white': !isYellow,
'bg-vega-yellow text-black bg-right-top bg-no-repeat bg-contain': 'bg-vega-yellow text-black bg-right-top bg-no-repeat bg-contain':
@ -55,7 +58,7 @@ export const Nav = ({
); );
return ( return (
<div className={themeWrapperClasses}> <div className={themeWrapperClasses} data-testid="navbar">
<div className={navbarClasses}> <div className={navbarClasses}>
<div className="flex gap-4 items-center"> <div className="flex gap-4 items-center">
{icon} {icon}