Compare commits

...
14 changed files with 203 additions and 67 deletions
+1 -1
View File
@@ -6,7 +6,7 @@ name: 'Add Issues To Project Board'
types:
- opened
env:
GH_TOKEN: ${{ secrets.GH_NEW_CARD_TO_PROJECT }}
GH_TOKEN: ${{ secrets.PROJECT_MANAGE_ACTION }}
PROJECT_ID: ${{ secrets.FRONT_END_PROJECT_ID }}
ISSUE_ID: ${{ github.event.issue.node_id }}
USER: ${{ github.actor }}
@@ -40,7 +40,7 @@ context.skip('Transactions page', function () {
.first()
.click({ force: true });
} else {
cy.slack('Unable to find any transactions on page');
cy.log('Unable to find any transactions on page');
cy.screenshot();
}
});
@@ -78,7 +78,7 @@ context.skip('Transactions page', function () {
}
});
} else {
cy.slack('Unable to find any transactions on page');
cy.log('Unable to find any transactions on page');
cy.screenshot();
}
});
@@ -54,7 +54,7 @@ export const PartyBlockStake = ({
{p?.stakingSummary.currentStakeAvailable ? (
<KeyValueTable>
<KeyValueTableRow noBorder={true}>
<div>{t('Available stake')}</div>
<div>{t('Associated to key')}</div>
<div>
<GovernanceAssetBalance
price={p.stakingSummary.currentStakeAvailable}
@@ -62,7 +62,7 @@ export const PartyBlockStake = ({
</div>
</KeyValueTableRow>
<KeyValueTableRow noBorder={true}>
<div>{t('Active stake')}</div>
<div>{t('Staked to validator')}</div>
<div>
<GovernanceAssetBalance price={linkedStake || '0'} />
</div>
@@ -369,6 +369,10 @@ describe('Closed markets', { tags: '@smoke' }, () => {
.first()
.find('button svg')
.should('exist');
cy.get(rowSelector)
.find('[col-id="successorMarketID"]')
.first()
.should('have.text', ' - ');
});
// test market list for market in terminated state
@@ -9,6 +9,7 @@ const bidCumulative = 'cumulative-vol-9889001';
const midPrice = 'middle-mark-price-4612690000';
const priceResolution = 'resolution';
const dealTicketPrice = 'order-price';
const dealTicketSize = 'order-size';
const resPrice = 'price-990';
describe('order book', { tags: '@smoke' }, () => {
@@ -74,6 +75,18 @@ describe('order book', { tags: '@smoke' }, () => {
cy.getByTestId(dealTicketPrice).should('have.value', '98.94585');
});
it('copy size to deal ticket form', () => {
// 6003-ORDB-009
cy.getByTestId(bidCumulative).click();
cy.getByTestId(dealTicketSize).should('have.value', '7');
});
it('copy size to deal ticket form', () => {
// 6003-ORDB-009
cy.getByTestId(bidVolume).click();
cy.getByTestId(dealTicketSize).should('have.value', '1');
});
it('change price resolution', () => {
// 6003-ORDB-008
const resolutions = [
+104 -22
View File
@@ -1,4 +1,5 @@
import { act, render, screen, within } from '@testing-library/react';
import { act, render, screen, within, waitFor } from '@testing-library/react';
import { MemoryRouter } from 'react-router-dom';
import { Closed } from './closed';
import { MarketStateMapping, PropertyKeyType } from '@vegaprotocol/types';
import { PositionStatus } from '@vegaprotocol/types';
@@ -211,15 +212,22 @@ describe('Closed', () => {
it('renders correctly formatted and filtered rows', async () => {
await act(async () => {
render(
<MockedProvider
mocks={[marketsMock, marketsDataMock, positionsMock, oracleDataMock]}
>
<VegaWalletContext.Provider
value={{ pubKey } as VegaWalletContextShape}
<MemoryRouter>
<MockedProvider
mocks={[
marketsMock,
marketsDataMock,
positionsMock,
oracleDataMock,
]}
>
<Closed />
</VegaWalletContext.Provider>
</MockedProvider>
<VegaWalletContext.Provider
value={{ pubKey } as VegaWalletContextShape}
>
<Closed />
</VegaWalletContext.Provider>
</MockedProvider>
</MemoryRouter>
);
});
// screen.debug(document, Infinity);
@@ -230,6 +238,7 @@ describe('Closed', () => {
'Description',
'Status',
'Settlement date',
'Successor market',
'Best bid',
'Best offer',
'Mark price',
@@ -247,6 +256,7 @@ describe('Closed', () => {
market.tradableInstrument.instrument.name,
MarketStateMapping[market.state],
'3 days ago',
'-',
/* eslint-disable @typescript-eslint/no-non-null-assertion */
addDecimalsFormatNumber(marketsData.bestBidPrice, market.decimalPlaces),
addDecimalsFormatNumber(
@@ -315,20 +325,22 @@ describe('Closed', () => {
};
await act(async () => {
render(
<MockedProvider
mocks={[
mixedMarketsMock,
marketsDataMock,
positionsMock,
oracleDataMock,
]}
>
<VegaWalletContext.Provider
value={{ pubKey } as VegaWalletContextShape}
<MemoryRouter>
<MockedProvider
mocks={[
mixedMarketsMock,
marketsDataMock,
positionsMock,
oracleDataMock,
]}
>
<Closed />
</VegaWalletContext.Provider>
</MockedProvider>
<VegaWalletContext.Provider
value={{ pubKey } as VegaWalletContextShape}
>
<Closed />
</VegaWalletContext.Provider>
</MockedProvider>
</MemoryRouter>
);
});
@@ -359,4 +371,74 @@ describe('Closed', () => {
});
expect(cells).toEqual(expectedRows.map((m) => m.node.id));
});
it('successor marked should be visible', async () => {
const mixedMarkets = [
{
__typename: 'MarketEdge' as const,
node: createMarketFragment({
id: 'include-0',
state: MarketState.STATE_SETTLED,
successorMarketID: 'successorMarketID',
}),
},
{
__typename: 'MarketEdge' as const,
node: {
...createMarketFragment({
id: 'successorMarketID',
state: MarketState.STATE_ACTIVE,
}),
tradableInstrument: {
...createMarketFragment().tradableInstrument,
instrument: {
...createMarketFragment().tradableInstrument.instrument,
id: 'successorAssset',
name: 'Successor Market Name',
code: 'SuccessorCode',
},
},
},
},
];
const mixedMarketsMock: MockedResponse<MarketsQuery> = {
request: {
query: MarketsDocument,
},
result: {
data: {
marketsConnection: {
__typename: 'MarketConnection',
edges: mixedMarkets,
},
},
},
};
render(
<MemoryRouter>
<MockedProvider
mocks={[
mixedMarketsMock,
marketsDataMock,
positionsMock,
oracleDataMock,
]}
>
<VegaWalletContext.Provider
value={{ pubKey } as VegaWalletContextShape}
>
<Closed />
</VegaWalletContext.Provider>
</MockedProvider>
</MemoryRouter>
);
await waitFor(() => {
expect(
screen.getByRole('button', { name: 'SuccessorCode' })
).toBeInTheDocument();
});
});
});
+38 -1
View File
@@ -4,7 +4,11 @@ import type {
VegaICellRendererParams,
VegaValueFormatterParams,
} from '@vegaprotocol/datagrid';
import { AgGridLazy as AgGrid, COL_DEFS } from '@vegaprotocol/datagrid';
import {
AgGridLazy as AgGrid,
COL_DEFS,
MarketNameCell,
} from '@vegaprotocol/datagrid';
import { useMemo } from 'react';
import { t } from '@vegaprotocol/i18n';
import { MarketState, MarketStateMapping } from '@vegaprotocol/types';
@@ -20,6 +24,7 @@ import type {
import {
MarketActionsDropdown,
closedMarketsWithDataProvider,
marketProvider,
} from '@vegaprotocol/markets';
import { useVegaWallet } from '@vegaprotocol/wallet';
import { useAssetDetailsDialogStore } from '@vegaprotocol/assets';
@@ -27,6 +32,7 @@ import type { ColDef } from 'ag-grid-community';
import { SettlementDateCell } from './settlement-date-cell';
import { SettlementPriceCell } from './settlement-price-cell';
import { useDataProvider } from '@vegaprotocol/data-provider';
import { useMarketClickHandler } from '../../lib/hooks/use-market-click-handler';
type SettlementAsset =
MarketMaybeWithData['tradableInstrument']['instrument']['product']['settlementAsset'];
@@ -48,6 +54,7 @@ interface Row {
tradingTerminationOracleId: string;
settlementAsset: SettlementAsset;
realisedPNL: string | undefined;
successorMarketID: string | undefined | null;
}
export const Closed = () => {
@@ -109,6 +116,7 @@ export const Closed = () => {
instrument.product.dataSourceSpecForTradingTermination.id,
settlementAsset: instrument.product.settlementAsset,
realisedPNL: position?.node.realisedPNL,
successorMarketID: market.successorMarketID,
};
return row;
@@ -120,6 +128,28 @@ export const Closed = () => {
);
};
export const SuccessorMarketRenderer = ({
value,
}: VegaICellRendererParams<Row, 'successorMarketID'>) => {
const { data } = useDataProvider({
dataProvider: marketProvider,
variables: {
marketId: value || '',
},
skip: !value,
});
const onMarketClick = useMarketClickHandler();
return data ? (
<MarketNameCell
value={data.tradableInstrument.instrument.code}
data={data}
onMarketClick={onMarketClick}
/>
) : (
' - '
);
};
const ClosedMarketsDataGrid = ({
rowData,
error,
@@ -199,6 +229,11 @@ const ClosedMarketsDataGrid = ({
},
},
},
{
headerName: t('Successor market'),
field: 'successorMarketID',
cellRenderer: 'SuccessorMarketRenderer',
},
{
headerName: t('Best bid'),
field: 'bestBidPrice',
@@ -311,7 +346,9 @@ const ClosedMarketsDataGrid = ({
defaultColDef={{
resizable: true,
minWidth: 100,
flex: 1,
}}
components={{ SuccessorMarketRenderer }}
overlayNoRowsTemplate={error ? error.message : t('No markets')}
/>
);
-2
View File
@@ -3,7 +3,6 @@ import { addMockGQLCommand } from './lib/mock-gql';
import { addMockSubscription } from './lib/mock-ws';
import { addMockWalletCommand } from './lib/mock-rest';
import { addMockWeb3ProviderCommand } from './lib/commands/mock-web3-provider';
import { addSlackCommand } from './lib/commands/slack';
import { addHighlightLog } from './lib/commands/highlight-log';
import { addGetAssets } from './lib/commands/get-assets';
import { addVegaWalletReceiveFaucetedAsset } from './lib/commands/vega-wallet-receive-fauceted-asset';
@@ -26,7 +25,6 @@ import { addVegaWalletTopUpRewardsPool } from './lib/commands/vega-wallet-top-up
import { addAssociateTokensToVegaWallet } from './lib/commands/associate-tokens-to-vega-wallet';
addGetTestIdcommand();
addSlackCommand();
addMockGQLCommand();
addMockSubscription();
addMockWalletCommand();
-28
View File
@@ -1,28 +0,0 @@
declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace Cypress {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Chainable<Subject> {
slack(message: string): void;
}
}
}
export function addSlackCommand() {
// @ts-ignore - ignoring Cypress type error which gets resolved when Cypress uses the command
Cypress.Commands.add('slack', (message) => {
const text = `${message}: ${JSON.stringify(Cypress.spec)}`;
cy.log('NOTIFYING SLACK');
const webhook = Cypress.env('SLACK_WEBHOOK');
if (!webhook) {
return;
}
cy.request('POST', webhook, {
text,
});
});
}
@@ -66,10 +66,13 @@ export const OrderbookManager = ({ marketId }: OrderbookManagerProps) => {
decimalPlaces={market?.decimalPlaces ?? 0}
positionDecimalPlaces={market?.positionDecimalPlaces ?? 0}
assetSymbol={market?.tradableInstrument.instrument.product.quoteName}
onClick={(price: string) => {
onClick={({ price, size }) => {
if (price) {
updateOrder(marketId, { price });
}
if (size) {
updateOrder(marketId, { size });
}
}}
midPrice={marketData?.midPrice}
/>
+30 -4
View File
@@ -11,7 +11,7 @@ interface OrderbookRowProps {
decimalPlaces: number;
positionDecimalPlaces: number;
price: string;
onClick?: (price: string) => void;
onClick?: (args: { price?: string; size?: string }) => void;
type: VolumeType;
}
@@ -43,6 +43,7 @@ const CumulativeVol = memo(
testId,
positionDecimalPlaces,
cumulativeValue,
onClick,
}: {
ask?: number;
bid?: number;
@@ -50,6 +51,7 @@ const CumulativeVol = memo(
testId?: string;
className?: string;
positionDecimalPlaces: number;
onClick?: (size?: string | number) => void;
}) => {
const volume = cumulativeValue ? (
<NumericCell
@@ -61,7 +63,15 @@ const CumulativeVol = memo(
/>
) : null;
return (
return onClick && volume ? (
<button
data-testid={testId}
onClick={() => onClick(cumulativeValue)}
className="hover:dark:bg-neutral-800 hover:bg-neutral-200 text-right pr-1"
>
{volume}
</button>
) : (
<div className="pr-1" data-testid={testId}>
{volume}
</div>
@@ -89,7 +99,9 @@ export const OrderbookRow = React.memo(
<PriceCell
testId={`price-${price}`}
value={BigInt(price)}
onClick={() => onClick && onClick(addDecimal(price, decimalPlaces))}
onClick={() =>
onClick && onClick({ price: addDecimal(price, decimalPlaces) })
}
valueFormatted={addDecimalsFixedFormatNumber(price, decimalPlaces)}
className={
type === VolumeType.ask
@@ -97,8 +109,15 @@ export const OrderbookRow = React.memo(
: 'text-market-green-600 dark:text-market-green'
}
/>
<NumericCell
<PriceCell
testId={`${txtId}-vol-${price}`}
onClick={(value) =>
onClick &&
value &&
onClick({
size: addDecimal(value, positionDecimalPlaces),
})
}
value={value}
valueFormatted={addDecimalsFixedFormatNumber(
value,
@@ -107,6 +126,13 @@ export const OrderbookRow = React.memo(
/>
<CumulativeVol
testId={`cumulative-vol-${price}`}
onClick={() =>
onClick &&
cumulativeValue &&
onClick({
size: addDecimal(cumulativeValue, positionDecimalPlaces),
})
}
positionDecimalPlaces={positionDecimalPlaces}
cumulativeValue={cumulativeValue}
/>
+2 -2
View File
@@ -70,7 +70,7 @@ describe('Orderbook', () => {
).toBeInTheDocument();
// Before resolution change the price is 122.934
await fireEvent.click(await screen.getByTestId('price-122901'));
expect(onClickSpy).toBeCalledWith('122.901');
expect(onClickSpy).toBeCalledWith({ price: '122.901' });
const resolutionSelect = screen.getByTestId(
'resolution'
) as HTMLSelectElement;
@@ -86,6 +86,6 @@ describe('Orderbook', () => {
10
);
await fireEvent.click(await screen.getByTestId('price-12294'));
expect(onClickSpy).toBeCalledWith('122.94');
expect(onClickSpy).toBeCalledWith({ price: '122.94' });
});
});
+2 -2
View File
@@ -32,7 +32,7 @@ const OrderbookTable = ({
decimalPlaces: number;
positionDecimalPlaces: number;
type: VolumeType;
onClick?: (price: string) => void;
onClick?: (args: { price?: string; size?: string }) => void;
}) => {
return (
<div
@@ -69,7 +69,7 @@ const OrderbookTable = ({
interface OrderbookProps {
decimalPlaces: number;
positionDecimalPlaces: number;
onClick?: (price: string) => void;
onClick?: (args: { price?: string; size?: string }) => void;
midPrice?: string;
bids: PriceLevelFieldsFragment[];
asks: PriceLevelFieldsFragment[];
+1
View File
@@ -141,6 +141,7 @@ export const createMarketFragment = (
},
__typename: 'TradableInstrument',
},
successorMarketID: null,
__typename: 'Market',
};