Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
chloeYue committed Dec 17, 2024
1 parent 617220f commit 0dfc59b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 35 deletions.
4 changes: 2 additions & 2 deletions test/e2e/json-rpc/wallet_revokePermissions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('Revoke Dapp Permissions', function () {
await loginWithBalanceValidation(driver);
const testDapp = new TestDapp(driver);
await testDapp.openTestDappPage();
await testDapp.check_ifAccountIsConnected(ACCOUNT_1);
await testDapp.check_connectedAccounts(ACCOUNT_1);

// wallet_revokePermissions request
const revokePermissionsRequest = JSON.stringify({
Expand All @@ -37,7 +37,7 @@ describe('Revoke Dapp Permissions', function () {
// Response of method call
assert.deepEqual(result, null);

await testDapp.check_ifAccountIsConnected(ACCOUNT_1, false);
await testDapp.check_connectedAccounts(ACCOUNT_1, false);
},
);
});
Expand Down
40 changes: 11 additions & 29 deletions test/e2e/page-objects/pages/test-dapp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ class TestDapp {
console.log('Connect account to test dapp');
await this.driver.clickElement(this.connectAccountButton);
await this.confirmConnectAccountModal();
await this.check_ifAccountIsConnected(publicAddress);
await this.check_connectedAccounts(publicAddress);
await this.driver.waitForSelector(this.localhostNetworkMessage);
}

Expand All @@ -316,48 +316,30 @@ class TestDapp {
await this.driver.clickElement(this.revokePermissionButton);
await this.driver.refresh();
await this.check_pageIsLoaded();
await this.check_ifAccountIsConnected(publicAddress, false);
await this.check_connectedAccounts(publicAddress, false);
}

/**
* Check if the account is connected to the test dapp.
* Check if the accounts connected to the test dapp.
*
* @param publicAddress - The public address to check if the account is connected to the test dapp.
* @param shouldBeConnected - Whether the account should be connected to the test dapp. Defaults to true.
* @param connectedAccounts - Account addresses to check if connected to test dapp, separated by a comma.
* @param shouldBeConnected - Whether the accounts should be connected to test dapp. Defaults to true.
*/
async check_ifAccountIsConnected(
publicAddress: string,
async check_connectedAccounts(
connectedAccounts: string,
shouldBeConnected: boolean = true,
) {
if (shouldBeConnected) {
console.log('Verify connected accounts:', connectedAccounts);
await this.driver.waitForSelector({
css: this.connectedAccount,
text: publicAddress.toLowerCase(),
text: connectedAccounts.toLowerCase(),
});
} else {
console.log('Verify accounts not connected:', connectedAccounts);
await this.driver.assertElementNotPresent({
css: this.connectedAccount,
text: publicAddress.toLowerCase(),
});
}
}

/**
* Verifies the accounts connected to the test dapp.
*
* @param connectedAccounts - The expected connected accounts separated by a comma. If no accounts are connected we can omit the param.
*/
async check_connectedAccounts(connectedAccounts: string = '') {
console.log('Verify connected accounts');
if (connectedAccounts) {
await this.driver.waitForSelector({
css: this.connectedAccount,
text: connectedAccounts,
});
} else {
await this.driver.waitForSelector({
css: this.connectedAccount,
text: ' ',
text: connectedAccounts.toLowerCase(),
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ describe('Request Queuing', function () {
// Open test dapp
const testDapp = new TestDapp(driver);
await testDapp.openTestDappPage();
await testDapp.check_connectedAccounts(
DEFAULT_FIXTURE_ACCOUNT.toLowerCase(),
);
await testDapp.check_connectedAccounts(DEFAULT_FIXTURE_ACCOUNT);

// Trigger a tx
await testDapp.clickSimpleSendButton();
Expand Down Expand Up @@ -71,7 +69,7 @@ describe('Request Queuing', function () {
await driver.waitUntilXWindowHandles(2);

// Cleared eth_accounts account label
await testDapp.check_connectedAccounts();
await testDapp.check_connectedAccounts(DEFAULT_FIXTURE_ACCOUNT, false);
},
);
});
Expand Down

0 comments on commit 0dfc59b

Please sign in to comment.