-
Notifications
You must be signed in to change notification settings - Fork 359
Added automated tests with cypress for Schedule form under Applicatio… #9504
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
base: master
Are you sure you want to change the base?
Added automated tests with cypress for Schedule form under Applicatio… #9504
Conversation
@asirvadAbrahamVarghese Can you split the tests up into multiple tests. Try not to combine everything into 1 test. The different test cases can be:
|
Can you change the file name to schedule.cy.js |
cc @jrafanie |
/* ===== Adding a schedule ===== */ | ||
addSchedule(); | ||
cy.get('#main_div #flash_msg_div .alert-success').contains( | ||
'Schedule "Test name" was saved' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note, we'll need to be careful of side effect test which modify the tables that are presented in the UI as a failure could fail to clean up after itself. This could cause other tests to fail, for example, if they are listing schedules and asserting the contents.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
‘Test name’ and ‘Dummy name’ are the two possible schedules created during these tests. To handle cleanup, defined an afterEach block that checks for these names and deletes them if they exist, especially in cases where assertions might fail - 82d569885aa283acb65a0e51db59ae14aebe088f
During GHA, since these tests will run against a blank database, we shouldn’t expect any pre-existing records with those names. However, if that’s not guaranteed, we might have to consider to generate unique schedule names for each test using a combination of a base name and a timestamp or date string, with the help of Date utility functions.
It looks like some of the tests are sporadic in nature and are fairly slow. Sporadic failures are often timing issues waiting for ajax or pages to be rendered as the computer drives the browser much faster than a user would. I don't know what's "too slow" but it would be good to note any steps in the tests that are slow and either comment on it so we can try to fix it later or see if we can make them faster. How slow is it locally @asirvadAbrahamVarghese ? |
FYI, I started on some work to try to get each cypress test file to login only once and share that session with each test in the file. Unfortunately, there is other state in the session that leaks between tests in this way, but it might be something we can do if we can figure out how to share just the login and not have to do that in each test. See: #9499 |
Yeah right @jrafanie, this can fail intermittently due to timing issues, I am looking further into that. With session management implemented (as in PR #9499 ), the execution time should improve. I just ran the tests using session management. |
Checked commits asirvadAbrahamVarghese/manageiq-ui-classic@cc52e2c~...82d5698 with ruby 3.1.5, rubocop 1.56.3, haml-lint 0.62.0, and yamllint |
By the way, we haven't really documented it but there are two improvements to set in your environment but they must be understood as they can cause issues
|
}); | ||
|
||
afterEach(() => { | ||
cy.get('li.list-group-item').each(($el) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One concern to keep in mind is tests here can fail in any part of the test. You may need to ensure you're on the right page by visiting it first, before looking for the list group item.
Ultimately, I hope we can minimize the tests that make changes to what's presented on the various screens by saving or creating objects. The hope is we can "tag" these tests with "rollback" or "transaction" or something so we can transparently tell the database to begin a transaction and automatically roll it back afterwards.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (err.message.includes(`Cannot read properties of undefined (reading 'received')`) || // Error handler for Chrome | ||
if (err.message.includes(`Cannot read properties of undefined (reading 'received')`) || // Error handler for Chrome | ||
err.message.includes(`Cannot read properties of undefined (reading '0')`) || // Error handler for Chrome | ||
err.message.includes('response.filtered_item_list[0] is undefined') || // Error handler for Firefox |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know we're handling errors here. I'm curious if these are from web socket notifications. If so, I wonder if we can improve behavior and reliability by disabling web socket notifications in cypress EXCEPT in tests that are testing web socket notifications. I haven't looked at that yet cc @GilbertCherrie @elsamaryv
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Along these same lines, I was noticing that we always load the 4 dashboard widgets (chart/reports) after login on each page. Part of the PR I started doing to try to share the same login between tests in the same file, #9499, I wanted to change login to load a different page after the login such as /utilization or /optimization... I wonder if we can leverage the "my settings" start page to pick a page that is a faster start page for all users:
Another option would be to customize our default dashboard for cypress to have no widgets on the loading page and switch to a dashboard with graphs/charts for tests for dashboards.
cc @Fryguy (note, I think Jason had the idea for the start page)
Tried with CYPRESS=true ( |
…n-Settings
CP4AIOPS-14547
Pr that adds cypress tests for Schedule form(Settings > Application Settings > Settings > Schedules > Configuration > Add a new schedule)
Tests executed across browsers



@miq-bot assign @GilbertCherrie
@miq-bot add-label cypress
@miq-bot add-label test