diff --git a/frontend/cypress/integration/first.spec.js b/frontend/cypress/integration/first.spec.js index 09febc75b8c083d6b06a5e03b2f4980276c301da..0bbdf14fcb559bf317a4a7b49e1ed83431d588fb 100644 --- a/frontend/cypress/integration/first.spec.js +++ b/frontend/cypress/integration/first.spec.js @@ -1,5 +1,33 @@ -describe("Simple test", () => { - it("Works", () => { - expect(true).to.equal(true) +describe('Create exercise', () => { + it('Exercise creation', function() { + this.login(this.athleteUser) + cy.get('#nav-exercises').click() + cy.get('#btn-create-exercise').click() + cy.url().should('include', 'exercise.html') + + typeIn( + 'Workout', + 'Description', + '10', + '10', + '10', + 'Legs', + ) + cy.intercept({method: 'POST', url: '/api/exercises/' }).as('createRequest') + cy.get('#btn-ok-exercise').click() + cy.wait('@createRequest') + // Successfully created exercise + cy.url().should('include', 'exercises.html') }) + + + function typeIn(name, description, unit, duration, calories, muscleGroup) { + cy.get('#inputName', { timeout: 10000 }).type(name) + cy.get('#inputDescription').type(description) + cy.get('#inputUnit').type(unit) + cy.get('#inputDuration').type(duration) + cy.get('#inputCalories').type(calories) + cy.get('select[name="muscleGroup"]').eq(0).select(muscleGroup, {force: true}) + } + })