Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Secfit Frontend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
T2
Secfit Frontend
Commits
2eeb0d4c
Commit
2eeb0d4c
authored
4 years ago
by
Sigmund Berbom
Browse files
Options
Downloads
Patches
Plain Diff
testing for deleteFormData
parent
74fda480
Branches
master
No related tags found
No related merge requests found
Pipeline
#129068
passed
4 years ago
Stage: test
Stage: production
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
cypress/integration/test_spec.js
+233
-75
233 additions, 75 deletions
cypress/integration/test_spec.js
with
233 additions
and
75 deletions
cypress/integration/test_spec.js
+
233
−
75
View file @
2eeb0d4c
...
...
@@ -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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment