-
Notifications
You must be signed in to change notification settings - Fork 5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[e2e]: blockaid toggle settings (#20454)
* wip * toggle settings e2e * fix test * removed unused code * fix failing snapshot * lint fix * fix git conflict * test: ppom ci (#20896) * ppom ci * Move ppom test inside snaps folder * fix failing test * fix failing snapshot test * fix snapshot test * improve variable naming * improve testid * update snapshot --------- Co-authored-by: seaona <[email protected]>
- Loading branch information
1 parent
ca7c028
commit 8157dc9
Showing
8 changed files
with
105 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ | |
"user-actions-benchmark:chrome": "SELENIUM_BROWSER=chrome ts-node test/e2e/user-actions-benchmark.js", | ||
"benchmark:firefox": "SELENIUM_BROWSER=firefox ts-node test/e2e/benchmark.js", | ||
"build:test": "SEGMENT_HOST='https://api.segment.io' SEGMENT_WRITE_KEY='FAKE' SENTRY_DSN_DEV=https://[email protected]/0000000 PORTFOLIO_URL=http://127.0.0.1:8080 yarn build test", | ||
"build:test:flask": "yarn build test --build-type flask", | ||
"build:test:flask": "BLOCKAID_FILE_CDN=storage.googleapis.com/ppom-mock-cdn yarn build test --build-type flask", | ||
"build:test:mv3": "ENABLE_MV3=true SEGMENT_HOST='https://api.segment.io' SEGMENT_WRITE_KEY='FAKE' SENTRY_DSN_DEV=https://[email protected]/0000000 PORTFOLIO_URL=http://127.0.0.1:8080 yarn build test", | ||
"build:test:dev:mv3": "ENABLE_MV3=true SEGMENT_HOST='https://api.segment.io' SEGMENT_WRITE_KEY='FAKE' SENTRY_DSN_DEV=https://[email protected]/0000000 PORTFOLIO_URL=http://127.0.0.1:8080 yarn build:dev testDev --apply-lavamoat=false", | ||
"test": "yarn lint && yarn test:unit && yarn test:unit:jest", | ||
|
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,87 @@ | ||
const { strict: assert } = require('assert'); | ||
const { | ||
withFixtures, | ||
unlockWallet, | ||
openDapp, | ||
defaultGanacheOptions, | ||
getWindowHandles, | ||
} = require('../helpers'); | ||
const FixtureBuilder = require('../fixture-builder'); | ||
|
||
const mainnetProviderConfig = { | ||
providerConfig: { | ||
chainId: '0x1', | ||
nickname: '', | ||
rpcUrl: '', | ||
type: 'mainnet', | ||
}, | ||
}; | ||
|
||
describe('PPOM Settings', function () { | ||
it('should not show the PPOM warning when toggle is off', async function () { | ||
await withFixtures( | ||
{ | ||
dapp: true, | ||
fixtures: new FixtureBuilder() | ||
.withNetworkController(mainnetProviderConfig) | ||
.withPermissionControllerConnectedToTestDapp() | ||
.build(), | ||
ganacheOptions: defaultGanacheOptions, | ||
title: this.test.title, | ||
}, | ||
async ({ driver }) => { | ||
await driver.navigate(); | ||
await unlockWallet(driver); | ||
|
||
await openDapp(driver); | ||
await driver.clickElement('#maliciousPermit'); | ||
const windowHandles = await getWindowHandles(driver, 3); | ||
await driver.switchToWindow(windowHandles.popup); | ||
|
||
const blockaidResponseTitle = | ||
'[data-testid="security-provider-banner-alert"]'; | ||
const exists = await driver.isElementPresent(blockaidResponseTitle); | ||
assert.equal(exists, false, 'This is a deceptive request'); | ||
}, | ||
); | ||
}); | ||
|
||
it('should show the PPOM warning when the toggle is on', async function () { | ||
await withFixtures( | ||
{ | ||
dapp: true, | ||
fixtures: new FixtureBuilder() | ||
.withNetworkController(mainnetProviderConfig) | ||
.withPermissionControllerConnectedToTestDapp() | ||
.build(), | ||
ganacheOptions: defaultGanacheOptions, | ||
title: this.test.title, | ||
}, | ||
async ({ driver }) => { | ||
await driver.navigate(); | ||
await unlockWallet(driver); | ||
|
||
await driver.clickElement( | ||
'[data-testid="account-options-menu-button"]', | ||
); | ||
|
||
await driver.clickElement({ text: 'Settings', tag: 'div' }); | ||
await driver.clickElement({ text: 'Experimental', tag: 'div' }); | ||
|
||
await driver.clickElement( | ||
'[data-testid="settings-toggle-security-alert-blockaid"] .toggle-button > div', | ||
); | ||
|
||
await openDapp(driver); | ||
await driver.clickElement('#maliciousPermit'); | ||
const windowHandles = await getWindowHandles(driver, 3); | ||
await driver.switchToWindow(windowHandles.popup); | ||
|
||
const blockaidResponseTitle = | ||
'[data-testid="security-provider-banner-alert"]'; | ||
const exists = await driver.isElementPresent(blockaidResponseTitle); | ||
assert.equal(exists, true, 'This is a deceptive request'); | ||
}, | ||
); | ||
}); | ||
}); |
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
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