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: [M3-8226] - Cypress integration tests for account "Maintenance" tab #10694

Merged
merged 11 commits into from
Jul 30, 2024

Conversation

AzureLatte
Copy link
Contributor

@AzureLatte AzureLatte commented Jul 18, 2024

Description 📝

Add Cypress integration tests using mock API data to ensure the Cloud Manager "Maintenance" tab on the Account page (/account/maintenance) works as expected.

Changes 🔄

  • Add new test in e2e packages/manager/cypress/e2e/core/account/account-maintenance.spec.ts
  • Add new intercepts functions in account.ts

How to test 🧪

yarn cy:run -s "cypress/e2e/core/account/account-maintenance.spec.ts"

As an Author I have considered 🤔

Check all that apply

  • 👀 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

@AzureLatte AzureLatte self-assigned this Jul 18, 2024
@AzureLatte AzureLatte requested a review from a team as a code owner July 18, 2024 18:25
@AzureLatte AzureLatte requested review from jdamore-linode and removed request for a team July 18, 2024 18:25
@AzureLatte AzureLatte requested a review from a team as a code owner July 18, 2024 18:26
@AzureLatte AzureLatte requested review from bnussman-akamai and hana-akamai and removed request for a team July 18, 2024 18:26
Copy link

github-actions bot commented Jul 18, 2024

Coverage Report:
Base Coverage: 82.46%
Current Coverage: 82.46%

@AzureLatte
Copy link
Contributor Author

observing a timeout issue during integration test. So remove "ready for review" and checking now

@AzureLatte
Copy link
Contributor Author

Ready for review

});
});

// Confirm download buttons work
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ideally we would like to check the contents of the CSV files but looks like the file is empty after downloading. I think it is because we are mocking responses but not actually have those maintenance messages.

Just a quick note that we might unable to confirm the contents of the CSV match an expected string or similar that was mentioned in the ticket.

Copy link
Contributor

@jdamore-linode jdamore-linode Jul 25, 2024

Choose a reason for hiding this comment

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

@AzureLatte I'm puzzled by this one! I’m observing the empty CSVs being downloaded when the test runs, but if I click either of the "Download CSV" buttons myself inside the Cypress debugger, the file that gets downloaded has the expected mock data:

"Entity Label","Entity Type","Entity ID","Date","Type","Status","Reason"
"linode-1","linode","1","2023-04-17T03:16:20.148Z","live_migration","pending","We must replace faulty RAM in your Linode's host."
"linode-2","linode","2","2023-10-24T20:57:33.195Z","cold_migration","started","There is an issue with the power supply of your Linode's host."

Very strange!

Tomorrow I'll take a closer look at how Cloud handles this to see if it gives us any hints what's happening here. In the meantime, this is all looking really great! If we can't figure out what's going on with the CSV files, we can talk about spinning it off into a separate task so that all of this other work doesn't get held up!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

but if I click either of the "Download CSV" buttons myself inside the Cypress debugger, the file that gets downloaded has the expected mock data:

Did you config something special before? I am asking because on my side, the downloaded file is also empty even if I clicked the button manually.

Copy link
Contributor

Choose a reason for hiding this comment

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

Even weirder! Nothing specific that I can think of, but I may have been using it.only(...) on the test while I was looking at it -- not that that should make any difference, though 🤔

Copy link
Contributor Author

@AzureLatte AzureLatte Jul 26, 2024

Choose a reason for hiding this comment

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

I tried several times again manually and noticed that every time when I click the button the first time, it downloads an empty CSV file while all the following clicks result in correct file with expected mock data.

Copy link
Contributor

Choose a reason for hiding this comment

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

@AzureLatte You're right, seeing the same behavior on my end! Taking a look right now!

Copy link
Contributor

Choose a reason for hiding this comment

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

@AzureLatte I'm about 90% sure that this is actually a Cloud Manager bug and not a test/mock issue.

Got a bit distracted by another issue and about to step away for lunch, but I'll follow up here with more info soon! If there's an easy fix it might be nice to just take care of it in this PR, but there's a good chance we'll spin this off into a bug ticket!

Copy link
Contributor

Choose a reason for hiding this comment

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

@AzureLatte Ok, definitely a bug, and pretty easy to reproduce outside of Cypress:

  1. Build and serve Cloud via yarn dev
  2. Using the dev tools in the bottom left, enable Mock Service Worker
  3. Navigate to the Maintenance page at /account/maintenance
  4. Click "Download CSV" for either table, observe empty CSV data (besides column headers)
  5. Click "Download CSV" again, observe CSV is populated with data

Not the strongest with React, but my understanding of what's going on in MaintenanceTable.tsx is that the CSV data is not automatically fetched when the MaintenanceTable component mounts (that's what the false value on line 94 does). That makes sense because this could potentially fetch a lot of data, and doing it automatically wouldn't make sense since it's only used when customers click the "Download CSV" button.

Instead, it fetches the data when the user clicks the download button, but because the CSV data gets passed to the DownloadCSV component as a prop, it doesn't actually take effect, so to speak, until after the next re-render which presumably happens after the CSV file is downloaded.

I don't know what the proper fix for this would be, so I wrote a pair of tickets:

  • M3-8392 for the bug itself
  • M3-8393 to test CSV download functionality (it may be helpful to have a test before M3-8392 is worked on so that whoever does the development for that has a test case they can use to confirm their work, but not crucial since this is pretty reproducible)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you, I will add a TODO comment in this PR.

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.

Nice work @AzureLatte! Approved pending some kind of handling of the Download CSV stuff:

  • Remove or comment out what's here and re-add it for M3-8393
  • Leave it the way it is and just add the content assertions for M3-8393 (probably the approach that makes the most sense)

Thanks again for all this work! The tests are great and they helped catch a bug! 🐛

@jdamore-linode jdamore-linode added the Add'tl Approval Needed Waiting on another approval! label Jul 26, 2024
@bnussman-akamai bnussman-akamai added Approved Multiple approvals and ready to merge! and removed Add'tl Approval Needed Waiting on another approval! labels Jul 26, 2024
@AzureLatte AzureLatte merged commit 1d5dde8 into linode:develop Jul 30, 2024
18 of 19 checks passed
@AzureLatte AzureLatte deleted the M3-8226 branch July 30, 2024 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Approved Multiple approvals and ready to merge!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants