Skip to content

Commit

Permalink
fix(e2e): Fixed viewport
Browse files Browse the repository at this point in the history
  • Loading branch information
HajekOndrej authored and mroz22 committed Nov 5, 2024
1 parent f497c45 commit 9dcaacc
Show file tree
Hide file tree
Showing 66 changed files with 124 additions and 74 deletions.
3 changes: 3 additions & 0 deletions packages/suite-web/e2e/support/constants/languageMap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const languageMap = {
es: 'Español',
};
4 changes: 4 additions & 0 deletions packages/suite-web/e2e/support/enums/currency.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export enum Currency {
EUR = 'eur',
USD = 'usd',
}
3 changes: 3 additions & 0 deletions packages/suite-web/e2e/support/enums/language.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export enum Language {
Spanish = 'es',
}
5 changes: 5 additions & 0 deletions packages/suite-web/e2e/support/enums/theme.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export enum Theme {
System = 'system',
Dark = 'dark',
Light = 'light',
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/// <reference types="cypress" />

import { Currency } from '../../enums/currency';
import { Language } from '../../enums/language';
import { languageMap } from '../../constants/languageMap';
import { Theme } from '../../enums/theme';

class SettingsGeneral {
changeFiatCurrency(currency: Currency) {
cy.getTestElement('@settings/fiat-select/input')
.should('be.visible')
.click({ scrollBehavior: 'bottom' });
cy.getTestElement(`@settings/fiat-select/option/${currency}`).click();
}

changeTheme(theme: Theme) {
cy.getTestElement('@theme/color-scheme-select/input')
.should('be.visible')
.click({ scrollBehavior: 'bottom' });
cy.getTestElement(`@theme/color-scheme-select/option/${theme}`).click();
cy.getTestElement('@theme/color-scheme-select/input').should(
'contain',
Cypress._.capitalize(theme),
);
}

changeLanguage(language: Language) {
cy.getTestElement('@settings/language-select/input').click({ scrollBehavior: 'bottom' });
cy.getTestElement(`@settings/language-select/option/${language}`).click({ force: true });
cy.getTestElement('@settings/language-select/input').should(
'contain',
languageMap[language],
);
}
}

export const onSettingGeneralPage = new SettingsGeneral();
2 changes: 1 addition & 1 deletion packages/suite-web/e2e/tests/backup/t2t1-fail.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('Backup fail', () => {
cy.task('startEmu', { wipe: true, model: 'T2T1' });
cy.task('setupEmu', { needs_backup: true });
cy.task('startBridge');
cy.viewport(1440, 2560).resetDb();
cy.viewport('macbook-13').resetDb();
cy.prefixedVisit('/');
cy.passThroughInitialRun();

Expand Down
2 changes: 1 addition & 1 deletion packages/suite-web/e2e/tests/backup/t2t1-success.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('Backup success', () => {
});
cy.task('startBridge');

cy.viewport(1440, 2560).resetDb();
cy.viewport('macbook-13').resetDb();
cy.prefixedVisit('/');
cy.passThroughInitialRun();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// @retry=2

import { onNavBar } from '../../support/pageObjects/topBarObject';
import { onSettingsMenu } from '../../support/pageObjects/settingsMenuObject';
import { onSettingsDevicePage } from '../../support/pageObjects/settingsDeviceObject';
import { onSettingsMenu } from '../../support/pageObjects/settings/settingsMenuObject';
import { onSettingsDevicePage } from '../../support/pageObjects/settings/settingsDeviceObject';
import { onMultiShareBackupModal } from '../../support/pageObjects/multiShareBackupObject';

const mnemonic =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

describe('Windows 7 with outdated chrome ', () => {
before(() => {
cy.viewport(1440, 2560);
cy.viewport('macbook-13');
cy.resetDb();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

describe('Ubuntu with outdated firefox ', () => {
before(() => {
cy.viewport(1440, 2560);
cy.viewport('macbook-13');
cy.resetDb();
});

Expand Down
2 changes: 1 addition & 1 deletion packages/suite-web/e2e/tests/browser/safari.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

describe('Safari on MacOS 14 ', () => {
before(() => {
cy.viewport(1440, 2560);
cy.viewport('macbook-13');
cy.resetDb();
});

Expand Down
2 changes: 1 addition & 1 deletion packages/suite-web/e2e/tests/dashboard/dashboard.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('Dashboard', () => {
});
cy.task('startBridge');

cy.viewport(1440, 2560).resetDb();
cy.viewport('macbook-13').resetDb();
cy.interceptInvityApi();
cy.prefixedVisit('/');
cy.passThroughInitialRun();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('Dashboard', () => {
cy.task('setupEmu');
cy.task('startBridge');

cy.viewport(1440, 2560).resetDb();
cy.viewport('macbook-13').resetDb();
cy.prefixedVisit('/');
cy.passThroughInitialRun();

Expand Down
2 changes: 1 addition & 1 deletion packages/suite-web/e2e/tests/firmware/firmware.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
describe('Firmware', () => {
beforeEach(() => {
// use portrait mode monitor to prevent scrolling in settings
cy.viewport(1440, 2560).resetDb();
cy.viewport('macbook-13').resetDb();
});

it(`Firmware 2.5.2 outdated notification banner should open firmware update modal`, () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const metadataEl = '@metadata/addressLabel/bc1q7e6qu5smalrpgqrx9k2gnf0hgjyref5p3

describe('Metadata - address labeling', () => {
beforeEach(() => {
cy.viewport(1440, 2560).resetDb();
cy.viewport('macbook-13').resetDb();
});

it(provider, () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { onNavBar } from '../../support/pageObjects/topBarObject';

describe('Dropbox api errors', () => {
beforeEach(() => {
cy.viewport(1440, 2560).resetDb();
cy.viewport('macbook-13').resetDb();
});

it('Malformed token', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const provider = 'google';

describe('Google api errors', () => {
beforeEach(() => {
cy.viewport(1440, 2560).resetDb();
cy.viewport('macbook-13').resetDb();
cy.task('startEmu', { wipe: true });
cy.task('setupEmu', { mnemonic: 'mnemonic_all' });
cy.task('startBridge');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const fixtures = [

describe('Metadata - suite is watching cloud provider and syncs periodically', () => {
beforeEach(() => {
cy.viewport(1440, 2560).resetDb();
cy.viewport('macbook-13').resetDb();
});
fixtures.forEach(f => {
it(`${f.provider}-${f.desc}`, () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const providers = ['google'] as const;

describe('Metadata - Output labeling', () => {
beforeEach(() => {
cy.viewport(1440, 2560).resetDb();
cy.viewport('macbook-13').resetDb();
cy.task('rmDir', { dir: Cypress.config('downloadsFolder'), recursive: true, force: true });
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe(
() => {
beforeEach(() => {
// use portrait mode monitor to prevent scrolling in settings
cy.viewport(1440, 2560).resetDb();
cy.viewport('macbook-13').resetDb();
});

providers.forEach(f => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { onNavBar } from '../../support/pageObjects/topBarObject';
describe(`Metadata - switching between cloud providers`, () => {
beforeEach(() => {
// use portrait mode monitor to prevent scrolling in settings
cy.viewport(1440, 2560).resetDb();
cy.viewport('macbook-13').resetDb();
});

it('Start with one and switch to another', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function checkStateNotificationsForErrors(): void {

describe('Metadata - wallet labeling', () => {
beforeEach(() => {
cy.viewport(1440, 2560).resetDb();
cy.viewport('macbook-13').resetDb();
cy.task('startEmu', { wipe: true });
cy.task('setupEmu', {
mnemonic: 'mnemonic_all',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const acceptAnalyticsConsentOnInitializedDevice = () => {
describe('Onboarding - analytics consent', () => {
beforeEach(() => {
cy.task('startBridge');
cy.viewport(1440, 2560).resetDb();
cy.viewport('macbook-13').resetDb();
});

it('analytics consent appears on any route that is visited initially. this time /accounts', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ describe('Onboarding - recover wallet T1B1', () => {
cy.task('startEmu', { model: 'T1B1', version: '1-latest', wipe: true });
cy.task('startBridge');

cy.viewport(1440, 2560).resetDb();
cy.viewport('macbook-13').resetDb();
cy.prefixedVisit('/');
cy.disableFirmwareHashCheck();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('Onboarding - recover wallet T1B1', () => {
beforeEach(() => {
cy.task('startBridge');
cy.task('startEmu', { model: 'T1B1', version: '1-latest', wipe: true });
cy.viewport(1440, 2560).resetDb();
cy.viewport('macbook-13').resetDb();
cy.prefixedVisit('/');
cy.disableFirmwareHashCheck();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('Onboarding - recover wallet T1B1', () => {
beforeEach(() => {
cy.task('startBridge');
cy.task('startEmu', { model: 'T1B1', version: '1-latest', wipe: true });
cy.viewport(1440, 2560).resetDb();
cy.viewport('macbook-13').resetDb();
cy.prefixedVisit('/');
cy.disableFirmwareHashCheck();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { onNavBar } from '../../../support/pageObjects/topBarObject';
describe('Onboarding - recover wallet T2T1', () => {
beforeEach(() => {
cy.task('startBridge');
cy.viewport(1440, 2560).resetDb();
cy.viewport('macbook-13').resetDb();
cy.prefixedVisit('/');
// note: this is an example of test that can not be parametrized to be both integration (isolated) test and e2e test.
// the problem is that it always needs to run the newest possible emulator. If this was pinned to use emulator which is currently
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('Onboarding - T2T1 in recovery mode', () => {
cy.task('startBridge');
cy.task('startEmu', { wipe: true, model: 'T2T1', version: '2.5.3' });
cy.resetDb();
cy.viewport(1440, 2560);
cy.viewport('macbook-13');
cy.prefixedVisit('/');
cy.getTestElement('@analytics/continue-button').click();
cy.getTestElement('@analytics/continue-button').click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('Onboarding - recover wallet T2T1', () => {
beforeEach(() => {
cy.task('startBridge');
cy.task('startEmu', { wipe: true, model: 'T2T1', version: '2.5.3' });
cy.viewport(1440, 2560).resetDb();
cy.viewport('macbook-13').resetDb();
cy.prefixedVisit('/');

cy.step('Go through analytics and confirm firmware', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/suite-web/e2e/tests/onboarding/transport.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

describe('Onboarding - transport webusb/bridge', () => {
beforeEach(() => {
cy.viewport(1440, 2560).resetDb();
cy.viewport('macbook-13').resetDb();
cy.prefixedVisit('/');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('ApplicationLog', () => {
cy.task('startEmu', { wipe: true });
cy.task('setupEmu');
cy.task('startBridge');
cy.viewport(1440, 2560).resetDb();
cy.viewport('macbook-13').resetDb();
cy.prefixedVisit('/');
cy.passThroughInitialRun();
});
Expand Down
2 changes: 1 addition & 1 deletion packages/suite-web/e2e/tests/settings/autodetect.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

describe('Language and theme detection', () => {
beforeEach(() => {
cy.viewport(1440, 2560).resetDb();
cy.viewport('macbook-13').resetDb();
});

// TODO: [low prio] extend the test to work even when the user has dark settings
Expand Down
2 changes: 1 addition & 1 deletion packages/suite-web/e2e/tests/settings/coins.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ describe('Coin Settings', () => {
});

// // this helps with unstable click to btc
cy.contains('span', 'Got it!').should('be.visible').click();
cy.contains('span', 'Got it!').should('be.visible').click({ scrollBehavior: 'bottom' });
cy.wait(500);
// disable Bitcoin
cy.getTestElement('@settings/wallet/network/btc').click();
Expand Down
18 changes: 8 additions & 10 deletions packages/suite-web/e2e/tests/settings/general.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
import { EventType } from '@trezor/suite-analytics';
import { ExtractByEventType, Requests } from '../../support/types';
import { onNavBar } from '../../support/pageObjects/topBarObject';
import { onSettingGeneralPage } from '../../support/pageObjects/settings/settingsGeneralObject';
import { Currency } from '../../support/enums/currency';
import { Language } from '../../support/enums/language';
import { Theme } from '../../support/enums/theme';

let requests: Requests;

Expand All @@ -13,8 +17,7 @@ describe('General settings', () => {
cy.task('startEmu', { wipe: true });
cy.task('setupEmu', { needs_backup: false });
cy.task('startBridge');
// use portrait mode monitor to prevent scrolling in settings
cy.viewport(1440, 2560).resetDb();
cy.viewport('macbook-13').resetDb();
cy.prefixedVisit('/');
cy.passThroughInitialRun();
cy.discoveryShouldFinish();
Expand All @@ -36,8 +39,7 @@ describe('General settings', () => {
});

// change fiat
cy.getTestElement('@settings/fiat-select/input').click({ scrollBehavior: false });
cy.getTestElement('@settings/fiat-select/option/eur').click({ force: true });
onSettingGeneralPage.changeFiatCurrency(Currency.EUR);

cy.findAnalyticsEventByType<ExtractByEventType<EventType.SettingsGeneralChangeFiat>>(
requests,
Expand All @@ -54,9 +56,7 @@ describe('General settings', () => {
onNavBar.openSettings();

// change dark mode
cy.getTestElement('@theme/color-scheme-select/input').click();
cy.getTestElement('@theme/color-scheme-select/option/dark').click({ force: true });
cy.getTestElement('@theme/color-scheme-select/input').should('contain', 'Dark');
onSettingGeneralPage.changeTheme(Theme.Dark);

cy.findAnalyticsEventByType<ExtractByEventType<EventType.SettingsGeneralChangeTheme>>(
requests,
Expand All @@ -74,9 +74,7 @@ describe('General settings', () => {
cy.contains('Current version');

// change language
cy.getTestElement('@settings/language-select/input').click({ scrollBehavior: 'bottom' });
cy.getTestElement('@settings/language-select/option/es').click({ force: true });
cy.getTestElement('@settings/language-select/input').should('contain', 'Español');
onSettingGeneralPage.changeLanguage(Language.Spanish);

cy.findAnalyticsEventByType<ExtractByEventType<EventType.SettingsGeneralChangeLanguage>>(
requests,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('Safety Checks Settings', () => {
cy.task('startEmu', { wipe: true });
cy.task('setupEmu');
cy.task('startBridge');
cy.viewport(1440, 2560).resetDb();
cy.viewport('macbook-13').resetDb();
cy.prefixedVisit('/');
cy.passThroughInitialRun();
onNavBar.openSettings();
Expand Down
Loading

0 comments on commit 9dcaacc

Please sign in to comment.