Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: [POM] Migrate connections e2e tests to TS and Page Object Model #29609

Merged
merged 22 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { Driver } from '../../../../webdriver/driver';

class ReviewPermissionsConfirmation {
driver: Driver;

private readonly reviewPermissionsConfirmationTitle = {
text: 'Review permissions',
tag: 'h3',
};

private readonly confirmReviewPermissionsButton =
'[data-testid="page-container-footer-next"]';

constructor(driver: Driver) {
this.driver = driver;
}

async check_pageIsLoaded(): Promise<void> {
try {
await this.driver.waitForSelector(
this.reviewPermissionsConfirmationTitle,
);
} catch (e) {
console.log(
'Timeout while waiting for Review permissions confirmation page to be loaded',
e,
);
throw e;
}
console.log('Review permissions confirmation page is loaded');
}

async confirmReviewPermissions(): Promise<void> {
console.log('Confirm review permissions');
await this.driver.clickElementAndWaitForWindowToClose(
this.confirmReviewPermissionsButton,
);
}
}

export default ReviewPermissionsConfirmation;
27 changes: 27 additions & 0 deletions test/e2e/page-objects/pages/permission/site-permission-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { Driver } from '../../../webdriver/driver';
class SitePermissionPage {
private driver: Driver;

private readonly confirmDisconnectButton = '[data-testid="disconnect-all"]';

private readonly confirmEditAccountsButton =
'[data-testid="connect-more-accounts-button"]';

Expand All @@ -18,6 +20,18 @@ class SitePermissionPage {
tag: 'p',
};

private readonly disconnectButton = '[data-test-id="disconnect-all"]';

private readonly disconnectConfirmMessage = {
text: 'MetaMask isn’t connected to this site',
tag: 'p',
};

private readonly disconnectModalTitle = {
text: 'Disconnect',
tag: 'h4',
};

private readonly editAccountsModalTitle = {
text: 'Edit accounts',
tag: 'h4',
Expand Down Expand Up @@ -59,6 +73,19 @@ class SitePermissionPage {
console.log('Site permission page is loaded');
}

/**
* Disconnect all permissions for accounts and networks
*/
async disconnectAll(): Promise<void> {
console.log('Disconnect all permissions for accounts and networks');
await this.driver.clickElement(this.disconnectButton);
await this.driver.waitForSelector(this.disconnectModalTitle);
await this.driver.clickElementAndWaitToDisappear(
this.confirmDisconnectButton,
);
await this.driver.waitForSelector(this.disconnectConfirmMessage);
}

/**
* Edit permissions for accounts on site permission page
*
Expand Down
8 changes: 7 additions & 1 deletion test/e2e/page-objects/pages/test-dapp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -612,13 +612,16 @@ class TestDapp {
* @param options - Options for connecting account to test dapp.
* @param [options.connectAccountButtonEnabled] - Indicates if the connect account button should be enabled.
* @param options.publicAddress - The public address to connect to test dapp.
* @param [options.chainId] - The chain id to connect to, defaults to 0x539.
*/
async connectAccount({
connectAccountButtonEnabled = true,
publicAddress,
chainId = '0x539',
}: {
connectAccountButtonEnabled?: boolean;
publicAddress?: string;
chainId?: string;
}) {
console.log('Connect account to test dapp');
await this.driver.clickElement(this.connectAccountButton);
Expand All @@ -634,7 +637,10 @@ class TestDapp {
}
if (publicAddress) {
await this.check_connectedAccounts(publicAddress);
await this.driver.waitForSelector(this.localhostNetworkMessage);
await this.driver.waitForSelector({
css: '#chainId',
text: chainId,
});
}
}

Expand Down
137 changes: 0 additions & 137 deletions test/e2e/tests/connections/review-permissions-page.spec.js

This file was deleted.

Loading
Loading