From 41ffd51325564740a2d9b7c75d0b84bedaf676c8 Mon Sep 17 00:00:00 2001 From: Nikolas De Giorgis Date: Thu, 23 Oct 2025 10:18:02 +0100 Subject: [PATCH] tests: add GapLimits e2e test. --- .github/workflows/playwright.yml | 2 +- frontends/web/package-lock.json | 1 + frontends/web/playwright.config.ts | 4 +- frontends/web/tests/gapSettings.test.ts | 79 +++++++++++++++++++++++++ 4 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 frontends/web/tests/gapSettings.test.ts diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 2e15ff5ae5..457d24417d 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -95,7 +95,7 @@ jobs: run: make webe2etest - name: Upload Playwright artifacts - if: failure() + if: always() uses: actions/upload-artifact@v4 with: name: playwright-artifacts diff --git a/frontends/web/package-lock.json b/frontends/web/package-lock.json index dc7a19b42e..3df33a8057 100644 --- a/frontends/web/package-lock.json +++ b/frontends/web/package-lock.json @@ -1620,6 +1620,7 @@ }, "node_modules/@parcel/watcher-wasm/node_modules/napi-wasm": { "version": "1.1.0", + "extraneous": true, "inBundle": true, "license": "MIT" }, diff --git a/frontends/web/playwright.config.ts b/frontends/web/playwright.config.ts index 2210c77cef..b9aabd4df3 100644 --- a/frontends/web/playwright.config.ts +++ b/frontends/web/playwright.config.ts @@ -22,9 +22,9 @@ export default defineConfig({ use: { baseURL: `http://${HOST}:${FRONTEND_PORT}`, headless: true, - video: 'retain-on-failure', + video: 'on', screenshot: 'only-on-failure', - trace: 'retain-on-failure', + trace: 'on', launchOptions: { // By default, tests are not run in slow motion. // Can be enabled by setting the PLAYWRIGHT_SLOW_MO environment variable to a value > 0. diff --git a/frontends/web/tests/gapSettings.test.ts b/frontends/web/tests/gapSettings.test.ts new file mode 100644 index 0000000000..07783feab7 --- /dev/null +++ b/frontends/web/tests/gapSettings.test.ts @@ -0,0 +1,79 @@ +/** +* Copyright 2025 Shift Crypto AG +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + + + +import { test } from './helpers/fixtures'; +import { ServeWallet } from './helpers/servewallet'; +import { expect } from '@playwright/test'; +import { clickButtonWithText } from './helpers/dom'; +import { deleteAccountsFile } from './helpers/fs'; + +let servewallet: ServeWallet; + +test('Gap limits are correctly saved', async ({ page, host, frontendPort, servewalletPort }) => { + + await test.step('Start servewallet', async () => { + servewallet = new ServeWallet(page, servewalletPort, frontendPort, host); + await servewallet.start(); + }); + + + await test.step('Navigate to the app', async () => { + await page.goto(`http://${host}:${frontendPort}`); + const body = page.locator('body'); + await expect(body).toContainText('Please connect your BitBox and tap the side to continue.'); + }); + + await test.step('Type into gap limit inputs', async () => { + await page.getByRole('link', { name: 'Settings' }).click(); + await page.getByRole('link', { name: 'Advanced settings' }).click(); + await page.getByRole('button', { name: 'Custom gap limit settings' }).click(); + + const recvInput = page.locator('#gapLimitReceive'); + await recvInput.clear(); + await recvInput.click(); + await page.keyboard.press('5'); + await page.waitForTimeout(1000); + await page.keyboard.press('0'); + + + const changeInput = page.locator('#gapLimitChange'); + await changeInput.clear(); + await changeInput.click(); + await page.keyboard.press('6'); + await page.waitForTimeout(1000); + await page.keyboard.press('0'); + + await clickButtonWithText(page, 'Confirm'); + }); + + await test.step('Verify gap limit inputs are correctly saved', async () => { + await page.getByRole('button', { name: 'Custom gap limit settings' }).click(); + const recvInput = page.locator('#gapLimitReceive'); + await expect(recvInput).toHaveValue('50'); + const changeInput = page.locator('#gapLimitChange'); + await expect(changeInput).toHaveValue('60'); + }); +}); + +test.beforeEach(() => { + deleteAccountsFile(); +}); + +test.afterAll(() => { + servewallet.stop(); +});