Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…rontEnd into us23_planejar_sprint
  • Loading branch information
danieloda committed Dec 2, 2017
2 parents 1968522 + c5a447c commit 2e9a86a
Show file tree
Hide file tree
Showing 6 changed files with 329 additions and 38 deletions.
8 changes: 8 additions & 0 deletions cypress/fixtures/login.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"auth_token": "token123",
"user": {
"id": 1,
"name": "Carla",
"email": "[email protected]"
}
}
14 changes: 14 additions & 0 deletions cypress/fixtures/projects.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[
{
"id": 1,
"name": "Owla",
"description": "Improving classes",
"user_id": 2
},
{
"id": 2,
"name": "Falko",
"description": "Agile Projects Manager",
"user_id": 2
}
]
7 changes: 7 additions & 0 deletions cypress/fixtures/user.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"id": 1,
"name": "Carla",
"email": "[email protected]",
"github": "carlaGit",
"access_token": null
}
38 changes: 22 additions & 16 deletions cypress/integration/authorization_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,7 @@ describe('Authorization tests', function (){
method: 'POST',
url: '/authenticate',
status: 200,
response: {
'auth_token': 'token123',
'user': {
'id': 1,
'name': 'Carla',
'email': '[email protected]'
}
}
response: 'fixture:login.json'
}).as('login')
})

Expand Down Expand Up @@ -94,14 +87,7 @@ describe('Authorization tests', function (){
method: 'POST',
url: '/users',
status: 200,
response: {
'auth_token': 'token123',
'user': {
'id': 1,
'name': 'Carla',
'email': '[email protected]'
}
}
response: 'fixture:login.json'
}).as('register')

cy.get('#pills-register-tab').click()
Expand Down Expand Up @@ -160,4 +146,24 @@ describe('Authorization tests', function (){

cy.url().should('eq', 'http://localhost:8080/#/')
})

it('should logout user', function(){
cy.get('form').within(function () {
cy.get('input:first').eq(0).should('have.attr', 'placeholder', 'Email')
.type('[email protected]').should('have.value', '[email protected]')

cy.get('input:last').eq(0).should('have.attr', 'placeholder', 'Password')
.type('123456789').should('have.value', '123456789')
})

cy.get('.falko-button').eq(0).click()

cy.get('#noProjects')

cy.get('.navbar').within(function(){
cy.get('#logout').click()
})

cy.url().should('eq', 'http://localhost:8080/#/')
})
})
169 changes: 147 additions & 22 deletions cypress/integration/projects_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,7 @@ describe('Projects tests', function(){
method: 'POST',
url: '/authenticate',
status: 200,
response: {
'auth_token': 'token123',
'user': {
'id': 1,
'name': 'Carla',
'email': '[email protected]'
}
}
response: 'fixture:login.json'
}).as('login')

cy.get('form').within(function () {
Expand All @@ -35,20 +28,7 @@ describe('Projects tests', function(){
method: 'GET',
url: '/users\/1/projects',
status: 200,
response: [
{
"id": 1,
"name": "Owla",
"description": "Improving classes",
"user_id": 2,
},
{
"id": 2,
"name": "Falko",
"description": "Agile Projects Manager",
"user_id": 2,
}
]
response: 'fixture:projects.json'
}).as('getProjects')
})

Expand Down Expand Up @@ -143,5 +123,150 @@ describe('Projects tests', function(){
cy.get('.card-text').eq(11).contains('New Project Description')
})
})

it('should cancel add project process', function () {

login()

cy.get('#addButton').contains('Add a Project').click()

cy.wait(200)

cy.get('.modal-footer').eq(0).within(function () {
cy.get('.falko-button-grey').contains('Close').click()
})

cy.get('.card-header').eq(0).contains('Owla')
cy.get('.card-header').eq(1).contains('Falko')
})

it('should edit a project', function(){
login()

cy.route({
method: 'GET',
url: '/projects\/2',
status: 200,
response:
{
"description":"Agile Projects Manager" ,
"github_slug": "fga-gpp-mds/owla",
"id":2,
"is_project_from_github":true,
"is_scoring":false,
"name":"Falko",
"user_id":1,
}
}).as('getProject')

cy.get('.card-body').eq(1).click()

cy.wait('@getProject')

cy.get('.card-title').contains('Falko')
cy.get('.card-text').contains('Agile Projects Manager')

cy.get('#editbutton').eq(0).click()
cy.get('.modal-header').contains('Edit Project')

cy.get('input').eq(1).type(' plus').should('have.value','Falko plus')
cy.get('input').eq(2).type(' plus').should('have.value','Agile Projects Manager plus')

cy.get('.v-switch-label').contains('off')

cy.route({
method: 'PUT',
url: '/projects\/2',
status: 200,
response:
{
"description":"AAgile Projects Manager plus" ,
"github_slug": "fga-gpp-mds/owla",
"id":2,
"is_project_from_github":true,
"is_scoring":false,
"name":"Falko plus",
"user_id":1,
},
}).as('updateProject')

cy.route({
method: 'GET',
url: '/projects\/2',
status: 200,
response:
{
"description":"Agile Projects Manager plus" ,
"github_slug": "fga-gpp-mds/owla",
"id":2,
"is_project_from_github":true,
"is_scoring":false,
"name":"Falko plus",
"user_id":1,
}
}).as('getProjectUp')


cy.get('.modal-footer').within(function(){
cy.get('.falko-button').eq(0).contains('Save').click()
})

cy.wait('@getProjectUp')

cy.get('.card-title').contains('Falko plus')
cy.get('.card-text').contains('Agile Projects Manager plus')
})

it('should delete project', function(){
login()

cy.route({
method: 'GET',
url: '/projects\/1',
status: 200,
response:
{
"description": "Agile Projects Manager",
"github_slug": "fga-gpp-mds/owla",
"id": 2,
"is_project_from_github": true,
"is_scoring": false,
"name": "Falko",
"user_id": 1,
}
}).as('getProject')

cy.route({
method: 'DELETE',
url: '/projects/1',
status: 200,
response: {}
}).as('deleteProject')


cy.get('.card-header').eq(0).contains('Owla').click()

cy.route({
method: 'GET',
url: '/users\/1/projects',
status: 200,
response: [{
"id": 2,
"name": "Falko",
"description": "Agile Projects Manager",
"user_id": 2
}]
}).as('getProjectsAfterDelete')

cy.get('#deletebutton').contains('Delete').click()

cy.wait(200)

cy.get('.modal-footer').eq(1).within(function(){
cy.get('.falko-button').click()
})

cy.get('.card-header').contains('Falko')
})
})

Loading

0 comments on commit 2e9a86a

Please sign in to comment.