Skip to content

Commit

Permalink
test(suite-native): add e2e test for device authenticity check
Browse files Browse the repository at this point in the history
  • Loading branch information
yanascz committed Nov 19, 2024
1 parent b438c73 commit 0c39ec6
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 4 deletions.
2 changes: 1 addition & 1 deletion suite-native/app/e2e/pageObjects/bottomSheetActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class BottomSheetActions {
async skipViewOnlyMode() {
const skipViewOnlyModeButton = element(by.id('skip-view-only-mode'));

await waitFor(skipViewOnlyModeButton).toBeVisible().withTimeout(10000);
await waitFor(skipViewOnlyModeButton).toBeVisible().withTimeout(20000);
await skipViewOnlyModeButton.tap();
}
}
Expand Down
16 changes: 16 additions & 0 deletions suite-native/app/e2e/pageObjects/deviceAuthenticitySummary.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class DeviceAuthenticitySummary {
async waitForScreen() {
await waitFor(element(by.id('@screen/AuthenticitySummary')))
.toBeVisible()
.withTimeout(10000);
}

async tapCloseButton() {
const closeButton = element(by.id('@device-authenticity/close-button'));

await waitFor(closeButton).toBeVisible().withTimeout(10000);
await closeButton.tap();
}
}

export const onDeviceAuthenticitySummary = new DeviceAuthenticitySummary();
15 changes: 15 additions & 0 deletions suite-native/app/e2e/pageObjects/deviceSettingsActions.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import { scrollUntilVisible } from '../utils';

const checkAuthenticityButtonId = by.id('@device-authenticity/check-button');

class DeviceSettingsActions {
async waitForScreen() {
await waitFor(element(by.id('@screen/DeviceSettings')))
Expand Down Expand Up @@ -25,6 +29,17 @@ class DeviceSettingsActions {
await waitFor(disablePinProtectionButton).toBeVisible().withTimeout(10000);
await disablePinProtectionButton.tap();
}

async scrollUntilCheckAuthenticityButtonIsVisible() {
await scrollUntilVisible(checkAuthenticityButtonId);
}

async tapCheckAuthenticityButton() {
const checkAuthenticityButton = element(checkAuthenticityButtonId);

await waitFor(checkAuthenticityButton).toBeVisible().withTimeout(10000);
await checkAuthenticityButton.tap();
}
}

export const onDeviceSettings = new DeviceSettingsActions();
19 changes: 19 additions & 0 deletions suite-native/app/e2e/tests/deviceSettings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { onAlertSheet } from '../pageObjects/alertSheetActions';
import { onBottomSheet } from '../pageObjects/bottomSheetActions';
import { onCoinEnablingInit } from '../pageObjects/coinEnablingActions';
import { onConnectingDevice } from '../pageObjects/connectingDevice';
import { onDeviceAuthenticitySummary } from '../pageObjects/deviceAuthenticitySummary';
import { onDeviceManager } from '../pageObjects/deviceManagerActions';
import { onDeviceSettings } from '../pageObjects/deviceSettingsActions';
import { onOnboarding } from '../pageObjects/onboardingActions';
Expand Down Expand Up @@ -77,4 +78,22 @@ conditionalDescribe(device.getPlatform() !== 'android', 'Device settings', () =>

await onDeviceSettings.waitForScreen();
});

test('Check device authenticity', async () => {
await onDeviceSettings.scrollUntilCheckAuthenticityButtonIsVisible();
await onDeviceSettings.tapCheckAuthenticityButton();

await onAlertSheet.tapPrimaryButton();
await TrezorUserEnvLink.pressNo();

await onDeviceSettings.tapCheckAuthenticityButton();

await onAlertSheet.tapPrimaryButton();
await TrezorUserEnvLink.pressYes();

await onDeviceAuthenticitySummary.waitForScreen();
await onDeviceAuthenticitySummary.tapCloseButton();

await onDeviceSettings.waitForScreen();
});
});
2 changes: 1 addition & 1 deletion suite-native/app/e2e/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export const prepareTrezorEmulator = async (seed: string = MNEMONICS.mnemonic_im
// Prepare Trezor device for test scenario
await TrezorUserEnvLink.disconnect();
await TrezorUserEnvLink.connect();
await TrezorUserEnvLink.startEmu({ wipe: true });
await TrezorUserEnvLink.startEmu({ model: 'T3T1', wipe: true });
await TrezorUserEnvLink.setupEmu({
label: TREZOR_DEVICE_LABEL,
mnemonic: seed,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,12 @@ export const DeviceAuthenticityCard = () => {
<Text variant="body" color="textSubdued">
<Translation id="moduleDeviceSettings.authenticity.content" />
</Text>
<Button size="small" colorScheme="tertiaryElevation0" onPress={showInfoAlert}>
<Button
size="small"
colorScheme="tertiaryElevation0"
onPress={showInfoAlert}
testID="@device-authenticity/check-button"
>
<Translation id="moduleDeviceSettings.authenticity.checkButton" />
</Button>
</VStack>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,11 @@ export const DeviceAuthenticitySummaryScreen = ({
<Translation id="moduleDeviceSettings.authenticity.summary.compromised.contactSupportButton" />
</Button>
)}
<Button colorScheme={closeColorScheme} onPress={navigateToInitialScreen}>
<Button
colorScheme={closeColorScheme}
onPress={navigateToInitialScreen}
testID="@device-authenticity/close-button"
>
<Translation id="generic.buttons.close" />
</Button>
</VStack>
Expand Down

0 comments on commit 0c39ec6

Please sign in to comment.