Fix e2e tests

The e2e tests have been updated for `@metamask/phishing-warning@1.1.0`.
The iframe case was updated with a new design, which required test
changes. The third test that was meant to ensure the phishing page
can't redirect to an extension page has been updated to navigate
directly to the phishing warning page and setting the URL manually via
query parameters, as that was the only way to test that redirect.
feature/default_network_editable
Mark Stacey 3 years ago
parent 24c3175ec7
commit 5a5e541b5e
  1. 4
      development/build/scripts.js
  2. 2
      package.json
  3. 5
      test/e2e/mock-page-with-disallowed-iframe/index.html
  4. 17
      test/e2e/tests/phishing-detection.spec.js
  5. 8
      yarn.lock

@ -137,8 +137,8 @@ function getSegmentWriteKey({ buildType, environment }) {
/**
* Get the URL for the phishing warning page, if it has been set.
*
* @param options0
* @param options0.testing
* @param {object} options - The phishing warning page options.
* @param {boolean} options.testing - Whether this is a test build or not.
* @returns {string} The URL for the phishing warning page, or `undefined` if no URL is set.
*/
function getPhishingWarningPageUrl({ testing }) {

@ -252,7 +252,7 @@
"@metamask/eslint-config-nodejs": "^9.0.0",
"@metamask/eslint-config-typescript": "^9.0.1",
"@metamask/forwarder": "^1.1.0",
"@metamask/phishing-warning": "^1.0.0",
"@metamask/phishing-warning": "^1.1.0",
"@metamask/test-dapp": "^5.0.0",
"@sentry/cli": "^1.58.0",
"@storybook/addon-a11y": "^6.3.12",

@ -7,7 +7,8 @@
function setIframeSource() {
const urlSearchParams = new URLSearchParams(window.location.search);
const params = Object.fromEntries(urlSearchParams.entries());
document.getElementById('frame').src = params.extensionUrl;
const extensionUrl = new URL(params.extensionUrl);
document.getElementById('frame').src = `http://localhost:9999/#hostname=${encodeURIComponent(extensionUrl.hostname)}&href=${encodeURIComponent(extensionUrl.href)}`;
}
window.onload = setIframeSource;
</script>
@ -16,4 +17,4 @@
<iframe id="frame" width=900 height=900>
</body>
</html>
</html>

@ -76,6 +76,10 @@ describe('Phishing Detection', function () {
const iframe = await driver.findElement('iframe');
await driver.switchToFrame(iframe);
await driver.clickElement({
text: 'Open this warning in a new tab',
});
await driver.switchToWindowWithTitle('MetaMask Phishing Detection');
await driver.clickElement({
text: 'continuing at your own risk',
});
@ -110,7 +114,18 @@ describe('Phishing Detection', function () {
const iframe = await driver.findElement('iframe');
await driver.switchToFrame(iframe);
await driver.assertElementNotPresent({
await driver.clickElement({
text: 'Open this warning in a new tab',
});
await driver.switchToWindowWithTitle('MetaMask Phishing Detection');
await driver.clickElement({
text: 'continuing at your own risk',
});
// Ensure we're not on the wallet home page
await driver.assertElementNotPresent('[data-testid="wallet-balance"]');
// Ensure we're still on the warning page, meaning that the navigation failed
await driver.findElement({
text: 'continuing at your own risk',
});
},

@ -2967,10 +2967,10 @@
"@metamask/safe-event-emitter" "^2.0.0"
through2 "^2.0.3"
"@metamask/phishing-warning@^1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@metamask/phishing-warning/-/phishing-warning-1.0.0.tgz#e40ddecbaff4ae5af038eb8f5607b1f72cf97ea4"
integrity sha512-bRdd16NonDTsWI5Vwaac4wvTS61XRW2phc0FBXrdkj9WHKTo747MKOZht4bWmgCHtlZMYrT4wIQGt+NeyU6rag==
"@metamask/phishing-warning@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@metamask/phishing-warning/-/phishing-warning-1.1.0.tgz#0d5764327c413dd1900db786e295bd729530ca66"
integrity sha512-39N7lU9fdkXZKHn/hbkiEhv1oJ3mabPjYMk22582a7XzdBD5wgxDf5qHsXXQlOq+uI3lBU9VVKD7K7Z2lcgapw==
dependencies:
"@metamask/design-tokens" "^1.6.0"
"@metamask/post-message-stream" "^4.0.0"

Loading…
Cancel
Save