Skip to content

Commit

Permalink
Merge branch 'main' into LW-11556/advanced_mode_receive_tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ljagiela committed Sep 25, 2024
2 parents da936cb + d38eff3 commit b0f3cc9
Show file tree
Hide file tree
Showing 28 changed files with 498 additions and 44 deletions.
2 changes: 1 addition & 1 deletion apps/browser-extension-wallet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"openpgp": "^5.11.2",
"p-debounce": "^4.0.0",
"pluralize": "^8.0.0",
"posthog-js": "^1.68.4",
"posthog-js": "^1.161.3",
"process": "^0.11.10",
"qrcode": "^1.5.3",
"react": "17.0.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,11 @@ export class PostHogClient<Action extends string = string> {
request_batching: false,
api_host: this.postHogHost,
autocapture: false,
opt_out_useragent_filter: true,
disable_compression: true,
disable_session_recording: true,
capture_pageview: false,
capture_pageleave: false,
disable_compression: true,
// Disables PostHog user ID persistence - we manage ID ourselves with userIdService
disable_persistence: true,
disable_cookie: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,23 +67,31 @@ export const SignMessageDrawer: React.FC = () => {

const renderInitialState = () => (
<>
<Text.Body.Large weight="$bold">{t('core.signMessage.instructions')}</Text.Body.Large>
<Text.Body.Normal className={styles.subtitle}>{t('core.signMessage.subtitle')}</Text.Body.Normal>
<Text.Body.Large weight="$bold" data-testid={'drawer-header-title'}>
{t('core.signMessage.instructions')}
</Text.Body.Large>
<Text.Body.Normal className={styles.subtitle} data-testid={'drawer-header-subtitle'}>
{t('core.signMessage.subtitle')}
</Text.Body.Normal>
{isHardwareWallet && hardwareWalletError && (
<div className={styles.errorMessage}>
<Text.Body.Normal color="error">{hardwareWalletError}</Text.Body.Normal>
</div>
)}
<div className={styles.inputGroup}>
<Text.Body.Normal weight="$medium">{t('core.signMessage.addressLabel')}</Text.Body.Normal>
<Text.Body.Normal weight="$medium" data-testid={'address-label'}>
{t('core.signMessage.addressLabel')}
</Text.Body.Normal>
<WalletOwnAddressDropdown
addresses={usedAddresses}
onSelect={setSelectedAddress}
placeholder={t('core.signMessage.selectAddress')}
/>
</div>
<div className={styles.inputGroup}>
<Text.Body.Normal weight="$medium">{t('core.signMessage.messageLabel')}</Text.Body.Normal>
<Text.Body.Normal weight="$medium" data-testid={'message-to-sign-label'}>
{t('core.signMessage.messageLabel')}
</Text.Body.Normal>
<TextArea
placeholder={t('core.signMessage.messagePlaceholder')}
value={message}
Expand All @@ -98,12 +106,16 @@ export const SignMessageDrawer: React.FC = () => {

const renderPasswordPrompt = () => (
<>
<Text.Body.Large weight="$bold">{t('core.signMessage.passwordTitle')}</Text.Body.Large>
<Text.Body.Normal className={styles.subtitle}>{t('core.signMessage.passwordSubtitle')}</Text.Body.Normal>
<Text.Body.Large weight="$bold" data-testid={'drawer-header-title'}>
{t('core.signMessage.passwordTitle')}
</Text.Body.Large>
<Text.Body.Normal className={styles.subtitle} data-testid={'drawer-header-subtitle'}>
{t('core.signMessage.passwordSubtitle')}
</Text.Body.Normal>
<PasswordInput
onChange={setPassword}
label={t('core.signMessage.passwordLabel')}
dataTestId="sign-message-password-input"
dataTestId="password-input"
error={!!error}
errorMessage={error}
wrapperClassName={styles.passwordWrapper}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,19 @@ export const useDrawerConfiguration = ({
if (signatureObject?.signature && !error) {
return (
<CopyToClipboard text={signatureObject.signature}>
<Button onClick={handleCopy}>
<Button onClick={handleCopy} data-testid={'copy-button'}>
{t('core.signMessage.copyToClipboard')}
<CopyToClipboardImg className={styles.newFolderIcon} />
</Button>
</CopyToClipboard>
);
}
return (
<Button onClick={handleSign} disabled={!selectedAddress || !message || isSigningInProgress}>
<Button
onClick={handleSign}
disabled={!selectedAddress || !message || isSigningInProgress}
data-testid={'sign-message-button'}
>
{getActionButtonLabel()}
</Button>
);
Expand Down Expand Up @@ -84,6 +88,7 @@ export const useDrawerConfiguration = ({
closeDrawer();
clearSecrets();
}}
data-testid={'close-button'}
>
{t('core.signMessage.closeButton')}
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type Props = {
tooltipLabel?: string;
dropdownRender?: (menus: ReactNode) => ReactNode;
onCopy?: () => void;
testId?: 'AddressDisplayItem';
testId: string;
};

export const AddressDisplayItem = ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,12 @@ export const WalletOwnAddressDropdown = ({

return (
<Dropdown menu={menuProps} trigger={['click']}>
<Button variant="outlined" color="secondary" className={cn(styles.dropdownBtn)}>
<Button
variant="outlined"
color="secondary"
className={cn(styles.dropdownBtn)}
data-testid="select-address-button"
>
<span className={styles.content}>{selectedAddress}</span>
</Button>
</Dropdown>
Expand Down
5 changes: 1 addition & 4 deletions packages/e2e-tests/src/assert/helpAndSupportPageAssert.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import { browser } from '@wdio/globals';
import { expect } from 'chai';
import HelpAndSupportPage from '../elements/helpAndSupportPage';

class HelpAndSupportPageAssert {
assertSeeHelpAndSupportPage = async () => {
assertSeeHelpAndSupportPageURL = async () => {
// might need to be updated in the future
await browser.switchWindow('iohk.zendesk.com');
const currentUrl = await browser.getUrl();
const expectedUrl = 'https://iohk.zendesk.com/hc/en-us/requests/new';
expect(currentUrl).to.equal(expectedUrl);
await HelpAndSupportPage.breadcrumbPart1.waitForDisplayed();
await HelpAndSupportPage.breadcrumbPart2.waitForDisplayed();
};
}

Expand Down
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();
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();
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();
14 changes: 0 additions & 14 deletions packages/e2e-tests/src/elements/helpAndSupportPage.ts

This file was deleted.

10 changes: 10 additions & 0 deletions packages/e2e-tests/src/elements/menuHeader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export class MenuHeader {
private MENU_ADDRESS_BOOK_BUTTON = '//li[@data-testid="header-menu-address-book"]';
private MENU_ADD_NEW_WALLET_BUTTON = '[data-testid="header-menu-new-wallet"]';
private MENU_SETTINGS_BUTTON = '//li[@data-testid="header-menu-settings"]';
private MENU_SIGN_MESSAGE_BUTTON = '//li[@data-testid="header-menu-sign-message"]';
private MENU_LOCK_BUTTON = '//li[@data-testid="header-menu-lock"]';
private MENU_WALLET_OPTION_ITEM = '//button[@data-testid="wallet-option-item"]';
private MENU_WALLET_OPTION_NAME = '//span[@data-testid="wallet-option-title"]';
Expand Down Expand Up @@ -103,6 +104,10 @@ export class MenuHeader {
return $(this.MENU_SETTINGS_BUTTON);
}

get menuSignMessageButton(): ChainablePromiseElement<WebdriverIO.Element> {
return $(this.MENU_SIGN_MESSAGE_BUTTON);
}

get menuLockButton(): ChainablePromiseElement<WebdriverIO.Element> {
return $(this.MENU_LOCK_BUTTON);
}
Expand Down Expand Up @@ -198,6 +203,11 @@ export class MenuHeader {
await this.menuSettingsButton.click();
}

async clickSignMessageButton(): Promise<void> {
await this.menuSignMessageButton.waitForClickable();
await this.menuSignMessageButton.click();
}

async clickAddressBookOption(): Promise<void> {
await this.menuAddressBookButton.click();
}
Expand Down
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();
Loading

0 comments on commit b0f3cc9

Please sign in to comment.