Skip to content

Commit f097f64

Browse files
authored
test(all): add service worker log capture (#1468)
* test(all): add service worker log capture * test(all): capture all log levels for service worker logs
1 parent 14a7d53 commit f097f64

File tree

7 files changed

+32
-8
lines changed

7 files changed

+32
-8
lines changed

.github/actions/test/e2e/action.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ runs:
5151
BROWSER: ${{ inputs.BROWSER }}
5252
DISPLAY: ${{ inputs.DISPLAY }}
5353
BATCH: ${{ inputs.BATCH }}
54+
SERVICE_WORKER_LOGS: true
5455
run: |
5556
commonTags="@Testnet and not @Pending"
5657
tagsToRun="'${commonTags}'"

packages/e2e-tests/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ UI-mapped gherkin tests for the Lace browser extension
5656
environment variable)
5757
- `TEST_DAPP_URL=<url>`(required)
5858
- url for test DApp (only for DApp Connector tests)
59+
- `SERVICE_WORKER_LOGS=true|false` default=false (optional)
60+
- enables service worker logs collection
5961

6062
## Run single feature file with params
6163

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class WalletAddressPageAssert {
2727
}
2828
await WalletAddressPage.drawerHeaderCloseButton.waitForDisplayed();
2929
await WalletAddressPage.drawerHeaderSubtitle.waitForDisplayed();
30-
expect(await WalletAddressPage.drawerHeaderSubtitle.getText()).to.equal(
30+
expect(await WalletAddressPage.drawerHeaderSubtitle.getText()).contains(
3131
await t('qrInfo.scanQRCodeToConnectWallet')
3232
);
3333
await WalletAddressPage.qrCode.waitForDisplayed();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Feature: Wallet accounts
99
When I click the menu button
1010
And I click on chevron for wallet number 1
1111
Then "Accounts" menu is displayed
12-
And I see 24 accounts on the list
12+
And I see 50 accounts on the list
1313
And each account item contains icon, logo and path
1414

1515
@LW-9299

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Feature: Wallet accounts
99
When I click the menu button
1010
And I click on chevron for wallet number 1
1111
Then "Accounts" menu is displayed
12-
And I see 24 accounts on the list
12+
And I see 50 accounts on the list
1313
And each account item contains icon, logo and path
1414

1515
@LW-9319

packages/e2e-tests/src/hooks/scenarioTagRunner.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@ import { browser } from '@wdio/globals';
99
import consoleManager from '../utils/consoleManager';
1010

1111
import { clearWalletRepository } from '../fixture/walletRepositoryInitializer';
12+
import allure from '@wdio/allure-reporter';
1213

1314
// eslint-disable-next-line no-unused-vars
1415
Before(async () => {
15-
// use Before hooks in feature steps file, see AddressBook.ts as an example
16+
if (String(process.env.SERVICE_WORKER_LOGS) === 'true') {
17+
await consoleManager.startLogsCollection();
18+
}
1619
});
1720

1821
After({ tags: 'not @Pending and not @pending' }, async () => {
@@ -27,5 +30,16 @@ After({ tags: 'not @Pending and not @pending' }, async () => {
2730
});
2831

2932
AfterStep(async (scenario) => {
30-
if (scenario.result.status === 'FAILED') await browser.takeScreenshot();
33+
if (scenario.result.status === 'FAILED') {
34+
await browser.takeScreenshot();
35+
36+
if (String(process.env.SERVICE_WORKER_LOGS) === 'true') {
37+
const logs = await consoleManager.getLogsAsString();
38+
if (logs !== undefined) {
39+
allure.addAttachment('Service worker logs', logs, 'text/plain');
40+
}
41+
}
42+
await consoleManager.clearLogs();
43+
await consoleManager.closeOpenedCdpSessions();
44+
}
3145
});

packages/e2e-tests/src/utils/consoleManager.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ export class ConsoleManager {
2929
ConsoleManager.cdpSessions.push(client);
3030
await client.send(this.CONSOLE_ENABLE);
3131
client.on('Console.messageAdded', async (entry: any) => {
32-
if (entry.message.level !== 'debug') {
33-
ConsoleManager.capturedLogs.push(entry.message);
34-
}
32+
ConsoleManager.capturedLogs.push(entry.message);
3533
});
3634
});
3735
});
@@ -42,6 +40,15 @@ export class ConsoleManager {
4240
};
4341

4442
getLogs = async (): Promise<ConsoleLogEntry[]> => ConsoleManager.capturedLogs;
43+
44+
getLogsAsString = async (): Promise<string | undefined> => {
45+
let logs;
46+
for (const log of ConsoleManager.capturedLogs) {
47+
logs = `${logs} ${JSON.stringify(log)}`;
48+
}
49+
return logs;
50+
};
51+
4552
closeOpenedCdpSessions = async (): Promise<void> => {
4653
await this.clearLogs();
4754
ConsoleManager.cdpSessions.map(async (session) => {

0 commit comments

Comments
 (0)