* feat: add node url to footer, add link to change node * feat: add test for trading footer * chore: add comment about url manipulation * fix: #862 fix cypress tests * fix: #862 remove constant link Co-authored-by: Madalina Raicu <madalina@raygroup.uk>
This commit is contained in:
parent
b4a20042d3
commit
9b360af2c1
@ -4,7 +4,6 @@ import { connectVegaWallet } from '../support/vega-wallet';
|
|||||||
const marketInfoBtn = 'Info';
|
const marketInfoBtn = 'Info';
|
||||||
const row = 'key-value-table-row';
|
const row = 'key-value-table-row';
|
||||||
const marketTitle = 'accordion-title';
|
const marketTitle = 'accordion-title';
|
||||||
const link = 'link';
|
|
||||||
const externalLink = 'external-link';
|
const externalLink = 'external-link';
|
||||||
|
|
||||||
describe('market info is displayed', { tags: '@smoke' }, () => {
|
describe('market info is displayed', { tags: '@smoke' }, () => {
|
||||||
@ -154,7 +153,10 @@ describe('market info is displayed', { tags: '@smoke' }, () => {
|
|||||||
validateMarketDataRow(1, 'Supplied Stake', '0.56767 tBTC');
|
validateMarketDataRow(1, 'Supplied Stake', '0.56767 tBTC');
|
||||||
validateMarketDataRow(2, 'Market Value Proxy', '6.77678 tBTC');
|
validateMarketDataRow(2, 'Market Value Proxy', '6.77678 tBTC');
|
||||||
|
|
||||||
cy.getByTestId(link).should('have.text', 'View liquidity provision table');
|
cy.getByTestId('view-liquidity-link').should(
|
||||||
|
'have.text',
|
||||||
|
'View liquidity provision table'
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('oracle displayed', () => {
|
it('oracle displayed', () => {
|
||||||
|
@ -52,7 +52,9 @@ describe('markets table', { tags: '@smoke' }, () => {
|
|||||||
'ETHBTC.QM21',
|
'ETHBTC.QM21',
|
||||||
'SOLUSD',
|
'SOLUSD',
|
||||||
];
|
];
|
||||||
cy.getByTestId('link').should('have.attr', 'href', '/markets').click();
|
cy.getByTestId('view-market-list-link')
|
||||||
|
.should('have.attr', 'href', '/markets')
|
||||||
|
.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.contains('Market').click(); // sort by market name
|
||||||
|
26
apps/trading/components/footer/footer.spec.tsx
Normal file
26
apps/trading/components/footer/footer.spec.tsx
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
import { fireEvent, render, screen } from '@testing-library/react';
|
||||||
|
import { Footer } from './footer';
|
||||||
|
import { useEnvironment } from '@vegaprotocol/environment';
|
||||||
|
|
||||||
|
jest.mock('@vegaprotocol/environment');
|
||||||
|
|
||||||
|
describe('Footer', () => {
|
||||||
|
it('renders a button to open node switcher', () => {
|
||||||
|
const mockOpenNodeSwitcher = jest.fn();
|
||||||
|
const node = 'n99.somenetwork.vega.xyz';
|
||||||
|
const nodeUrl = `https://${node}`;
|
||||||
|
|
||||||
|
// @ts-ignore mock env hook
|
||||||
|
useEnvironment.mockImplementation(() => ({
|
||||||
|
VEGA_URL: `https://api.${node}/graphql`,
|
||||||
|
setNodeSwitcherOpen: mockOpenNodeSwitcher,
|
||||||
|
}));
|
||||||
|
|
||||||
|
render(<Footer />);
|
||||||
|
|
||||||
|
fireEvent.click(screen.getByRole('button'));
|
||||||
|
expect(mockOpenNodeSwitcher).toHaveBeenCalled();
|
||||||
|
const link = screen.getByText(node);
|
||||||
|
expect(link).toHaveAttribute('href', nodeUrl);
|
||||||
|
});
|
||||||
|
});
|
@ -1,9 +1,28 @@
|
|||||||
|
import { useEnvironment } from '@vegaprotocol/environment';
|
||||||
|
import { t } from '@vegaprotocol/react-helpers';
|
||||||
|
import { ButtonLink, Link } from '@vegaprotocol/ui-toolkit';
|
||||||
|
|
||||||
export const Footer = () => {
|
export const Footer = () => {
|
||||||
|
const { VEGA_URL, setNodeSwitcherOpen } = useEnvironment();
|
||||||
return (
|
return (
|
||||||
<footer className="px-4 py-2 text-xs border-t border-default bg-neutral-100 dark:bg-neutral-800">
|
<footer className="px-4 py-1 text-xs border-t border-default">
|
||||||
<div className="flex justify-between">
|
<div className="flex justify-between">
|
||||||
<div>Status</div>
|
<div className="flex gap-2">
|
||||||
|
{VEGA_URL && <NodeUrl url={VEGA_URL} />}
|
||||||
|
<ButtonLink onClick={setNodeSwitcherOpen}>{t('Change')}</ButtonLink>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const NodeUrl = ({ url }: { url: string }) => {
|
||||||
|
// get base url from api url, api sub domain
|
||||||
|
const urlObj = new URL(url);
|
||||||
|
const nodeUrl = urlObj.origin.replace(/^[^.]+\./g, '');
|
||||||
|
return (
|
||||||
|
<Link href={'https://' + nodeUrl} target="_blank">
|
||||||
|
{nodeUrl}
|
||||||
|
</Link>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
@ -65,7 +65,9 @@ export const SelectMarketLandingTable = ({
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-4 text-md">
|
<div className="mt-4 text-md">
|
||||||
<Link href="/markets">{'Or view full market list'}</Link>
|
<Link href="/markets" data-testid="view-market-list-link">
|
||||||
|
{'Or view full market list'}
|
||||||
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
@ -320,7 +320,10 @@ export const Info = ({ market, onSelect }: InfoProps) => {
|
|||||||
assetSymbol={assetSymbol}
|
assetSymbol={assetSymbol}
|
||||||
>
|
>
|
||||||
<Link passHref={true} href={`/liquidity/${market.id}`}>
|
<Link passHref={true} href={`/liquidity/${market.id}`}>
|
||||||
<UiToolkitLink onClick={() => onSelect(market.id)}>
|
<UiToolkitLink
|
||||||
|
onClick={() => onSelect(market.id)}
|
||||||
|
data-testid="view-liquidity-link"
|
||||||
|
>
|
||||||
{t('View liquidity provision table')}
|
{t('View liquidity provision table')}
|
||||||
</UiToolkitLink>
|
</UiToolkitLink>
|
||||||
</Link>
|
</Link>
|
||||||
|
Loading…
Reference in New Issue
Block a user