Skip to content

Commit

Permalink
feat(e2e): Convert cy to pw test suite settings/safety-checks.test.ts (
Browse files Browse the repository at this point in the history
  • Loading branch information
Vere-Grey authored Dec 11, 2024
1 parent df0159b commit 27542eb
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 75 deletions.
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.

0 comments on commit 27542eb

Please sign in to comment.