From 9b360af2c12eaa93f25a49358919299850d8b5b5 Mon Sep 17 00:00:00 2001 From: Matthew Russell Date: Mon, 7 Nov 2022 18:53:43 -0600 Subject: [PATCH] feat(#862): show current node and button to open node switcher (#1894) * 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 --- .../src/integration/market-info.cy.ts | 6 +++-- .../trading-e2e/src/integration/markets.cy.ts | 4 ++- .../trading/components/footer/footer.spec.tsx | 26 +++++++++++++++++++ apps/trading/components/footer/footer.tsx | 23 ++++++++++++++-- .../select-market/select-market.tsx | 4 ++- .../components/market-info/info-market.tsx | 5 +++- 6 files changed, 61 insertions(+), 7 deletions(-) create mode 100644 apps/trading/components/footer/footer.spec.tsx diff --git a/apps/trading-e2e/src/integration/market-info.cy.ts b/apps/trading-e2e/src/integration/market-info.cy.ts index 19d061fe1..2811f212a 100644 --- a/apps/trading-e2e/src/integration/market-info.cy.ts +++ b/apps/trading-e2e/src/integration/market-info.cy.ts @@ -4,7 +4,6 @@ import { connectVegaWallet } from '../support/vega-wallet'; const marketInfoBtn = 'Info'; const row = 'key-value-table-row'; const marketTitle = 'accordion-title'; -const link = 'link'; const externalLink = 'external-link'; 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(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', () => { diff --git a/apps/trading-e2e/src/integration/markets.cy.ts b/apps/trading-e2e/src/integration/markets.cy.ts index 9e34e3a2b..7ea500b85 100644 --- a/apps/trading-e2e/src/integration/markets.cy.ts +++ b/apps/trading-e2e/src/integration/markets.cy.ts @@ -52,7 +52,9 @@ describe('markets table', { tags: '@smoke' }, () => { 'ETHBTC.QM21', '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.contains('AAPL.MF21').should('be.visible'); cy.contains('Market').click(); // sort by market name diff --git a/apps/trading/components/footer/footer.spec.tsx b/apps/trading/components/footer/footer.spec.tsx new file mode 100644 index 000000000..c1631f2f1 --- /dev/null +++ b/apps/trading/components/footer/footer.spec.tsx @@ -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(