diff --git a/package.json b/package.json index 8e46c5c8119f..562065b50f9b 100644 --- a/package.json +++ b/package.json @@ -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://fake@sentry.io/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://fake@sentry.io/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://fake@sentry.io/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", diff --git a/test/e2e/run-all.js b/test/e2e/run-all.js index 811f6b8fb94c..289d2b94f16b 100644 --- a/test/e2e/run-all.js +++ b/test/e2e/run-all.js @@ -108,6 +108,7 @@ async function main() { 'test-snap-manageAccount.spec.js', 'test-snap-rpc.spec.js', 'test-snap-lifecycle.spec.js', + 'ppom-toggle-settings.spec.js', ]; testPaths = testPaths.filter((p) => filteredTests.every((filteredTest) => !p.endsWith(filteredTest)), diff --git a/test/e2e/snaps/ppom-toggle-settings.spec.js b/test/e2e/snaps/ppom-toggle-settings.spec.js new file mode 100644 index 000000000000..f3a19631aca6 --- /dev/null +++ b/test/e2e/snaps/ppom-toggle-settings.spec.js @@ -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'); + }, + ); + }); +}); diff --git a/ui/components/app/security-provider-banner-alert/__snapshots__/security-provider-banner-alert.test.js.snap b/ui/components/app/security-provider-banner-alert/__snapshots__/security-provider-banner-alert.test.js.snap index 9213377809e7..a5395a81917f 100644 --- a/ui/components/app/security-provider-banner-alert/__snapshots__/security-provider-banner-alert.test.js.snap +++ b/ui/components/app/security-provider-banner-alert/__snapshots__/security-provider-banner-alert.test.js.snap @@ -4,6 +4,7 @@ exports[`Security Provider Banner Alert should match snapshot 1`] = `
+ {description} {details && ( diff --git a/ui/pages/settings/experimental-tab/__snapshots__/experimental-tab.test.js.snap b/ui/pages/settings/experimental-tab/__snapshots__/experimental-tab.test.js.snap index 580fa9631e14..c0c14c5068f2 100644 --- a/ui/pages/settings/experimental-tab/__snapshots__/experimental-tab.test.js.snap +++ b/ui/pages/settings/experimental-tab/__snapshots__/experimental-tab.test.js.snap @@ -29,6 +29,7 @@ exports[`ExperimentalTab with desktop enabled renders ExperimentalTab component

{t('securityAlertsDescription')} -

+