Skip to content

Commit

Permalink
Covered more test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
filipsekulic committed Feb 13, 2023
1 parent ab99d91 commit 186dd8b
Show file tree
Hide file tree
Showing 3 changed files with 158 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ describe('Confirm Page Container Content', () => {
disabled: true,
origin: 'http://localhost:4200',
hideTitle: false,
txData: {
securityProviderResponse: {
flagAsDangerous: undefined,
reason: 'Some reason...',
reason_header: 'Some reason header...',
},
},
};
});

Expand Down Expand Up @@ -126,4 +133,40 @@ describe('Confirm Page Container Content', () => {

expect(queryByText('Address Book Account 1')).not.toBeInTheDocument();
});

it('should render SecurityProviderBannerMessage component properly', () => {
const { queryByText } = renderWithProvider(
<ConfirmPageContainerContent {...props} />,
store,
);

expect(queryByText('Request not verified')).toBeInTheDocument();
expect(
queryByText(
'Because of an error, this request was not verified by the security provider. Proceed with caution.',
),
).toBeInTheDocument();
expect(
queryByText('This is based on information from'),
).toBeInTheDocument();
});

it('should not render SecurityProviderBannerMessage component when flagAsDangerous is 0', () => {
props.txData.securityProviderResponse = {
flagAsDangerous: 0,
};

const { queryByText } = renderWithProvider(
<ConfirmPageContainerContent {...props} />,
store,
);

expect(queryByText('Request not verified')).toBeNull();
expect(
queryByText(
'Because of an error, this request was not verified by the security provider. Proceed with caution.',
),
).toBeNull();
expect(queryByText('This is based on information from')).toBeNull();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ const props = {
origin: 'https://happydapp.website/governance?futarchy=true',
},
type: MESSAGE_TYPE.ETH_SIGN,
securityProviderResponse: {
flagAsDangerous: undefined,
reason: 'Some reason...',
reason_header: 'Some reason header...',
},
},
};

Expand Down Expand Up @@ -115,4 +120,32 @@ describe('SignatureRequestOriginal', () => {
expect(getByText('Message \\u202E test:')).toBeInTheDocument();
expect(getByText('Hi, \\u202E Alice!')).toBeInTheDocument();
});

it('should render SecurityProviderBannerMessage component properly', () => {
render();
expect(screen.getByText('Request not verified')).toBeInTheDocument();
expect(
screen.getByText(
'Because of an error, this request was not verified by the security provider. Proceed with caution.',
),
).toBeInTheDocument();
expect(
screen.getByText('This is based on information from'),
).toBeInTheDocument();
});

it('should not render SecurityProviderBannerMessage component when flagAsDangerous is 0', () => {
props.txData.securityProviderResponse = {
flagAsDangerous: 0,
};

render();
expect(screen.queryByText('Request not verified')).toBeNull();
expect(
screen.queryByText(
'Because of an error, this request was not verified by the security provider. Proceed with caution.',
),
).toBeNull();
expect(screen.queryByText('This is based on information from')).toBeNull();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -275,5 +275,87 @@ describe('Signature Request Component', () => {

expect(getByText('Reject 2 requests')).toBeInTheDocument();
});

it('should render SecurityProviderBannerMessage component properly', () => {
const msgParams = {
data: JSON.stringify(messageData),
version: 'V4',
origin: 'test',
};

const { queryByText } = renderWithProvider(
<SignatureRequest
hardwareWalletRequiresConnection={false}
clearConfirmTransaction={() => undefined}
cancel={() => undefined}
cancelAll={() => undefined}
mostRecentOverviewPage="/"
showRejectTransactionsConfirmationModal={() => undefined}
history={{ push: '/' }}
sign={() => undefined}
txData={{
msgParams,
securityProviderResponse: {
flagAsDangerous: undefined,
reason: 'Some reason...',
reason_header: 'Some reason header...',
},
}}
fromAccount={{ address: fromAddress }}
provider={{ type: 'rpc' }}
unapprovedMessagesCount={2}
/>,
store,
);

expect(queryByText('Request not verified')).toBeInTheDocument();
expect(
queryByText(
'Because of an error, this request was not verified by the security provider. Proceed with caution.',
),
).toBeInTheDocument();
expect(
queryByText('This is based on information from'),
).toBeInTheDocument();
});

it('should not render SecurityProviderBannerMessage component when flagAsDangerous is 0', () => {
const msgParams = {
data: JSON.stringify(messageData),
version: 'V4',
origin: 'test',
};

const { queryByText } = renderWithProvider(
<SignatureRequest
hardwareWalletRequiresConnection={false}
clearConfirmTransaction={() => undefined}
cancel={() => undefined}
cancelAll={() => undefined}
mostRecentOverviewPage="/"
showRejectTransactionsConfirmationModal={() => undefined}
history={{ push: '/' }}
sign={() => undefined}
txData={{
msgParams,
securityProviderResponse: {
flagAsDangerous: 0,
},
}}
fromAccount={{ address: fromAddress }}
provider={{ type: 'rpc' }}
unapprovedMessagesCount={2}
/>,
store,
);

expect(queryByText('Request not verified')).toBeNull();
expect(
queryByText(
'Because of an error, this request was not verified by the security provider. Proceed with caution.',
),
).toBeNull();
expect(queryByText('This is based on information from')).toBeNull();
});
});
});

0 comments on commit 186dd8b

Please sign in to comment.