Skip to content

Commit

Permalink
fix: proposal confirmation form test
Browse files Browse the repository at this point in the history
  • Loading branch information
fmorency committed Nov 7, 2024
1 parent 6461f5d commit 3071081
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
5 changes: 0 additions & 5 deletions components/groups/forms/proposals/ConfirmationForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,7 @@ export default function ConfirmationForm({
if (messageData.amount && !Array.isArray(messageData.amount)) {
messageData.amount = [messageData.amount];
}
console.log({ messageData });
const composedMessage = composer(messageData as MessageTypeMap[typeof message.type]);
console.log({ composedMessage });
if (!composedMessage || !composedMessage.value) {
console.error('Composed message or its value is undefined:', composedMessage);
throw new Error(`Failed to compose message for type: ${message.type}`);
Expand Down Expand Up @@ -183,8 +181,6 @@ export default function ConfirmationForm({
const CID = await uploadMetaDataToIPFS();

const messages: Any[] = formData.messages.map(message => getMessageObject(message));
console.log(formData.messages);
console.log({ messages });
const msg = cosmos.group.v1.MessageComposer.fromPartial.submitProposal({
groupPolicyAddress: policyAddress,
messages: messages,
Expand All @@ -194,7 +190,6 @@ export default function ConfirmationForm({
summary: formData.metadata.summary,
exec: 0,
});
console.log({ msg });
const fee = await estimateFee(address ?? '', [msg]);
await tx([msg], {
fee,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,25 +43,22 @@ describe('ConfirmationModal Component', () => {

test('renders component with correct details', () => {
renderWithChainProvider(<ConfirmationModal {...mockProps} />);
expect(screen.getByText('Confirmation')).toBeInTheDocument();
expect(screen.getByLabelText('proposal-details')).toBeInTheDocument();
expect(screen.getByText(mockProposalFormData.title)).toBeInTheDocument();
expect(screen.getByText('manifest1hj5fv...8ws9ct')).toBeInTheDocument();

// TODO: This is never displayed in the component
// expect(screen.getByText(mockFormData.summary)).toBeInTheDocument();

expect(screen.getByText('MESSAGES')).toBeInTheDocument();
expect(screen.getByText('METADATA')).toBeInTheDocument();
expect(screen.getByLabelText('meta-details')).toBeInTheDocument();
expect(screen.getByText('Messages')).toBeInTheDocument();
expect(screen.getByText('Type')).toBeInTheDocument();
expect(screen.getByText('send')).toBeInTheDocument();
expect(screen.getByText('Metadata')).toBeInTheDocument();
expect(screen.getByText(mockProposalFormData.metadata.authors)).toBeInTheDocument();
expect(screen.getByText(mockProposalFormData.metadata.title)).toBeInTheDocument();
expect(screen.getByText(mockProposalFormData.metadata.summary)).toBeInTheDocument();
expect(screen.getByText(mockProposalFormData.metadata.details)).toBeInTheDocument();
});

test('calls prevStep when "Prev: Metadata" button is clicked', () => {
renderWithChainProvider(<ConfirmationModal {...mockProps} />);
const prevButton = screen.getByText('Prev: Metadata');
const prevButton = screen.getByText('Back: Metadata');
fireEvent.click(prevButton);
expect(mockProps.prevStep).toHaveBeenCalled();
});
Expand Down

0 comments on commit 3071081

Please sign in to comment.