mirror of
https://github.com/freqtrade/frequi.git
synced 2024-09-20 09:31:10 +00:00
Playwright backtesting tests
This commit is contained in:
parent
47de346df9
commit
5a475100e7
51
e2e/backtest.spec.ts
Normal file
51
e2e/backtest.spec.ts
Normal file
|
@ -0,0 +1,51 @@
|
|||
import { test, expect } from '@playwright/test';
|
||||
import { setLoginInfo, defaultMocks } from './helpers';
|
||||
|
||||
test.describe('Backtesting', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await defaultMocks(page);
|
||||
page.route('**/api/v1/show_config', (route) => {
|
||||
return route.fulfill({ path: `./cypress/fixtures/backtest/show_config_webserver.json` });
|
||||
});
|
||||
page.route('**/api/v1/strategies', (route) => {
|
||||
return route.fulfill({ path: `./cypress/fixtures/backtest/strategies.json` });
|
||||
});
|
||||
|
||||
await page.route('**/api/v1/backtest', (route) => {
|
||||
if (route.request().method() === 'POST') {
|
||||
route.fulfill({
|
||||
path: './cypress/fixtures/backtest/backtest_post_start.json',
|
||||
});
|
||||
} else if (route.request().method() === 'GET') {
|
||||
route.fulfill({
|
||||
path: './cypress/fixtures/backtest/backtest_get_end.json',
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
await setLoginInfo(page);
|
||||
});
|
||||
test('Starts webserver mode', async ({ page }) => {
|
||||
await page.goto('/backtest');
|
||||
|
||||
await expect(page.locator('a', { hasText: 'Backtest' })).toBeInViewport();
|
||||
await expect(page.getByText('Run backtest')).toBeInViewport();
|
||||
await expect(page.getByText('Strategy', { exact: true })).toBeInViewport();
|
||||
|
||||
const strategySelect = page.locator('select[id="strategy-select"]');
|
||||
await expect(strategySelect).toBeVisible();
|
||||
await expect(strategySelect).toBeInViewport();
|
||||
|
||||
await strategySelect.selectOption('SampleStrategy');
|
||||
const option = page.locator('option[value="SampleStrategy"]');
|
||||
await expect(option).toBeAttached();
|
||||
const analyzeButton = page.locator('[id="bt-analyze-btn"]');
|
||||
await expect(analyzeButton).toBeDisabled();
|
||||
|
||||
const startBacktestButton = page.locator('button[id="start-backtest"]');
|
||||
await Promise.all([startBacktestButton.click(), page.waitForResponse('**/api/v1/backtest')]);
|
||||
|
||||
// All buttons are now enabled
|
||||
await expect(analyzeButton).toBeEnabled();
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user