mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-10 10:21:55 +00:00
Increase login tests
This commit is contained in:
parent
cdaac965b1
commit
6873496832
|
@ -10,7 +10,10 @@ describe('Login', () => {
|
||||||
cy.get('#name-input').should('exist');
|
cy.get('#name-input').should('exist');
|
||||||
cy.get('#username-input').should('exist');
|
cy.get('#username-input').should('exist');
|
||||||
cy.get('#password-input').should('exist');
|
cy.get('#password-input').should('exist');
|
||||||
|
// Modal popup will use "OK" instead of "submit"
|
||||||
|
cy.get('button[type=submit]').should('not.exist');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Explicit login page', () => {
|
it('Explicit login page', () => {
|
||||||
cy.visit('/login');
|
cy.visit('/login');
|
||||||
cy.get('button').should('contain', 'Login');
|
cy.get('button').should('contain', 'Login');
|
||||||
|
@ -18,10 +21,60 @@ describe('Login', () => {
|
||||||
cy.get('.card-header').contains('Freqtrade bot Login');
|
cy.get('.card-header').contains('Freqtrade bot Login');
|
||||||
// Test prefilled URL
|
// Test prefilled URL
|
||||||
cy.get('input[id=url-input]').should('have.value', 'http://localhost:8080');
|
cy.get('input[id=url-input]').should('have.value', 'http://localhost:8080');
|
||||||
cy.get('#name-input').should('exist');
|
cy.get('input[id=name-input]').should('exist');
|
||||||
cy.get('#username-input').should('exist');
|
cy.get('input[id=username-input]').should('exist');
|
||||||
cy.get('#password-input').should('exist');
|
cy.get('input[id=password-input]').should('exist');
|
||||||
|
cy.get('button[type=submit]').should('exist');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Test Login', () => {
|
||||||
|
cy.visit('/login');
|
||||||
|
cy.get('input[id=name-input]').type('TestBot');
|
||||||
|
cy.get('input[id=username-input]').type('Freqtrader');
|
||||||
|
cy.get('input[id=password-input]').type('SuperDuperBot');
|
||||||
|
|
||||||
|
cy.intercept(
|
||||||
|
{
|
||||||
|
method: 'Post',
|
||||||
|
url: '**/api/v1/token/login',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
statusCode: 200,
|
||||||
|
// eslint-disable-next-line @typescript-eslint/camelcase
|
||||||
|
body: { access_token: 'access_token_tesst', refresh_token: 'refresh_test' },
|
||||||
|
headers: { 'access-control-allow-origin': '*' },
|
||||||
|
},
|
||||||
|
).as('login');
|
||||||
|
cy.get('button[type=submit]')
|
||||||
|
.click()
|
||||||
|
.should(() => {
|
||||||
|
const loginInfo = JSON.parse(localStorage.getItem('ftAuthLoginInfo') || '{}');
|
||||||
|
console.log('logininfo', loginInfo);
|
||||||
|
const bot1 = 'ftbot.0';
|
||||||
|
const resp = {
|
||||||
|
'ftbot.0': {
|
||||||
|
botName: 'TestBot',
|
||||||
|
apiUrl: 'http://localhost:8080',
|
||||||
|
accessToken: 'access_token_tesst',
|
||||||
|
refreshToken: 'refresh_test',
|
||||||
|
autoRefresh: true,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
expect(loginInfo[bot1].botName).to.eq('TestBot');
|
||||||
|
expect(loginInfo[bot1].botName).to.eq('TestBot');
|
||||||
|
expect(loginInfo[bot1].apiUrl).to.eq('http://localhost:8080');
|
||||||
|
expect(loginInfo[bot1].accessToken).to.eq('access_token_tesst');
|
||||||
|
expect(loginInfo[bot1].refreshToken).to.eq('refresh_test');
|
||||||
|
});
|
||||||
|
// Forwarded to Main page
|
||||||
|
cy.location().should((loc) => {
|
||||||
|
expect(loc.pathname).to.eq('/');
|
||||||
|
expect(loc.search).to.eq('');
|
||||||
|
});
|
||||||
|
cy.get('button').should('contain', 'Add new bot');
|
||||||
|
cy.get('span').should('contain', 'TestBot');
|
||||||
|
});
|
||||||
|
|
||||||
it('Redirect when not logged in', () => {
|
it('Redirect when not logged in', () => {
|
||||||
cy.visit('/trade');
|
cy.visit('/trade');
|
||||||
cy.location().should((loc) => {
|
cy.location().should((loc) => {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user