Skip to content

Commit

Permalink
End to End Testing: Separate test files
Browse files Browse the repository at this point in the history
  • Loading branch information
ongsweelong committed Nov 2, 2024
1 parent 7ea4e98 commit 3ea302b
Show file tree
Hide file tree
Showing 26 changed files with 1,806 additions and 2,012 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/combined-CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
DB_NAME: ${{ secrets.DB_NAME }}
run: |
mysql -h $DB_IP -u $DB_USER -p$DB_PASS $DB_NAME < tcAll.sql
# Step 6: Start the Next.js server in the background
- name: Start Next.js server
run: npm run dev &
Expand Down
66 changes: 66 additions & 0 deletions cypress/e2e/Actual-Tests/test_case_10_1.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// Test Case 10.1: View Application History
describe('Staff Able to View Application History', () => {
// 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/'); // Adjust the URL if needed

// 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: Log in as Samsul Saifullah using cy.origin for third-party login
cy.origin('https://wfhtrackingsystem.kinde.com', () => {
cy.get('input[name="p_username"]').type('151495');
cy.get('button[type="submit"]').click();

cy.get('input[name="p_password"]', { timeout: 10000 }).should('be.visible');

cy.get('input[name="p_password"]').type('password');
cy.get('button[type="submit"]').click({ multiple: true });
});
});

it('should view "My Schedule" page and "Create new arrangement" page', () => {
// Step 3: Navigate to the "My arrangement requests" page
cy.get('nav').should('contain', 'All-In-One');
cy.get('nav').contains('Arrangement').click();
cy.get('nav').contains('My requests').click();

// Step 4: Navigate to the my arrangement request page
cy.get('button').contains('Processed').click();

const formatDate = (date) => {
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0'); // Months are 0-indexed
const day = String(date.getDate()).padStart(2, '0');
return `${year}-${month}-${day}`;
};

// Get today's date
const today = new Date();
const threeDaysLater = new Date(today);
const fourDaysLater = new Date(today);
const sixDaysLater = new Date(today);

// Adjust the future dates
threeDaysLater.setDate(today.getDate() + 3);
fourDaysLater.setDate(today.getDate() + 4);
sixDaysLater.setDate(today.getDate() + 6);


cy.contains(formatDate(threeDaysLater).toString()).should('exist');
cy.contains(formatDate(fourDaysLater).toString()).should('exist');
cy.contains(formatDate(sixDaysLater).toString()).should('exist');
['AM', 'Approved', 'Rejected', 'Withdrawn'].forEach((status) => {
cy.contains(status).should('exist');
});

});

});
71 changes: 71 additions & 0 deletions cypress/e2e/Actual-Tests/test_case_10_2.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
//Test Case 10.2: Filter by Start Date
describe('Staff Able to filter Application History', () => {
// 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/'); // Adjust the URL if needed

// 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: Log in as Samsul Saifullah using cy.origin for third-party login
cy.origin('https://wfhtrackingsystem.kinde.com', () => {
cy.get('input[name="p_username"]').type('151495');
cy.get('button[type="submit"]').click();

cy.get('input[name="p_password"]', { timeout: 10000 }).should('be.visible');

cy.get('input[name="p_password"]').type('password');
cy.get('button[type="submit"]').click({ multiple: true });
});
});

it('should view "My arrangement requests" page', () => {
// Step 3: Navigate to the "My arrangement requests" page
cy.get('nav').should('contain', 'All-In-One');
cy.get('nav').contains('Arrangement').click();
cy.get('nav').contains('My requests').click();

// Step 4: Navigate to the My arrangement requests page
cy.get('button').contains('Processed').click();
cy.wait(2000);

const formatDate = (date) => {
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0'); // Months are 0-indexed
const day = String(date.getDate()).padStart(2, '0');
return `${year}-${month}-${day}`;
};

// Get today's date and 3 days later from current date
const today = new Date();
const threeDaysLater = new Date(today);

// Adjust the future dates
threeDaysLater.setDate(today.getDate() + 3);

// filter by date
cy.get('input[placeholder="Start date (YYYY-MM-DD)"]')
.click() // Click to focus on the input
.type(formatDate(threeDaysLater).toString());

cy.get('svg#search-icn') // Click on Search Icon
.click();
cy.wait(2000);


// Check that the processed arrangement requests exists
cy.contains(formatDate(threeDaysLater).toString()).should('exist');
['AM', 'Approved'].forEach((status) => {
cy.contains(status).should('exist');
});

});

});
45 changes: 45 additions & 0 deletions cypress/e2e/Actual-Tests/test_case_10_3.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// /Test Case 10.3: Edge Case - No WFH Application History Exists
describe('Staff do not have WFH Arrangement History', () => {
// 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/'); // Adjust the URL if needed

// 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: Log in as Nara Young using cy.origin for third-party login
cy.origin('https://wfhtrackingsystem.kinde.com', () => {
cy.get('input[name="p_username"]').type('151513');
cy.get('button[type="submit"]').click();

cy.get('input[name="p_password"]', { timeout: 10000 }).should('be.visible');

cy.get('input[name="p_password"]').type('password');
cy.get('button[type="submit"]').click({ multiple: true });
});
});

it('should show "No arrangement requests found."', () => {
// Step 3: Navigate to the "My arrangement requests" page
cy.get('nav').should('contain', 'All-In-One');
cy.get('nav').contains('Arrangement').click();
cy.get('nav').contains('My requests').click();

cy.contains('No arrangement requests found.').should('exist');

// Step 4: Navigate to the Processed tab
cy.get('button').contains('Processed').click();

cy.contains('No arrangement requests found.').should('exist');


});

});
60 changes: 60 additions & 0 deletions cypress/e2e/Actual-Tests/test_case_13_1.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
//Test Case 13.1: Withdraw Entire Approved Recurring WFH Arrangement
describe('Withdraw Entire Approved Recurring WFH Arrangement ', () => {
// 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/'); // Adjust the URL if needed

// 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: Log in as Manni Devi using cy.origin for third-party login
cy.origin('https://wfhtrackingsystem.kinde.com', () => {
cy.get('input[name="p_username"]').type('210018');
cy.get('button[type="submit"]').click();

cy.get('input[name="p_password"]', { timeout: 10000 }).should('be.visible');

cy.get('input[name="p_password"]').type('password');
cy.get('button[type="submit"]').click({ multiple: true });
});
});

it('should be able to withdraw approved arrangements', () => {
// Step 3: Navigate to the "My arrangement requests" page
cy.get('nav').should('contain', 'All-In-One');
cy.get('nav').contains('Arrangement').click();
cy.get('nav').contains('My requests').click();

cy.get('button').contains('Processed').click();
cy.wait(2000);

cy.get('button[id="arrangement-sheet-trigger"]').eq(2).click({ force: true });

// Interact with the <select> element
cy.get('button[role="combobox"]').first().click(); // Click the first matching button


// Wait for the dropdown content to be visible (optional, for stability)
cy.get('[role="listbox"]').should('be.visible');

// Click on the "AM" option
cy.get('[role="option"]').contains('Withdraw entire arrangement').click();

cy.get('textarea') // Use the appropriate selector for your textarea
.click() // Click on the textarea to focus it
.type('Testing WFH E2E Test Case 13.1'); // Type the desired text

// Submit
cy.get('button[type="submit"]').click();

cy.contains('Arrangement(s) updated successfully').should('exist');

});
});
61 changes: 61 additions & 0 deletions cypress/e2e/Actual-Tests/test_case_13_2.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
//Test Case 13.2: Withdraw a Specific Day from an Approved Recurring WFH Arrangement
describe('Withdraw Sepcific Approved Recurring WFH Arrangement ', () => {
// 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/'); // Adjust the URL if needed

// 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: Log in as Manni Devi using cy.origin for third-party login
cy.origin('https://wfhtrackingsystem.kinde.com', () => {
cy.get('input[name="p_username"]').type('210018');
cy.get('button[type="submit"]').click();

cy.get('input[name="p_password"]', { timeout: 10000 }).should('be.visible');

cy.get('input[name="p_password"]').type('password');
cy.get('button[type="submit"]').click({ multiple: true });
});
});

it('should be able to withdraw one approved recurring arrangements', () => {
// Step 3: Navigate to the "My arrangement requests" page
cy.get('nav').should('contain', 'All-In-One');
cy.get('nav').contains('Arrangement').click();
cy.get('nav').contains('My requests').click();

cy.get('button').contains('Processed').click();
cy.wait(2000);

// Step 4: Navigate to the my arrangement request page
cy.get('button[id="arrangement-sheet-trigger"]').eq(3).click({ force: true });

// Interact with the <select> element
cy.get('button[role="combobox"]').first().click(); // Click the first matching button


// Wait for the dropdown content to be visible (optional, for stability)
cy.get('[role="listbox"]').should('be.visible');

// Click on the "AM" option
cy.get('[role="option"]').contains('Withdraw this specific arrangement').click();

cy.get('textarea') // Use the appropriate selector for your textarea
.click() // Click on the textarea to focus it
.type('Testing WFH E2E Test Case 13.2'); // Type the desired text

// Submit
cy.get('button[type="submit"]').click();

cy.contains('Arrangement(s) updated successfully').should('exist');

});
});
61 changes: 61 additions & 0 deletions cypress/e2e/Actual-Tests/test_case_13_3.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Test Case 13.3: Withdraw an Approved Ad-Hoc WFH Arrangement & Test Case 13.4: Edge Case - Withdrawal Less Than 24 Hours Before WFH Day
describe('Withdraw an Approved Ad-Hoc WFH Arrangement ', () => {
// 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/'); // Adjust the URL if needed

// 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: Log in as Manni Devi using cy.origin for third-party login
cy.origin('https://wfhtrackingsystem.kinde.com', () => {
cy.get('input[name="p_username"]').type('210018');
cy.get('button[type="submit"]').click();

cy.get('input[name="p_password"]', { timeout: 10000 }).should('be.visible');

cy.get('input[name="p_password"]').type('password');
cy.get('button[type="submit"]').click({ multiple: true });
});
});

it('should be able to withdraw approved ad-hoc arrangements', () => {
// Step 3: Navigate to the "My arrangement requests" page
cy.get('nav').should('contain', 'All-In-One');
cy.get('nav').contains('Arrangement').click();
cy.get('nav').contains('My requests').click();

cy.get('button').contains('Processed').click();
cy.wait(2000);

// Step 4: Navigate to the my arrangement request page
cy.get('button[id="arrangement-sheet-trigger"]').eq(1).click({ force: true });

// Interact with the <select> element
cy.get('button[role="combobox"]').first().click(); // Click the first matching button


// Wait for the dropdown content to be visible (optional, for stability)
cy.get('[role="listbox"]').should('be.visible');

// Click on the "AM" option
cy.get('[role="option"]').contains('Withdraw').click();

cy.get('textarea') // Use the appropriate selector for your textarea
.click() // Click on the textarea to focus it
.type('Testing WFH E2E Test Case 13.3'); // Type the desired text

// Submit
cy.get('button[type="submit"]').click();

cy.contains('Arrangement(s) updated successfully').should('exist');

});
});
Loading

0 comments on commit 3ea302b

Please # to comment.