Skip to content
Snippets Groups Projects
Commit e5b094be authored by hollum's avatar hollum
Browse files

integration tests on goal

parent b6e53fd9
No related branches found
No related tags found
No related merge requests found
Pipeline #164092 passed with stage
in 29 seconds
const getDate = () => {
let d = new Date();
const offset = d.getTimezoneOffset();
d = new Date(d.getTime() - (offset*60*1000));
return d.toISOString().split('T')[0];
}
//
describe('Create goal', () => {
it('Go to goals', function() {
this.login(this.athleteUser)
cy.get('#nav-goals').click()
cy.get('#btn-create-goal').click()
cy.url().should('include', 'goal.html')
cy.get('#inputName', { timeout: 10000 }).type("GOAL_NAME")
cy.get('#inputDescription').type("GOAL_DESCRIPTION")
cy.get('#inputDateTime')
.click()
.then(input => {
input[0].dispatchEvent(new Event('input', { bubbles: true }))
input.val('2017-04-30T13:00')
})
.click()
cy.intercept({method: 'POST', url: '/api/goal/' }).as('createRequest')
cy.get('#btn-ok-goal').click()
cy.wait('@createRequest')
cy.url().should('include', 'goals.html')
})
it('Edit goal', function() {
this.login(this.athleteUser)
cy.get('#nav-goals').click()
cy.get('.card-link')
.eq(0).click()
cy.intercept({method: 'GET', url: '/api/goal/2/' }).as('createRequest')
cy.wait('@createRequest')
cy.intercept({method: 'DELETE', url: '/api/goal/2/' }).as('createRequest')
cy.get('#btn-delete-goal').click()
cy.wait('@createRequest')
cy.url().should('include', 'goals.html')
})
})
......@@ -16,7 +16,6 @@
// Import commands.js using ES2015 syntax:
import './commands'
/*
var coachUser = {
username: null,
......@@ -106,7 +105,7 @@ before(() => {
...athleteUser,
...generateUser()
}
registerUser(coachUser)
//registerUser(coachUser)
registerUser(athleteUser)
cy.visit(`${baseUrl}/index.html`)
})
......@@ -116,5 +115,3 @@ beforeEach(() => {
cy.wrap(athleteUser).as('athleteUser')
cy.wrap(login).as('login')
})
*/
......@@ -33,6 +33,7 @@ async function createGoal() {
async function deleteExercise(id) {
let response = await sendRequest("DELETE", `${HOST}/api/goal/${id}/`);
console.log(`${HOST}/api/goal/${id}/`)
if (!response.ok) {
let data = await response.json();
let alert = createAlert(`Could not delete goal ${id}`, data);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment