Add dashboard playwright test

This commit is contained in:
Matthias 2024-04-09 07:02:08 +02:00
parent 75ed9bb3b4
commit c2f693c896

39
e2e/dashboard.spec.ts Normal file
View File

@ -0,0 +1,39 @@
import { test, expect } from '@playwright/test';
import { setLoginInfo, defaultMocks, tradeMocks } from './helpers';
test.describe('Dashboard', () => {
test.beforeEach(async ({ page }) => {
await defaultMocks(page);
await tradeMocks(page);
await setLoginInfo(page);
});
test('Dashboard Page', async ({ page }) => {
await Promise.all([
page.goto('/dashboard'),
page.waitForResponse('**/status'),
page.waitForResponse('**/profit'),
page.waitForResponse('**/balance'),
// page.waitForResponse('**/trades'),
page.waitForResponse('**/whitelist'),
page.waitForResponse('**/blacklist'),
page.waitForResponse('**/locks'),
]);
await expect(page.locator('.drag-header', { hasText: 'Bot comparison' })).toBeVisible();
await expect(page.locator('.drag-header', { hasText: 'Bot comparison' })).toBeInViewport();
await expect(page.locator('.drag-header', { hasText: 'Daily Profit' })).toBeVisible();
await expect(page.locator('.drag-header', { hasText: 'Daily Profit' })).toBeInViewport();
await expect(page.locator('.drag-header', { hasText: 'Open trades' })).toBeVisible();
await expect(page.locator('.drag-header', { hasText: 'Open trades' })).toBeInViewport();
await expect(page.locator('.drag-header', { hasText: 'Cumulative Profit' })).toBeVisible();
await expect(page.locator('.drag-header', { hasText: 'Cumulative Profit' })).toBeInViewport();
await expect(page.locator('span', { hasText: 'TestBot' })).toBeVisible();
await expect(page.locator('span', { hasText: 'Summary' })).toBeVisible();
// Scroll to bottom
await page.locator('.drag-header', { hasText: 'Trades Log' }).scrollIntoViewIfNeeded();
await expect(page.locator('.drag-header', { hasText: 'Closed Trades' })).toBeInViewport();
await expect(page.locator('.drag-header', { hasText: 'Profit Distribution' })).toBeInViewport();
await expect(page.locator('.drag-header', { hasText: 'Trades Log' })).toBeInViewport();
});
});