Skip to content

Commit

Permalink
End to End Testing: Test Cases 8.1, 8.2
Browse files Browse the repository at this point in the history
  • Loading branch information
je-rnic committed Nov 1, 2024
1 parent ad0c5a4 commit edf5132
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 0 deletions.
52 changes: 52 additions & 0 deletions cypress/e2e/Actual-Tests/test_case_8_1.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Test Case 8.1:
describe("HR and Senior Management Login to WFH Tracking System", () => {
// Use before to run setup code before the tests
before(() => {
// Step 1: Visit the homepage and log in once
cy.visit("https://wfh-tracking-system.vercel.app/");

// Ensure the page has loaded
cy.get("body").should("be.visible");

// Verify the 'Nav Bar' is visible
cy.get("nav").should("contain", "All-In-One");

// Navigate to the login page
cy.get("a").click();

// Step 2: Login as James Tan using cy.origin for third-party login
cy.origin("https://wfhtrackingsystem.kinde.com", () => {
// Input Staff ID
cy.get('input[name="p_username"]').type("160075");
cy.get('button[type="submit"]').click();

// Wait for the password input to be visible
cy.get('input[name="p_password"]', { timeout: 10000 }).should(
"be.visible",
);
cy.get('input[name="p_password"]').type("password");
cy.contains('button[type="submit"]', "Continue").click({
multiple: true,
});
});
});

it("should view requests and schedules", () => {
// Ensure the page has loaded
cy.get("body").should("be.visible");
cy.reload();

// Step 3: Navigate to Overall schedules page
cy.get("nav").contains("Schedule").click();
cy.get("nav").contains("Overall and team").click();
});

// Clear sessions after each test
afterEach(() => {
cy.clearCookies();
cy.clearLocalStorage();
cy.window().then((win) => {
win.sessionStorage.clear();
});
});
});
48 changes: 48 additions & 0 deletions cypress/e2e/Actual-Tests/test_case_8_2.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Test Case 8.2: Edge Case - Invalid HR/Senior Management Credentials
describe("Invalid Login Credentials", () => {
// Use before to run setup code before the tests
beforeEach(() => {
// Step 1: Visit the homepage and log in once
cy.visit("https://wfh-tracking-system.vercel.app/");

// Ensure the page has loaded
cy.get("body").should("be.visible");

// Verify the 'Nav Bar' is visible
cy.get("nav").should("contain", "All-In-One");

// Navigate to the login page
cy.get("a").click();
});

it("should show 'No account found with this username'", () => {
// Step 2: Invalid Staff ID using cy.origin for third-party login
cy.origin("https://wfhtrackingsystem.kinde.com", () => {
cy.get('input[name="p_username"]').type("000000");
cy.get('button[type="submit"]').click();
cy.contains("No account found with this username");
cy.wait(2000);
});
});

it("should show 'Please provide a valid password'", () => {
// Step 3: Valid Staff ID and invalid password using cy.origin for third-party login
cy.origin("https://wfhtrackingsystem.kinde.com", () => {
cy.get('input[name="p_username"]').type("160075");
cy.get('button[type="submit"]').click();

// Wait for the password input to be visible
cy.get('input[name="p_password"]', { timeout: 10000 }).should(
"be.visible",
);

cy.get('input[name="p_password"]').type("wrongpassword");
cy.contains('button[type="submit"]', "Continue").click({
multiple: true,
});
cy.wait(2000);
cy.contains("Please provide a valid password");
});
});

});

0 comments on commit edf5132

Please # to comment.