frequi_origin/cypress/e2e/backtesting.cy.ts

45 lines
1.4 KiB
TypeScript
Raw Normal View History

import { setLoginInfo, defaultMocks } from './helpers';
2022-04-12 18:52:48 +00:00
function backtestMocks() {
2022-04-12 18:52:48 +00:00
cy.intercept('GET', '**/api/v1/show_config', {
fixture: 'backtest/show_config_backtest.json',
}).as('ShowConf');
cy.intercept('GET', '**/api/v1/strategies', { fixture: 'backtest/strategies.json' }).as(
'Strategies',
);
}
describe('Backtesting', () => {
2022-04-13 17:55:27 +00:00
it('Starts webserver mode', () => {
2022-04-12 18:52:48 +00:00
///
defaultMocks();
backtestMocks();
2022-04-12 18:52:48 +00:00
setLoginInfo();
cy.visit('/backtest');
cy.wait('@Ping');
cy.wait('@ShowConf');
// cy.wait('@Strategies');
cy.get('a').should('contain', 'Backtest');
cy.contains('Run backtest');
cy.contains('Strategy');
const strategySelect = cy.get('select[id=strategy-select]');
strategySelect.should('exist');
strategySelect.select('SampleStrategy');
cy.get('option[value=SampleStrategy]').should('exist');
2022-04-13 17:55:27 +00:00
cy.get('[id=bt-analyze-btn]').should('be.disabled');
2022-04-12 18:52:48 +00:00
cy.intercept('POST', '**/api/v1/backtest', { fixture: 'backtest/backtest_post_start.json' }).as(
'BacktestStart',
);
2022-04-13 17:55:27 +00:00
cy.intercept('GET', '**/api/v1/backtest', { fixture: 'backtest/backtest_get_end.json' }).as(
'BacktestPoll',
);
2022-04-12 18:52:48 +00:00
cy.get('button[id=start-backtest]').click();
cy.wait('@BacktestStart');
2022-04-13 17:55:27 +00:00
cy.wait('@BacktestPoll');
// All buttons are now enabled
cy.get('[id=bt-analyze-btn]').should('be.enabled');
2022-04-12 18:52:48 +00:00
});
});