Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: [DI-22618] - E2E Cypress Automation of Custom Date Time Range Picker #11626

Merged
merged 34 commits into from
Feb 19, 2025

Conversation

agorthi-akamai
Copy link
Contributor

@agorthi-akamai agorthi-akamai commented Feb 6, 2025

Description 📝

This integration test suite validates the Dashboard in CloudPulse, focusing on custom date-time selection and preset time ranges. It ensures that the time picker correctly applies selected values, API requests contain the expected start and end times in GMT+5:30 (IST), and metrics update accordingly. The tests cover custom date selection, various preset time ranges (Last 30 Days, Last Month, etc.), and API request validation to ensure accurate data retrieval.

Preview:
Screenshot 2025-02-06 at 3 31 20 PM

  • ...
  • ...

Target release date 🗓️ 10/02/2025

How to test 🧪

yarn cy:run -s "cypress/e2e/core/cloudpulse/timerange-verification.spec.ts" --browser chrome

As an Author, to speed up the review process, I considered 🤔

👀 Doing a self review
❔ Our contribution guidelines
🤏 Splitting feature into small PRs
➕ Adding a changeset
🧪 Providing/improving test coverage
🔐 Removing all sensitive information from the code and PR description
🚩 Using a feature flag to protect the release
👣 Providing comprehensive reproduction steps
📑 Providing or updating our documentation
🕛 Scheduling a pair reviewing session
📱 Providing mobile support
♿ Providing accessibility support


  • I have read and considered all applicable items listed above.

As an Author, before moving this PR from Draft to Open, I confirmed ✅

  • All unit tests are passing
  • TypeScript compilation succeeded without errors
  • Code passes all linting rules

@agorthi-akamai agorthi-akamai marked this pull request as ready for review February 6, 2025 10:07
@agorthi-akamai agorthi-akamai requested review from a team as code owners February 6, 2025 10:07
@agorthi-akamai agorthi-akamai requested review from dmcintyr-akamai, bnussman-akamai and bill-akamai and removed request for a team February 6, 2025 10:07
@agorthi-akamai agorthi-akamai marked this pull request as draft February 6, 2025 15:36
@agorthi-akamai
Copy link
Contributor Author

I am moving this PR to Draft because the test cases are passing locally but failing on Jenkins. I need to investigate the discrepancies further.

@bnussman-akamai bnussman-akamai changed the title test[DI-22618]:E2E Cypress Automation of Custom Date Time Range Picker test: [DI-22618] - E2E Cypress Automation of Custom Date Time Range Picker Feb 6, 2025
@jdamore-linode jdamore-linode self-requested a review February 10, 2025 14:02
Copy link
Contributor

@jdamore-linode jdamore-linode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@agorthi-akamai see my comments on date-utils, that might help put you in the right direction

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple things with this file:

  • This doesn't belong in support/constants -- it'd be better off renamed support/util/datetime.ts or something like that. However...
  • Utils are meant to be reusable, but these look very specific to this group of tests. Would these functions be better off defined in timerange-verification.spec.ts or is there an opportunity to make them more usable?
  • Tying these utils to a specific timezone is a big part of the reason why these utils can't be reused, and is also probably a cause of the test failures in CI

@agorthi-akamai agorthi-akamai marked this pull request as ready for review February 14, 2025 04:05
@agorthi-akamai
Copy link
Contributor Author

I'm transitioning the draft to an open state since the test cases are now working fine. I can successfully interact with the date picker and perform the necessary actions

Copy link
Contributor

@venkymano-akamai venkymano-akamai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving

Also there is a typecheck that is failing

Copy link

github-actions bot commented Feb 17, 2025

Coverage Report:
Base Coverage: 80.07%
Current Coverage: 80.07%

@kmuddapo
Copy link

@jdamore-linode Could you please review and approve it if all the feedbacks are addressed.

Copy link
Contributor

@jdamore-linode jdamore-linode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @agorthi-akamai. Posted a few nits/clean up suggestions that I'd like to see addressed where applicable but otherwise looks good

Comment on lines 211 to 247
/**
* Generates a date in Indian Standard Time (IST) based on a specified number of days offset,
* hour, and minute. The function also provides individual date components such as day, hour,
* minute, month, and AM/PM.
*
* @param {number} daysOffset - The number of days to adjust from the current date. Positive
* values give a future date, negative values give a past date.
* @param {number} hour - The hour to set for the resulting date (0-23).
* @param {number} [minute=0] - The minute to set for the resulting date (0-59). Defaults to 0.
*
* @returns {Object} - Returns an object containing:
* - `actualDate`: The formatted date and time in IST (YYYY-MM-DD HH:mm).
* - `day`: The day of the month as a number.
* - `hour`: The hour in the 24-hour format as a number.
* - `minute`: The minute of the hour as a number.
* - `month`: The month of the year as a number.
*/
const getDateRangeInGMT = (
daysOffset: number,
hour: number,
minute: number = 0
) => {
const now = DateTime.now().setZone('GMT'); // Set the timezone to GMT
const targetDate = now
.startOf('month')
.plus({ days: daysOffset })
.set({ hour, minute });

const actualDate = targetDate.toFormat('yyyy-LL-dd HH:mm'); // Format in GMT
return {
actualDate,
day: targetDate.day,
hour: targetDate.hour,
minute: targetDate.minute,
month: targetDate.month,
};
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mind moving this to the top with the other functions?

cy.get('[aria-label="Select hours"]')
.scrollIntoView({ easing: 'linear' })
.within(() => {
cy.get(`[aria-label="${startHour} hours"]`).click({ force: true });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we performing all these clicks with forced: true? I'm not seeing anything special about the UI at a glance that would require it, were you running into some roadblock without it?

Comment on lines 282 to 285
// Clicks the button closest to the Clock Icon, bypassing any visible state with `force: true`.
cy.get('[data-testid="ClockIcon"]')
.closest('button')
.click({ force: true });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Clicks the button closest to the Clock Icon, bypassing any visible state with `force: true`.
cy.get('[data-testid="ClockIcon"]')
.closest('button')
.click({ force: true });
cy.findByLabelText('Choose time, selected time is', { exact: false })
.should('be.visible')
.click();

It'd be better to find the button using its label if we can avoid cy.get -- you could alternatively pass a regex to avoid needing { exact: false } if you want.


// Selects the start hour, minute, and meridiem (AM/PM) in the time picker.

cy.get('[aria-label="Select hours"]')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
cy.get('[aria-label="Select hours"]')
cy.findByLabelText('Select hours')

Everywhere where we're calling cy.get('[aria-label="..."]') can be replaced with cy.findByLabelText('...')

});

// Click the "Apply" button to confirm the start date and time
cy.findByRole('button', { name: 'Apply' }).should('be.visible').click();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason not to use ui.button.findByTitle() when interacting with this button?

Comment on lines 311 to 316
cy.findByPlaceholderText('Select Start Date')
.scrollIntoView({ easing: 'linear' })
.should('be.visible')
.invoke('val') // Get the current value
.then(cleanText) // Clean the value
.should('equal', `${startActualDate} PM`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, just an easier way to do this

Suggested change
cy.findByPlaceholderText('Select Start Date')
.scrollIntoView({ easing: 'linear' })
.should('be.visible')
.invoke('val') // Get the current value
.then(cleanText) // Clean the value
.should('equal', `${startActualDate} PM`);
cy.findByPlaceholderText('Select Start Date')
.scrollIntoView({ easing: 'linear' })
.should('be.visible')
.should('have.value', `${cleanText(startActualDate)} PM`)

I think there are a few places this could be applied

});

// Click on the "Presets" button
cy.findByRole('button', { name: 'Presets' }).should('be.visible').click();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the question about the Apply button before. If there isn't a specific reason we're selecting the button this way, we should prefer ui.button.findByTitle('Presets') instead

test: [DI-22618] - E2E Cypress Automation of Custom Date Time Range Picker
@agorthi-akamai
Copy link
Contributor Author

I have addressed the review comments and made the necessary changes

@linode-gh-bot
Copy link
Collaborator

Cloud Manager UI test results

🎉 520 passing tests on test run #31 ↗︎

❌ Failing✅ Passing↪️ Skipped🕐 Duration
0 Failing520 Passing3 Skipped104m 9s

@venkymano-akamai
Copy link
Contributor

Merging this since joe's comments are also addressed, jobs pass, UT's pass and cypress pass.

@venkymano-akamai venkymano-akamai merged commit ef3e811 into linode:develop Feb 19, 2025
23 checks passed
Copy link

cypress bot commented Feb 19, 2025

Cloud Manager E2E    Run #7245

Run Properties:  status check passed Passed #7245  •  git commit ef3e811249: test: [DI-22618] - E2E Cypress Automation of Custom Date Time Range Picker (#116...
Project Cloud Manager E2E
Branch Review develop
Run status status check passed Passed #7245
Run duration 30m 24s
Commit git commit ef3e811249: test: [DI-22618] - E2E Cypress Automation of Custom Date Time Range Picker (#116...
Committer agorthi-akamai
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 5
Tests that did not run due to a developer annotating a test with .skip  Pending 3
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 521
View all changes introduced in this branch ↗︎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants