diff --git a/test/e2e/tests/connections/connect.spec.js b/test/e2e/tests/connections/connect.spec.js index 64d0bfea07a1..3da5e94a28df 100644 --- a/test/e2e/tests/connections/connect.spec.js +++ b/test/e2e/tests/connections/connect.spec.js @@ -9,7 +9,7 @@ const { const FixtureBuilder = require('../../fixture-builder'); describe('Connections page', function () { - it('should disconnect when click on Disconnect button in connections page', async function () { + it('should show connections page', async function () { await withFixtures( { dapp: true, @@ -36,6 +36,10 @@ describe('Connections page', function () { '[data-testid ="account-options-menu-button"]', ); await driver.clickElement({ text: 'All Permissions', tag: 'div' }); + await driver.clickElementAndWaitToDisappear({ + text: 'Got it', + tag: 'button', + }); await driver.clickElement({ text: '127.0.0.1:8080', tag: 'p', @@ -50,13 +54,56 @@ describe('Connections page', function () { tag: 'p', }); assert.ok(connectionsPageNetworkInfo, 'Connections Page is defined'); + }, + ); + }); + it('should disconnect when click on Disconnect button in connections page', async function () { + await withFixtures( + { + dapp: true, + fixtures: new FixtureBuilder().build(), + title: this.test.fullTitle(), + ganacheOptions: defaultGanacheOptions, + }, + async ({ driver, ganacheServer }) => { + await logInWithBalanceValidation(driver, ganacheServer); + await connectToDapp(driver); + + // It should render connected status for button if dapp is connected + const getConnectedStatus = await driver.waitForSelector({ + css: '#connectButton', + text: 'Connected', + }); + assert.ok(getConnectedStatus, 'Account is connected to Dapp'); + + // Switch to extension Tab + await driver.switchToWindowWithTitle( + WINDOW_TITLES.ExtensionInFullScreenView, + ); await driver.clickElement( - '[data-testid ="account-list-item-menu-button"]', + '[data-testid ="account-options-menu-button"]', ); + await driver.clickElement({ text: 'All Permissions', tag: 'div' }); + await driver.clickElementAndWaitToDisappear({ + text: 'Got it', + tag: 'button', + }); + await driver.clickElement({ + text: '127.0.0.1:8080', + tag: 'p', + }); + const connectionsPageAccountInfo = await driver.isElementPresent({ + text: 'See your accounts and suggest transactions', + tag: 'p', + }); + assert.ok(connectionsPageAccountInfo, 'Connections Page is defined'); + const connectionsPageNetworkInfo = await driver.isElementPresent({ + text: 'Use your enabled networks', + tag: 'p', + }); + assert.ok(connectionsPageNetworkInfo, 'Connections Page is defined'); await driver.clickElement({ text: 'Disconnect', tag: 'button' }); await driver.clickElement('[data-testid ="disconnect-all"]'); - await driver.clickElement('button[aria-label="Back"]'); - await driver.clickElement({ text: 'All Permissions', tag: 'div' }); const noAccountConnected = await driver.isElementPresent({ text: 'MetaMask isn’t connected to this site', tag: 'p', diff --git a/test/e2e/tests/metrics/dapp-viewed.spec.js b/test/e2e/tests/metrics/dapp-viewed.spec.js index 774e3a30890f..c87819e1bdeb 100644 --- a/test/e2e/tests/metrics/dapp-viewed.spec.js +++ b/test/e2e/tests/metrics/dapp-viewed.spec.js @@ -277,6 +277,10 @@ describe('Dapp viewed Event @no-mmi', function () { text: '127.0.0.1:8080', tag: 'p', }); + await driver.clickElement({ + text: 'Disconnect', + tag: 'button', + }); await driver.clickElement('[data-testid ="disconnect-all"]'); // validate dapp is not connected await driver.clickElement(