Files
trezor-suite/suite/e2e/tests/settings/application-log.test.ts
2026-01-13 17:40:27 +01:00

60 lines
2.6 KiB
TypeScript

import { readFileSync } from 'fs-extra';
import { expect, test } from '../../support/fixtures';
test.describe('Application Logs', { tag: ['@T3W1', '@T3T1'] }, () => {
test.beforeEach(async ({ onboardingPage, settingsPage }) => {
await onboardingPage.completeOnboarding();
await settingsPage.navigateTo('application');
});
test(
'Display and export application logs',
{ tag: ['@webOnly', '@T3W1', '@T3T1'] },
async ({ page }, testInfo) => {
const displayedLogs = await test.step('Display application logs', async () => {
await page.getByTestId('@settings/menu/general').click();
await page.getByTestId('@settings/show-log-button').click();
await expect(page.getByTestId('@modal/application-log')).toBeVisible();
await expect(page.getByTestId('@log/content')).not.toBeEmpty();
return page.getByTestId('@log/content').textContent();
});
const exportedLogPath =
await test.step('Export application logs and save them to filesystem', async () => {
const downloadPromise = page.waitForEvent('download');
await page.getByTestId('@log/export-button').click();
const download = await downloadPromise;
const exportedLogsPath = `${testInfo.outputDir}/${download.suggestedFilename()}`;
await download.saveAs(exportedLogsPath);
return exportedLogsPath;
});
await test.step('Compare displayed and exported logs', () => {
const exportedLogs = readFileSync(exportedLogPath, 'utf-8');
expect(exportedLogs).toBe(displayedLogs);
testInfo.attachments.push({
name: 'exported-log.txt',
path: exportedLogPath,
contentType: 'text/plain',
});
});
},
);
test(
'Display application logs',
{ tag: ['@desktopOnly', '@T3W1', '@T3T1'] },
async ({ page }) => {
await page.getByTestId('@settings/menu/general').click();
await page.getByTestId('@settings/show-log-button').click();
await expect(page.getByTestId('@modal/application-log')).toBeVisible();
await expect(page.getByTestId('@log/content')).not.toBeEmpty();
await expect(page.getByTestId('@log/export-button')).toBeVisible();
// Playwright does not support downloading files in electron, we would have to mock it
},
);
});