Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat convert cy pw suite settings safety #15886

Merged
merged 1 commit into from
Dec 11, 2024
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
@@ -0,0 +1,72 @@
import { test, expect } from '../../support/fixtures';

test.describe('Safety Checks Settings', { tag: ['@group=settings'] }, () => {
test.use({ emulatorStartConf: { wipe: true } });
test.beforeEach(async ({ onboardingPage, settingsPage }) => {
await onboardingPage.completeOnboarding();
await settingsPage.navigateTo();
await settingsPage.deviceTabButton.click();
});

test('There is button in device settings, that opens safety checks modal.', async ({
window: page,
}) => {
await page.getByTestId('@settings/device/safety-checks-button').click();
await expect(page.getByTestId('@safety-checks-apply')).toBeVisible();
});

test('Only one level is selected at a time', async ({ window: page }) => {
// Open the safety checks modal.
await page.getByTestId('@settings/device/safety-checks-button').click();

// There should be two radio buttons, one checked and one not.
await expect(page.locator('[data-testid*="@radio-button"]')).toHaveCount(2);
await expect(
page.locator('[data-testid*="@radio-button"][data-checked="true"]'),
).toHaveCount(1);
await expect(
page.locator('[data-testid*="@radio-button"][data-checked="false"]'),
).toHaveCount(1);

await page.locator('[data-testid*="@radio-button"][data-checked="false"]').click();
// After switching the value, there should still be one checked and one unchecked.
await expect(
page.locator('[data-testid*="@radio-button"][data-checked="true"]'),
).toHaveCount(1);
await expect(
page.locator('[data-testid*="@radio-button"][data-checked="false"]'),
).toHaveCount(1);
});

test('Apply button is enabled only when value is changed', async ({ window: page }) => {
// Open the safety checks modal.
await page.getByTestId('@settings/device/safety-checks-button').click();

await expect(page.getByTestId('@safety-checks-apply')).toBeDisabled();
await page.locator('[data-testid*="@radio-button"][data-checked="false"]').click();
await expect(page.getByTestId('@safety-checks-apply')).not.toBeDisabled();
});

test('Device safety_check setting is changed after pressing the apply button', async ({
window: page,
trezorUserEnvLink,
}) => {
await page.getByTestId('@settings/device/safety-checks-button').click();
// Don't assume the device is set to any particular value.
// Just switch to the one that is not currently checked.
await page.locator('[data-testid*="@radio-button"][data-checked="false"]').click();
const targetValue = await page
.locator('[data-testid*="@radio-button"][data-checked="true"]')
.getAttribute('data-testid');
if (!targetValue) {
throw new Error('Target value not found');
}
// Changing safety_checks to targetValue
await page.getByTestId('@safety-checks-apply').click();
await expect(page.getByTestId('@prompts/confirm-on-device')).toBeVisible();
await trezorUserEnvLink.pressYes();

await page.getByTestId('@settings/device/safety-checks-button').click();
await expect(page.getByTestId(targetValue)).toHaveAttribute('data-checked', 'true');
});
});
75 changes: 0 additions & 75 deletions packages/suite-web/e2e/tests/settings/safety-checks.test.ts

This file was deleted.

Loading