-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(extension): add tests for Sign Message feature (#1441)
- Loading branch information
1 parent
a59aaa2
commit d38eff3
Showing
17 changed files
with
472 additions
and
13 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
39 changes: 39 additions & 0 deletions
39
packages/e2e-tests/src/assert/settings/MessageSigningAllDoneDrawerAssert.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,39 @@ | ||
import MessageSigningAllDoneDrawer from '../../elements/settings/MessageSigningAllDoneDrawer'; | ||
import { expect } from 'chai'; | ||
import { t } from '../../utils/translationService'; | ||
import clipboard from 'clipboardy'; | ||
|
||
class MessageSigningAllDoneDrawerAssert { | ||
async assertSeeAllDoneDrawer() { | ||
await MessageSigningAllDoneDrawer.drawerHeaderCloseButton.waitForClickable(); | ||
await MessageSigningAllDoneDrawer.drawerNavigationTitle.waitForDisplayed(); | ||
expect(await MessageSigningAllDoneDrawer.drawerNavigationTitle.getText()).to.equal( | ||
await t('core.signMessage.title') | ||
); | ||
|
||
await MessageSigningAllDoneDrawer.image.waitForDisplayed(); | ||
await MessageSigningAllDoneDrawer.title.waitForDisplayed(); | ||
expect(await MessageSigningAllDoneDrawer.title.getText()).to.equal(await t('core.signMessage.successTitle')); | ||
await MessageSigningAllDoneDrawer.description.waitForDisplayed(); | ||
expect(await MessageSigningAllDoneDrawer.description.getText()).to.equal( | ||
await t('core.signMessage.successDescription') | ||
); | ||
await MessageSigningAllDoneDrawer.signature.waitForDisplayed(); | ||
expect(await MessageSigningAllDoneDrawer.signature.getText()).to.not.be.empty; | ||
|
||
await MessageSigningAllDoneDrawer.copyButton.waitForClickable(); | ||
expect(await MessageSigningAllDoneDrawer.copyButton.getText()).to.equal( | ||
await t('core.signMessage.copyToClipboard') | ||
); | ||
await MessageSigningAllDoneDrawer.closeButton.waitForClickable(); | ||
expect(await MessageSigningAllDoneDrawer.closeButton.getText()).to.equal(await t('core.signMessage.closeButton')); | ||
} | ||
|
||
async assertSignatureInClipboardIsCorrect() { | ||
const displayedSignature = await MessageSigningAllDoneDrawer.signature.getText(); | ||
const signatureFromClipboard = await clipboard.read(); | ||
expect(signatureFromClipboard).to.equal(displayedSignature); | ||
} | ||
} | ||
|
||
export default new MessageSigningAllDoneDrawerAssert(); |
36 changes: 36 additions & 0 deletions
36
packages/e2e-tests/src/assert/settings/MessageSigningConfirmationDrawerAssert.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,36 @@ | ||
import { expect } from 'chai'; | ||
import { t } from '../../utils/translationService'; | ||
import MessageSigningSignConfirmationDrawer from '../../elements/settings/MessageSigningConfirmationDrawer'; | ||
|
||
class MessageSigningConfirmationDrawerAssert { | ||
async assertSeeSignConfirmationDrawer() { | ||
await MessageSigningSignConfirmationDrawer.drawerHeaderCloseButton.waitForClickable(); | ||
await MessageSigningSignConfirmationDrawer.drawerNavigationTitle.waitForDisplayed(); | ||
expect(await MessageSigningSignConfirmationDrawer.drawerNavigationTitle.getText()).to.equal( | ||
await t('core.signMessage.title') | ||
); | ||
|
||
await MessageSigningSignConfirmationDrawer.drawerHeaderTitle.waitForDisplayed(); | ||
expect(await MessageSigningSignConfirmationDrawer.drawerHeaderTitle.getText()).to.equal( | ||
await t('core.signMessage.passwordTitle') | ||
); | ||
await MessageSigningSignConfirmationDrawer.drawerHeaderSubtitle.waitForDisplayed(); | ||
expect(await MessageSigningSignConfirmationDrawer.drawerHeaderSubtitle.getText()).to.equal( | ||
await t('core.signMessage.passwordSubtitle') | ||
); | ||
|
||
await MessageSigningSignConfirmationDrawer.passwordInput.waitForEnabled(); | ||
|
||
await MessageSigningSignConfirmationDrawer.signMessageButton.waitForEnabled(); | ||
expect(await MessageSigningSignConfirmationDrawer.signMessageButton.getText()).to.equal( | ||
await t('core.signMessage.signButton') | ||
); | ||
|
||
await MessageSigningSignConfirmationDrawer.closeButton.waitForDisplayed(); | ||
expect(await MessageSigningSignConfirmationDrawer.closeButton.getText()).to.equal( | ||
await t('core.signMessage.closeButton') | ||
); | ||
} | ||
} | ||
|
||
export default new MessageSigningConfirmationDrawerAssert(); |
61 changes: 61 additions & 0 deletions
61
packages/e2e-tests/src/assert/settings/MessageSigningInputDrawerAssert.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,61 @@ | ||
import MessageSigningInputDrawer from '../../elements/settings/MessageSigningInputDrawer'; | ||
import { expect } from 'chai'; | ||
import { t } from '../../utils/translationService'; | ||
|
||
class MessageSigningInputDrawerAssert { | ||
async assertSeeMessageSigningInputDrawer() { | ||
await MessageSigningInputDrawer.drawerHeaderCloseButton.waitForClickable(); | ||
await MessageSigningInputDrawer.drawerNavigationTitle.waitForDisplayed(); | ||
expect(await MessageSigningInputDrawer.drawerNavigationTitle.getText()).to.equal(await t('core.signMessage.title')); | ||
|
||
await MessageSigningInputDrawer.drawerHeaderTitle.waitForDisplayed(); | ||
expect(await MessageSigningInputDrawer.drawerHeaderTitle.getText()).to.equal( | ||
await t('core.signMessage.instructions') | ||
); | ||
await MessageSigningInputDrawer.drawerHeaderSubtitle.waitForDisplayed(); | ||
expect(await MessageSigningInputDrawer.drawerHeaderSubtitle.getText()).to.equal( | ||
await t('core.signMessage.subtitle') | ||
); | ||
|
||
await MessageSigningInputDrawer.addressLabel.waitForDisplayed(); | ||
expect(await MessageSigningInputDrawer.addressLabel.getText()).to.equal(await t('core.signMessage.addressLabel')); | ||
await MessageSigningInputDrawer.selectAddressButton.waitForDisplayed(); | ||
expect(await MessageSigningInputDrawer.selectAddressButton.getText()).to.equal( | ||
await t('core.signMessage.selectAddress') | ||
); | ||
|
||
await MessageSigningInputDrawer.messageToSignLabel.waitForDisplayed(); | ||
expect(await MessageSigningInputDrawer.messageToSignLabel.getText()).to.equal( | ||
await t('core.signMessage.messageLabel') | ||
); | ||
await MessageSigningInputDrawer.messageInput.waitForDisplayed(); | ||
expect(await MessageSigningInputDrawer.messageInput.getAttribute('placeholder')).to.equal( | ||
await t('core.signMessage.messagePlaceholder') | ||
); | ||
|
||
await MessageSigningInputDrawer.signMessageButton.waitForDisplayed(); | ||
expect(await MessageSigningInputDrawer.signMessageButton.getText()).to.equal( | ||
await t('core.signMessage.signButton') | ||
); | ||
|
||
await MessageSigningInputDrawer.closeButton.waitForDisplayed(); | ||
expect(await MessageSigningInputDrawer.closeButton.getText()).to.equal(await t('core.signMessage.closeButton')); | ||
} | ||
|
||
async assertSeeFollowingAddressesOnTheDropdownMenu(expectedAddresses: string[]) { | ||
await MessageSigningInputDrawer.addressMenu.waitForClickable(); | ||
const actualAddresses = await ( | ||
await MessageSigningInputDrawer.addresses | ||
).map(async (address) => await address.getText()); | ||
|
||
expect(actualAddresses).to.deep.equal(expectedAddresses); | ||
} | ||
|
||
async assertSeeSelectedAddress(expectedAddress: string) { | ||
await MessageSigningInputDrawer.selectAddressButton.waitForDisplayed(); | ||
const actualAddress = await MessageSigningInputDrawer.selectAddressButton.getText(); | ||
expect(actualAddress).to.equal(expectedAddress); | ||
} | ||
} | ||
|
||
export default new MessageSigningInputDrawerAssert(); |
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
48 changes: 48 additions & 0 deletions
48
packages/e2e-tests/src/elements/settings/MessageSigningAllDoneDrawer.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,48 @@ | ||
/* eslint-disable no-undef */ | ||
import CommonDrawerElements from '../CommonDrawerElements'; | ||
import type { ChainablePromiseElement } from 'webdriverio'; | ||
|
||
class MessageSigningAllDoneDrawer extends CommonDrawerElements { | ||
private IMAGE = '[data-testid="result-message-img"]'; | ||
private TITLE = '[data-testid="result-message-title"]'; | ||
private DESCRIPTION = '[data-testid="result-message-description"]'; | ||
private SIGNATURE = '[data-testid="sign-message-signature"]'; | ||
private COPY_BUTTON = '[data-testid="copy-button"]'; | ||
private CLOSE_BUTTON = '[data-testid="close-button"]'; | ||
|
||
get image(): ChainablePromiseElement<WebdriverIO.Element> { | ||
return $(this.IMAGE); | ||
} | ||
|
||
get title(): ChainablePromiseElement<WebdriverIO.Element> { | ||
return $(this.TITLE); | ||
} | ||
|
||
get description(): ChainablePromiseElement<WebdriverIO.Element> { | ||
return $(this.DESCRIPTION); | ||
} | ||
|
||
get signature(): ChainablePromiseElement<WebdriverIO.Element> { | ||
return $(this.SIGNATURE); | ||
} | ||
|
||
get copyButton(): ChainablePromiseElement<WebdriverIO.Element> { | ||
return $(this.COPY_BUTTON); | ||
} | ||
|
||
get closeButton(): ChainablePromiseElement<WebdriverIO.Element> { | ||
return $(this.CLOSE_BUTTON); | ||
} | ||
|
||
async clickOnCopySignatureToClipboardButton(): Promise<void> { | ||
await this.copyButton.waitForClickable(); | ||
await this.copyButton.click(); | ||
} | ||
|
||
async clickOnCloseButton(): Promise<void> { | ||
await this.closeButton.waitForClickable(); | ||
await this.closeButton.click(); | ||
} | ||
} | ||
|
||
export default new MessageSigningAllDoneDrawer(); |
23 changes: 23 additions & 0 deletions
23
packages/e2e-tests/src/elements/settings/MessageSigningConfirmationDrawer.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,23 @@ | ||
/* eslint-disable no-undef */ | ||
import CommonDrawerElements from '../CommonDrawerElements'; | ||
import type { ChainablePromiseElement } from 'webdriverio'; | ||
|
||
class MessageSigningConfirmationDrawer extends CommonDrawerElements { | ||
private PASSWORD_INPUT = '[data-testid="password-input"]'; | ||
private SIGN_MESSAGE_BUTTON = '[data-testid="sign-message-button"]'; | ||
private CLOSE_BUTTON = '[data-testid="close-button"]'; | ||
|
||
get passwordInput(): ChainablePromiseElement<WebdriverIO.Element> { | ||
return $(this.PASSWORD_INPUT); | ||
} | ||
|
||
get signMessageButton(): ChainablePromiseElement<WebdriverIO.Element> { | ||
return $(this.SIGN_MESSAGE_BUTTON); | ||
} | ||
|
||
get closeButton(): ChainablePromiseElement<WebdriverIO.Element> { | ||
return $(this.CLOSE_BUTTON); | ||
} | ||
} | ||
|
||
export default new MessageSigningConfirmationDrawer(); |
Oops, something went wrong.