Skip to content
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
Expand Up @@ -8,6 +8,7 @@ declare module '@playwright/test' {
// Methods
discoveryShouldFinish(): Promise<void>;
selectDropdownOptionWithRetry(dropdown: Locator, option: Locator): Promise<void>;
getReduxObject(objectPath: string): Promise<any>;
expectReduxObjectNotToBeEmpty(
objectPath: string,
options?: { timeout?: number },
Expand Down Expand Up @@ -51,14 +52,19 @@ export const enhancePage = (page: Page): Page => {
});
};

page.getReduxObject = async (objectPath: string) => {
const state = await page.evaluate(() => window.store.getState());

return get(state, objectPath);
};

page.expectReduxObjectNotToBeEmpty = async function (
objectPath: string,
options = { timeout: 5000 },
) {
await test.step('Expect Redux object not to be empty', async () => {
await expect(async () => {
const state = await page.evaluate(() => window.store.getState());
const testedObject = get(state, objectPath);
const testedObject = await page.getReduxObject(objectPath);
expect(testedObject).toBeDefined();
expect(testedObject).not.toBeNull();
expect(testedObject).not.toEqual({});
Expand All @@ -73,8 +79,7 @@ export const enhancePage = (page: Page): Page => {
) {
await test.step('Expect Redux object to equal', async () => {
await expect(async () => {
const state = await page.evaluate(() => window.store.getState());
const testedObject = get(state, objectPath);
const testedObject = await page.getReduxObject(objectPath);
expect(testedObject).toStrictEqual(expectedValue);
}).toPass({ timeout: options.timeout });
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ test.describe('Passphrase with cardano', { tag: ['@group=passphrase'] }, () => {
await trezorUserEnvLink.stopEmu();
await expect(page.getByTestId('@deviceStatus-disconnected')).toBeVisible();
await trezorUserEnvLink.startEmu({ model: emulatorStartConf.model, wipe: false });
await expect(page.getByTestId('@deviceStatus-connected')).toBeVisible();
await expect(page.getByTestId('@deviceStatus-connected')).toBeVisible({
timeout: 15_000,
});
});
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same performance degradation as we saw in t2t1-recovery-persistence.test.ts test. I have message ready for tech connect channel, I just asked our qa for quick confirmation on real devices.

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,21 @@ test.describe('Trading - Swap coins', { tag: ['@group=trading', '@webOnly'] }, (
await expect(devicePrompt.cryptoAmountWithSymbolOf('total')).toHaveText(
formattedSendAmount,
);
await expect(devicePrompt.cryptoAmountOf('fee')).toHaveText(solanaFee);
// Temporary debug information to solve issue that is happening only on CI.
// Suite probably fails to simulate fees and use fallback. That is correct behaviour.
// We are trying to find out whether there is something in redux state that could help us detect such situation.
// Goal would be to detect such a state and adjust expected fee to fallback value.
const debugFeeInfo = JSON.stringify(
await page.getReduxObject('wallet.trading.composedTransactionInfo'),
null,
2,
);
Comment on lines +97 to +101
Copy link
Preview

Copilot AI Oct 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding error handling around the Redux state access and JSON.stringify operations to prevent test failures if the state is unavailable or contains circular references.

Suggested change
const debugFeeInfo = JSON.stringify(
await page.getReduxObject('wallet.trading.composedTransactionInfo'),
null,
2,
);
let debugFeeInfo: string;
try {
const reduxObj = await page.getReduxObject('wallet.trading.composedTransactionInfo');
debugFeeInfo = JSON.stringify(reduxObj, null, 2);
} catch (err) {
debugFeeInfo = `Could not serialize Redux transaction info: ${err}`;
}

Copilot uses AI. Check for mistakes.

const verboseErrorMessage =
'Fee displayed on the device does not match expected fee from form. Redux transaction info: ' +
debugFeeInfo;
await expect(devicePrompt.cryptoAmountOf('fee'), verboseErrorMessage).toHaveText(
solanaFee,
);
await expect(devicePrompt).toDisplayOnEmulator({
header: { title: 'Summary' },
body: [
Expand All @@ -105,7 +119,6 @@ test.describe('Trading - Swap coins', { tag: ['@group=trading', '@webOnly'] }, (

await devicePrompt.waitForFinalPromptAndConfirm();
});

// Thanks to our mocked responses, the crypto is actually not send.
await test.step('Send crypto to provider', async () => {
await page.clock.install();
Expand Down
Loading