Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/uitests #1602

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ Developers
* Alexandra Rhodes - https://github.com/arhodes130
* Jayanth Bontha - https://github.com/JayanthBontha
* Ethan Winters - https://github.com/ebwinters
* Ganna Fedorenko - https://github.com/sandie911

Translators
-----------
Expand Down
Empty file added database
Empty file.
10 changes: 10 additions & 0 deletions uitests/cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const { defineConfig } = require("cypress");

module.exports = defineConfig({
e2e: {
baseUrl:'http://localhost:8000/en/',
setupNodeEvents(on, config) {
// implement node event listeners here
},
},
});
13 changes: 13 additions & 0 deletions uitests/cypress/e2e/1-features.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
describe('template spec', () => {
beforeEach(() => {
cy.visit('software/features')

})
it('Image correct header test', () => {
cy.get('.header-hero-image')
})
it('Get started', () => {
cy.get('a.btn.btn-primary.rounded-1.bg-dark-blue.py-2.px-5').click();
cy.url().should('include', 'login');
})
})
64 changes: 64 additions & 0 deletions uitests/cypress/e2e/2-registration.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
function generateRandomName() {
const randomString = Math.random().toString(36).substring(2, 15);
return `test_${randomString}`;
}

function generateRandomEmail() {
const randomString = Math.random().toString(36).substring(2, 15);
return `test${randomString}@wger-test.com`;
}

function generateRandomPassword() {
return Math.random().toString(36).substring(2, 15);
}

describe('register form tests', () => {
beforeEach(() => {
cy.visit('user/registration')
})

it('Valid data ', () => {
const name = generateRandomName();
const email = generateRandomEmail();
const password = generateRandomPassword();

// Storing credentials for later use
cy.writeFile('cypress/fixtures/credentials.json', {
name,
email,
password
});

cy.get('#id_username').type(name);
cy.get('#id_email').type(email);
cy.get('#id_password1').type(password);
cy.get('#id_password2').type(password);
cy.get('#submit-id-submit').click();
cy.wait(3000);
cy.location('pathname').should('eq', '/en/dashboard');
})
it('InValid data email', () => {
cy.get('#id_username').type('Anisa');
cy.get('#id_email').type('arfedorekr.com');
cy.get('#id_password1').type('HjKllpnnB');
cy.get('#id_password2').type('HjKllpnnB');
cy.get('#submit-id-submit').click();
cy.wait(3000);
})
it('InValid data username', () => {
cy.get('#id_username').type(' ');
cy.get('#id_email').type('[email protected]');
cy.get('#id_password1').type('HjKllpnnB');
cy.get('#id_password2').type('HjKllpnnB');
cy.get('#submit-id-submit').click();
cy.wait(3000);
})
it('InValid data password', () => {
cy.get('#id_username').type('Zina');
cy.get('#id_email').type('[email protected]');
cy.get('#id_password1').type('hhh');
cy.get('#id_password2').type('hhh');
cy.get('#submit-id-submit').click();
cy.wait(3000);
})
})
40 changes: 40 additions & 0 deletions uitests/cypress/e2e/3-login.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
describe('Login form', () => {
beforeEach(() => {
cy.visit('user/login')

})
it('Valid Login', () => {
// Reading credentials
cy.fixture('credentials').then((creds) => {
const { name, email, password } = creds;
cy.get('#id_username').type(name);
cy.get('#id_password').type(password);
cy.get('#submit-id-submit').click();
cy.wait(3000);
cy.url().should('include', 'dashboard');
});
})
it('Get started', () => {
cy.get('#main-sidebar').find('a[href="/en/user/registration"]').click();
cy.wait(3000);
cy.url().should('include', 'registration');
})
it('Login/Register', () => {
cy.get('#main-navbar-navigation').find('a[href="#"]').click();
cy.get('ul.dropdown-menu.show').should('be.visible');
cy.get('ul.dropdown-menu.show').find('a[href="/en/user/login"]').click();
cy.url().should('include', 'login');
cy.go('forward').get('#main-navbar-navigation').find('a[href="#"]').click();

cy.get('ul.dropdown-menu.show').find('a[href="/en/user/registration"]').click();
cy.url().should('include', 'registration');
cy.go('forward').get('#main-navbar-navigation').find('a[href="#"]').click();


cy.get('ul.dropdown-menu.show').find('a[href="/en/user/password/reset/"]').click();
cy.url().should('include', 'reset');


})

})
80 changes: 80 additions & 0 deletions uitests/cypress/e2e/4-dashboard.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/// <reference types="Cypress" />
describe('dashboard page tests', () => {
beforeEach(() => {
cy.visit('dashboard')

})

it('workout btn ', () => {
cy.get('a[href="/en/routine/add"]').click();
cy.wait(3000);
cy.get('#page-title');

})

it('nutritional plan add', () => {

cy.get('#react-nutrition-dashboard').find('button').click();
cy.wait(2000);
cy.get('form');
cy.get('#description').clear().type('Lose weight');
cy.get('#goalEnergy').click();
cy.get(' #energy').type('1600');
cy.get('#protein').type('89');
cy.get('#carbohydrates').type('48');
cy.get('#fat').type('117');
cy.get('div[class="MuiStack-root css-zpn2w"]').find('button').click();
cy.wait(2000);
cy.get('div[class="MuiStack-root css-1xhj18k"]');
})
it('add weight entry', () => {

cy.get('#react-weight-dashboard').find('button').click();
cy.get('#weight').clear().type(60);
cy.get('div[class="MuiStack-root css-zpn2w"]').find('button').click();
cy.wait(2000);
cy.get('#react-weight-dashboard');

})


it('add invalid data weight entry', () => {

cy.get('#react-weight-dashboard').find('button').click();
cy.get('div[class="MuiStack-root css-zpn2w"]').find('button').click();
cy.wait(2000);
cy.get('form');
})


it('close weight entry', () => {

cy.get('#react-weight-dashboard').find('button').click();
cy.wait(3000);
cy.get('svg[class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-vubbuv"]').first().click();
cy.wait(2000);
cy.get('#content');
})

it('language', () => {

cy.get('div[class="btn-group dropup"]').find('button').click();
cy.get('a[href="/tr/dashboard"]').click();
cy.get('h2').invoke('text').then((actualText) => {
const trimmedText = actualText.trim();
expect(trimmedText).to.equal('Gösterge Paneli');

cy.get('div[class="btn-group dropup"]').find('button').click();
cy.get('a[href="/zh-hans/dashboard"]').click();
cy.get('h2').invoke('text').then((actualText) => {
const trimmedText = actualText.trim();
expect(trimmedText).to.equal('儀表板');



})
});

})

})
99 changes: 99 additions & 0 deletions uitests/cypress/e2e/5-navigation.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/// <reference types="Cypress" />
describe('navigation dashboard page tests', () => {
beforeEach(() => {
cy.visit('dashboard')

})

it('Find header menu', () => {
cy.get('#main-navbar-navigation');

})

it('Visible Training menu', () => {
cy.get('.nav-item.dropdown').first().click();
cy.get('ul.dropdown-menu.show').should('be.visible');

cy.get('a.dropdown-item').first().click();
cy.location('pathname').should('eq', '/en/routine/overview');
cy.go('back').get('.nav-item.dropdown').first().click();

cy.get('a.dropdown-item').eq(1).click();
cy.location('pathname').should('eq', '/en/routine/schedule/overview');
cy.go('back').get('.nav-item.dropdown').first().click();


cy.get('a.dropdown-item').eq(2).click();
cy.get('#main-content');
cy.go('back').get('.nav-item.dropdown').first().click();


cy.get('a.dropdown-item').eq(3).click();
cy.location('pathname').should('eq', '/en/measurement/');
cy.go('back').get('.nav-item.dropdown').first().click();

cy.get('a.dropdown-item').eq(4).click();
cy.location('pathname').should('eq', '/en/gallery/overview');
cy.go('back').get('.nav-item.dropdown').first().click();


cy.get('a.dropdown-item').eq(5).click();
cy.location('pathname').should('eq', '/en/routine/template/overview');
cy.go('back').get('.nav-item.dropdown').first().click();


cy.get('a.dropdown-item').eq(6).click();
cy.location('pathname').should('eq', '/en/routine/template/public');
cy.go('back').get('.nav-item.dropdown').first().click();

cy.get('a.dropdown-item').eq(7).click();
cy.location('pathname').should('eq', '/en/exercise/overview/');
cy.go('back');


})

it('Visible Nutrition menu', () => {
cy.get('.nav-item.dropdown').eq(1).click();
cy.get('ul.dropdown-menu.show').should('be.visible');

cy.get('a.dropdown-item').eq(8).click();
cy.location('pathname').should('eq', '/en/nutrition/overview/');
cy.go('back').get('.nav-item.dropdown').eq(1).click();

cy.get('a.dropdown-item').eq(9).click()
cy.location('pathname').should('eq', '/en/nutrition/calculator/bmi/');
cy.go('back').get('.nav-item.dropdown').eq(1).click();

cy.get('a.dropdown-item').eq(10).click()
cy.location('pathname').should('eq', '/en/nutrition/calculator/calories/');
cy.go('back').get('.nav-item.dropdown').eq(1).click();

cy.get('a.dropdown-item').eq(11).click();
cy.location('pathname').should('eq', '/en/nutrition/ingredient/overview/');
cy.go('back');
})

it('Visible Body weight', () => {
cy.get('.nav-item.dropdown').eq(2).click();
cy.get('ul.dropdown-menu.show').should('be.visible');

cy.get('a.dropdown-item').eq(12).click();
cy.location('pathname').should('eq', '/en/weight/overview');
cy.go('back').get('.nav-item.dropdown').eq(2).click();

cy.get('a.dropdown-item').eq(13).click();
cy.location('pathname').should('eq', '/en/weight/add/');
cy.go('back');
})


it('Visible About this software', () => {
cy.get('.nav-item.dropdown').eq(3).click();
cy.get('ul.dropdown-menu.show').should('be.visible');
cy.get('a.dropdown-item').eq(14).click();
cy.location('pathname').should('eq', '/en/software/about-us');
cy.go('back');
})

})
5 changes: 5 additions & 0 deletions uitests/cypress/fixtures/credentials.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "test_uovpbtu6mjr",
"email": "[email protected]",
"password": "qix315i0nv"
}
5 changes: 5 additions & 0 deletions uitests/cypress/fixtures/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "[email protected]",
"body": "Fixtures are a great way to mock data for responses to routes"
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions uitests/cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add('login', (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
Cypress.Commands.add('getDataTest', (dataTestSelector) =>{
return cy.get('[data-test="${dataTestSelector}"]')
})
20 changes: 20 additions & 0 deletions uitests/cypress/support/e2e.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// ***********************************************************
// This example support/e2e.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands'

// Alternatively you can use CommonJS syntax:
// require('./commands')
Loading