|
| 1 | +import { test, expect } from '@playwright/test' |
| 2 | +import { privateKey, privateKeyAddress } from '../utils/test-inputs' |
| 3 | +import { fillPrivateKeyWithoutPassword } from '../utils/fillPrivateKey' |
| 4 | +import { warnSlowApi } from '../utils/warnSlowApi' |
| 5 | +import { mockApi } from '../utils/mockApi' |
| 6 | +import { expectNoErrorsInConsole } from '../utils/expectNoErrorsInConsole' |
| 7 | + |
| 8 | +test.beforeEach(async ({ page }) => { |
| 9 | + await warnSlowApi(page) |
| 10 | + await mockApi(page, 500000000000) |
| 11 | + // Unmock validators list API |
| 12 | + await page.unroute('**/validator/list?*') |
| 13 | + await expectNoErrorsInConsole(page, { |
| 14 | + ignoreError: message => { |
| 15 | + // Some validator icons need authentication |
| 16 | + if (message.text().includes('status of 403')) return true |
| 17 | + }, |
| 18 | + }) |
| 19 | + |
| 20 | + await page.goto('/open-wallet/private-key') |
| 21 | + await fillPrivateKeyWithoutPassword(page, { |
| 22 | + privateKey: privateKey, |
| 23 | + privateKeyAddress: privateKeyAddress, |
| 24 | + persistenceCheckboxChecked: false, |
| 25 | + persistenceCheckboxDisabled: false, |
| 26 | + }) |
| 27 | + await expect(page.getByTestId('account-selector')).toBeVisible() |
| 28 | +}) |
| 29 | + |
| 30 | +test.describe('Validators', () => { |
| 31 | + test('Content-Security-Policy should allow validator icons', async ({ page, baseURL }) => { |
| 32 | + expect(baseURL).toBe('http://localhost:5000') |
| 33 | + expect((await page.request.head('/')).headers()).toHaveProperty('content-security-policy') |
| 34 | + |
| 35 | + const someValidatorIconPromise = page.waitForResponse( |
| 36 | + response => |
| 37 | + response.url().startsWith('https://s3.amazonaws.com/keybase_processed_uploads/') && |
| 38 | + response.status() === 200, |
| 39 | + ) |
| 40 | + |
| 41 | + await page.getByRole('link', { name: 'Stake' }).click() |
| 42 | + await expect(page.getByRole('heading', { name: 'Validators' })).toBeVisible() |
| 43 | + // Wait for validators to be shown, then scroll to them to trigger lazy loading. |
| 44 | + await expect(page.getByText('Everstake')).toBeVisible() |
| 45 | + await page.getByText('Everstake').scrollIntoViewIfNeeded() |
| 46 | + await (await someValidatorIconPromise).finished() |
| 47 | + // Expect no errors. |
| 48 | + }) |
| 49 | +}) |
0 commit comments