Skip to content

Commit

Permalink
Web/tests (#217)
Browse files Browse the repository at this point in the history
* Registration and login tests

* Cypress tests

* Fix

* Fix port

* Update default.json

* Delete canvasjs.min.js

* Delete canvasjs.react.js

* Update default.json

* Update EditRestauranOwnerProfiletTesting.js
  • Loading branch information
MatLazic authored Jan 17, 2020
1 parent b2273e3 commit 412afd5
Show file tree
Hide file tree
Showing 15 changed files with 1,440 additions and 2 deletions.
3 changes: 2 additions & 1 deletion config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
"AWS_ACCESS_KEY_ID": "",
"AWS_SECRET_ACCESS_KEY": "",
"sequelize_Database": ""
}
}

1 change: 1 addition & 0 deletions cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
5 changes: 5 additions & 0 deletions cypress/fixtures/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "[email protected]",
"body": "Fixtures are a great way to mock data for responses to routes"
}
80 changes: 80 additions & 0 deletions cypress/integration/ConsultantLoginTesting.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
describe('TestSiteConnection', function() {
it('Check if site is running', function() {
cy.visit('localhost:80')
})
})

describe('TestLoginFailedWhenWrongPassword', function() {
it('Test if logging with wrong password fails', function() {
cy.visit('localhost:80')

cy.contains('Are you a consultant').click()
cy.get('.normal').first().click()

cy.get('input').first().type('TestConsultant')
cy.get('input').last().type('12345678')
cy.get('.normal').last().click()

cy.contains('Invalid username or password')
})
})

describe('LoginFailedWhenMissingPassword', function() {
it('Test if logging with missing password fails', function() {
cy.visit('localhost:80')

cy.contains('Are you a consultant').click()
cy.get('.normal').first().click()

cy.get('input').first().type('TestConsultant')
cy.get('.normal').last().click()

cy.url().should('not.include', '/.+')
})
})

describe('TestLoginFailedWhenUsernameDoesNotExits', function() {
it('Test if logging with non existing username fails', function() {
cy.visit('localhost:80')

cy.contains('Are you a consultant').click()
cy.get('.normal').first().click()

cy.get('input').first().type('ABCDEFGHIJKL')
cy.get('input').last().type('123456')
cy.get('.normal').last().click()

cy.contains('Invalid username or password')
})
})

describe('LoginFailedWhenMissingUsername', function() {
it('Test if logging with missing username fails', function() {
cy.visit('localhost:80')

cy.contains('Are you a consultant').click()
cy.get('.normal').first().click()

cy.get('input').last().type('123456')
cy.get('.normal').last().click()

cy.url().should('not.include', '/.+') })
})


describe('TestLogin', function() {
it('Test if logging with password fails', function() {
cy.visit('localhost:80')

cy.contains('Are you a consultant').click()
cy.get('.normal').first().click()

cy.get('input').first().type('TestConsultant')
cy.get('input').last().type('123456')
cy.get('.normal').last().click()

cy.url().should('include', '/Consultant')
})

})

95 changes: 95 additions & 0 deletions cypress/integration/ConsultantRegistrationTesting.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
describe('TestSiteConnection', function() {
it('Check if site is running', function() {
cy.visit('localhost:80')
})
})

describe('TestRegisteringAlreadyExistingEmail', function() {
it('Test if user will be registered if providing already existing email', function() {
cy.visit('localhost:80')

cy.contains('Are you a consultant').click()
cy.get('.normal').last().click()

cy.get('input').first().type('[email protected]')
cy.get('input').eq(1).type('TestConsultant2')
cy.get('input').eq(2).type('Test')
cy.get('input').eq(3).type('Consultant')
cy.get('input').eq(4).type('OurCompanyRocks')
cy.get('input').eq(5).type('123456')
cy.get('input').last().type('123456')

cy.get('.normal').last().click()

cy.contains('Email already taken')


})
})

describe('TestRegisteringAlreadyExistingUsername', function() {
it('Test if user will be registered if providing already existing username', function() {
cy.visit('localhost:80')

cy.contains('Are you a consultant').click()
cy.contains('Sign up').click()

cy.get('input').first().type('[email protected]')
cy.get('input').eq(1).type('TestConsultant')
cy.get('input').eq(2).type('Test')
cy.get('input').eq(3).type('Consultant')
cy.get('input').eq(4).type('OurCompanyRocks')
cy.get('input').eq(5).type('123456')
cy.get('input').last().type('123456')

cy.get('.normal').last().click()

cy.contains('Username already taken')

})
})


describe('TestProvidingDifferentPasswords', function() {
it('Test if user will be registered if providing differing passwords', function() {
cy.visit('localhost:80')

cy.contains('Are you a consultant').click()
cy.contains('Sign up').click()

cy.get('input').first().type('[email protected]')
cy.get('input').eq(1).type('TestUser2')
cy.get('input').eq(2).type('Test')
cy.get('input').eq(3).type('User')
cy.get('input').eq(4).type('OurCompanyRocks')
cy.get('input').eq(5).type('123456')
cy.get('input').last().type('654321')

cy.get('.normal').last().click()

cy.contains('Password confirmation has to be identical to the password.')

})
})


describe('TestDataInWrongFormat', function() {
it('Test if user will be registered if some data is in wrong format or missing', function() {
cy.visit('localhost:80')

cy.contains('Are you consultant').click()
cy.contains('Sign up').click()

cy.get('input').first().type('test.user2test.com')
cy.get('input').eq(1).type('Test')
cy.get('input').eq(2).type('Test')
cy.get('input').eq(5).type('1234')
cy.get('input').last().type('1234')

cy.get('.normal').last().click()

cy.url().should('not.include', '/.+')

})
})

86 changes: 86 additions & 0 deletions cypress/integration/CustomerRegistrationTesting.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
describe('TestSiteConnection', function() {
it('Check if site is running', function() {
cy.visit('localhost:80')
})
})

describe('TestRegisteringAlreadyExistingEmail', function() {
it('Test if user will be registered if providing already existing email', function() {
cy.visit('localhost:80')

cy.contains('Sign up').click()
cy.contains('Customer').click()

cy.get('input').first().type('[email protected]')
cy.get('input').eq(1).type('TestUser2')
cy.get('input').eq(2).type('123456')
cy.get('input').last().type('123456')

cy.get('.normal').last().click()

cy.get('input').first().type('Test Restaurant')

cy.contains('Email already taken')


})
})

describe('TestRegisteringAlreadyExistingUsername', function() {
it('Test if user will be registered if providing already existing username', function() {
cy.visit('localhost:80')

cy.contains('Sign up').click()
cy.contains('Customer').click()

cy.get('input').first().type('[email protected]')
cy.get('input').eq(1).type('TestCustomer')
cy.get('input').eq(2).type('123456')
cy.get('input').last().type('123456')

cy.get('.normal').last().click()

cy.contains('Username already taken')

})
})


describe('TestProvidingDifferentPasswords', function() {
it('Test if user will be registered if providing differing passwords', function() {
cy.visit('localhost:80')

cy.contains('Sign up').click()
cy.contains('Customer').click()

cy.get('input').first().type('[email protected]')
cy.get('input').eq(1).type('TestCustomer2')
cy.get('input').eq(2).type('123456')
cy.get('input').last().type('654321')

cy.get('.normal').last().click()

cy.contains('Password confirmation has to be identical to the password.')

})
})


describe('TestDataInWrongFormat', function() {
it('Test if user will be registered if some data is in wrong format or missing', function() {
cy.visit('localhost:80')

cy.contains('Sign up').click()
cy.contains('Customer').click()

cy.get('input').first().type('test.user2test.com')
cy.get('input').eq(2).type('1234')
cy.get('input').last().type('1234')

cy.get('.normal').last().click()

cy.url().should('not.include', '/.+')

})
})

43 changes: 43 additions & 0 deletions cypress/integration/EditRestauranOwnerProfiletTesting.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
describe('TestLogin', function() {
it('Test if logging with password fails', function() {
cy.visit('localhost:80')

cy.contains('Log in').click()

cy.get('input').first().type('TestUser')
cy.get('input').last().type('123456')
cy.get('.normal').last().click()

cy.wait(2000)
cy.visit('localhost:80/Profile')

})

})

describe('TestChangingMail', function() {
it('Test if changing mail will really change it', function() {

cy.get('input').first().clear()
cy.get('input').first().type('[email protected]')
cy.get('.normal').last().click()

cy.contains('Log in').click()

cy.get('input').first().type('TestUser')
cy.get('input').last().type('123456')
cy.get('.normal').last().click()

cy.wait(2000)
cy.visit('localhost:80/Profile')


cy.get('input').first().invoke('val').should('include', '[email protected]')

cy.get('input').first().clear()
cy.get('input').first().type('[email protected]')
cy.get('.normal').last().click()

})

})
49 changes: 49 additions & 0 deletions cypress/integration/EditRestaurantTesting.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
describe('TestLogin', function() {
it('Test if logging with password fails', function() {
cy.visit('localhost:80')

cy.contains('Log in').click()

cy.get('input').first().type('TestUser')
cy.get('input').last().type('123456')
cy.get('.normal').last().click()

})

})

describe('TestEditRestaurantFail', function() {
it('Test if editing restaurant will fail with no acceptable data', function() {

cy.contains('Edit information').click()

cy.get('input').eq(2).clear()
cy.get('input').eq(2).type('ABCDEF 4321')
cy.get('.normal').last().click()

cy.contains('Location data cannot be calculated')

cy.type({esc})
})
})


describe('TestEditRestaurant', function() {
it('Test if editing restaurant work', function() {


cy.contains('Edit information').click()
cy.get('input').eq(2).clear()
cy.get('input').eq(2).type('Slavonska 10')
cy.get('.normal').last().click()

cy.contains('Slavonska 10')

cy.wait(3000)
cy.contains('Edit information').click()

cy.get('input').eq(2).clear()
cy.get('input').eq(2).type('Unska 4')
cy.get('.normal').last().click()
})
})
Loading

0 comments on commit 412afd5

Please sign in to comment.