Skip to content

Commit

Permalink
merged back master
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Hatch committed Dec 21, 2023
2 parents bd2a465 + d4e6912 commit fa169ef
Show file tree
Hide file tree
Showing 30 changed files with 5,645 additions and 6,731 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
plugins: ['prettier'],
overrides: [
{
files: ['*.ts', '*.tsx', '*.js'],
files: ['*.ts', '*.tsx', '*.js', 'json'],
parser: '@typescript-eslint/parser',
},
],
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ jobs:

steps:
- uses: actions/checkout@v3

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- run: npm ci
- run: npm run build --if-present
# - run: npm test

# - name: Test Report
# uses: dorny/test-reporter@v1
# if: success() || failure() # run this step even if previous step failed
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ or
You can run test with Jest Preview with the following command. You can see the result at <http://locahost:3336> for test using React Testing Library along with Jest Preview.

```sh
npm test:preview
npm run test:preview
```

or
Expand Down
9 changes: 8 additions & 1 deletion app/components/Effect.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as Sentry from '@sentry/remix'
import type { ServerApi } from 'stellar-sdk'

import { FormattedMessage } from 'react-intl'
Expand Down Expand Up @@ -122,7 +123,13 @@ const Data = ({ op, type }: any) => {
<span title={op.name}>{truncate(op.name)}</span>
</div>

{type !== 'data_removed' && (
{/* logging and workaround for issue seen on testnet where the value was undefined and it crashed */}
{op.value === undefined &&
Sentry.captureMessage(
`op.value undefined for op ${JSON.stringify(op)}`,
)}

{type !== 'data_removed' && op.value && (
<div>
<FormattedMessage id="value" />
{': '}
Expand Down
92 changes: 0 additions & 92 deletions app/components/operations/__tests__/ManageData.test.js

This file was deleted.

54 changes: 54 additions & 0 deletions app/components/operations/__tests__/ManageData.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { render, screen } from '@testing-library/react'
import enTranslation from '../../../lib/languages/en.json'
import zhHansTranslation from '../../../lib/languages/zh-Hans.json'

import { IntlProvider } from 'react-intl'

import ManageData from '../ManageData'

describe('ManageData', () => {
it('decodes ordinary string values', () => {
render(
<IntlProvider locale="en" messages={enTranslation}>
<ManageData name="lang" value="aW5kb25lc2lhbg==" />
</IntlProvider>,
)

expect(
screen.getByText((content) => {
return content.includes('indonesian')
}),
).toBeInTheDocument()
})

it('decodes utf8 string values', () => {
render(
<IntlProvider locale="zh-CN" messages={zhHansTranslation}>
<ManageData name="utf8value" value="6ams6ams6JmO6JmO" />
</IntlProvider>,
)

expect(
screen.getByText((content) => {
return content.includes('马马虎虎')
}),
).toBeInTheDocument()
})

it('truncates a long key and long value', () => {
const aLongPrefix = 'some_really_long_12345678901234567890123456789'
const aLongName = `name_${aLongPrefix}`
const aLongValue = Buffer.from(`value_${aLongPrefix}`).toString('base64')
render(
<IntlProvider locale="en" messages={enTranslation}>
<ManageData name={aLongName} value={aLongValue} />
</IntlProvider>,
)

expect(
screen.getByText((content) => {
return content.includes('value_some_really_long_1234...')
}),
).toBeInTheDocument()
})
})
69 changes: 0 additions & 69 deletions app/components/shared/__tests__/AccountLink.test.js

This file was deleted.

52 changes: 52 additions & 0 deletions app/components/shared/__tests__/AccountLink.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { render, screen } from '@testing-library/react'
import { BrowserRouter } from 'react-router-dom'

import type { KnownAccountProps } from '../../../data/known_accounts'
import knownAccounts from '../../../data/known_accounts'
import AccountLink, { BaseAccountLink } from '../AccountLink'

interface TKnownAccountProps extends KnownAccountProps {
displayName: string
}

const ACC_KNOWN = Object.keys(knownAccounts).find(
(key) => (knownAccounts[key] as TKnownAccountProps).displayName === 'NaoBTC',
) as string
const ACC_UNKNOWN = 'GCGG3CIRBG2TTBR4HYZJ7JLDRFKZIYOAHFXRWLU62CA2QN52P2SUQNPJ'
const LABEL = 'Anchor'

describe('AccountLink', () => {
it('renders with label', () => {
render(
<BrowserRouter>
<AccountLink label={LABEL} account={ACC_UNKNOWN} />
</BrowserRouter>,
)

expect(screen.getByText(LABEL)).toBeInTheDocument()
})

it('renders short account for label when no label property', () => {
render(
<BrowserRouter>
<AccountLink account={ACC_UNKNOWN} />
</BrowserRouter>,
)

expect(screen.getByText(ACC_UNKNOWN.slice(0, 4))).toBeInTheDocument()
})

it('renders anchor name in italics if account a known anchor', () => {
render(
<BrowserRouter>
<BaseAccountLink label={''} address={ACC_KNOWN} hideKnown={false} />
</BrowserRouter>,
)

expect(screen.getByText('NaoBTC')).toBeInTheDocument()
})
})

describe('MuxedAccount', () => {
it.todo('muxed account renders muxed and base')
})
Loading

0 comments on commit fa169ef

Please sign in to comment.