Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(extension): e2e - add tests for DApps: empty state + app on the …
…… (#2707)
- Loading branch information
Showing
21 changed files
with
419 additions
and
160 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,126 @@ | ||
import { expect } from 'chai'; | ||
import { t } from '../utils/translationService'; | ||
import AuthorizeDAppPage from '../elements/dappConnector/authorizeDAppPage'; | ||
import AuthorizedDAppsPage from '../elements/dappConnector/authorizedDAppsPage'; | ||
import AuthorizeDAppModal from '../elements/dappConnector/authorizeDAppModal'; | ||
import ExampleDAppPage from '../elements/dappConnector/testDAppPage'; | ||
|
||
export type ExpectedAuthorizedDAppDetails = { | ||
hasLogo: boolean; | ||
name: string; | ||
url: string; | ||
}; | ||
|
||
class DAppConnectorAssert { | ||
async assertSeeAuthorizeDAppPage(expectedDappName: string, expectedDappUrl: string) { | ||
await AuthorizeDAppPage.headerLogo.waitForDisplayed(); | ||
await AuthorizeDAppPage.betaPill.waitForDisplayed(); | ||
await expect(await AuthorizeDAppPage.betaPill.getText()).to.equal(await t('core.dapp.beta')); | ||
|
||
await AuthorizeDAppPage.pageTitle.waitForDisplayed(); | ||
await expect(await AuthorizeDAppPage.pageTitle.getText()).to.equal(await t('dapp.connect.header')); | ||
|
||
await AuthorizeDAppPage.dAppLogo.waitForDisplayed(); | ||
await AuthorizeDAppPage.dAppName.waitForDisplayed(); | ||
await expect(await AuthorizeDAppPage.dAppName.getText()).to.equal(expectedDappName); | ||
await AuthorizeDAppPage.dAppUrl.waitForDisplayed(); | ||
await expect(await AuthorizeDAppPage.dAppUrl.getText()).to.equal(expectedDappUrl); | ||
|
||
await AuthorizeDAppPage.banner.container.waitForDisplayed(); | ||
await AuthorizeDAppPage.banner.icon.waitForDisplayed(); | ||
await AuthorizeDAppPage.banner.description.waitForDisplayed(); | ||
await expect(await AuthorizeDAppPage.banner.description.getText()).to.equal(await t('core.authorizeDapp.warning')); | ||
await this.assertSeeAuthorizePagePermissions(); | ||
|
||
await AuthorizeDAppPage.authorizeButton.waitForDisplayed(); | ||
await expect(await AuthorizeDAppPage.authorizeButton.getText()).to.equal(await t('dapp.connect.btn.accept')); | ||
await AuthorizeDAppPage.cancelButton.waitForDisplayed(); | ||
await expect(await AuthorizeDAppPage.cancelButton.getText()).to.equal(await t('dapp.connect.btn.cancel')); | ||
} | ||
|
||
async assertSeeAuthorizePagePermissions() { | ||
await AuthorizeDAppPage.permissionsTitle.waitForDisplayed(); | ||
await expect(await AuthorizeDAppPage.permissionsTitle.getText()).to.equal( | ||
`${await t('package.core.authorizeDapp.title', true)}:` | ||
); | ||
|
||
await AuthorizeDAppPage.permissionsList.waitForDisplayed(); | ||
const currentTexts = await AuthorizeDAppPage.permissionsListItems.map(async (option) => await option.getText()); | ||
|
||
const expectedTexts = [ | ||
await t('package.core.authorizeDapp.seeNetwork', true), | ||
await t('package.core.authorizeDapp.seeWalletUtxo', true), | ||
await t('package.core.authorizeDapp.seeWalletBalance', true), | ||
await t('package.core.authorizeDapp.seeWalletAddresses', true) | ||
]; | ||
|
||
await expect(currentTexts).to.have.all.members(expectedTexts); | ||
} | ||
|
||
async assertSeeDAppConnectionModal() { | ||
await AuthorizeDAppModal.container.waitForDisplayed(); | ||
await AuthorizeDAppModal.title.waitForDisplayed(); | ||
await expect(await AuthorizeDAppModal.title.getText()).to.equal(await t('dapp.connect.modal.header')); | ||
|
||
await AuthorizeDAppModal.description.waitForDisplayed(); | ||
await expect(await AuthorizeDAppModal.description.getText()).to.equal(await t('dapp.connect.modal.description')); | ||
|
||
await AuthorizeDAppModal.alwaysButton.waitForDisplayed(); | ||
await expect(await AuthorizeDAppModal.alwaysButton.getText()).to.equal(await t('dapp.connect.modal.allowAlways')); | ||
|
||
await AuthorizeDAppModal.onceButton.waitForDisplayed(); | ||
await expect(await AuthorizeDAppModal.onceButton.getText()).to.equal(await t('dapp.connect.modal.allowOnce')); | ||
} | ||
|
||
async assertWalletFoundButNotConnectedInTestDApp() { | ||
await expect(await ExampleDAppPage.walletItem.getAttribute('value')).to.equal('lace'); | ||
await expect(await ExampleDAppPage.walletFound.getText()).to.equal('true'); | ||
await expect(await ExampleDAppPage.walletConnected.getText()).to.equal('false'); | ||
await expect(await ExampleDAppPage.walletApiVersion.getText()).to.equal('0.1.0'); | ||
await expect(await ExampleDAppPage.walletName.getText()).to.equal('lace'); | ||
await expect(await ExampleDAppPage.walletNetworkId.getText()).to.be.empty; | ||
await expect(await ExampleDAppPage.walletBalance.getText()).to.be.empty; | ||
await expect(await ExampleDAppPage.walletChangeAddress.getText()).to.be.empty; | ||
await expect(await ExampleDAppPage.walletStakingAddress.getText()).to.be.empty; | ||
await expect(await ExampleDAppPage.walletUsedAddress.getText()).to.be.empty; | ||
} | ||
|
||
async assertSeeAuthorizedDAppsEmptyState(mode: 'extended' | 'popup') { | ||
if (mode === 'extended') { | ||
await AuthorizedDAppsPage.drawerNavigationTitle.waitForDisplayed(); | ||
await expect(await AuthorizedDAppsPage.drawerNavigationTitle.getText()).to.equal( | ||
await t('browserView.settings.heading') | ||
); | ||
|
||
await AuthorizedDAppsPage.closeButton.waitForDisplayed(); | ||
await AuthorizedDAppsPage.backButton.waitForDisplayed({ reverse: true }); | ||
} else { | ||
await AuthorizedDAppsPage.closeButton.waitForDisplayed({ reverse: true }); | ||
await AuthorizedDAppsPage.backButton.waitForDisplayed(); | ||
} | ||
|
||
await AuthorizedDAppsPage.drawerHeaderTitle.waitForDisplayed(); | ||
await expect(await AuthorizedDAppsPage.drawerHeaderTitle.getText()).to.equal(await t('dapp.list.title')); | ||
|
||
await AuthorizedDAppsPage.drawerHeaderSubtitle.waitForDisplayed(); | ||
await expect(await AuthorizedDAppsPage.drawerHeaderSubtitle.getText()).to.equal(await t('dapp.list.subTitleEmpty')); | ||
|
||
await AuthorizedDAppsPage.emptyStateImage.waitForDisplayed(); | ||
await AuthorizedDAppsPage.emptyStateText.waitForDisplayed(); | ||
await expect(await AuthorizedDAppsPage.emptyStateText.getText()).to.equal(await t('dapp.list.empty.text')); | ||
|
||
expect(await AuthorizedDAppsPage.dAppContainers.length).to.equal(0); | ||
} | ||
|
||
async assertSeeAuthorizedDAppsOnTheList(expectedDApps: ExpectedAuthorizedDAppDetails[]) { | ||
expect(await AuthorizedDAppsPage.dAppContainers.length).to.equal(expectedDApps.length); | ||
for (const [i, expectedDapp] of expectedDApps.entries()) { | ||
await AuthorizedDAppsPage.dAppLogos[i].waitForDisplayed({ reverse: !expectedDApps[i].hasLogo }); | ||
await expect(await AuthorizedDAppsPage.dAppNames[i].getText()).to.equal(expectedDapp.name); | ||
await expect(await AuthorizedDAppsPage.dAppUrls[i].getText()).to.equal(expectedDapp.url); | ||
await AuthorizedDAppsPage.dAppRemoveButtons[i].waitForDisplayed(); | ||
} | ||
} | ||
} | ||
|
||
export default new DAppConnectorAssert(); |
This file was deleted.
Oops, something went wrong.
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
49 changes: 49 additions & 0 deletions
49
packages/e2e-tests/src/elements/dappConnector/authorizedDAppsPage.ts
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,49 @@ | ||
/* eslint-disable no-undef */ | ||
import { ChainablePromiseElement } from 'webdriverio'; | ||
import { ChainablePromiseArray } from 'webdriverio/build/types'; | ||
import CommonDrawerElements from '../CommonDrawerElements'; | ||
|
||
class AuthorizedDAppsPage extends CommonDrawerElements { | ||
private SUBTITLE = '[data-testid="dapp-list-subtitle"]'; | ||
private EMPTY_STATE_IMAGE = '[data-testid="dapp-list-empty-image"]'; | ||
private EMPTY_STATE_TEXT = '[data-testid="dapp-list-empty-text"]'; | ||
private DAPP_CONTAINER = '[data-testid="dapp-container-id"]'; | ||
private DAPP_LOGO = '[data-testid="connected-dapp-logo"]'; | ||
private DAPP_NAME = '[data-testid="connected-dapp-name"]'; | ||
private DAPP_URL = '[data-testid="connected-dapp-url"]'; | ||
private DAPP_DELETE_ICON = '[data-testid="dapp-delete-icon-id"]'; | ||
|
||
get drawerHeaderSubtitle(): ChainablePromiseElement<WebdriverIO.Element> { | ||
return $(this.SUBTITLE); | ||
} | ||
|
||
get emptyStateImage(): ChainablePromiseElement<WebdriverIO.Element> { | ||
return $(this.EMPTY_STATE_IMAGE); | ||
} | ||
|
||
get emptyStateText(): ChainablePromiseElement<WebdriverIO.Element> { | ||
return $(this.EMPTY_STATE_TEXT); | ||
} | ||
|
||
get dAppContainers(): ChainablePromiseArray<WebdriverIO.ElementArray> { | ||
return $$(this.DAPP_CONTAINER); | ||
} | ||
|
||
get dAppLogos(): ChainablePromiseArray<WebdriverIO.ElementArray> { | ||
return $$(this.DAPP_LOGO); | ||
} | ||
|
||
get dAppNames(): ChainablePromiseArray<WebdriverIO.ElementArray> { | ||
return $$(this.DAPP_NAME); | ||
} | ||
|
||
get dAppUrls(): ChainablePromiseArray<WebdriverIO.ElementArray> { | ||
return $$(this.DAPP_URL); | ||
} | ||
|
||
get dAppRemoveButtons(): ChainablePromiseArray<WebdriverIO.ElementArray> { | ||
return $$(this.DAPP_DELETE_ICON); | ||
} | ||
} | ||
|
||
export default new AuthorizedDAppsPage(); |
32 changes: 32 additions & 0 deletions
32
packages/e2e-tests/src/elements/dappConnector/removeDAppModal.ts
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,32 @@ | ||
/* eslint-disable no-undef */ | ||
import { ChainablePromiseElement } from 'webdriverio'; | ||
|
||
class RemoveDAppModal { | ||
private CONTAINER = '.ant-modal-body'; | ||
private TITLE = '[data-testid="delete-dapp-modal-title"]'; | ||
private DESCRIPTION = '[data-testid="delete-dapp-modal-description"]'; | ||
private CONFIRM_BUTTON = '[data-testid="delete-dapp-modal-confirm"]'; | ||
private CANCEL_BUTTON = '[data-testid="delete-dapp-modal-cancel"]'; | ||
|
||
get container(): ChainablePromiseElement<WebdriverIO.Element> { | ||
return $(this.CONTAINER); | ||
} | ||
|
||
get title(): ChainablePromiseElement<WebdriverIO.Element> { | ||
return $(this.TITLE); | ||
} | ||
|
||
get description(): ChainablePromiseElement<WebdriverIO.Element> { | ||
return $(this.DESCRIPTION); | ||
} | ||
|
||
get confirmButton(): ChainablePromiseElement<WebdriverIO.Element> { | ||
return $(this.CONFIRM_BUTTON); | ||
} | ||
|
||
get cancelButton(): ChainablePromiseElement<WebdriverIO.Element> { | ||
return $(this.CANCEL_BUTTON); | ||
} | ||
} | ||
|
||
export default new RemoveDAppModal(); |
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
Oops, something went wrong.