Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Build

on: pull_request

jobs:
build:
name: Build
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up NodeJS
uses: actions/setup-node@v4
with:
node-version: 'lts/Iron'
check-latest: true

- name: Install dependencies
run: npm ci

- name: Build
run: npm run build
24 changes: 24 additions & 0 deletions src/views/manualAccount/ManualAccountForm-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const accountTypeButtonName: Record<number, string> = {
[AccountTypes.SAVINGS]: 'Savings',
[AccountTypes.LOAN]: 'Loan',
[AccountTypes.CREDIT_CARD]: 'Credit Card',
[AccountTypes.PROPERTY]: 'Property',
}

const buildMockApi = (apiOverrides: Partial<typeof baseApiValue> = {}) => ({
Expand Down Expand Up @@ -111,6 +112,17 @@ describe('<ManualAccountForm />', () => {

expect(screen.getByLabelText(/interest rate/i)).toBeInTheDocument()
})

it('renders the property type select field and allows selecting a value', async () => {
const { user } = await renderManualAccountForm({ accountType: AccountTypes.PROPERTY })

expect(screen.getByLabelText(/property type/i)).toBeInTheDocument()
Comment thread
wesrisenmay-mx marked this conversation as resolved.

await user.click(screen.getByLabelText(/property type/i))
await user.click(await screen.findByRole('option', { name: 'Vehicle' }))

expect(screen.getByRole('combobox', { name: /property type/i })).toHaveTextContent('Vehicle')
Comment thread
mwclemy marked this conversation as resolved.
})
})

describe('Personal and Business Selection', () => {
Expand Down Expand Up @@ -172,6 +184,18 @@ describe('<ManualAccountForm />', () => {
expect((await screen.findAllByText(/is required/i)).length).toBeGreaterThan(0)
expect(mockApi.createAccount).not.toHaveBeenCalled()
})

it('shows a required error for property type when saving without selecting a value', async () => {
const { user, mockApi } = await renderManualAccountForm({
accountType: AccountTypes.PROPERTY,
})

await user.type(screen.getByLabelText(/account name/i), 'My Property')
await user.click(screen.getByTestId('save-manual-account-button'))

expect(await screen.findByText('Property type is required')).toBeInTheDocument()
expect(mockApi.createAccount).not.toHaveBeenCalled()
})
})

describe('Form Submission', () => {
Expand Down
24 changes: 17 additions & 7 deletions src/views/manualAccount/ManualAccountForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import _startsWith from 'lodash/startsWith'
import _isEmpty from 'lodash/isEmpty'

import Button from '@mui/material/Button'
import MenuItem from '@mui/material/MenuItem'
import { Text } from '@mxenabled/mxui'
import { MessageBox } from '@kyper/messagebox'
import { useTokens } from '@kyper/tokenprovider'
import { Select, SelectionBox, TextField } from 'src/privacy/input'
import { SelectionBox, TextField } from 'src/privacy/input'

import { __ } from 'src/utilities/Intl'
import { fadeOut } from 'src/utilities/Animation'
Expand Down Expand Up @@ -307,15 +308,24 @@ export const ManualAccountForm = React.forwardRef<HTMLInputElement, ManualAccoun
} else if (field.type === 'Select') {
return (
<div key={i} style={styles.selectInput}>
<Select
data-test="select-input"
errorText={errors[field.name]}
items={field.options}
<TextField
Comment thread
mwclemy marked this conversation as resolved.
error={!!errors[field.name]}
fullWidth={true}
helperText={errors[field.name]}
inputProps={{ 'data-test': 'select-input' }}
label={field.label}
name={field.name}
onChange={handleTextInputChange}
placeholder={__('Select a value')}
/>
required={field.validation?.required || false}
select={true}
value={values[field.name]}
>
{field.options?.map((option) => (
<MenuItem key={option.value} value={option.value}>
{option.label}
</MenuItem>
))}
</TextField>
</div>
)
} else {
Expand Down
Loading