Skip to content

Gx3 1375 tools qa alert frame window alerts #599

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 10 commits into from
Jan 23, 2024
4 changes: 2 additions & 2 deletions .github/workflows/CI-Suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
with:
browser: electron
command: | #EDITAR AQUÍ EL ARCHIVO SUITE A EJECUTAR:
yarn file cypress/e2e/Tests/Elements/GX3-1100-RadioButtons.cy.js
yarn file cypress/e2e/Tests/Alert-Frame-Window/GX3-1375-Alerts.cy.js

- name: ✅Import Test Results to Xray
if: always()
Expand All @@ -65,7 +65,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: "GX3-1106" #tools-qa-elements-radio-buttons.
testExecKey: 'GX3-1382' #tools-qa-elements-radio-buttons.
projectKey: 'GX3' #EDITAR EN CASO DE TRABAJAR CON OTRO PROYECTO.

- name: 🔔Slack Notification of Done
Expand Down
48 changes: 48 additions & 0 deletions cypress/e2e/Tests/Alert-Frame-Window/GX3-1375-Alerts.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { alertPage } from '@pages/Alert-Frame-Window/GX3-1375-Alerts';
import { faker } from '@faker-js/faker';
import data from '@data/GX3-1375-Alert.json';
const valueEntered = faker.music.songName();
describe('ToolsQA | Alert-Frame-Window | Alerts', () => {
beforeEach(() => {
cy.visit('/alerts');
cy.url().should('include', data.enpoint);
});
it('1376 | TC1: Validar mensaje de alerta del primer botton "Click me" cuando es clickeado', () => {
alertPage.clickFirtsButtonClickMe();
alertPage.windowAlert({ expectedMsj: data.AlertMsj1 });
});
it('1376 | TC2: Validar mensaje de alerta del segundo botton "Click me" después de 5 segundos', () => {
alertPage.clickSecondButtonClickMe();
alertPage.windowAlert({ expectedMsj: data.AlertMsj2 });
});
it('1376 | TC3: Validar mensaje del tercer botton "Click me" cuando se clickea "OK"', () => {
alertPage.clickThirthButtonClickMe();
alertPage.windowConfirm({ expectedMsj: data.AlertMsj3, sendOkOption: 'true' });

alertPage.getThirthMsjButtonClickme().then(ActualMsj => {
expect(ActualMsj).to.equal(data.ElementMsj1);
});
});
it('1376 | TC4: Validar mensaje del tercer botton "Click me" cuando se clickea "Cancel"', () => {
alertPage.clickThirthButtonClickMe();
alertPage.windowConfirm({ expectedMsj: data.AlertMsj3, sendOkOption: 'false' });

alertPage.getThirthMsjButtonClickme().then(ActualMsj => {
expect(ActualMsj).to.equal(data.ElementMsj2);
});
});
it('1376 | TC5: Validar No visualizar mensaje del cuarto botton "Click me" cuando SOLO se clickea "Ok"', () => {
alertPage.windowPrompt({ expectedMsj: data.AlertMsj4, sendValueOrOption: 'okOption' });
alertPage.get.fourthMsjButtonClickme().should('not.exist');
});
it('1376 | TC6: Validar No visualizar mensaje del cuarto botton "Click me" cuando SOLO se clickea "Cancel"', () => {
alertPage.windowPrompt({ expectedMsj: data.AlertMsj4, sendValueOrOption: 'cancelOption' });
alertPage.get.fourthMsjButtonClickme().should('not.exist');
});
it('1376 | TC7: Validar visualizar mensaje del cuarto botton "Click me" cuando se introduce un valor en el prompt', () => {
alertPage.windowPrompt({ expectedMsj: data.AlertMsj4, sendValueOrOption: valueEntered });
alertPage.getFourthMsjButtonClickme().then(ActualMsj => {
expect(ActualMsj).to.equal(`You entered ${valueEntered}`);
});
});
});
9 changes: 9 additions & 0 deletions cypress/fixtures/data/GX3-1375-Alert.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"enpoint": "alerts",
"AlertMsj1": "You clicked a button",
"AlertMsj2": "This alert appeared after 5 seconds",
"AlertMsj3": "Do you confirm action?",
"AlertMsj4": "Please enter your name",
"ElementMsj1": "You selected Ok",
"ElementMsj2": "You selected Cancel"
}
57 changes: 57 additions & 0 deletions cypress/support/pages/Alert-Frame-Window/GX3-1375-Alerts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
class Alerts {
get = {
firtsButtonClickMe: () => cy.get('[id="alertButton"]'),
secondButtonClickMe: () => cy.get('[id="timerAlertButton"]'),
thirthButtonClickMe: () => cy.get('#confirmButton'),
fourthButtonClickMe: () => cy.get('#promtButton'),
thirthMsjButtonClickme: () => cy.get('[id="confirmResult"]'),
fourthMsjButtonClickme: () => cy.get('[id="promptResult"]'),
};

clickFirtsButtonClickMe() {
this.get.firtsButtonClickMe().click();
}
clickSecondButtonClickMe() {
this.get.secondButtonClickMe().click();
}
clickThirthButtonClickMe() {
this.get.thirthButtonClickMe().click();
}
clickFourthButtonClickMe() {
return this.get.fourthButtonClickMe().click();
}
getThirthMsjButtonClickme() {
return this.get.thirthMsjButtonClickme().invoke('text');
}
getFourthMsjButtonClickme() {
return this.get.fourthMsjButtonClickme().invoke('text');
}

windowAlert({ expectedMsj }) {
cy.on('window:alert', alert => {
expect(alert).to.equal(expectedMsj);
});
}

windowConfirm({ expectedMsj, sendOkOption }) {
cy.on('window:confirm', alert => {
expect(alert).to.equal(expectedMsj);
let choiceAlert = sendOkOption === 'true' ? true : false;
return choiceAlert;
});
}

windowPrompt({ expectedMsj, sendValueOrOption }) {
cy.window().then(win => {
let cancelOption = false,
okOption = '';
sendValueOrOption = sendValueOrOption === 'okOption' ? okOption : sendValueOrOption;
sendValueOrOption = sendValueOrOption === 'cancelOption' ? cancelOption : sendValueOrOption;
cy.stub(win, 'prompt').returns(sendValueOrOption).as('promptStub');
this.clickFourthButtonClickMe();
cy.get('@promptStub').should('be.calledWith', expectedMsj);
});
}
}

export const alertPage = new Alerts();
49 changes: 49 additions & 0 deletions cypress/test-plan/in-sprint/sprint-34/GX3-1375.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# ⚡️ToolsQA | Alert-Frame-Window | Alerts

[GX3-1375](https://upexgalaxy34.atlassian.net/browse/GX3-1375) Created: 16/1/24 Updated: 16/1/24

- As a QA learner,
- I want to test:
- **Click Button to see alert.**
- **On button click, alert will appear after 5 seconds.**
- **On button click, confirm box will appear.**
- **On button click, prompt box will appear.**
- So that I can improve my testing skills for this scenario.

🚩BUSINESS RULES SPEC

For the first “Click me” button:

must appear an alert with the text “You clicked a button”.

For the second “Click me” button:

must appear an alert 5 seconds after the click with the text “This alert appeared after 5 seconds”.

For the thirth “Click me” button:

must appear a confirm box with the text “Do you confirm action?” and options “OK” and “Cancel”.

IF: option “OK” is clicked

THEN: must appear a “You selected Ok” confirmation message.

IF: option “Cancel” is clicked

THEN: must appear a “You selected Cancel“ confirmation message.

For the fourth “Click me” button:

must appear a prompt with the text “Please enter your name” with a text field and options “OK” and “Cancel”.

IF: the field is empty and the “OK” button is pressed.

THEN: the prompt window must close.

IF: the field is completed and the “OK” button is pressed.

THEN: must appear “You entered” and the text that the user inserted.

IF: the “Cancel” button is pressed.

THEN: the prompt window must close.