|
| 1 | +/** |
| 2 | +* Copyright 2025 Shift Crypto AG |
| 3 | +* |
| 4 | +* Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +* you may not use this file except in compliance with the License. |
| 6 | +* You may obtain a copy of the License at |
| 7 | +* |
| 8 | +* http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +* |
| 10 | +* Unless required by applicable law or agreed to in writing, software |
| 11 | +* distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +* See the License for the specific language governing permissions and |
| 14 | +* limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | +import { test } from './helpers/fixtures'; |
| 20 | +import { ServeWallet } from './helpers/servewallet'; |
| 21 | +import { expect } from '@playwright/test'; |
| 22 | +import { clickButtonWithText } from './helpers/dom'; |
| 23 | +import { deleteAccountsFile } from './helpers/fs'; |
| 24 | + |
| 25 | +let servewallet: ServeWallet; |
| 26 | + |
| 27 | +test('Gap limits are correctly saved', async ({ page, host, frontendPort, servewalletPort }) => { |
| 28 | + |
| 29 | + await test.step('Start servewallet', async () => { |
| 30 | + servewallet = new ServeWallet(page, servewalletPort, frontendPort, host); |
| 31 | + await servewallet.start(); |
| 32 | + }); |
| 33 | + |
| 34 | + |
| 35 | + await test.step('Navigate to the app', async () => { |
| 36 | + await page.goto(`http://${host}:${frontendPort}`); |
| 37 | + const body = page.locator('body'); |
| 38 | + await expect(body).toContainText('Please connect your BitBox and tap the side to continue.'); |
| 39 | + }); |
| 40 | + |
| 41 | + await test.step('Type into gap limit inputs', async () => { |
| 42 | + await page.getByRole('link', { name: 'Settings' }).click(); |
| 43 | + await page.getByRole('link', { name: 'Advanced settings' }).click(); |
| 44 | + await page.getByRole('button', { name: 'Custom gap limit settings' }).click(); |
| 45 | + |
| 46 | + const recvInput = page.locator('#gapLimitReceive'); |
| 47 | + await recvInput.clear(); |
| 48 | + await recvInput.click(); |
| 49 | + await page.keyboard.press('5'); |
| 50 | + await expect(page.locator('label[for="gapLimitReceive"]')).toHaveText( |
| 51 | + 'Gap limit for receive addresses:The gap limit must be at least 20.' |
| 52 | + ); |
| 53 | + await page.waitForTimeout(1000); |
| 54 | + await expect(recvInput).toBeFocused(); |
| 55 | + await page.keyboard.press('0'); |
| 56 | + await expect(recvInput).toBeFocused(); |
| 57 | + |
| 58 | + |
| 59 | + const changeInput = page.locator('#gapLimitChange'); |
| 60 | + await changeInput.clear(); |
| 61 | + await changeInput.click(); |
| 62 | + await page.keyboard.press('1'); |
| 63 | + await expect(page.locator('label[for="gapLimitChange"]')).toHaveText( |
| 64 | + 'Gap limit for change addresses:The gap limit must be at least 6.' |
| 65 | + ); |
| 66 | + await page.waitForTimeout(1000); |
| 67 | + await expect(changeInput).toBeFocused(); |
| 68 | + await page.keyboard.press('0'); |
| 69 | + await expect(changeInput).toBeFocused(); |
| 70 | + |
| 71 | + await clickButtonWithText(page, 'Confirm'); |
| 72 | + }); |
| 73 | + |
| 74 | + await test.step('Verify gap limit inputs are correctly saved', async () => { |
| 75 | + await page.getByRole('button', { name: 'Custom gap limit settings' }).click(); |
| 76 | + const recvInput = page.locator('#gapLimitReceive'); |
| 77 | + await expect(recvInput).toHaveValue('50'); |
| 78 | + const changeInput = page.locator('#gapLimitChange'); |
| 79 | + await expect(changeInput).toHaveValue('10'); |
| 80 | + }); |
| 81 | +}); |
| 82 | + |
| 83 | +test.beforeEach(() => { |
| 84 | + deleteAccountsFile(); |
| 85 | +}); |
| 86 | + |
| 87 | +test.afterAll(() => { |
| 88 | + servewallet.stop(); |
| 89 | +}); |
0 commit comments