diff --git a/components/bank/components/__tests__/historyBox.test.tsx b/components/bank/components/__tests__/historyBox.test.tsx index 68108daf..602e4182 100644 --- a/components/bank/components/__tests__/historyBox.test.tsx +++ b/components/bank/components/__tests__/historyBox.test.tsx @@ -41,7 +41,6 @@ describe('HistoryBox', () => { totalPages={2} /> ); - expect(screen.getByText('Transaction History')).toBeInTheDocument(); }); test('displays transactions', () => { diff --git a/components/bank/components/__tests__/tokenList.test.tsx b/components/bank/components/__tests__/tokenList.test.tsx index 9d2fed84..30cb698c 100644 --- a/components/bank/components/__tests__/tokenList.test.tsx +++ b/components/bank/components/__tests__/tokenList.test.tsx @@ -71,7 +71,7 @@ describe('TokenList', () => { pageSize={1} /> ); - expect(screen.getByText('Your Assets')).toBeInTheDocument(); + expect(screen.getByText('utoken1')).toBeInTheDocument(); }); test('displays loading skeleton when isLoading is true', () => { @@ -111,11 +111,9 @@ describe('TokenList', () => { refetchHistory={jest.fn()} address={''} pageSize={1} + searchTerm={'Token 1'} /> ); - const searchInput = screen.getByPlaceholderText('Search for a token...'); - fireEvent.change(searchInput, { target: { value: 'Token 1' } }); - expect(screen.getByText('Token 1')).toBeInTheDocument(); expect(screen.queryByText('Token 2')).not.toBeInTheDocument(); }); diff --git a/components/factory/components/__tests__/MyDenoms.test.tsx b/components/factory/components/__tests__/MyDenoms.test.tsx index 52a414e4..7999fa45 100644 --- a/components/factory/components/__tests__/MyDenoms.test.tsx +++ b/components/factory/components/__tests__/MyDenoms.test.tsx @@ -4,7 +4,7 @@ import { screen, cleanup, fireEvent, waitFor } from '@testing-library/react'; import DenomList from '@/components/factory/components/DenomList'; import matchers from '@testing-library/jest-dom/matchers'; import { renderWithChainProvider } from '@/tests/render'; -import { mockDenom, mockMfxDenom } from '@/tests/mock'; +import { mockDenom, mockDenom2, mockMfxDenom } from '@/tests/mock'; expect.extend(matchers); @@ -40,11 +40,12 @@ const renderWithProps = (props = {}) => { isError: null, refetchDenoms: jest.fn(), address: '', + pageSize: 2, }; return renderWithChainProvider(); }; -const allDenoms = [mockDenom, mockMfxDenom]; +const allDenoms = [mockDenom, mockDenom2]; describe('MyDenoms', () => { afterEach(() => { @@ -64,7 +65,7 @@ describe('MyDenoms', () => { test('renders denoms correctly', () => { renderWithProps({ denoms: allDenoms }); - const mfxs = screen.getAllByText('MFX'); + const mfxs = screen.getAllByText('TEST2'); mfxs.forEach(element => { expect(element).toBeInTheDocument(); }); @@ -76,12 +77,9 @@ describe('MyDenoms', () => { }); test('filters denoms based on search query', async () => { - renderWithProps({ denoms: allDenoms }); - const searchInput = screen.getByPlaceholderText('Search for a token...'); - fireEvent.change(searchInput, { target: { value: 'MFX' } }); - + renderWithProps({ denoms: allDenoms, searchTerm: 'TEST2' }); await waitFor(() => { - const tests = screen.getAllByText('MFX'); + const tests = screen.getAllByText('TEST2'); tests.forEach(element => { expect(element).toBeInTheDocument(); }); @@ -91,10 +89,7 @@ describe('MyDenoms', () => { }); test("displays 'No tokens found' when no denoms match search query", async () => { - renderWithProps({ denoms: allDenoms }); - - const searchInput = screen.getByPlaceholderText('Search for a token...'); - fireEvent.change(searchInput, { target: { value: 'Nonexistent Denom' } }); + renderWithProps({ denoms: allDenoms, searchTerm: 'Nonexistent Denom' }); await waitFor(() => { expect(screen.queryByText('TEST')).not.toBeInTheDocument(); }); diff --git a/components/factory/forms/__tests__/BurnForm.test.tsx b/components/factory/forms/__tests__/BurnForm.test.tsx index 0de5f99d..0fc98294 100644 --- a/components/factory/forms/__tests__/BurnForm.test.tsx +++ b/components/factory/forms/__tests__/BurnForm.test.tsx @@ -31,6 +31,7 @@ const mockProps = { address: 'cosmos1address', refetch: jest.fn(), balance: '1000000', + totalSupply: '1000000', }; function renderWithProps(props = {}) { diff --git a/components/factory/forms/__tests__/MintForm.test.tsx b/components/factory/forms/__tests__/MintForm.test.tsx index 7d5953e3..51fe83f9 100644 --- a/components/factory/forms/__tests__/MintForm.test.tsx +++ b/components/factory/forms/__tests__/MintForm.test.tsx @@ -24,6 +24,7 @@ const mockProps = { address: 'cosmos1address', refetch: jest.fn(), balance: '1000000', + totalSupply: '1000000', }; function renderWithProps(props = {}) { diff --git a/components/groups/components/__tests__/myGroups.test.tsx b/components/groups/components/__tests__/myGroups.test.tsx index 74f8f814..d708d027 100644 --- a/components/groups/components/__tests__/myGroups.test.tsx +++ b/components/groups/components/__tests__/myGroups.test.tsx @@ -85,7 +85,7 @@ describe('YourGroups Component', () => { test('renders empty group state correctly', () => { renderWithChainProvider(); - expect(screen.getByText('My groups')).toBeInTheDocument(); + expect(screen.getByText('Groups')).toBeInTheDocument(); }); test('renders loading state correctly', () => { diff --git a/components/groups/forms/groups/GroupDetailsForm.tsx b/components/groups/forms/groups/GroupDetailsForm.tsx index 31c1a90f..f012252c 100644 --- a/components/groups/forms/groups/GroupDetailsForm.tsx +++ b/components/groups/forms/groups/GroupDetailsForm.tsx @@ -1,14 +1,15 @@ -import React, { useState } from 'react'; -import { Formik, Form } from 'formik'; -import Yup from '@/utils/yupExtensions'; -import { Action, FormData } from '@/helpers/formReducer'; -import Link from 'next/link'; +import React from 'react'; +import { Formik, Form, useFormikContext } from 'formik'; +import * as Yup from 'yup'; import { TextInput, TextArea } from '@/components/react/inputs'; import { TrashIcon, PlusIcon } from '@/components/icons'; -import { isValidManifestAddress } from '@/utils/string'; import { MdContacts } from 'react-icons/md'; import { TailwindModal } from '@/components/react/modal'; +import Link from 'next/link'; + +import { Action, FormData } from '@/helpers/formReducer'; +import { isValidManifestAddress } from '@/utils/string'; const GroupSchema = Yup.object().shape({ title: Yup.string() @@ -48,7 +49,6 @@ const GroupSchema = Yup.object().shape({ } ) ), - description: Yup.string() .required('Description is required') .min(20, 'Description must be at least 20 characters') @@ -56,193 +56,205 @@ const GroupSchema = Yup.object().shape({ .noProfanity('Profanity is not allowed'), }); -export default function GroupDetails({ - nextStep, - formData, +function GroupDetailsFormFields({ dispatch, address, + isContactsOpen, + setIsContactsOpen, + activeAuthorIndex, + setActiveAuthorIndex, }: Readonly<{ - nextStep: () => void; - formData: FormData; dispatch: React.Dispatch; address: string; + isContactsOpen: boolean; + setIsContactsOpen: React.Dispatch>; + activeAuthorIndex: number | null; + setActiveAuthorIndex: React.Dispatch>; }>) { - const [isValidForm, setIsValidForm] = useState(false); - const [isContactsOpen, setIsContactsOpen] = useState(false); - const [activeAuthorIndex, setActiveAuthorIndex] = useState(null); - - const authors = Array.isArray(formData.authors) - ? formData.authors - : [formData.authors].filter(Boolean); + const { values, handleChange, setFieldValue, isValid } = useFormikContext(); + const authors = Array.isArray(values.authors) ? values.authors : [values.authors]; const updateField = (field: keyof FormData, value: any) => { dispatch({ type: 'UPDATE_FIELD', field, value }); }; return ( -
-
-
-
-

- Group details -

- 0 ? authors : [''], - }} - validationSchema={GroupSchema} - onSubmit={nextStep} - > - {({ isValid, setFieldValue, handleChange, values }) => { - setIsValidForm(isValid); - - return ( -
- ) => { - updateField('title', e.target.value); - handleChange(e); - }} - /> - -