Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
a3c5ab5
Added Cypress, created some tests.
RTC-13 Apr 7, 2023
9b9d48b
Added tests, fixtures, data-cy attributes
RTC-13 Apr 7, 2023
78ad945
Added TS105
RTC-13 Apr 7, 2023
43922ee
Added tests, cy-data
RTC-13 Apr 7, 2023
e66b20f
Update spec.cy.js
RTC-13 Apr 7, 2023
7f8af32
Update spec.cy.js
RTC-13 Apr 7, 2023
e51f134
Update spec.cy.js
RTC-13 Apr 7, 2023
b149812
Changed order of menu to match landing page order for consistancy
RTC-13 Apr 7, 2023
15b46b8
Organizing tests
RTC-13 Apr 7, 2023
a9d7ff8
Fixed Typo
RTC-13 Apr 7, 2023
5b84b5f
Update testInstructions.cy.js
RTC-13 Apr 7, 2023
13525b6
Added cypress opening script, Next step button testing
RTC-13 Apr 8, 2023
3858f48
Update testInstructions.cy.js
RTC-13 Apr 8, 2023
5073729
Added testing + test image
RTC-13 Apr 8, 2023
0ea8e88
Form validation test
RTC-13 Apr 9, 2023
975594c
TS302
RTC-13 Apr 9, 2023
6f99a0a
Form Error Feedback Testing
RTC-13 Apr 9, 2023
723eb9c
Added test TS303, other changes
RTC-13 Apr 19, 2023
a45a222
Added TS304
RTC-13 Apr 19, 2023
a07e388
Added TS305
RTC-13 Apr 19, 2023
f6580fe
Removed attributes
RTC-13 Apr 20, 2023
4be4169
Added TS305, Fixed test organization
RTC-13 Apr 21, 2023
a601633
Added TS305 Testing & Removed completed TODO
RTC-13 Apr 21, 2023
a7208cc
Added other details page test
RTC-13 Apr 21, 2023
e867cba
Added attributes
RTC-13 Apr 21, 2023
29888ec
Added cypress-file-upload, fixed otherDetails
RTC-13 Apr 22, 2023
ab167b7
Update otherDetails.cy.js
RTC-13 Apr 22, 2023
1ed0de0
Update otherDetails.cy.js
Apr 22, 2023
6b1d2b8
Organizing
RTC-13 Apr 22, 2023
983d597
Merge branch 'Add-Cypress-Testing' of https://github.com/navgurukul/k…
Apr 24, 2023
174914d
named the elements in the index and gave them an alias
Apr 24, 2023
3d54795
Test organization, renaming attributes
RTC-13 Apr 24, 2023
9858421
fixed error 404 when running cypress tests
Apr 25, 2023
fe50768
Update otherDetails.cy.js
Apr 29, 2023
096f161
completed cypress tasks TS307 and TS308
May 14, 2023
d0e7d7a
updated tasks TS307 & TS308
May 14, 2023
e289185
Update otherDetails.cy.js
May 15, 2023
2c62294
Update otherDetails.cy.js
LouisCatala May 22, 2023
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
9 changes: 9 additions & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const { defineConfig } = require("cypress");

module.exports = defineConfig({
e2e: {
setupNodeEvents(on, config) {
// implement node event listeners here
},
},
});
118 changes: 118 additions & 0 deletions cypress/e2e/landingPage.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
/// <reference types='Cypress' />
// TODO: Make links dynamic
beforeEach(() => {
cy.visit("http://localhost:8080/");
});

describe("Section 1: Landing page", () => {
// TS101
it("should display the logo top left, should redirect user to home page when logo is clicked", () => {
// display logo top left
cy.get('[data-cy="logo"]')
.should("have.css", "top", "0px")
.should("have.css", "left", "0px");

// clicking logo should redirect user to home page
cy.visit("http://localhost:8080/test/instructions");
cy.get('[data-cy="logo"]').click();

cy.url().should("equal", "http://localhost:8080/");
});
// TS101
it("should have a language dropdown with the options English, Hindi and Marathi: Verify language change", () => {
cy.get(`[data-cy="lang-dropdown"]`).should("have.value", "");

// open the select
cy.get(`[data-cy="lang-dropdown"]`).click();

// select English, verify change of language
cy.get(`[data-cy="en"]`).click();
cy.get('[data-cy="title"]').contains("Start Admisssion Test");

// select Hindin verify change of language
cy.get(`[data-cy="hi"]`).click();
cy.get('[data-cy="title"]').contains("परीक्षा शुरू करें");

// select Marathi, change language

cy.get(`[data-cy="ma"]`).click();
cy.get('[data-cy="title"]').contains("प्रवेश परीक्षा सुरू करा");
});

// TS103
it("should type in user's first and last names, submit form and verify move to test instructions", () => {
cy.fixture("users").then((users) => {
const user = users[0];

cy.get(`[data-cy="firstName-input"]`).type(user.firstName);
cy.get(`[data-cy="lastName-input"]`).type(user.lastName);
cy.get(`[data-cy="mobileNumber-input"]`).type(user.mobileNumber);
cy.get(`[data-cy="submitButton"]`)
.click()
.url()
.should("include", "test/instructions");
});
});

// TS103_02
it("should type in user's first and last names AND MIDDLE NAME, submit form and verify move to test instructions", () => {
cy.fixture("users").then((users) => {
const user = users[0];

cy.get(`[data-cy="firstName-input"]`).type(user.firstName);
// Middle NAME
cy.get(`[data-cy="middleName-input"]`).type(user.middleName);

cy.get(`[data-cy="lastName-input"]`).type(user.lastName);
cy.get(`[data-cy="mobileNumber-input"]`).type(user.mobileNumber);
cy.get(`[data-cy="submitButton"]`)
.click()
.wait(1000)
.url()
.should("include", "test/instructions");
});
});

// TS105
it("should submit button with invalid data, verify notification to user, URL should not change", () => {
// get the url before submit button is clicked
cy.url().then((urlBeforeSubmit) => {
cy.get(`[data-cy=submitButton]`).click();

// snackbar
cy.get('[data-cy="error-bar"]');

// get the url after submit button is clicked
cy.url().then((urlAfterSubmit) => {
// assert the URL before and after are the same
expect(urlBeforeSubmit).to.equal(urlAfterSubmit);
});
});
});

// TS105 Submit with invalid phone number
it("should submit button with invalid data, verify notification to user, URL should not change", () => {
cy.fixture("users").then((users) => {
const user = users[0];

// get the url before submit button is clicked
cy.url().then((urlBeforeSubmit) => {
// enter valid inputs for, first middle and last names: Invalid # Number
cy.get(`[data-cy="firstName-input"]`).type(user.firstName);
cy.get(`[data-cy="middleName-input"]`).type(user.middleName);
cy.get(`[data-cy="lastName-input"]`).type(user.lastName);

cy.get(`[data-cy=submitButton]`).click();

// snackbar
cy.get('[data-cy="error-bar"]');

// get the url after submit button is clicked
cy.url().then((urlAfterSubmit) => {
// assert the URL before and after are the same
expect(urlBeforeSubmit).to.equal(urlAfterSubmit);
});
});
});
});
});
162 changes: 162 additions & 0 deletions cypress/e2e/otherDetails.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
/// <reference types='Cypress' />

import "cypress-file-upload";

beforeEach(() => {

cy.visit("http://localhost:8080/test/studentdetails");

cy.fixture("users.json").then((users) => {
const user = users[0];

cy.get('[data-cy="firstName-input"]').type(user.firstName);
cy.get('[data-cy="middleName-input"]').type(user.middleName);
cy.get('[data-cy="lastName-input"]').type(user.lastName);
cy.get('[data-cy="waInput"]').type(user.mobileNumber);
cy.get('[data-cy="altInput"]').type(user.alternateNumber);

cy.get("#mui-1").type(user.dob);
cy.get('[data-cy="email-input"]').type(user.email);
cy.get('[data-cy="genderDropdown"]').click();
cy.get('[data-value="female"]').click();
});

const fileName = '1mb.png';
cy.fixture(fileName).then((fileContent) => {
cy.get('[data-cy="imageInput"]').attachFile({
fileContent,
fileName,
mimeType: 'image/png',
});
});
cy.get('form > .MuiPaper-root > [tabindex="0"]').click();


// Inputs
cy.get('[data-cy="city"]').as("cityInput");
cy.get('[data-cy="pin-Input"]').as("pinCodeDropdown");
cy.get('[data-cy="district-input"]').as("districtDropdown");
cy.get('[data-cy="state-input"]').as("stateSelectDropdown");
cy.get('[data-cy="currentStatus"]').as("currentStatusDropdown");
cy.get('[data-cy="maxQualification"]').as("maximumQualificationLabel");
cy.get('[data-cy="schoolMedium"]').as("schoolMediumDropdown");
cy.get('[data-cy="religion-input"]').as("religionDropdown");
});
describe("TS307_01_State_District_Dropdown", () => {
it("District Dropdown should be populated based on state selected ", () => {
cy.get("@stateSelectDropdown").click();
cy.get('[data-value="BR"]').click();
cy.get('@districtDropdown').click();
cy.get('[data-value="Arrah"]').click();
cy.get('@districtDropdown').click();
cy.get('[data-value="Sheikhpura"]').click();
cy.get('@districtDropdown').click();
cy.get('[data-value="Maharajgani"]').click();
cy.get('@districtDropdown').click();
cy.get('[data-value="Thakurganj"]').click();
});
});

describe("TS307_02_State_District_Dropdown",() => {
it("select a blank state and the page should prompt the user with an error message", () => {
cy.get("@cityInput").type("SLC");
cy.get("@pinCodeDropdown").type("440212");
cy.get("@currentStatusDropdown").click();
cy.get('[data-value="job"]').click();
cy.get("@maximumQualificationLabel").click();
cy.get('[data-value="class10th"]').click();
cy.get('#mui-3').type("50")
cy.get("@schoolMediumDropdown").click();
cy.get('[data-value="en"]').click();
cy.get('#mui-component-select-caste').click();
cy.get('[data-value="scSt"]').click()
cy.get('#mui-component-select-religion').click();
cy.get('[data-value="others"]').click();
cy.get('.MuiMobileStepper-root > .MuiButton-contained').click();
cy.get('.MuiGrid-container > :nth-child(1) > .MuiTypography-root').should('be.visible').and('contain.text', 'Select your State')
});
});

describe("TS308_01_City_PIN",() => {
it.skip("Should validate if website recognizes/invalid city and pin inputs", () => {
cy.get('@pinCodeDropdown')
.find('input')
.type('121212');
cy.get('#pin_code-helper-text').should('be.visible').and('contain.text', 'Ex. 4402xx');
cy.get("@cityInput")
.click()
.type("Salt Lake City");
cy.get('#city-helper-text').should('be.visible').and('contain.text', 'Ex. Bangalore')


cy.reload();
cy.wait(5000);
cy.fixture("users.json").then((users) => {
const user = users[0];

cy.get('[data-cy="firstName-input"]').type(user.firstName);
cy.get('[data-cy="middleName-input"]').type(user.middleName);
cy.get('[data-cy="lastName-input"]').type(user.lastName);
cy.get('[data-cy="waInput"]').type(user.mobileNumber);
cy.get('[data-cy="altInput"]').type(user.alternateNumber);

cy.get("#mui-1").type(user.dob);
cy.get('[data-cy="email-input"]').type(user.email);
cy.get('[data-cy="genderDropdown"]').click();
cy.get('[data-value="female"]').click();
});

const fileName = "test-image.jpg";
cy.fixture(fileName).then((fileContent) => {
cy.get('[data-cy="imageInput"]').attachFile({
fileContent,
fileName,
mimeType: "image/jpeg",
});
cy.get('form > .MuiPaper-root > [tabindex="0"]').click()

});
cy.get("@cityInput").type("Salt Lake City");
cy.get("@pinCodeDropdown").type("Gustavo");
cy.get('#pin_code-helper-text').should('be.visible').and('contain.text', 'Enter a valid Pin Code');
cy.get('@pinCodeDropdown')
.find('input')
.clear()
.type('1212125');
cy.get('#pin_code-helper-text').should('be.visible').and('contain.text', 'Enter a valid Pin Code');

cy.get("@cityInput")
.clear()
.type("Gustavo");
cy.get("@pinCodeDropdown")
.clear()
.type("123456");
cy.get("@stateSelectDropdown").click();
cy.get('#pin_code-helper-text').should('be.visible').and('contain.text', 'Ex. 4402xx');
cy.get('#city-helper-text').should('be.visible').and('contain.text', 'Error')
});
});

describe("TS309_01_Status_Qualification",() => {
it.only("Verify current status and maximum qualification dropdowns",() => {
cy.get("@stateSelectDropdown").click();
cy.get('[data-value="BR"]').click();
cy.get('@districtDropdown').click();
cy.get('[data-value="Arrah"]').click();
cy.get("@currentStatusDropdown").click();
cy.get('[data-value="study"]').click();
cy.get("@maximumQualificationLabel").click();
cy.get('[data-value="graduate"]').click();
cy.get('#mui-4').type("76.40");
cy.get('#mui-3').type("76.40");
cy.get("@cityInput").type("SLC");
cy.get("@pinCodeDropdown").type("440212");
cy.get("@schoolMediumDropdown").click();
cy.get('[data-value="en"]').click();
cy.get('#mui-component-select-caste').click();
cy.get('[data-value="scSt"]').click()
cy.get('#mui-component-select-religion').click();
cy.get('[data-value="others"]').click();
cy.get('.MuiMobileStepper-root > .MuiButton-contained').click()
});
});
Loading