-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: send failing contract (#12802)
## **Description** This PR is within the scope of the Quality Quest. We're including an e2e test case that send a failing contract in the test dApp. **Steps:** Given I am on the test dapp When I tap on the Send failing transaction button in the Failing Contract section Then the transaction bottom sheet should appear _And I should see a warning "this transaction will likely fail"_ <- This message is not present When I submit the transaction Then the transaction should appear in the transaction history ## **Related issues** Fixes: ## **Manual testing steps** 1. Go to this page... 2. 3. ## **Screenshots/Recordings** ### **Before** ### **After** ## **Pre-merge author checklist** - [✓] I’ve followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [✓] I've completed the PR template to the best of my ability - [✓] I’ve included tests if applicable - [✓] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [✓] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.
- Loading branch information
Showing
4 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
'use strict'; | ||
|
||
import { SmokeConfirmations } from '../../tags'; | ||
import TestHelpers from '../../helpers'; | ||
import { loginToApp } from '../../viewHelper'; | ||
|
||
import TabBarComponent from '../../pages/wallet/TabBarComponent'; | ||
import TestDApp from '../../pages/Browser/TestDApp'; | ||
import FixtureBuilder from '../../fixtures/fixture-builder'; | ||
import { | ||
withFixtures, | ||
defaultGanacheOptions, | ||
} from '../../fixtures/fixture-helper'; | ||
import { SMART_CONTRACTS } from '../../../app/util/test/smart-contracts'; | ||
import { ActivitiesViewSelectorsText } from '../../selectors/Transactions/ActivitiesView.selectors'; | ||
import Assertions from '../../utils/Assertions'; | ||
import { mockEvents } from '../../api-mocking/mock-config/mock-events'; | ||
|
||
describe(SmokeConfirmations('Failing contracts'), () => { | ||
const FAILING_CONTRACT = SMART_CONTRACTS.FAILING; | ||
|
||
beforeAll(async () => { | ||
jest.setTimeout(150000); | ||
await TestHelpers.reverseServerPort(); | ||
}); | ||
|
||
it('sends a failing contract transaction', async () => { | ||
|
||
const testSpecificMock = { | ||
GET: [ | ||
mockEvents.GET.suggestedGasFeesApiGanache | ||
], | ||
}; | ||
await withFixtures( | ||
{ | ||
dapp: true, | ||
fixture: new FixtureBuilder() | ||
.withGanacheNetwork() | ||
.withPermissionControllerConnectedToTestDapp() | ||
.build(), | ||
restartDevice: true, | ||
ganacheOptions: defaultGanacheOptions, | ||
smartContract: FAILING_CONTRACT, | ||
testSpecificMock, | ||
}, | ||
async ({ contractRegistry }) => { | ||
const failingAddress = await contractRegistry.getContractAddress( | ||
FAILING_CONTRACT, | ||
); | ||
await loginToApp(); | ||
|
||
// Navigate to the browser screen | ||
await TabBarComponent.tapBrowser(); | ||
await TestDApp.navigateToTestDappWithContract({ | ||
contractAddress: failingAddress, | ||
}); | ||
|
||
// Send a failing transaction | ||
await TestDApp.tapSendFailingTransactionButton(); | ||
await TestHelpers.delay(3000); | ||
|
||
await TestDApp.tapConfirmButton(); | ||
|
||
// Navigate to the activity screen | ||
await TabBarComponent.tapActivity(); | ||
|
||
// Assert the failed transaction is displayed | ||
await Assertions.checkIfTextIsDisplayed( | ||
ActivitiesViewSelectorsText.SMART_CONTRACT_INTERACTION | ||
); | ||
await Assertions.checkIfTextIsDisplayed( | ||
ActivitiesViewSelectorsText.FAILED_TEXT | ||
); | ||
}, | ||
); | ||
}); | ||
}); |