Skip to content

Gx 23427 ✅ tools qa forms practice form #410

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

Merged
merged 11 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from 7 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
4 changes: 2 additions & 2 deletions .github/workflows/CI-Suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
with:
browser: chrome
command: | #EDITAR AQUÍ EL ARCHIVO SUITE A EJECUTAR:
yarn file cypress/e2e/Tests/Suites/GX-23133-BrokenLinks.cy.js
yarn file cypress/e2e/Tests/Suites/GX-23427-PracticeForm.cy.js

- name: ✅Import Test Results to Xray
if: always()
Expand All @@ -64,7 +64,7 @@ jobs:
password: ${{secrets.XRAY_CLIENT_SECRET}}
testFormat: 'junit' #OPCIONES PARA CAMBIAR: 'junit' (para xml) o 'cucumber' (para json)
testPaths: 'reports/test-results.xml' #OPCIONES: '/test-results.xml' o 'cucumber-report.json'
testExecKey: 'GX-23135' #EDITAR AQUÍ EL TEST EXECUTION A IMPORTAR LAS PRUEBAS.
testExecKey: 'GX-23429' #EDITAR AQUÍ EL TEST EXECUTION A IMPORTAR LAS PRUEBAS.
projectKey: 'GX' #EDITAR EN CASO DE TRABAJAR CON OTRO PROYECTO.

- name: 🔔Slack Notification of Done
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/Tests/Suites/GX-23133-BrokenLinks.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ describe('US GX-23133 | ToolsQA | Elements | Broken Links Images', () => {
cy.visit('https://demoqa.com/broken');
});

it('23134 | TC01: Validar visualizar correctamente imagen de ToolsQA al tomar la Valid Image', () => {
it.only('23134 | TC01: Validar visualizar correctamente imagen de ToolsQA al tomar la Valid Image', () => {
cy.get('div>img[src="/images/Toolsqa.jpg"]').should('be.visible').and('have.prop', 'naturalWidth').and('be.greaterThan', 0);
});

Expand Down
195 changes: 195 additions & 0 deletions cypress/e2e/Tests/Suites/GX-23427-PracticeForm.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
import { removeLogs } from '@helper/RemoveLogs';
removeLogs();
import { faker } from '@faker-js/faker';
import dayjs from 'dayjs';
import { form } from '@pages/Forms/GX-23427-PracticeForm.page';
import { email, file, field, mobileNumber } from '../../../fixtures/data/GX-23427-PracticeForm';

describe('US GX-23427 | ToolsQA | Forms | Practice Form', () => {
beforeEach('PRC: Usuario debe ubicarse en Practice Form', () => {
cy.visit('https://demoqa.com/automation-practice-form');
});

it('23428 | TC01: Validar enviar formulario al ingresar datos válidos', () => {
//valido los input texts
const fakeFirstname = faker.name.firstName();
const fakeLastname = faker.name.lastName();
const fakePhone = faker.datatype.number({ min: 1100000000, max: 1199999999 });
const fakeAddress = faker.address.streetAddress();
const fakeEmail = faker.internet.email();
form.typeFirstname(fakeFirstname);
form.typeLastname(fakeLastname);
form.typeEmail(fakeEmail);
form.typeMobileNumber(fakePhone);
form.typeAddress(fakeAddress);

//#################
//elije genero de manera aleatoria
const randomGender = Cypress._.random(0, 2);
form.selectGender(randomGender);

//fecha por defecto del input-date sea igual a fecha actual
const currentDate = dayjs().format('DD/MMM/YYYY').split('/').join(' ');
form.currentDateSelector().should('be.equal', currentDate);

//valida que se despliegue un menu al clickear sobre el input-date
form.get
.datepicker()
.click()
.then(t => {
cy.wrap(t).get('.react-datepicker').should('be.visible');
cy.wrap(t).get('.react-datepicker').click();
});

//seleccion de materias random
const matching = faker.random.alpha({ count: 1, casing: 'lower', bannedChars: ['f', 'j', 'k', 'ñ', 'q', 'w', 'x', 'z'] });
form.subjectsSelector(matching);

//checkbox
const randomCheck = Cypress._.random(0, 2);
form.hobbieChecker(randomCheck);

//agregar archivo
form.uploadFile(file.upex_logo);

//elige ciudad y estado
const randomLocationByState = Cypress._.random(0, 3);
form.stateSelector(randomLocationByState);
form.citySelector();

//#################
form.submitForm();

cy.get('.modal-content').should('be.visible');
cy.get('tr').eq(1).should('contain', fakeFirstname);
cy.get('tr').eq(1).should('contain', fakeLastname);
cy.get('tr').eq(2).should('contain', fakeEmail);
form.get
.genderTag()
.eq(randomGender)
.invoke('text')
.then(element => {
cy.get('tr').eq(3).should('contain', element);
});

cy.get('tr').eq(4).should('contain', fakePhone);

//tomo el valor de los subjects
cy.get('[class*="subjects-auto-complete__multi-value__label"]')
.invoke('text')
.then(label => {
cy.get('tr').eq(6).should('contain', label);
});

form.get
.checkboxTagnames()
.eq(randomCheck)
.invoke('text')
.then(element => {
cy.get('tr').eq(7).should('contain', element);
});

cy.get('tr').eq(8).should('contain', file.name);
cy.get('tr').eq(9).should('contain', fakeAddress);

//validate state on popup
cy.get('.css-1uccc91-singleValue')
.eq(0)
.invoke('text')
.then(txt => {
cy.get('tr').eq(10).should('contain', txt);
});

//validate city on popup
cy.get('.css-1uccc91-singleValue')
.eq(1)
.invoke('text')
.then(txt => {
cy.get('tr').eq(10).should('contain', txt);
});

//valido color de bordes con datos válidos
form.get.firstname().should('have.css', 'border-color', field.greenBorder);
form.get.lastname().should('have.css', 'border-color', field.greenBorder);
form.get.email().should('have.css', 'border-color', field.greenBorder);
form.get.genderTag().eq(randomGender).should('have.css', 'color', field.greenBorder);
form.get.mobilenumber().should('have.css', 'border-color', field.greenBorder);
form.get.datepicker().should('have.css', 'border-color', field.greenBorder);
form.get.checkboxTagnames().eq(randomCheck).should('have.css', 'color', field.greenBorder);
form.get.address().should('have.css', 'border-color', field.greenBorder);
});

it.skip('23428 | TC02: Validar NO enviar formulario al ingresar datos inválidos', () => {
Copy link
Contributor

@LauraMont LauraMont Jul 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Por aquí falto la validación de subject, entiendo que en el SUT no pasa que al fallar pero los criterios indican que este campo no debe estar vacío

Copy link
Author

@vertonepa vertonepa Jul 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, es lo que estaba por reportar de este bug antes del mantenimiento. El error me lo trae el input Mobile, este campo no puede tener menos de 10 dígitos y en la página de DemoQA me lo marca así, pero al ejecutar el test en Cypress esta prueba no pasa porque el campo me lo toma como correcto si la cantidad de dígitos está entre 1 y 9.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfecto ,me parece correcto que sea bug. Lo que te comentaba era por que no estas validando que el campo subject este en rojo ya que en los criterios de aceptacion indica que es un campo que no puede ir vacio,siguiendo esa logica su comportamiento deberia ser igual a los otros campos requeridos

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahora que lo revisé dice que ese campo no puede estar vacío aunque no menciona que se torne rojo al dejarlo así, también es distinto el comportamiento porque no se muestra de ningún color después de enviar datos. Y ahora me doy cuenta que el hecho de que se puedan enviar datos aunque este campo esté vacío también es un bug porque se especifica que no se despliega la info con los datos enviados en este caso.

form.typeEmail(email.invalid.noMinimChar.afterAtSign);
form.typeMobileNumber(mobileNumber.insufficientDigits);

form.submitForm();

//campos que contienen datos no permitidos
form.get.firstname().should('have.css', 'border-color', field.redBorder);
form.get.lastname().should('have.css', 'border-color', field.redBorder);
form.get.email().should('have.css', 'border-color', field.redBorder);
form.get.mobilenumber().should('have.css', 'border-color', field.redBorder);
form.get.genderTag().eq(1).should('have.css', 'color', field.redBorder);

//campos que admiten no contener datos
form.get.checkboxTagnames().eq(1).should('have.css', 'color', field.greenBorder);
form.get.address().should('have.css', 'border-color', field.greenBorder);
});

it('23428 | TC03: Validar NO enviar formulario cuando email no contiene @', () => {
const fakeFirstname = faker.name.firstName();
const fakeLastname = faker.name.lastName();
const randomGender = Cypress._.random(0, 2);
form.typeFirstname(fakeFirstname);
form.typeLastname(fakeLastname);
form.typeEmail(email.invalid.noAtSign);
form.typeMobileNumber(mobileNumber.valid);
form.selectGender(randomGender);

form.submitForm();
form.get.email().should('have.css', 'border-color', field.redBorder);
});

it('23428 | TC04: Validar NO enviar formulario cuando email no contiene 1 caracter alfanumérico antes del @', () => {
const fakeFirstname = faker.name.firstName();
const fakeLastname = faker.name.lastName();
const randomGender = Cypress._.random(0, 2);
form.typeFirstname(fakeFirstname);
form.typeLastname(fakeLastname);
form.typeEmail(email.invalid.noMinimChar.beforeAtSign);
form.typeMobileNumber(mobileNumber.valid);
form.selectGender(randomGender);

form.submitForm();
form.get.email().should('have.css', 'border-color', field.redBorder);
});

it('23428 | TC05: Validar NO enviar formulario cuando email no contiene "punto" luego de 1 caracter alfanumérico después del @', () => {
const fakeFirstname = faker.name.firstName();
const fakeLastname = faker.name.lastName();
const randomGender = Cypress._.random(0, 2);
form.typeFirstname(fakeFirstname);
form.typeLastname(fakeLastname);
form.typeEmail(email.invalid.noDot);
form.typeMobileNumber(mobileNumber.valid);
form.selectGender(randomGender);

form.submitForm();
form.get.email().should('have.css', 'border-color', field.redBorder);
});

it('23428 | TC06: Validar NO enviar formulario cuando email no contiene 2 caracteres alfanuméricos después del "punto"', () => {
const fakeFirstname = faker.name.firstName();
const fakeLastname = faker.name.lastName();
const randomGender = Cypress._.random(0, 2);
form.typeFirstname(fakeFirstname);
form.typeLastname(fakeLastname);
form.typeEmail(email.invalid.noMinimChar.afterDot);
form.typeMobileNumber(mobileNumber.valid);
form.selectGender(randomGender);

form.submitForm();
form.get.email().should('have.css', 'border-color', field.redBorder);
});
});
29 changes: 29 additions & 0 deletions cypress/fixtures/data/GX-23427-PracticeForm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"email": {
"invalid": {
"noAtSign": "valid_emailgmail.com",
"noMinimChar": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Te recuerdo por si acaso el formato de un mail: <user>@<org>.<tipo/extension>
Teniendo en cuenta lo anterior puedes llamar a tus variables :

  • noUser
  • noOrg
  • noExt o noTipo

"beforeAtSign": "@gmail.com",
"afterAtSign": "invalid_email@",
"afterDot": "[email protected]"
},
"noDot": "invalid_email@gmailcom"
}
},

"file": {
"upex_logo": "cypress/fixtures/images/upexlogo.png",
"name": "upexlogo"
},

"field": {
"greenBorder": "rgb(40, 167, 69)",
"redBorder": "rgb(220, 53, 69)"
},

"mobileNumber": {
"insufficientDigits": "112345678",
"valid": "1123456789"
}

}
47 changes: 23 additions & 24 deletions cypress/support/pages/Elements/GX-22038-TextBox.Page.js
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Se cambiaron las comillas dobles a simples por configuración del repositorio

Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
//Elementos
class form {
get = {
fullnameImput: () => cy.get("#userName"),
EmailInput: () => cy.get("#userEmail"),
currentAddressInput: () => cy.get("#currentAddress"),
permanentAddressInput: () => cy.get("#permanentAddress"),
submitBtn: () => cy.get("#submit"),
textBox: () => cy.get('.mb-1'),
redBorder: () => cy.get('.field-error'),
}
// Accionables de cypress
enterName(value) {
this.get.fullnameImput().type(value);
}
enterEmail(value) {
this.get.EmailInput().type(value);
}
enterCurrentAddress(value) {
this.get.currentAddressInput().type(value)
}
enterPermanentAddress(value) {
this.get.permanentAddressInput().type(value)
}

get = {
fullnameImput: () => cy.get('#userName'),
EmailInput: () => cy.get('#userEmail'),
currentAddressInput: () => cy.get('#currentAddress'),
permanentAddressInput: () => cy.get('#permanentAddress'),
submitBtn: () => cy.get('#submit'),
textBox: () => cy.get('.mb-1'),
redBorder: () => cy.get('.field-error'),
};
// Accionables de cypress
enterName(value) {
this.get.fullnameImput().type(value);
}
enterEmail(value) {
this.get.EmailInput().type(value);
}
enterCurrentAddress(value) {
this.get.currentAddressInput().type(value);
}
enterPermanentAddress(value) {
this.get.permanentAddressInput().type(value);
}
}
export const textForm = new form()
export const textForm = new form();
92 changes: 92 additions & 0 deletions cypress/support/pages/Forms/GX-23427-PracticeForm.page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
class Form {
//getters
get = {
firstname: () => cy.get('#firstName'),
lastname: () => cy.get('#lastName'),
email: () => cy.get('#userEmail'),
gender: () => cy.get('.custom-control.custom-radio.custom-control-inline'),
genderRadio: () => this.get.gender().find('[id*="gender-radio"]'), //arreglo de tres posiciones -> male - female - other
genderTag: () => this.get.gender().find('.custom-control-label'),
mobilenumber: () => cy.get('#userNumber'),
datepicker: () => cy.get('#dateOfBirthInput'),
subjectsInput: () => cy.get('#subjectsInput'),
subjectOptions: () => cy.get('[id^="react-select-2-option"]'),
hobbieCheckbox: () => cy.get('.custom-control.custom-checkbox.custom-control-inline'), //arreglo de tres posiciones -> sports - reading - music
checkboxButton: () => this.get.hobbieCheckbox().find('[type="checkbox"]'),
checkboxTagnames: () => this.get.hobbieCheckbox().find('.custom-control-label'),
pictureButton: () => cy.get('[type="file"]'),
address: () => cy.get('#currentAddress'),
stateButton: () => cy.get('#state .css-tlfecz-indicatorContainer'),
cityButton: () => cy.get('#city .css-tlfecz-indicatorContainer'),
statesAndCities: () => cy.get('[class$=-option]'),
submitButton: () => cy.get('#submit'),
};

//actions - methods
typeFirstname(randomFirst) {
this.get.firstname().type(randomFirst);
}

typeLastname(randomLast) {
this.get.lastname().type(randomLast);
}

typeEmail(randomEmail) {
this.get.email().type(randomEmail);
}

//selecciona un género de manera aleatoria
selectGender(randomGender) {
this.get.genderRadio().eq(randomGender).click({ force: true });
}

typeMobileNumber(number) {
this.get.mobilenumber().type(number);
}

//Nos da una fecha aleatoria del date picker
currentDateSelector() {
return this.get.datepicker().invoke('val');
}

//seleccionar un elemento de un dropdown list dinámico
subjectsSelector(matching) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Muy buena la manera de seleccionar las opciones de este elemento ✨

this.get.subjectsInput().type(matching);
this.get.subjectOptions().then(i => {
const r = Cypress._.random(0, i.length - 1);
cy.wrap(i).eq(r).click();
});
}

hobbieChecker(randomCheck) {
this.get.checkboxButton().eq(randomCheck).check({ force: true });
}

uploadFile(file) {
this.get.pictureButton().selectFile(file);
}

typeAddress(text) {
this.get.address().type(text);
}

//DropDown Estático:: Selecciona un estado y luego una ciudad
stateSelector(randomLocationByState) {
this.get.stateButton().click();
this.get.statesAndCities().eq(randomLocationByState).click({ force: true });
}

citySelector() {
this.get.cityButton().click();
this.get.statesAndCities().then(cityList => {
const position = Cypress._.random(0, cityList.length - 1);
cy.wrap(cityList).eq(position).click({ force: true });
});
}

submitForm() {
this.get.submitButton().click();
}
}

export const form = new Form();
Loading