-
Notifications
You must be signed in to change notification settings - Fork 365
[WIP] - Added automated tests with cypress for Zone form #9535
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?
[WIP] - Added automated tests with cypress for Zone form #9535
Conversation
7e68886
to
3f7777e
Compare
TODO:
|
3d1b598
to
a589f51
Compare
cy.getFormInputFieldById(descriptionInputFieldId) | ||
.clear() | ||
.type(updatedServerIp); | ||
cy.getFormSelectFieldById(maxScanSelectFieldId).select(updatedMaxScanLimit); |
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.
Similar to the question above about the input fields type()
possibly doing async stuff afterwards... I'm seeing one run of this test retry 4 times. So, don't waste time trying to debug it until this test actually fails all 10 attempts but wanted to share in case there was something obvious async you saw when you ran this manually.

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.
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.
haha, I didn't get any takers on reviewing #9533 so it's stalled. Reducing our session writes on requests that shouldn't be updating session doesn't fix the problem but it does reduce the likelihood of a timing bug with much less session writes across threads.
a589f51
to
8afddae
Compare
cy.wait('@createZone'); | ||
} | ||
|
||
function validateFormElements(isEditForm = false) { |
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.
After we do a few pages of these, we'll probably have shared behavior we can extract. It's probably best to get a few of these in first.
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 am not really sure about the best approach to extract these, one way would be to have separate methods in a shared helper file for each field, something like:
function validateNameField(isDisabled = false) {
cy.getFormLabelByInputId('name').should('be.visible');
cy.getFormInputFieldById('name')
.should('be.visible')
.then((nameField) => {
if (isDisabled) {
expect(nameField).to.be.disabled;
} else {
expect(nameField).to.not.be.disabled;
}
});
}
But we might end up with a pile of methods 😴
More flexible one would be to get the set of field configs and then do the assertions:
function validateFormFields(fieldConfigs) {
fieldConfigs.forEach((config) => {
const { id, fieldType = 'input', shouldBeDisabled = false } = config;
// Check label
cy.getFormLabelByInputId(id).should('be.visible');
// Check field
if (fieldType === 'input') {
cy.getFormInputFieldById(id)
.should('be.visible')
.then((field) => {
if (shouldBeDisabled) {
expect(field).to.be.disabled;
} else {
expect(field).to.not.be.disabled;
}
});
} else if (fieldType === 'select') {
cy.getFormSelectFieldById(id)
.should('be.visible')
.then((field) => {
if (shouldBeDisabled) {
expect(field).to.be.disabled;
} else {
expect(field).to.not.be.disabled;
}
});
}
});
}
and use it like:
validateFormFields([
{ id: 'name', shouldBeDisabled: true },
{ id: 'description' },
{ fieldType: 'select', id: 'concurrent_vm_scans' },
]);
Any thoughts?
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.
Sorry, I didn't see this reply. yeah, I think something like that is what we should do. How many pages have we done this for now? Maybe after we have several done and can figure out a clean way to do this...
One for validating form labels and one for form input fields seem the most logical to me. Keep this in mind as you do these and propose an interface and maybe we can try converting one of these tests to use it... and we can judge before vs. after.
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.
PR with form element validation commands: #9635
8afddae
to
71f0088
Compare
e6a5a69
to
cdb42e8
Compare
cdb42e8
to
2663fe4
Compare
LGTM so far. Just a few comments above. |
2663fe4
to
21a2097
Compare
21a2097
to
8576556
Compare
CP4AIOPS-17892
Pr that adds cypress tests for Zone form: Settings > Application Settings > Settings > Zones > Configuration > Add/Edit Zone
- Validate add form elements
- Validate edit form elements
- Add, edit & delete a zone
@miq-bot assign @elsamaryv
@miq-bot add-label cypress
@miq-bot add-label test