Skip to content
Snippets Groups Projects
Commit 2eeb0d4c authored by Sigmund Berbom's avatar Sigmund Berbom
Browse files

testing for deleteFormData

parent 74fda480
Branches master
No related tags found
No related merge requests found
Pipeline #129068 passed
......@@ -208,6 +208,24 @@ const offersResult = {
"results": []
}
const exercise = {
"url": "https://secfit-t2-backend.herokuapp.com/api/exercises/1/",
"id": 1,
"name": "Benkpress",
"description": "Press vektstang",
"unit": "kg",
"instances": []
}
const exercise2 = {
"url": "https://secfit-t2-backend.herokuapp.com/api/exercises/1/",
"id": 1,
"name": "Knebøy",
"description": "Press vektstang",
"unit": "kg",
"instances": []
}
const fileName = "filnavn.txt"
const athleteFilesResult = {
......@@ -220,7 +238,195 @@ const athleteFilesResult = {
// const wor
describe('profilepage', () => {
// describe('profilepage', () => {
// beforeEach(() => {
// cy.visit('/')
// cy.contains('Log in').click()
// console.log(cy.get('input'))
// cy.get('input[name="username"]').type('endre')
// cy.get('input[name="password"]').type('endre')
// cy.intercept(
// {
// method: 'POST', // Route all GET requests
// url: 'https://secfit-t2-backend.herokuapp.com/api/token/', // that have a URL that matches '/users/*'
// },
// {
// "refresh": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoicmVmcmVzaCIsImV4cCI6MTYxNTE5NTMzMiwianRpIjoiZTEyYzU5YjcwNzBjNGJlMjhiNzRkNGJlY2E3NmVhYjciLCJ1c2VyX2lkIjo0fQ.qCmqEjEIXsic1YEE1teZmNJc5ggdaFBEm_ab0rUvdoQ",
// "access": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNjE1MTA5MjMyLCJqdGkiOiIwZGE4MWQzZjIzOTQ0YTI1OGFjYTI2OWViMzkwNWViMyIsInVzZXJfaWQiOjR9.eKNn54JEkHaP7ny4VZ2Pazwa9diphAe1BPCXTaG7BMs"
// }// and force the response to be: []
// )
// cy.intercept(
// {
// method: 'POST', // Route all GET requests
// url: 'https://secfit-t2-backend.herokuapp.com/api/token/*', // that have a URL that matches '/users/*'
// },
// {
// "refresh": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoicmVmcmVzaCIsImV4cCI6MTYxNTE5NTMzMiwianRpIjoiZTEyYzU5YjcwNzBjNGJlMjhiNzRkNGJlY2E3NmVhYjciLCJ1c2VyX2lkIjo0fQ.qCmqEjEIXsic1YEE1teZmNJc5ggdaFBEm_ab0rUvdoQ",
// "access": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNjE1MTA5MjMyLCJqdGkiOiIwZGE4MWQzZjIzOTQ0YTI1OGFjYTI2OWViMzkwNWViMyIsInVzZXJfaWQiOjR9.eKNn54JEkHaP7ny4VZ2Pazwa9diphAe1BPCXTaG7BMs"
// }// and force the response to be: []
// )
// cy.intercept(
// {
// method: 'GET', // Route all GET requests
// url: 'https://secfit-t2-backend.herokuapp.com/api/users/?user=current', // that have a URL that matches '/users/*'
// },
// responseUser1
// )
// cy.intercept(
// {
// method: 'GET', // Route all GET requests
// url: `https://secfit-t2-backend.herokuapp.com/api/users/${userId1}`,
// },
// userResults1
// )
// cy.intercept(
// {
// method: 'GET', // Route all GET requests
// url: `https://secfit-t2-backend.herokuapp.com/api/users/${userId2}`,
// },
// userResults2
// ).as('getUser2')
// cy.intercept(
// {
// method: 'GET', // Route all GET requests
// url: `https://secfit-t2-backend.herokuapp.com/api/users/`,
// },
// usersResult
// )
// cy.intercept(
// {
// method: 'GET', // Route all GET requests
// url: `https://secfit-t2-backend.herokuapp.com/api/exercises/`,
// },
// exerciseResults
// )
// cy.intercept(
// {
// method: 'PATCH',
// url: `https://secfit-t2-backend.herokuapp.com/api/users/${userId1}`,
// },
// updatedUser
// ).as('updateUser')
// cy.intercept(
// {
// method: 'GET',
// url: `https://secfit-t2-backend.herokuapp.com/api/workouts/?ordering=-date`,
// },
// workoutsResult
// )
// cy.intercept(
// {
// method: 'GET',
// url: `https://secfit-t2-backend.herokuapp.com/api/workouts/${workoutId2}/`,
// },
// workout2
// ).as('populateWorkout')
// cy.intercept(
// {
// method: 'GET',
// url: `https://secfit-t2-backend.herokuapp.com/api/comments/`,
// },
// commentsResult
// )
// cy.intercept(
// {
// method: 'GET',
// url: `https://secfit-t2-backend.herokuapp.com/api/offers/*`,
// },
// offersResult
// )
// cy.intercept(
// {
// method: 'GET',
// url: `https://secfit-t2-backend.herokuapp.com/api/athlete-files/*`,
// },
// athleteFilesResult
// )
// cy.get('#btn-login').click()
// cy.visit('/')
// });
// it('render own profilepage', () => {
// cy.visit('/profilepage.html')
// cy.get("#username").should("have.value", username1)
// cy.get("#birthday").should("have.value", birthday1)
// cy.get("#favoriteExercise").should("have.value", favoriteExercise1)
// cy.get("#bio").should("have.value", bio1)
// })
// it('render other profilepage', () => {
// cy.visit(`/profilepage.html?id=${userId2}`)
// cy.get("#username").should("have.value", username2)
// cy.get("#birthday").should("have.value", birthday2)
// cy.get("#favoriteExercise").should("have.value", favoriteExercise2)
// cy.get("#bio").should("have.value", bio2)
// })
// it('edit profilepage', () => {
// cy.visit(`/profilepage.html`)
// cy.get('#edit-profile-page-button').click()
// cy.get("#username").clear().type(newUsername).should("have.value", newUsername)
// cy.get("#birthday").clear().type(newBirthday).should("have.value", newBirthday)
// cy.get("#favoriteExercise-select").select(newFavoriteExercise).should("have.value", newFavoriteExercise)
// cy.get("#bio").clear().type(newBio).should("have.value", newBio)
// cy.get("#save-profile-page-button").click()
// cy.wait('@updateUser').then(interception => {
// expect(interception.response.body.username).to.equal(newUsername)
// expect(interception.response.body.birthday).to.equal(newBirthday)
// expect(interception.response.body.bio).to.equal(newBio)
// expect(interception.response.body.favorite_exercise).to.equal(newFavoriteExercise)
// })
// })
// it('search profile', () => {
// cy.visit('/')
// cy.get('#profileSearch').type(username2)
// cy.get('#profiles option').should('have.length', 2)
// .first().should('have.value', username2)
// .next().should('have.value', username3)
// cy.get('.search-submit').click()
// cy.get("#username").should("have.value", username2)
// cy.get("#birthday").should("have.value", birthday2)
// cy.get("#favoriteExercise").should("have.value", favoriteExercise2)
// cy.get("#bio").should("have.value", bio2)
// })
// it('go to profile from workouts', () => {
// cy.visit('/workouts.html')
// cy.get('tr > td.pointer').contains(username2).click()
// cy.get("#username").should("have.value", username2)
// cy.get("#birthday").should("have.value", birthday2)
// cy.get("#favoriteExercise").should("have.value", favoriteExercise2)
// cy.get("#bio").should("have.value", bio2)
// })
// it('go to profile from workout', () => {
// cy.visit(`/workout.html?id=${workoutId2}`)
// cy.wait('@populateWorkout')
// cy.get('#inputOwner').should("have.value", username2)
// cy.get('#inputOwner').click()
// cy.get("#username").should("have.value", username2)
// cy.get("#birthday").should("have.value", birthday2)
// cy.get("#favoriteExercise").should("have.value", favoriteExercise2)
// cy.get("#bio").should("have.value", bio2)
// })
// it('go to profile with button', () => {
// cy.get('#btn-username').click()
// cy.get("#username").should("have.value", username1)
// cy.get("#birthday").should("have.value", birthday1)
// cy.get("#favoriteExercise").should("have.value", favoriteExercise1)
// cy.get("#bio").should("have.value", bio1)
// })
// it('visit my athletes', () => {
// cy.visit('/myathletes.html')
// cy.get(`#tab-${username2}`).click()
// cy.get(`#tab-contents-${username2} > div > a`).first().should("have.text", fileName)
// })
// })
describe('exercise', () => {
beforeEach(() => {
cy.visit('/')
cy.contains('Log in').click()
......@@ -254,6 +460,20 @@ describe('profilepage', () => {
},
responseUser1
)
cy.intercept(
{
method: 'GET', // Route all GET requests
url: 'https://secfit-t2-backend.herokuapp.com/api/exercises/1/', // that have a URL that matches '/users/*'
},
exercise
)
cy.intercept(
{
method: 'PUT', // Route all GET requests
url: 'https://secfit-t2-backend.herokuapp.com/api/exercises/1/', // that have a URL that matches '/users/*'
},
exercise
)
cy.intercept(
{
method: 'GET', // Route all GET requests
......@@ -327,83 +547,21 @@ describe('profilepage', () => {
cy.get('#btn-login').click()
cy.visit('/')
});
it('render own profilepage', () => {
cy.visit('/profilepage.html')
cy.get("#username").should("have.value", username1)
cy.get("#birthday").should("have.value", birthday1)
cy.get("#favoriteExercise").should("have.value", favoriteExercise1)
cy.get("#bio").should("have.value", bio1)
})
it('render other profilepage', () => {
cy.visit(`/profilepage.html?id=${userId2}`)
cy.get("#username").should("have.value", username2)
cy.get("#birthday").should("have.value", birthday2)
cy.get("#favoriteExercise").should("have.value", favoriteExercise2)
cy.get("#bio").should("have.value", bio2)
})
it('edit profilepage', () => {
cy.visit(`/profilepage.html`)
cy.get('#edit-profile-page-button').click()
cy.get("#username").clear().type(newUsername).should("have.value", newUsername)
cy.get("#birthday").clear().type(newBirthday).should("have.value", newBirthday)
cy.get("#favoriteExercise-select").select(newFavoriteExercise).should("have.value", newFavoriteExercise)
cy.get("#bio").clear().type(newBio).should("have.value", newBio)
cy.get("#save-profile-page-button").click()
cy.wait('@updateUser').then(interception => {
expect(interception.response.body.username).to.equal(newUsername)
expect(interception.response.body.birthday).to.equal(newBirthday)
expect(interception.response.body.bio).to.equal(newBio)
expect(interception.response.body.favorite_exercise).to.equal(newFavoriteExercise)
})
})
it('search profile', () => {
cy.visit('/')
cy.get('#profileSearch').type(username2)
cy.get('#profiles option').should('have.length', 2)
.first().should('have.value', username2)
.next().should('have.value', username3)
cy.get('.search-submit').click()
cy.get("#username").should("have.value", username2)
cy.get("#birthday").should("have.value", birthday2)
cy.get("#favoriteExercise").should("have.value", favoriteExercise2)
cy.get("#bio").should("have.value", bio2)
})
it('go to profile from workouts', () => {
cy.visit('/workouts.html')
cy.get('tr > td.pointer').contains(username2).click()
cy.get("#username").should("have.value", username2)
cy.get("#birthday").should("have.value", birthday2)
cy.get("#favoriteExercise").should("have.value", favoriteExercise2)
cy.get("#bio").should("have.value", bio2)
})
it('go to profile from workout', () => {
cy.visit(`/workout.html?id=${workoutId2}`)
cy.wait('@populateWorkout')
cy.get('#inputOwner').should("have.value", username2)
cy.get('#inputOwner').click()
cy.get("#username").should("have.value", username2)
cy.get("#birthday").should("have.value", birthday2)
cy.get("#favoriteExercise").should("have.value", favoriteExercise2)
cy.get("#bio").should("have.value", bio2)
})
it('go to profile with button', () => {
cy.get('#btn-username').click()
cy.get("#username").should("have.value", username1)
cy.get("#birthday").should("have.value", birthday1)
cy.get("#favoriteExercise").should("have.value", favoriteExercise1)
cy.get("#bio").should("have.value", bio1)
})
it('deleteOldFormData exercises', () => {
cy.visit('/exercise.html?id=1')
cy.get('#btn-edit-exercise').click()
cy.get('#btn-edit-exercise').click()
cy.get('#inputName').type('Knebøy')
cy.get('#btn-cancel-exercise').click()
cy.get('#inputName').should("have.value", "Benkpress")
it('visit my athletes', () => {
cy.visit('/myathletes.html')
cy.get(`#tab-${username2}`).click()
cy.get(`#tab-contents-${username2} > div > a`).first().should("have.text", fileName)
cy.get('#btn-edit-exercise').click()
cy.get('#inputName').clear()
cy.get('#inputName').type('Knebøy')
cy.get('#btn-ok-exercise').click()
cy.get('#inputName').should("have.value", "Knebøy")
})
})
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment