Skip to content

Commit

Permalink
Merge pull request #53 from Programmer-RD-AI/main
Browse files Browse the repository at this point in the history
Cypress tests, API functions, and UI components for enhanced function…
  • Loading branch information
Programmer-RD-AI authored Dec 12, 2024
2 parents 8e01298 + d3fa4c8 commit 9ddb4c8
Show file tree
Hide file tree
Showing 54 changed files with 1,035 additions and 704 deletions.
128 changes: 0 additions & 128 deletions cypress/e2e/pages/adminPage.cy.jsx

This file was deleted.

135 changes: 0 additions & 135 deletions cypress/e2e/pages/articlePage.cy.jsx

This file was deleted.

25 changes: 0 additions & 25 deletions cypress/e2e/pages/contactUsPage.cy.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,10 @@ describe("ContactUsPage", () => {
cy.contains("Contact Us").should("exist");
});

it("should display the welcome message", () => {
cy.contains("We would love to hear from you!").should("be.visible");
});

it("should display the description text", () => {
cy.contains(
"Whether you have questions, feedback, or just want to say hello, feel free to reach out to us using the form below."
).should("be.visible");
});

it("should have a submit button", () => {
cy.contains("Send Message").should("be.visible");
});

it("should show fade-in and zoom effects on the page elements", () => {
// Check if the title appears after fade-in
cy.get("h1").should("be.visible");

// Check if the form container appears after zoom-in
cy.get("div.MuiPaper-root").should("be.visible");
});

it("should show the follow us on social media section", () => {
cy.contains("Follow us on social media").should("be.visible");
cy.contains(
"Stay connected and follow us on our social media channels for the latest updates and news."
).should("be.visible");
});

it("should display correct layout for different screen sizes", () => {
cy.viewport(1024, 768); // Desktop view
cy.get("form").should("be.visible");
Expand Down
31 changes: 0 additions & 31 deletions cypress/e2e/pages/homePage.cy.jsx

This file was deleted.

56 changes: 0 additions & 56 deletions cypress/e2e/pages/loginPage.cy.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,60 +9,4 @@ describe("Login Page", () => {
cy.get('input[name="password"]').should("exist"); // Check for password input
cy.get('button[type="submit"]').should("contain", "Log In"); // Check for login button
});

it("should show validation errors for empty form submission", () => {
cy.get('button[type="submit"]').click(); // Try submitting without filling out the form

cy.get('input[name="email"]')
.should("have.class", "Mui-error") // Check for error on email input
.and("have.attr", "aria-invalid", "true"); // Ensure the email field is invalid
cy.get('input[name="password"]')
.should("have.class", "Mui-error") // Check for error on password input
.and("have.attr", "aria-invalid", "true"); // Ensure the password field is invalid

cy.get(".MuiFormHelperText-root").should("exist"); // Check for validation error messages
});

it("should show an error message for invalid email format", () => {
cy.get('input[name="email"]').type("invalid-email"); // Enter invalid email
cy.get('button[type="submit"]').click(); // Submit the form
cy.get('input[name="email"]').should("have.class", "Mui-error"); // Check for error
cy.get(".MuiFormHelperText-root").should("contain", "Email is not valid"); // Ensure the specific error message appears
});

it("should successfully log in and navigate to homepage", () => {
const validEmail = "[email protected]"; // Update with an easily verifiable test email
const validPassword = "password123"; // Update with a valid test password

cy.intercept("POST", "/api/login", { statusCode: 200 }).as("loginRequest"); // Mock successful login response

cy.get('input[name="email"]').type(validEmail); // Enter valid email
cy.get('input[name="password"]').type(validPassword); // Enter valid password
cy.get('button[type="submit"]').click(); // Submit the form

cy.wait("@loginRequest"); // Wait for the login request to complete

// Verify successful navigation
cy.url().should("eq", Cypress.config().baseUrl + "/"); // Check homepage URL
cy.contains("Welcome"); // Replace with actual homepage text
});

it("should show error message when login fails", () => {
const invalidEmail = "[email protected]";
const invalidPassword = "wrongpassword";

cy.intercept("POST", "/auth/login", {
statusCode: 401,
body: { message: "Invalid email or password" },
}).as("loginFail");

cy.get('input[name="email"]').type(invalidEmail); // Enter invalid email
cy.get('input[name="password"]').type(invalidPassword); // Enter invalid password
cy.get('button[type="submit"]').click(); // Submit the form

cy.wait("@loginFail"); // Wait for the failed login request

// Verify error message is displayed
cy.get(".MuiSnackbar-root").should("contain", "Invalid email or password"); // Check for error notification
});
});
Loading

0 comments on commit 9ddb4c8

Please sign in to comment.