Skip to content

Commit

Permalink
Revert changes in homepage.ts, update snap-account-settings test, and…
Browse files Browse the repository at this point in the history
… implement missing page objects and methods
  • Loading branch information
devin-ai-integration[bot] committed Sep 20, 2024
1 parent 0ffb51b commit 637cad7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 69 deletions.
14 changes: 14 additions & 0 deletions test/e2e/page-objects/pages/header-navbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@ class HeaderNavbar {

private lockMetaMaskButton: string;

private settingsButton: string;

constructor(driver: Driver) {
this.driver = driver;
this.accountMenuButton = '[data-testid="account-menu-icon"]';
this.accountOptionMenu = '[data-testid="account-options-menu-button"]';
this.lockMetaMaskButton = '[data-testid="global-menu-lock"]';
this.settingsButton = '[data-testid="settings-button"]';
}

async openAccountMenu(): Promise<void> {
Expand All @@ -24,6 +27,17 @@ class HeaderNavbar {
await this.driver.clickElement(this.accountOptionMenu);
await this.driver.clickElement(this.lockMetaMaskButton);
}

async clickSettingsButton(): Promise<void> {
console.log('Clicking settings button');
try {
await this.driver.clickElement(this.settingsButton);
console.log('Settings button clicked successfully');
} catch (error) {
console.error('Failed to click settings button', error);
throw new Error(`Unable to click settings button: ${(error as Error).message}`);
}
}
}

export default HeaderNavbar;
60 changes: 0 additions & 60 deletions test/e2e/page-objects/pages/homepage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,66 +168,6 @@ class HomePage {
`Amount for transaction ${expectedNumber} is displayed as ${expectedAmount}`,
);
}

async openAddAccountModal(): Promise<void> {
console.log('Opening Add Account modal');
try {
await this.driver.clickElement(
'[data-testid="multichain-account-menu-popover-action-button"]',
);
console.log('Add Account modal opened successfully');
} catch (error) {
console.error('Failed to open Add Account modal', error);
throw new Error(`Unable to open Add Account modal: ${(error as Error).message}`);
}
}

async assertAddAccountSnapButtonNotPresent(): Promise<void> {
console.log('Asserting Add account Snap button is not present');
try {
await this.driver.assertElementNotPresent(
{
text: 'Add account Snap',
tag: 'button',
},
{
findElementGuard: {
text: 'Add a new Ethereum account',
tag: 'button',
},
},
);
console.log('Add account Snap button is not present as expected');
} catch (error) {
console.error('Failed to assert Add account Snap button is not present', error);
throw new Error(`Add account Snap button is unexpectedly present: ${(error as Error).message}`);
}
}

async assertAddAccountSnapButtonPresent(): Promise<void> {
console.log('Asserting Add account Snap button is present');
try {
await this.driver.findElement({
text: 'Add account Snap',
tag: 'button',
});
console.log('Add account Snap button is present as expected');
} catch (error) {
console.error('Failed to assert Add account Snap button is present', error);
throw new Error(`Add account Snap button is unexpectedly not present: ${(error as Error).message}`);
}
}

async closeModal(): Promise<void> {
console.log('Closing modal');
try {
await this.driver.clickElement('.mm-box button[aria-label="Close"]');
console.log('Modal closed successfully');
} catch (error) {
console.error('Failed to close modal', error);
throw new Error(`Unable to close modal: ${(error as Error).message}`);
}
}
}

export default HomePage;
19 changes: 10 additions & 9 deletions test/e2e/tests/account/snap-account-settings.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import SettingsPage from '../../page-objects/pages/settings-page';
import ExperimentalSettings from '../../page-objects/pages/experimental-settings';
import { loginWithBalanceValidation } from '../../page-objects/flows/login.flow';
import HeaderNavbar from '../../page-objects/pages/header-navbar';
import HomePage from '../../page-objects/pages/homepage';
import AccountListPage from '../../page-objects/pages/account-list-page';

describe('Add snap account experimental settings', function (this: Suite) {
it('switch "Enable Add account snap" to on', async function () {
Expand All @@ -20,22 +20,23 @@ describe('Add snap account experimental settings', function (this: Suite) {

// Make sure the "Add snap account" button is not visible.
const headerNavbar = new HeaderNavbar(driver);
const homePage = new HomePage(driver);
await homePage.openAccountMenu();
await homePage.openAddAccountModal();
await homePage.assertAddAccountSnapButtonNotPresent();
await homePage.closeModal();
await headerNavbar.openAccountMenu();
const accountListPage = new AccountListPage(driver);
await accountListPage.openAddAccountModal();
await accountListPage.check_addAccountSnapButtonNotPresent();
await accountListPage.closeAccountModal();

// Navigate to experimental settings and enable Add account Snap.
await headerNavbar.clickSettingsButton();
const settingsPage = new SettingsPage(driver);
await settingsPage.goToExperimentalSettings();
const experimentalSettings = new ExperimentalSettings(driver);
await experimentalSettings.toggleAddAccountSnap();

// Make sure the "Add account Snap" button is visible.
await homePage.openAccountMenu();
await homePage.openAddAccountModal();
await homePage.assertAddAccountSnapButtonPresent();
await headerNavbar.openAccountMenu();
await accountListPage.openAddAccountModal();
await accountListPage.check_addAccountSnapButtonIsDisplayed();
},
);
});
Expand Down

0 comments on commit 637cad7

Please sign in to comment.