From 9deb427afcdd4446680e367afb67397a728d5d88 Mon Sep 17 00:00:00 2001 From: MatheusRich Date: Mon, 12 Feb 2018 23:05:26 -0200 Subject: [PATCH 1/8] Adding login command to cypress This allows use the login function in every place, avoiding code duplication --- cypress/integration/authorization_spec.js | 37 ++++++++--------------- cypress/integration/projects_spec.js | 32 +++----------------- cypress/integration/users_spec.js | 25 +-------------- cypress/support/commands.js | 32 ++++++++++++++++++++ 4 files changed, 51 insertions(+), 75 deletions(-) diff --git a/cypress/integration/authorization_spec.js b/cypress/integration/authorization_spec.js index 9307c9ce..5dee08e2 100644 --- a/cypress/integration/authorization_spec.js +++ b/cypress/integration/authorization_spec.js @@ -1,7 +1,5 @@ describe('Authorization tests', () => { beforeEach(() => { - cy.visit('localhost:8080/#/'); - cy.server(); // Stubing server response @@ -14,6 +12,8 @@ describe('Authorization tests', () => { }); it('should access homepage', () => { + cy.visit('localhost:8080/#/'); + cy.title().should('include', 'Falko'); cy.get('#loginRegisterComponent').within(() => { @@ -28,16 +28,7 @@ describe('Authorization tests', () => { }); it('should log in user', () => { - cy.get('form').within(() => { - cy.get('input:first').eq(0).should('have.attr', 'placeholder', 'Email') - .type('carla@gmail.com') - .should('have.value', 'carla@gmail.com'); - - cy.get('input:last').eq(0).should('have.attr', 'placeholder', 'Password') - .type('123456789') - .should('have.value', '123456789'); - }); - cy.get('#loginButton').click(); + cy.login() cy.url().should('eq', 'http://localhost:8080/#/projects'); }); @@ -55,6 +46,8 @@ describe('Authorization tests', () => { }, }, }).as('invalidLogin'); + + cy.visit('localhost:8080/#/'); cy.get('form').within(() => { cy.get('input:first').eq(0).should('have.attr', 'placeholder', 'Email') @@ -94,6 +87,8 @@ describe('Authorization tests', () => { response: 'fixture:login.json', }).as('register'); + cy.visit('localhost:8080/#/'); + cy.get('#pills-register-tab').click(); cy.get('form').within(() => { @@ -127,6 +122,8 @@ describe('Authorization tests', () => { response: {}, }).as('invalidRegister'); + cy.visit('localhost:8080/#/'); + cy.get('#pills-register-tab').click(); cy.get('form').within(() => { @@ -153,17 +150,7 @@ describe('Authorization tests', () => { }); it('should logout user', () => { - cy.get('form').within(() => { - cy.get('input:first').eq(0).should('have.attr', 'placeholder', 'Email') - .type('carla@gmail.com') - .should('have.value', 'carla@gmail.com'); - - cy.get('input:last').eq(0).should('have.attr', 'placeholder', 'Password') - .type('123456789') - .should('have.value', '123456789'); - }); - - cy.get('#loginButton').click(); + cy.login(); cy.get('#noProjects'); @@ -183,7 +170,9 @@ describe('Authorization tests', () => { }) it('should not access any page with user logged out', function(){ - cy.visit('localhost:8080/#/asdfasdf') + cy.visit('localhost:8080/#/'); + + cy.visit('localhost:8080/#/invalidURL') cy.get('#loginComponent') }) diff --git a/cypress/integration/projects_spec.js b/cypress/integration/projects_spec.js index 11fd08d7..ec7072b5 100644 --- a/cypress/integration/projects_spec.js +++ b/cypress/integration/projects_spec.js @@ -1,27 +1,5 @@ describe('Projects tests', function(){ - - function login(){ - cy.route({ - method: 'POST', - url: '/authenticate', - status: 200, - response: 'fixture:login.json' - }).as('login') - - cy.get('form').within(function () { - cy.get('input:first').eq(0).should('have.attr', 'placeholder', 'Email') - .type('carla@gmail.com').should('have.value', 'carla@gmail.com') - - cy.get('input:last').eq(0).should('have.attr', 'placeholder', 'Password') - .type('123456789').should('have.value', '123456789') - }) - - cy.get('.falko-button').eq(0).click() - } - beforeEach(function(){ - cy.visit('localhost:8080/#/') - cy.server() cy.route({ @@ -34,7 +12,7 @@ describe('Projects tests', function(){ it('should get projects', function(){ - login() + cy.login() cy.get('.card-header').eq(0).contains('Owla') cy.get('.card-body').within(function(){ @@ -74,7 +52,7 @@ describe('Projects tests', function(){ ] }).as('addProject') - login() + cy.login() cy.get('.falko-button').eq(0).click() @@ -126,7 +104,7 @@ describe('Projects tests', function(){ it('should cancel add project process', function () { - login() + cy.login() cy.get('#addButton').contains('Add a Project').click() @@ -141,7 +119,7 @@ describe('Projects tests', function(){ }) it('should edit a project', function(){ - login() + cy.login() cy.route({ method: 'GET', @@ -219,7 +197,7 @@ describe('Projects tests', function(){ }) it('should delete project', function(){ - login() + cy.login() cy.route({ method: 'GET', diff --git a/cypress/integration/users_spec.js b/cypress/integration/users_spec.js index 688d34a1..3e053be8 100644 --- a/cypress/integration/users_spec.js +++ b/cypress/integration/users_spec.js @@ -1,28 +1,5 @@ describe('Users tests', () => { - function login() { - cy.route({ - method: 'POST', - url: '/authenticate', - status: 200, - response: 'fixture:login.json', - }).as('login'); - - cy.get('form').within(() => { - cy.get('input:first').eq(0).should('have.attr', 'placeholder', 'Email') - .type('carla@gmail.com') - .should('have.value', 'carla@gmail.com'); - - cy.get('input:last').eq(0).should('have.attr', 'placeholder', 'Password') - .type('123456789') - .should('have.value', '123456789'); - }); - - cy.get('#loginButton').click(); - } - beforeEach(() => { - cy.visit('localhost:8080/#/'); - cy.server(); cy.route({ @@ -32,7 +9,7 @@ describe('Users tests', () => { response: 'fixture:projects.json', }).as('getProjects'); - login(); + cy.login(); cy.route({ method: 'GET', diff --git a/cypress/support/commands.js b/cypress/support/commands.js index c1f5a772..5f6cb5be 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -23,3 +23,35 @@ // // -- This is will overwrite an existing command -- // Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... }) + +Cypress.Commands.add('login', () => { + const user = { + email: 'carla@email.com', + password: '123456789', + } + + cy.visit('localhost:8080/#/'); + + cy.server(); + + cy.route({ + method: 'POST', + url: '/authenticate', + status: 200, + response: 'fixture:login.json', + }).as('login'); + + cy.get('form').within(() => { + cy.get('input:first').eq(0).should('have.attr', 'placeholder', 'Email') + .type(user.email) + .should('have.value', 'carla@email.com'); + + cy.get('input:last').eq(0).should('have.attr', 'placeholder', 'Password') + .type(user.password) + .should('have.value', '123456789'); + }); + + cy.get('#loginButton').click(); + + cy.wait('@login') +}) \ No newline at end of file From 62a5220ce9aaa15c042444010c3deb70c6e63e59 Mon Sep 17 00:00:00 2001 From: MatheusRich Date: Wed, 14 Feb 2018 22:19:36 -0200 Subject: [PATCH 2/8] Adding project.json fixture --- cypress/fixtures/project.json | 9 +++++++++ cypress/integration/projects_spec.js | 22 ++-------------------- 2 files changed, 11 insertions(+), 20 deletions(-) create mode 100644 cypress/fixtures/project.json diff --git a/cypress/fixtures/project.json b/cypress/fixtures/project.json new file mode 100644 index 00000000..db32d647 --- /dev/null +++ b/cypress/fixtures/project.json @@ -0,0 +1,9 @@ +{ + "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 +} \ No newline at end of file diff --git a/cypress/integration/projects_spec.js b/cypress/integration/projects_spec.js index ec7072b5..74588879 100644 --- a/cypress/integration/projects_spec.js +++ b/cypress/integration/projects_spec.js @@ -125,16 +125,7 @@ describe('Projects tests', function(){ 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, - } + response: 'fixture:project.json' }).as('getProject') cy.get('.card-body').eq(1).click() @@ -203,16 +194,7 @@ describe('Projects tests', function(){ 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, - } + response: 'fixture:project.json' }).as('getProject') cy.route({ From 92b8a2c1093c4e5f518ef0dff34453bd8e87c9dc Mon Sep 17 00:00:00 2001 From: MatheusRich Date: Wed, 14 Feb 2018 22:52:49 -0200 Subject: [PATCH 3/8] Adding dynamic ids in Projects.vue --- src/components/Projects/Projects.vue | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/components/Projects/Projects.vue b/src/components/Projects/Projects.vue index f53fe3cc..03ce009e 100644 --- a/src/components/Projects/Projects.vue +++ b/src/components/Projects/Projects.vue @@ -5,12 +5,12 @@  
-
+
-
+
-
-
+
+

{{project.name}}

@@ -26,7 +26,7 @@

- +
@@ -151,21 +151,21 @@ div a { color: #28639A; } -#projectCard:hover { - box-shadow: 0 4px 12px 0 rgba(0,0,0,0.2); - border-color: #5D6A6F; -} - -#projectCard { +.project-card { box-shadow: 0 2px 4px 0 rgba(0,0,0,0.3); transition: 0.2s; } -#projectHeader { +.project-card:hover { + box-shadow: 0 4px 12px 0 rgba(0,0,0,0.2); + border-color: #5D6A6F; +} + +.project-header { background-color: #5D6A6F; } -#projectTitle { +.project-title { margin: 0; color: white; } @@ -175,7 +175,7 @@ div a { font-style: italic; } -#grade { +.grade { margin-left: 1.5em; } From 54ef3632bae84dfcad28adf084c063cda523759a Mon Sep 17 00:00:00 2001 From: MatheusRich Date: Wed, 14 Feb 2018 22:53:16 -0200 Subject: [PATCH 4/8] Adding ids to buttons in Project.vue --- src/components/Projects/Project.vue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/Projects/Project.vue b/src/components/Projects/Project.vue index bef0ce99..0e0bc028 100644 --- a/src/components/Projects/Project.vue +++ b/src/components/Projects/Project.vue @@ -16,20 +16,20 @@
-
-
- +
From 97663dcc1115ee110f821d5e05d10e55e7bc4905 Mon Sep 17 00:00:00 2001 From: MatheusRich Date: Mon, 19 Feb 2018 21:41:22 -0300 Subject: [PATCH 5/8] Changing id of Add Sprint button --- src/components/Sprints/AddSprint.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/Sprints/AddSprint.vue b/src/components/Sprints/AddSprint.vue index b0517110..44d4ffb2 100644 --- a/src/components/Sprints/AddSprint.vue +++ b/src/components/Sprints/AddSprint.vue @@ -1,7 +1,7 @@