Skip to content

Commit

Permalink
data-test -> data-testid
Browse files Browse the repository at this point in the history
  • Loading branch information
mvadari committed Aug 1, 2024
1 parent 8de349b commit ac50fe0
Show file tree
Hide file tree
Showing 104 changed files with 522 additions and 480 deletions.
8 changes: 4 additions & 4 deletions src/containers/Transactions/DetailTab/HookDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const renderHookParameterName = (name: string) => {
const EmitDetails: FC<{ emitDetails: any }> = ({ emitDetails }) => {
const { t } = useTranslation()
return (
<div className="detail-subsection" data-test="emit-details">
<div className="detail-subsection" data-testid="emit-details">
<div className="detail-subtitle">{t('emit_details')}</div>
<li className="detail-line">
<Trans
Expand Down Expand Up @@ -114,17 +114,17 @@ export const HookDetails: FC<{ data: { tx: any; meta: any } }> = ({ data }) => {
if (!tx.EmitDetails && !tx.HookParameters && !meta.HookExecutions) return null

return (
<div className="detail-section" data-test="hooks">
<div className="detail-section" data-testid="hooks">
<div className="title">{t('hooks')}</div>
{tx.EmitDetails && <EmitDetails emitDetails={tx.EmitDetails} />}
{tx.HookParameters && (
<div className="detail-subsection" data-test="hook-params">
<div className="detail-subsection" data-testid="hook-params">
<div className="detail-subtitle">{t('hook_parameters')}</div>
{tx.HookParameters.map(HookParameter)}
</div>
)}
{meta.HookExecutions && (
<div className="detail-subsection" data-test="hook-executions">
<div className="detail-subsection" data-testid="hook-executions">
<div className="detail-subtitle">{t('hook_executions')}</div>
{meta.HookExecutions.map(HookExecution)}
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/containers/Transactions/DetailTab/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const DetailTab: FC<{ data: any }> = ({ data }) => {
}

return (
<div className="detail-section" data-test="status">
<div className="detail-section" data-testid="status">
<div className="title">{t('status')}</div>
{line1}
{t('transaction_validated')}
Expand Down
10 changes: 5 additions & 5 deletions src/containers/Transactions/SimpleTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,29 +44,29 @@ export const SimpleTab: FC<{ data: any; width: number }> = ({
<>
<SimpleRow
label={t('formatted_date', { timeZone: TIME_ZONE })}
data-test="tx-date"
data-testid="tx-date"
>
{time}
</SimpleRow>
<SimpleRow label={t('ledger_index')} data-test="ledger-index">
<SimpleRow label={t('ledger_index')} data-testid="ledger-index">
<RouteLink to={LEDGER_ROUTE} params={{ identifier: ledgerIndex }}>
{ledgerIndex}
</RouteLink>
</SimpleRow>
{account && (
<SimpleRow label={t('account')} data-test="account">
<SimpleRow label={t('account')} data-testid="account">
<Account account={account} />
</SimpleRow>
)}
<SimpleRow label={t('sequence_number')} data-test="sequence">
<SimpleRow label={t('sequence_number')} data-testid="sequence">
<Sequence
sequence={sequence}
ticketSequence={ticketSequence}
account={account}
isHook={isHook}
/>
</SimpleRow>
<SimpleRow label={t('transaction_cost')} data-test="tx-cost">
<SimpleRow label={t('transaction_cost')} data-testid="tx-cost">
{fee}
</SimpleRow>
</>
Expand Down
4 changes: 2 additions & 2 deletions src/containers/Transactions/test/Description.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ describe('Description container', () => {

it('renders sequence number with ticket', () => {
const wrapper = createWrapper(OfferCreateTicket)
expect(wrapper.find(`[data-test="sequence"]`)).toHaveText(
expect(wrapper.find(`[data-testid="sequence"]`)).toHaveText(
'79469284 (a Ticket was used for this Transaction)',
)
wrapper.unmount()
})

it('renders sequence number with hook', () => {
const wrapper = createWrapper(EmittedPayment)
expect(wrapper.find(`[data-test="sequence"]`)).toHaveText(
expect(wrapper.find(`[data-testid="sequence"]`)).toHaveText(
'0 (this Transaction was emitted by a Hook)',
)
wrapper.unmount()
Expand Down
34 changes: 18 additions & 16 deletions src/containers/Transactions/test/DetailTab.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,32 +51,34 @@ describe('DetailTab container', () => {

it('renders failed transaction', () => {
const wrapper = createWrapper(FailedTransaction)
expect(wrapper.find('.detail-section[data-test="status"]').text()).toEqual(
expect(
wrapper.find('.detail-section[data-testid="status"]').text(),
).toEqual(
expect.stringContaining(
'This transaction failed with a status code of tecINSUFFICIENT_RESERVE, and validated in ledger 37375929 on',
),
)
expect(
wrapper.find('.detail-section[data-test="status"] .fail').text(),
wrapper.find('.detail-section[data-testid="status"] .fail').text(),
).toEqual('tecINSUFFICIENT_RESERVE')
wrapper.unmount()
})

it('renders hooks section', () => {
const wrapper = createWrapper(HookPayment)
expect(wrapper.find('.detail-section[data-test="hooks"]')).toHaveLength(1)
expect(wrapper.find('.detail-section[data-testid="hooks"]')).toHaveLength(1)

const hooksWrapper = wrapper.find('.detail-section[data-test="hooks"]')
const hooksWrapper = wrapper.find('.detail-section[data-testid="hooks"]')

expect(
hooksWrapper.find('.detail-subsection[data-test="emit-details"]'),
hooksWrapper.find('.detail-subsection[data-testid="emit-details"]'),
).toHaveLength(0)

expect(
hooksWrapper.find('.detail-subsection[data-test="hook-params"]'),
hooksWrapper.find('.detail-subsection[data-testid="hook-params"]'),
).toHaveLength(1)
const paramWrapper = hooksWrapper.find(
'.detail-subsection[data-test="hook-params"]',
'.detail-subsection[data-testid="hook-params"]',
)
expect(paramWrapper.find('li')).toHaveLength(2)
expect(paramWrapper.find('li').at(0)).toHaveText('EVR2: evnHostUpdateReg')
Expand All @@ -85,10 +87,10 @@ describe('DetailTab container', () => {
)

expect(
hooksWrapper.find('.detail-subsection[data-test="hook-executions"]'),
hooksWrapper.find('.detail-subsection[data-testid="hook-executions"]'),
).toHaveLength(1)
const execWrapper = hooksWrapper.find(
'.detail-subsection[data-test="hook-executions"]',
'.detail-subsection[data-testid="hook-executions"]',
)
expect(execWrapper.find('li')).toHaveLength(1)
expect(execWrapper.find('.detail-line')).toHaveLength(4)
Expand All @@ -111,15 +113,15 @@ describe('DetailTab container', () => {

it('renders hooks section for emitted tx', () => {
const wrapper = createWrapper(EmittedPayment)
expect(wrapper.find('.detail-section[data-test="hooks"]')).toHaveLength(1)
expect(wrapper.find('.detail-section[data-testid="hooks"]')).toHaveLength(1)

const hooksWrapper = wrapper.find('.detail-section[data-test="hooks"]')
const hooksWrapper = wrapper.find('.detail-section[data-testid="hooks"]')

expect(
hooksWrapper.find('.detail-subsection[data-test="emit-details"]'),
hooksWrapper.find('.detail-subsection[data-testid="emit-details"]'),
).toHaveLength(1)
const emitWrapper = hooksWrapper.find(
'.detail-subsection[data-test="emit-details"]',
'.detail-subsection[data-testid="emit-details"]',
)
expect(emitWrapper.find('.detail-line')).toHaveLength(4)
expect(emitWrapper.find('.detail-line').at(0)).toHaveText(
Expand All @@ -138,14 +140,14 @@ describe('DetailTab container', () => {
expect(emitWrapper.find('.detail-line').at(3).find('a')).toExist()

expect(
hooksWrapper.find('.detail-subsection[data-test="hook-params"]'),
hooksWrapper.find('.detail-subsection[data-testid="hook-params"]'),
).toHaveLength(0)

expect(
hooksWrapper.find('.detail-subsection[data-test="hook-executions"]'),
hooksWrapper.find('.detail-subsection[data-testid="hook-executions"]'),
).toHaveLength(1)
const execWrapper = hooksWrapper.find(
'.detail-subsection[data-test="hook-executions"]',
'.detail-subsection[data-testid="hook-executions"]',
)
expect(execWrapper.find('li')).toHaveLength(1)
expect(execWrapper.find('.detail-line')).toHaveLength(4)
Expand Down
4 changes: 2 additions & 2 deletions src/containers/Validators/Simple/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const Simple = ({ data }: SimpleProps) => {
label: string,
) =>
d ? (
<div className="row" data-test={`score-${className}`}>
<div className="row" data-testid={`score-${className}`}>
<div className="label">{label}</div>
<div
className={`value ${className} score`}
Expand All @@ -34,7 +34,7 @@ const Simple = ({ data }: SimpleProps) => {
return (
<>
<SimpleRow label={t('domain')}>{data.domain || 'Unknown'}</SimpleRow>
<SimpleRow label={t('rippled_version')} data-test="version">
<SimpleRow label={t('rippled_version')} data-testid="version">
{data.server_version}
</SimpleRow>
<div className="row">
Expand Down
4 changes: 2 additions & 2 deletions src/containers/Validators/SimpleTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ export const SimpleTab: FC<{
label={`Last Ledger ${t('formatted_date', {
timeZone: TIME_ZONE,
})}`}
data-test="ledger-time"
data-testid="ledger-time"
>
{localizeDate(new Date(lastLedgerTime), language, DATE_OPTIONS)}
</SimpleRow>
)}
{ledgerIndex && (
<SimpleRow
label={`Last ${t('ledger_index')}`}
data-test="ledger-index"
data-testid="ledger-index"
>
<RouteLink to={LEDGER_ROUTE} params={{ identifier: ledgerIndex }}>
{ledgerIndex}
Expand Down
4 changes: 2 additions & 2 deletions src/containers/Validators/test/Validator.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,10 @@ describe('Validator container', () => {
expect(getLedger).toBeCalledWith('12345', undefined)
expect(document.title).toBe('Validator test.example.com')
// test ledger-time isn't updated
const lastLedgerDateTime = wrapper.find(`[data-test="ledger-time"]`)
const lastLedgerDateTime = wrapper.find(`[data-testid="ledger-time"]`)
expect(lastLedgerDateTime).not.toExist()
// test ledger-index stays the same
const lastLedgerIndex = wrapper.find(`[data-test="ledger-index"]`)
const lastLedgerIndex = wrapper.find(`[data-testid="ledger-index"]`)
expect(lastLedgerIndex).toExist()
expect(lastLedgerIndex.find('.value')).toHaveText('12345')
wrapper.unmount()
Expand Down
2 changes: 1 addition & 1 deletion src/containers/shared/components/Sequence.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const Sequence: FC<SequenceProps> = ({
return (
<span>
{sequence === 0 && !isPseudoTransaction ? (
<span className="row" data-test="sequence">
<span className="row" data-testid="sequence">
{ticketSequence}
{' ('}
{getContext()})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ export const Simple = ({ data }: TransactionSimpleProps) => {
return (
<>
{ammAccountID && (
<SimpleRow label={t('amm_account_id')} data-test="account_id">
<SimpleRow label={t('amm_account_id')} data-testid="account_id">
<Account account={ammAccountID} />
</SimpleRow>
)}
{bidMin && (
<SimpleRow label={t('min_slot_price')} data-test="min_slot_price">
<SimpleRow label={t('min_slot_price')} data-testid="min_slot_price">
<Amount value={bidMin} />
</SimpleRow>
)}
{bidMax && (
<SimpleRow label={t('max_slot_price')} data-test="max_slot_price">
<SimpleRow label={t('max_slot_price')} data-testid="max_slot_price">
<Amount value={bidMax} />
</SimpleRow>
)}
{authAccounts && (
<SimpleRow label={t('auth_accounts')} data-test="auth_accounts">
<SimpleRow label={t('auth_accounts')} data-testid="auth_accounts">
{authAccounts.map((accID: string) => (
<Account account={accID} />
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@ export const Simple = ({ data }: TransactionSimpleProps) => {
return (
<>
{ammAccountID && (
<SimpleRow label={t('amm_account_id')} data-test="account_id">
<SimpleRow label={t('amm_account_id')} data-testid="account_id">
<Account account={ammAccountID} />
</SimpleRow>
)}
{amount && (
<SimpleRow label={t('asset1')} data-test="asset1">
<SimpleRow label={t('asset1')} data-testid="asset1">
<Amount value={amount} />
</SimpleRow>
)}
{amount2 && (
<SimpleRow label={t('asset2')} data-test="asset2">
<SimpleRow label={t('asset2')} data-testid="asset2">
<Amount value={amount2} />
</SimpleRow>
)}
{tf && (
<SimpleRow label={t('trading_fee')} data-test="trading_fee">
<SimpleRow label={t('trading_fee')} data-testid="trading_fee">
{tf}%
</SimpleRow>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const Description = ({
const { Asset, Asset2 } = data.tx

return (
<div data-test="amm-delete-description">
<div data-testid="amm-delete-description">
<Trans
i18nKey="amm_delete_description"
components={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ export const Simple = ({ data }: TransactionSimpleProps<AMMDelete>) => {

return (
<>
<SimpleRow label={t('asset1')} data-test="asset1">
<SimpleRow label={t('asset1')} data-testid="asset1">
<Currency currency={Asset.currency} issuer={Asset.issuer} />
</SimpleRow>
<SimpleRow label={t('asset2')} data-test="asset2">
<SimpleRow label={t('asset2')} data-testid="asset2">
<Currency currency={Asset2.currency} issuer={Asset2.issuer} />
</SimpleRow>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ export const TableDetail = ({

return (
<div className="ammDelete">
<div data-test="asset">
<div data-testid="asset">
<span className="label">{t('asset1')}</span>
<Currency currency={Asset.currency} issuer={(Asset as any).issuer} />
</div>
<div data-test="asset2">
<div data-testid="asset2">
<span className="label">{t('asset2')}</span>
<Currency currency={Asset2.currency} issuer={(Asset2 as any).issuer} />
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('AMMDelete: Description', () => {
it('renders description for AMMDelete transaction', () => {
const wrapper = createWrapper(mockAMMDelete)

expect(wrapper.find('[data-test="amm-delete-description"]')).toHaveText(
expect(wrapper.find('[data-testid="amm-delete-description"]')).toHaveText(
'Attempted to delete the AMM for \uE900 XRP and FOO.rm5c42Crqpdch5fbuCdHmSMV1wrL9arV9.If there were more than 512 trustlines, this only removes 512 trustlines instead.',
)
expect(wrapper.find('a')).toHaveProp(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ describe('AMMDelete: TableDetail', () => {
it('renders with an expiration and offer', () => {
const wrapper = createWrapper(mockAMMDelete)

expect(wrapper.find('[data-test="asset"]')).toHaveText('Asset 1\uE900 XRP')
expect(wrapper.find('[data-test="asset2"]')).toHaveText(
expect(wrapper.find('[data-testid="asset"]')).toHaveText(
'Asset 1\uE900 XRP',
)
expect(wrapper.find('[data-testid="asset2"]')).toHaveText(
'Asset 2FOO.rm5c42Crqpdch5fbuCdHmSMV1wrL9arV9',
)
wrapper.unmount()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,27 @@ export const Simple = ({ data }: TransactionSimpleProps) => {
return (
<>
{ammAccountID && (
<SimpleRow label={t('amm_account_id')} data-test="account_id">
<SimpleRow label={t('amm_account_id')} data-testid="account_id">
<Account account={ammAccountID} />
</SimpleRow>
)}
{amount && (
<SimpleRow label={t('asset1in')} data-test="asset1">
<SimpleRow label={t('asset1in')} data-testid="asset1">
<Amount value={amount} />
</SimpleRow>
)}
{amount2 && (
<SimpleRow label={t('asset2in')} data-test="asset2">
<SimpleRow label={t('asset2in')} data-testid="asset2">
<Amount value={amount2} />
</SimpleRow>
)}
{ePrice && (
<SimpleRow label={t('effective_price')} data-test="effective_price">
<SimpleRow label={t('effective_price')} data-testid="effective_price">
<Amount value={ePrice} />
</SimpleRow>
)}
{lpTokenFormatted && (
<SimpleRow label={t('lp_tokens')} data-test="lp_tokens">
<SimpleRow label={t('lp_tokens')} data-testid="lp_tokens">
{lpTokenFormatted}
</SimpleRow>
)}
Expand Down
Loading

0 comments on commit ac50fe0

Please sign in to comment.