Skip to content

Commit

Permalink
Address dates should also be dynamic
Browse files Browse the repository at this point in the history
  • Loading branch information
MuhammadUmer44 committed Mar 28, 2024
1 parent 4bd4bed commit c54f073
Showing 1 changed file with 30 additions and 9 deletions.
39 changes: 30 additions & 9 deletions cypress/e2e/50_adminCustomDateSelect.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ describe('Admin Statistics Custom Date Range', () => {
let activeUser = 'alice';

const bounty: Cypress.Bounty = {
title: 'UmerTask',
title: 'UmerJobs',
category: 'Web development',
coding_language: ['Typescript', 'Javascript', 'Lightning'],
description: 'This is available',
Expand All @@ -16,7 +16,7 @@ describe('Admin Statistics Custom Date Range', () => {

it('Creates 25 bounties, navigates to Admin page, and verifies bounties count and visibility', () => {
for (let i = 1; i <= 25; i++) {
const updatedBounty = { ...bounty, title: `UmerTask${i}` };
const updatedBounty = { ...bounty, title: `UmerJobs${i}` };
cy.create_bounty(updatedBounty);
cy.wait(1000);
}
Expand All @@ -25,7 +25,7 @@ describe('Admin Statistics Custom Date Range', () => {
cy.wait(3000);

for (let i = 25; i >= 6; i--) {
cy.contains(`UmerTask${i}`, { timeout: 10000 }).should('exist');
cy.contains(`UmerJobs${i}`, { timeout: 10000 }).should('exist');
}

cy.contains('25').should('exist');
Expand All @@ -35,20 +35,41 @@ describe('Admin Statistics Custom Date Range', () => {
cy.contains('li', 'Custom').click();
cy.wait(1000);

cy.get('input[name="start"]').type('03/01/24');
cy.wait(600);
const startDate = new Date();
startDate.setDate(1);
const endDate = new Date();

cy.get('input[name="end"]').type('03/28/24');
cy.wait(600);
const formatStartDate = startDate.toLocaleDateString('en-US', {
month: '2-digit',
day: '2-digit',
year: 'numeric'
});
const formatEndDate = endDate.toLocaleDateString('en-US', {
month: '2-digit',
day: '2-digit',
year: 'numeric'
});

cy.get('input[name="start"]').clear().type(formatStartDate);
cy.get('input[name="end"]').clear().type(formatEndDate);
cy.contains('Save').click();
cy.wait(1000);

cy.contains('25').should('exist');
cy.wait(1000);

cy.get('[data-testid="month"]').contains('01 Mar - 28 Mar 2024');
cy.wait(600);
const expectedStartDateFormat = `${String(startDate.getDate()).padStart(
2,
'0'
)} ${startDate.toLocaleString('default', { month: 'short' })}`;
const expectedEndDateFormat = `${String(endDate.getDate()).padStart(
2,
'0'
)} ${endDate.toLocaleString('default', { month: 'short' })} ${endDate.getFullYear()}`;

const expectedDateRange = `${expectedStartDateFormat} - ${expectedEndDateFormat}`;

cy.get('[data-testid="month"]').should('have.text', expectedDateRange);

cy.logout(activeUser);
});
Expand Down

0 comments on commit c54f073

Please sign in to comment.