diff --git a/cypress/e2e/Actual-Tests/test_case_8_1.cy.js b/cypress/e2e/Actual-Tests/test_case_8_1.cy.js new file mode 100644 index 0000000..8676239 --- /dev/null +++ b/cypress/e2e/Actual-Tests/test_case_8_1.cy.js @@ -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(); + }); + }); +}); diff --git a/cypress/e2e/Actual-Tests/test_case_8_2.cy.js b/cypress/e2e/Actual-Tests/test_case_8_2.cy.js new file mode 100644 index 0000000..21935c9 --- /dev/null +++ b/cypress/e2e/Actual-Tests/test_case_8_2.cy.js @@ -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"); + }); + }); + +});