fix: lock widths of market table cells - make it durable for long values (#2360)

This commit is contained in:
macqbat 2022-12-08 12:30:05 +01:00 committed by GitHub
parent 088c399b9f
commit 19c1f2f8c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 41 additions and 11 deletions

View File

@ -1,6 +1,7 @@
import { aliasQuery } from '@vegaprotocol/cypress'; import { aliasQuery } from '@vegaprotocol/cypress';
import type { ProposalListFieldsFragment } from '@vegaprotocol/governance'; import type { ProposalListFieldsFragment } from '@vegaprotocol/governance';
import { Schema } from '@vegaprotocol/types'; import { Schema } from '@vegaprotocol/types';
import { generateMarketsData } from '../support/mocks/generate-markets';
const selectMarketOverlay = 'select-market-list'; const selectMarketOverlay = 'select-market-list';
@ -52,7 +53,6 @@ describe('home', { tags: '@regression' }, () => {
beforeEach(() => { beforeEach(() => {
cy.mockTradingPage(); cy.mockTradingPage();
cy.mockGQLSubscription(); cy.mockGQLSubscription();
cy.visit('/');
}); });
describe('default market found', () => { describe('default market found', () => {
@ -86,7 +86,6 @@ describe('home', { tags: '@regression' }, () => {
}); });
} }
}); });
cy.getByTestId('dialog-close').click(); cy.getByTestId('dialog-close').click();
cy.getByTestId(selectMarketOverlay).should('not.exist'); cy.getByTestId(selectMarketOverlay).should('not.exist');
@ -97,6 +96,36 @@ describe('home', { tags: '@regression' }, () => {
}); });
}); });
describe('market table should properly rendered', () => {
it('redirects to a default market with the landing dialog open', () => {
const override = {
marketsConnection: {
edges: [
{
node: {
data: {
markPrice: '46126900581221212121212121212121212121212121212',
},
},
},
],
},
};
const data = generateMarketsData(override);
cy.mockGQL((req) => {
aliasQuery(req, 'MarketsData', data);
});
cy.visit('/');
cy.wait('@Market');
cy.getByTestId(selectMarketOverlay)
.get('table')
.invoke('outerWidth')
.then((value) => {
expect(value).to.be.closeTo(554, 10);
});
});
});
describe('no markets found', () => { describe('no markets found', () => {
it('redirects to a the empty market page and displays welcome notice', () => { it('redirects to a the empty market page and displays welcome notice', () => {
cy.mockGQL((req) => { cy.mockGQL((req) => {

View File

@ -25,7 +25,8 @@ import { Last24hVolume } from '../last-24h-volume';
type Market = MarketWithData & MarketWithCandles; type Market = MarketWithData & MarketWithCandles;
export const cellClassNames = 'py-1 first:text-left text-right'; const ellipsisClasses = 'whitespace-nowrap overflow-hidden text-ellipsis';
export const cellClassNames = `py-1 first:text-left text-right ${ellipsisClasses}`;
const FeesInfo = () => { const FeesInfo = () => {
return ( return (
@ -82,7 +83,7 @@ const headers: Column[] = [
{ {
kind: ColumnKind.ProductType, kind: ColumnKind.ProductType,
value: t('Type'), value: t('Type'),
className: `py-2 text-left hidden sm:table-cell`, className: 'py-2 text-left hidden sm:table-cell',
onlyOnDetailed: false, onlyOnDetailed: false,
}, },
{ {
@ -204,13 +205,13 @@ export const columns = (
<UILink>{market.tradableInstrument.instrument.code}</UILink> <UILink>{market.tradableInstrument.instrument.code}</UILink>
</Link> </Link>
), ),
className: cellClassNames, className: `${cellClassNames} max-w-[110px]`,
onlyOnDetailed: false, onlyOnDetailed: false,
}, },
{ {
kind: ColumnKind.ProductType, kind: ColumnKind.ProductType,
value: market.tradableInstrument.instrument.product.__typename, value: market.tradableInstrument.instrument.product.__typename,
className: `py-2 text-left hidden sm:table-cell`, className: `py-2 text-left hidden sm:table-cell max-w-[50px] ${ellipsisClasses}`,
onlyOnDetailed: false, onlyOnDetailed: false,
}, },
{ {
@ -223,7 +224,7 @@ export const columns = (
noUpdate={noUpdate} noUpdate={noUpdate}
/> />
), ),
className: cellClassNames, className: `${cellClassNames} max-w-[100px]`,
onlyOnDetailed: false, onlyOnDetailed: false,
}, },
{ {
@ -236,7 +237,7 @@ export const columns = (
initialValue={candlesClose} initialValue={candlesClose}
/> />
), ),
className: cellClassNames, className: `${cellClassNames} max-w-[150px]`,
onlyOnDetailed: false, onlyOnDetailed: false,
}, },
{ {
@ -249,7 +250,7 @@ export const columns = (
data={candlesClose?.map((c: string) => Number(c)) || []} data={candlesClose?.map((c: string) => Number(c)) || []}
/> />
), ),
className: `${cellClassNames} hidden lg:table-cell`, className: `${cellClassNames} hidden lg:table-cell max-w-[80px]`,
onlyOnDetailed: false && candlesClose, onlyOnDetailed: false && candlesClose,
}, },
{ {
@ -271,7 +272,7 @@ export const columns = (
</button> </button>
), ),
dataTestId: 'settlement-asset', dataTestId: 'settlement-asset',
className: `${cellClassNames} hidden sm:table-cell`, className: `${cellClassNames} hidden sm:table-cell max-w-[100px]`,
onlyOnDetailed: false, onlyOnDetailed: false,
}, },
{ {

View File

@ -44,7 +44,7 @@ export const PriceCellChange = React.memo(
<span <span
className={`${signedNumberCssClass( className={`${signedNumberCssClass(
change change
)} flex items-center gap-2 font-mono text-ui-small`} )} flex items-center gap-2 justify-end font-mono text-ui-small`}
> >
<Arrow value={change} /> <Arrow value={change} />
<span data-testid="price-change-percentage"> <span data-testid="price-change-percentage">