Skip to content

Commit 0ecb0bf

Browse files
authored
test(extension): test maintenance, add retry for authorization window… (#685)
* test(extension): test maintenance, add retry for authorization window in dapp * test(extension): apply comments * test(extension): apply comments
1 parent 715dc8c commit 0ecb0bf

File tree

6 files changed

+42
-10
lines changed

6 files changed

+42
-10
lines changed

packages/e2e-tests/src/assert/drawerSendExtendedAssert.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,10 @@ class DrawerSendExtendedAssert {
295295
}
296296

297297
async assertReviewTransactionButtonIsEnabled(shouldBeEnabled: boolean) {
298-
await new TransactionNewPage().reviewTransactionButton.waitForClickable({ reverse: !shouldBeEnabled });
298+
await new TransactionNewPage().reviewTransactionButton.waitForClickable({
299+
reverse: !shouldBeEnabled,
300+
timeout: 10_000
301+
});
299302
}
300303

301304
async assertReviewTransactionButtonIsDisplayed(shouldBeDisplayed: boolean) {

packages/e2e-tests/src/assert/tokensPageAssert.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ class TokensPageAssert {
152152
(await TokensPage.getTokenBalanceAsFloatByName(tokenName)) === expectedValueRounded - 0.01 ||
153153
(await TokensPage.getTokenBalanceAsFloatByName(tokenName)) === expectedValueRounded,
154154
{
155-
timeout: 50_000,
155+
timeout: 120_000,
156156
interval: 3000,
157157
timeoutMsg: `failed while waiting for ${tokenName} value update`
158158
}

packages/e2e-tests/src/features/analytics/AnalyticsSettingsPopup.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Feature: Analytics - Settings - Popup View
33

44
Background:
55
Given Lace is ready for test
6+
And I de-authorize all DApps in popup mode
67

78
@LW-8560
89
Scenario: Analytics - Popup view - Settings - Network events - Switch network

packages/e2e-tests/src/features/e2e/SendTransactionDappE2E.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Feature: Send Transactions from Dapp - E2E
3232
And I click on a transaction: 1
3333
Then The Tx details are displayed as "package.core.activityDetails.received" for ADA with value: 3.00 and wallet: "WalletSendSimpleTransactionE2E" address
3434

35-
@LW-6797 @Testnet
35+
@LW-6797 @Testnet @wip
3636
Scenario: Send Token from DApp E2E
3737
And I save token: "LaceCoin2" balance
3838
And I open and authorize test DApp with "Only once" setting

packages/e2e-tests/src/pageobject/dAppConnectorPageObject.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ import RemoveDAppModal from '../elements/dappConnector/removeDAppModal';
1111
import testContext from '../utils/testContext';
1212
import ConfirmTransactionPage from '../elements/dappConnector/confirmTransactionPage';
1313
import NoWalletModal from '../elements/dappConnector/noWalletModal';
14+
import DAppConnectorAssert, { ExpectedDAppDetails } from '../assert/dAppConnectorAssert';
15+
import { Logger } from '../support/logger';
16+
import TestDAppPage from '../elements/dappConnector/testDAppPage';
1417

1518
class DAppConnectorPageObject {
1619
TEST_DAPP_URL = this.getTestDAppUrl();
@@ -32,6 +35,12 @@ class DAppConnectorPageObject {
3235
await browser.switchWindow(this.DAPP_CONNECTOR_WINDOW_HANDLE);
3336
}
3437

38+
async closeDappConnectorWindowHandle() {
39+
await browser.switchWindow(this.DAPP_CONNECTOR_WINDOW_HANDLE);
40+
await browser.closeWindow();
41+
await this.switchToTestDAppWindow();
42+
}
43+
3544
async switchToTestDAppWindow() {
3645
await browser.switchWindow(this.TEST_DAPP_NAME);
3746
}
@@ -91,6 +100,30 @@ class DAppConnectorPageObject {
91100
feeValue = feeValue.replace(' ADA', '').replace('Fee: ', '');
92101
await testContext.save('feeValueDAppTx', feeValue);
93102
}
103+
104+
async switchToDappConnectorPopupAndAuthorize(testDAppDetails: ExpectedDAppDetails, mode: 'Always' | 'Only once') {
105+
await this.waitAndSwitchToDAppConnectorWindow(3);
106+
await DAppConnectorAssert.assertSeeAuthorizeDAppPage(testDAppDetails);
107+
await this.clickButtonInDAppAuthorizationWindow('Authorize');
108+
await this.clickButtonInDAppAuthorizationModal(mode);
109+
await this.switchToTestDAppWindow();
110+
await DAppConnectorAssert.waitUntilBalanceNotEmpty();
111+
}
112+
async switchToDappConnectorPopupAndAuthorizeWithRetry(
113+
testDAppDetails: ExpectedDAppDetails,
114+
mode: 'Always' | 'Only once'
115+
) {
116+
try {
117+
await this.switchToDappConnectorPopupAndAuthorize(testDAppDetails, mode);
118+
} catch {
119+
Logger.log('Failed to authorize Dapp. Retry will be executed');
120+
if ((await browser.getWindowHandles()).length === 3) {
121+
await this.closeDappConnectorWindowHandle();
122+
}
123+
await TestDAppPage.refreshButton.click();
124+
await this.switchToDappConnectorPopupAndAuthorize(testDAppDetails, mode);
125+
}
126+
}
94127
}
95128

96129
export default new DAppConnectorPageObject();

packages/e2e-tests/src/steps/dAppConnectorSteps.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,7 @@ Then(/^I see test DApp on the Authorized DApps list$/, async () => {
171171

172172
When(/^I open and authorize test DApp with "(Always|Only once)" setting$/, async (mode: 'Always' | 'Only once') => {
173173
await DAppConnectorPageObject.openTestDApp();
174-
await DAppConnectorPageObject.waitAndSwitchToDAppConnectorWindow(3);
175-
await DAppConnectorAssert.assertSeeAuthorizeDAppPage(testDAppDetails);
176-
await DAppConnectorPageObject.clickButtonInDAppAuthorizationWindow('Authorize');
177-
await DAppConnectorPageObject.clickButtonInDAppAuthorizationModal(mode);
178-
await DAppConnectorPageObject.switchToTestDAppWindow();
179-
await DAppConnectorAssert.waitUntilBalanceNotEmpty();
174+
await DAppConnectorPageObject.switchToDappConnectorPopupAndAuthorizeWithRetry(testDAppDetails, mode);
180175
});
181176

182177
Then(/^I de-authorize all DApps in (extended|popup) mode$/, async (mode: 'extended' | 'popup') => {
@@ -214,7 +209,7 @@ Then(/^I click "(Send ADA|Send Token)" "Run" button in test DApp$/, async (runBu
214209
}
215210
await browser.waitUntil(async () => (await browser.getWindowHandles()).length === handlesBeforeClick + 1, {
216211
interval: 1000,
217-
timeout: 4000,
212+
timeout: 6000,
218213
timeoutMsg: `failed while waiting for ${handlesBeforeClick + 1} window handles`
219214
});
220215
break;

0 commit comments

Comments
 (0)