Skip to content

Commit

Permalink
Update cypress tests
Browse files Browse the repository at this point in the history
  • Loading branch information
xmatthias committed Jan 24, 2022
1 parent 6b9a590 commit a319db8
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions cypress/integration/login.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,26 @@ describe('Login', () => {
cy.get('button[type=submit]').should('exist');
});

it('Test Login', () => {
it('Redirect when not logged in', () => {
cy.visit('/trade');
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/login');
expect(loc.search).to.eq('?redirect=%2Ftrade');
});
});

it.only('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('**/api/v1/**', {
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('RandomAPICall');
cy.intercept(
{
method: 'Post',
Expand All @@ -45,21 +59,13 @@ describe('Login', () => {
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');
Expand All @@ -73,13 +79,7 @@ describe('Login', () => {
});
cy.get('button').should('contain', 'Add new bot');
cy.get('span').should('contain', 'TestBot');
});

it('Redirect when not logged in', () => {
cy.visit('/trade');
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/login');
expect(loc.search).to.eq('?redirect=%2Ftrade');
});
// Check API calls have been made.
cy.wait('@RandomAPICall');
});
});

0 comments on commit a319db8

Please sign in to comment.