-
-
-
YOUR BALANCE
-
{shiftDigits(balance, -exponent)}
-
-
-
EXPONENT
-
{denom?.denom_units[1]?.exponent}
-
-
-
CIRCULATING SUPPLY
-
{denom.display}
-
+
+
+
+
YOUR BALANCE
+
{shiftDigits(balance, -exponent)}
+
+
+
EXPONENT
+
{denom?.denom_units[1]?.exponent}
+
+
+
CIRCULATING SUPPLY
+
{denom.display}
-
-
-
-
setAmount(e.target.value)}
- />
-
-
-
-
- setRecipient(e.target.value)}
- />
+
+
{
+ setAmount(values.amount);
+ setRecipient(values.recipient);
+ handleMint();
+ }}
+ validateOnChange={true}
+ validateOnBlur={true}
+ >
+ {({ isValid, dirty, setFieldValue, errors, touched }) => (
+
-
- >
-
-
- {isMFX && (
-
+
)}
- setIsModalOpen(false)}
- payoutPairs={payoutPairs}
- updatePayoutPair={updatePayoutPair}
- addPayoutPair={addPayoutPair}
- removePayoutPair={removePayoutPair}
- handleMultiMint={handleMultiMint}
- isSigning={isSigning}
- />
-
+
+
setIsModalOpen(false)}
+ payoutPairs={payoutPairs}
+ updatePayoutPair={updatePayoutPair}
+ addPayoutPair={addPayoutPair}
+ removePayoutPair={removePayoutPair}
+ handleMultiMint={handleMultiMint}
+ isSigning={isSigning}
+ />
>
)}
diff --git a/components/factory/forms/__tests__/BurnForm.test.tsx b/components/factory/forms/__tests__/BurnForm.test.tsx
index ed13301..07fc43a 100644
--- a/components/factory/forms/__tests__/BurnForm.test.tsx
+++ b/components/factory/forms/__tests__/BurnForm.test.tsx
@@ -1,6 +1,6 @@
import { describe, test, afterEach, expect, jest } from 'bun:test';
import React from 'react';
-import { screen, fireEvent, cleanup } from '@testing-library/react';
+import { screen, fireEvent, cleanup, waitFor } from '@testing-library/react';
import BurnForm from '@/components/factory/forms/BurnForm';
import matchers from '@testing-library/jest-dom/matchers';
import { mockDenomMeta1, mockMfxDenom } from '@/tests/mock';
@@ -44,18 +44,40 @@ describe('BurnForm Component', () => {
).toBeInTheDocument();
});
- test('updates amount input correctly', () => {
+ test('updates amount input correctly', async () => {
renderWithProps();
- const amountInput = screen.getByPlaceholderText('Enter amount');
+ const amountInput = screen.getByLabelText('burn-amount-input');
fireEvent.change(amountInput, { target: { value: '100' } });
- expect(amountInput).toHaveValue('100');
+ await waitFor(() => {
+ expect(amountInput).toHaveValue(100);
+ });
});
- test('updates recipient input correctly', () => {
+ test('burn button is disabled when inputs are invalid', async () => {
renderWithProps();
+ const burnButton = screen.getByLabelText('burn-target-input');
+ expect(burnButton).toBeDisabled();
+
+ const amountInput = screen.getByPlaceholderText('Enter amount');
+ fireEvent.change(amountInput, { target: { value: '-100' } });
+
+ await waitFor(() => {
+ expect(burnButton).toBeDisabled();
+ });
+ });
+
+ test('burn button is enabled when inputs are valid', async () => {
+ renderWithProps();
+ const amountInput = screen.getByPlaceholderText('Enter amount');
const recipientInput = screen.getByPlaceholderText('Target address');
+ const burnButton = screen.getByText('Burn');
+
+ fireEvent.change(amountInput, { target: { value: '100' } });
fireEvent.change(recipientInput, { target: { value: 'cosmos1recipient' } });
- expect(recipientInput).toHaveValue('cosmos1recipient');
+
+ await waitFor(() => {
+ expect(burnButton).toBeEnabled();
+ });
});
// // TODO: Make this test pass
diff --git a/components/factory/forms/__tests__/MintForm.test.tsx b/components/factory/forms/__tests__/MintForm.test.tsx
index fe666ca..e59d663 100644
--- a/components/factory/forms/__tests__/MintForm.test.tsx
+++ b/components/factory/forms/__tests__/MintForm.test.tsx
@@ -1,10 +1,10 @@
import { describe, test, afterEach, expect, jest } from 'bun:test';
import React from 'react';
-import { screen, fireEvent, cleanup } from '@testing-library/react';
+import { screen, fireEvent, cleanup, waitFor } from '@testing-library/react';
import MintForm from '@/components/factory/forms/MintForm';
import matchers from '@testing-library/jest-dom/matchers';
import { renderWithChainProvider } from '@/tests/render';
-import { mockDenomMeta1 } from '@/tests/mock';
+import { mockDenomMeta1, mockMfxDenom } from '@/tests/mock';
expect.extend(matchers);
@@ -17,49 +17,77 @@ const mockProps = {
balance: '1000000',
};
+function renderWithProps(props = {}) {
+ return renderWithChainProvider(
);
+}
+
describe('MintForm Component', () => {
afterEach(cleanup);
test('renders form with correct details', () => {
- renderWithChainProvider(
);
+ renderWithProps();
expect(screen.getByText('NAME')).toBeInTheDocument();
expect(screen.getByText('YOUR BALANCE')).toBeInTheDocument();
expect(screen.getByText('EXPONENT')).toBeInTheDocument();
expect(screen.getByText('CIRCULATING SUPPLY')).toBeInTheDocument();
});
- test('updates amount input correctly', () => {
- renderWithChainProvider(
);
+ test('updates amount input correctly', async () => {
+ renderWithProps();
const amountInput = screen.getByLabelText('mint-amount-input');
fireEvent.change(amountInput, { target: { value: '100' } });
- expect(amountInput).toHaveValue('100');
+ await waitFor(() => {
+ expect(amountInput).toHaveValue(100);
+ });
});
- test('updates recipient input correctly', () => {
- renderWithChainProvider(
);
- const recipientInput = screen.getByLabelText('mint-recipient-input');
+ test('updates recipient input correctly', async () => {
+ renderWithProps();
+ const recipientInput = screen.getByPlaceholderText('Recipient address');
fireEvent.change(recipientInput, { target: { value: 'cosmos1recipient' } });
- expect(recipientInput).toHaveValue('cosmos1recipient');
+ await waitFor(() => {
+ expect(recipientInput).toHaveValue('cosmos1recipient');
+ });
});
- // TODO: Button is disabled when inputs are invalid
- // test('mint button is disabled when inputs are invalid', () => {
- // renderWithChainProvider(
);
- // const mintButton = screen.getByText('Mint');
- // expect(mintButton).toBeDisabled();
- // });
- //
- // TODO: Button is enabled when inputs are valid
- // Fix values validation in the component, this test should not pass as-is
- test('mint button is enabled when inputs are valid', () => {
- renderWithChainProvider(
);
- fireEvent.change(screen.getByLabelText('mint-amount-input'), {
- target: { value: '100' },
- });
- fireEvent.change(screen.getByLabelText('mint-recipient-input'), {
- target: { value: 'cosmos1recipient' },
+ test('mint button is disabled when inputs are invalid', async () => {
+ renderWithProps();
+ const mintButton = screen.getByText('Mint');
+ expect(mintButton).toBeDisabled();
+
+ const amountInput = screen.getByLabelText('mint-amount-input');
+ fireEvent.change(amountInput, { target: { value: '-100' } });
+
+ await waitFor(() => {
+ expect(mintButton).toBeDisabled();
});
+ });
+
+ test('mint button is enabled when inputs are valid', async () => {
+ renderWithProps();
+ const amountInput = screen.getByLabelText('mint-amount-input');
+ const recipientInput = screen.getByLabelText('mint-recipient-input');
const mintButton = screen.getByText('Mint');
- expect(mintButton).toBeEnabled();
+
+ fireEvent.change(amountInput, { target: { value: '1' } });
+ fireEvent.change(recipientInput, {
+ target: { value: 'manifest1aucdev30u9505dx9t6q5fkcm70sjg4rh7rn5nf' },
+ });
+
+ await waitFor(() => {
+ expect(mintButton).toBeEnabled();
+ });
+ });
+
+ test('renders multi mint button when token is mfx', () => {
+ renderWithProps({ denom: mockMfxDenom });
+ expect(screen.getByLabelText('multi-mint-button')).toBeInTheDocument();
+ });
+
+ test('renders not affiliated message when not admin and token is mfx', () => {
+ renderWithProps({ isAdmin: false, denom: mockMfxDenom });
+ expect(
+ screen.getByText('You are not affiliated with any PoA Admin entity.')
+ ).toBeInTheDocument();
});
});
diff --git a/components/groups/forms/groups/MemberInfoForm.tsx b/components/groups/forms/groups/MemberInfoForm.tsx
index b18b769..920683a 100644
--- a/components/groups/forms/groups/MemberInfoForm.tsx
+++ b/components/groups/forms/groups/MemberInfoForm.tsx
@@ -192,21 +192,18 @@ export default function MemberInfoForm({
-