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

black box testing for FR5

parent 5edbeb5d
No related branches found
No related tags found
No related merge requests found
Pipeline #166470 passed with stage
in 22 seconds
var baseUrl = "localhost:9090"
describe('Black box testing', () => {
function logWorkout(workoutname, publicbool){
cy.get("#btn-create-workout").click();
cy.get('input[name="name"]').type(workoutname);
if(publicbool){
cy.get("#inputVisibility").select("Public");
}else{
cy.get("#inputVisibility").select("Private")
}
cy.get('input[name="date"]').click().then(input => {
input[0].dispatchEvent(new Event('input', { bubbles: true }))
input.val('2017-04-30T13:00')
}).click()
cy.get('#inputNotes').type('This is a note')
cy.get("#btn-ok-workout").click();
}
it('Logg personal workout and check if added in my list', function() {
this.login(this.athleteUser)
cy.get('#list-my-workouts-list').click();
cy.get('h5').contains('Public Workout');
})
it('Logg public personal and check if added', function() {
this.login(this.athleteUser)
cy.get('#list-public-workouts-list').click();
cy.get('h5').contains('Public Workout');
})
it('Logg public and check if added', function() {
this.login(this.athleteUser)
logWorkout("Public Workout", true);
cy.url().should('include', "/workouts.html");
cy.get('h5').contains('Public Workout')
})
it('See details of public workout', function() {
this.login(this.athleteUser)
cy.get('#list-public-workouts-list').click();
cy.get('h5').contains('Public Workout').parent().click();
cy.get('#inputName').should('be.visible');
cy.get('#inputNotes').should('be.visible');
cy.get('#customFile').should('be.visible');
})
it('User should not be able to see other private workouts', function() {
this.login(this.athleteUser)
logWorkout("Private Workout", false);
cy.get('#btn-logout', { timeout: 10000 }).click()
cy.wait(4000)
this.login(this.coachUser)
cy.wait(2000)
cy.get('h5').contains('Private Workout').should('not.exist');
cy.get('#list-public-workouts-list').click();
cy.get('h5').contains('Private Workout').should('not.exist');
})
})
......@@ -4,30 +4,19 @@ describe('Create exercise', () => {
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.get('#inputName', { timeout: 10000 }).type('Workout')
cy.get('#inputDescription').type('Description')
cy.get('#inputUnit').type('10')
cy.get('#inputDuration').type("-10")
cy.get('#inputCalories').type("-10")
cy.get('select[name="muscleGroup"]').eq(0).select('Legs', {force: true})
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})
}
cy.get('.alert').should('be.visible');
})
})
......@@ -7,8 +7,8 @@ const getDate = () => {
//
describe('Create goal', () => {
it('Go to goals', function() {
describe('Check goals', () => {
it('Create goal', function() {
this.login(this.athleteUser)
cy.get('#nav-goals').click()
cy.get('#btn-create-goal').click()
......@@ -24,25 +24,49 @@ describe('Create goal', () => {
input.val('2017-04-30T13:00')
})
.click()
cy.intercept({method: 'POST', url: '/api/goal/' }).as('createRequest')
// cy.intercept({method: 'POST', url: '/api/goal/' }).as('createRequest')
cy.get('#btn-ok-goal').click()
cy.wait('@createRequest')
cy.wait(1000)
cy.get('h2').eq(0).contains("GOAL_NAME")
//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/1/' }).as('createRequest')
cy.wait('@createRequest')
cy.get('#inputName', { timeout: 10000 }).type("_EDITED")
//cy.intercept({method: 'DELETE', url: '/api/goal/1/' }).as('createRequest')
cy.get('#btn-ok-goal').click()
cy.wait(1000)
cy.get('h2').eq(0).contains("GOAL_NAME_EDITED")
})
it('Delete 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/1/' }).as('createRequest')
//cy.wait('@createRequest')
cy.wait(1000)
cy.intercept({method: 'DELETE', url: '/api/goal/1/' }).as('createRequest')
//cy.intercept({method: 'DELETE', url: '/api/goal/1/' }).as('createRequest')
cy.get('#btn-delete-goal').click()
cy.wait('@createRequest')
cy.wait(1000)
//cy.wait('@createRequest')
cy.url().should('include', 'goals.html')
})
......
......@@ -6,9 +6,14 @@ describe('Test profile page', () => {
this.login(this.athleteUser)
cy.get('#nav-profile').click()
cy.get('#phone_number').type("12345678")
cy.get('#main_gym').type("SiT Moholt")
cy.get('#favourite_exercise').type("Cardio")
cy.get('#btn-edit-account').click()
cy.wait(1000)
cy.url().should('include', 'profile.html')
cy.get('#main_gym').should('have.value', 'SiT Moholt');
cy.get('#favourite_exercise').should('have.value', 'Cardio');
})
......
......@@ -6,7 +6,7 @@ var baseUrl = "localhost:9090"
/**
* The only validation done in the frontend is thorugh email
*/
const ThreeHundredChars = "tdt4242 tdt4242 tdt4242 tdt4242 tdt4242 tdt4242 tdt4242 tdt4242 tdt4242 tdt4242 tdt4242 tdt4242 tdt4242 tdt4242 tdt4242 tdt4242 tdt4242 tdt4242 tdt4242 ";
const HundredAndFiftyTwo = "tdt4242 tdt4242 tdt4242 tdt4242 tdt4242 tdt4242 tdt4242 tdt4242 tdt4242 tdt4242 tdt4242 tdt4242 tdt4242 tdt4242 tdt4242 tdt4242 tdt4242 tdt4242 tdt4242 ";
describe('boundary tests registration page', () => {
beforeEach(() => {
......@@ -25,16 +25,16 @@ describe('boundary tests registration page', () => {
it('Test upper boundary limit', () => {
cy.get('input[name="username"]').type(ThreeHundredChars)
cy.get('input[name="email"]').type(ThreeHundredChars)
cy.get('input[name="password"]').type(ThreeHundredChars)
cy.get('input[name="password1"]').type(ThreeHundredChars)
cy.get('input[name="phone_number"]').type(ThreeHundredChars)
cy.get('input[name="country"]').type(ThreeHundredChars)
cy.get('input[name="city"]').type(ThreeHundredChars)
cy.get('input[name="street_address"]').type(ThreeHundredChars)
// cy.get('input[name="main_gym"]').type(ThreeHundredChars)
// cy.get('input[name="favourite_exercise"]').type(ThreeHundredChars)
cy.get('input[name="username"]').type(HundredAndFiftyTwo)
cy.get('input[name="email"]').type(HundredAndFiftyTwo)
cy.get('input[name="password"]').type(HundredAndFiftyTwo)
cy.get('input[name="password1"]').type(HundredAndFiftyTwo)
cy.get('input[name="phone_number"]').type(HundredAndFiftyTwo)
cy.get('input[name="country"]').type(HundredAndFiftyTwo)
cy.get('input[name="city"]').type(HundredAndFiftyTwo)
cy.get('input[name="street_address"]').type(HundredAndFiftyTwo)
cy.get('input[name="main_gym"]').type(HundredAndFiftyTwo)
cy.get('input[name="favourite_exercise"]').type(HundredAndFiftyTwo)
cy.get('#btn-create-account').click()
......@@ -46,8 +46,8 @@ describe('boundary tests registration page', () => {
cy.get('li').contains('country').children('ul').children('li').contains("Ensure this field has no more than 50 characters.")
cy.get('li').contains('city').children('ul').children('li').contains("Ensure this field has no more than 50 characters.")
cy.get('li').contains('street_address').children('ul').children('li').contains("Ensure this field has no more than 50 characters.")
// cy.get('li').contains('main_gym').children('ul').children('li').contains("Ensure this field has no more than 50 characters.")
// cy.get('li').contains('favourite_exercise').children('ul').children('li').contains("Ensure this field has no more than 50 characters.")
cy.get('li').contains('main_gym').children('ul').children('li').contains("Ensure this field has no more than 50 characters.")
cy.get('li').contains('favourite_exercise').children('ul').children('li').contains("Ensure this field has no more than 50 characters.")
});
......
......@@ -25,7 +25,7 @@
<template id="template-exercise">
<template id="template-goals">
<div class="card ml-1" style="width: 24rem;">
<div class="card-body">
<h2 class="card-title" ></h2>
......
const HOST = "http://localhost:8000";
const HOST = "http://localhost:9090";
......@@ -6,7 +6,7 @@ async function fetchExerciseTypes(request) {
let goals = data.results;
let container = document.getElementById('div-content');
let exerciseTemplate = document.querySelector("#template-exercise");
let exerciseTemplate = document.querySelector("#template-goals");
goals.forEach(goal => {
const exerciseAnchor = exerciseTemplate.content.firstElementChild.cloneNode(true);
exerciseAnchor.href = `goal.html?id=${goal.id}`;
......
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