From 5edbeb5de043f3089cebf2da13da934dc5eb4d08 Mon Sep 17 00:00:00 2001
From: hollum <hollum@hotmail.com>
Date: Fri, 18 Mar 2022 09:56:55 +0100
Subject: [PATCH] integration tests for new profile page

---
 frontend/cypress/integration/goals.spec.js   |  4 +--
 frontend/cypress/integration/profile.spec.js | 30 ++++++++++++++++++++
 frontend/cypress/support/index.js            |  2 +-
 3 files changed, 33 insertions(+), 3 deletions(-)
 create mode 100644 frontend/cypress/integration/profile.spec.js

diff --git a/frontend/cypress/integration/goals.spec.js b/frontend/cypress/integration/goals.spec.js
index d8a120b..e0708ff 100644
--- a/frontend/cypress/integration/goals.spec.js
+++ b/frontend/cypress/integration/goals.spec.js
@@ -37,10 +37,10 @@ describe('Create goal', () => {
         cy.get('.card-link')
             .eq(0).click()
 
-        cy.intercept({method: 'GET', url: '/api/goal/2/' }).as('createRequest')
+        cy.intercept({method: 'GET', url: '/api/goal/1/' }).as('createRequest')
         cy.wait('@createRequest')
 
-        cy.intercept({method: 'DELETE', url: '/api/goal/2/' }).as('createRequest')
+        cy.intercept({method: 'DELETE', url: '/api/goal/1/' }).as('createRequest')
         cy.get('#btn-delete-goal').click()
         cy.wait('@createRequest')
 
diff --git a/frontend/cypress/integration/profile.spec.js b/frontend/cypress/integration/profile.spec.js
new file mode 100644
index 0000000..028f773
--- /dev/null
+++ b/frontend/cypress/integration/profile.spec.js
@@ -0,0 +1,30 @@
+
+
+describe('Test profile page', () => {
+
+    it('Edit profile', function() {
+        this.login(this.athleteUser)
+
+        cy.get('#nav-profile').click()
+        cy.get('#phone_number').type("12345678")
+        cy.get('#btn-edit-account').click()
+        cy.url().should('include', 'profile.html')
+    })
+
+
+    it('Connect to coach and see if the coach is added in profile', function() {
+        this.login(this.athleteUser)
+
+        cy.get('#nav-mycoach').click()
+        cy.get('#input-coach').type(`${this.coachUser.username}`, {force: true})
+
+        cy.get('#button-edit-coach').click()
+        cy.get('#button-set-coach').click({force: true})
+        cy.wait(2000)
+
+        cy.get('#nav-profile').click()
+        cy.url().should('include', 'profile.html')
+        cy.get('#coach-content').contains(`${this.coachUser.username}`)
+    })
+
+})
diff --git a/frontend/cypress/support/index.js b/frontend/cypress/support/index.js
index 9fe152b..d63cbb6 100644
--- a/frontend/cypress/support/index.js
+++ b/frontend/cypress/support/index.js
@@ -105,7 +105,7 @@ before(() => {
         ...athleteUser,
         ...generateUser()
     }
-    //registerUser(coachUser)
+    registerUser(coachUser)
     registerUser(athleteUser)
     cy.visit(`${baseUrl}/index.html`)
 })
-- 
GitLab