Skip to content

Conversation

asirvadAbrahamVarghese
Copy link
Contributor

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
 

@asirvadAbrahamVarghese asirvadAbrahamVarghese requested a review from a team as a code owner August 4, 2025 18:31
@asirvadAbrahamVarghese asirvadAbrahamVarghese force-pushed the zone-form-automation-testing branch 2 times, most recently from 7e68886 to 3f7777e Compare August 5, 2025 08:47
@asirvadAbrahamVarghese
Copy link
Contributor Author

asirvadAbrahamVarghese commented Aug 5, 2025

TODO:

@asirvadAbrahamVarghese asirvadAbrahamVarghese changed the title Added automated tests with cypress for Zone form [WIP] - Added automated tests with cypress for Zone form Aug 6, 2025
@asirvadAbrahamVarghese asirvadAbrahamVarghese force-pushed the zone-form-automation-testing branch 4 times, most recently from 3d1b598 to a589f51 Compare August 7, 2025 10:42
cy.getFormInputFieldById(descriptionInputFieldId)
.clear()
.type(updatedServerIp);
cy.getFormSelectFieldById(maxScanSelectFieldId).select(updatedMaxScanLimit);
Copy link
Member

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.

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the session timing problem is the culprit here again, and doesn’t look like there’s anything async that’s needs to be awaited or handled
image

Copy link
Member

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.

@asirvadAbrahamVarghese asirvadAbrahamVarghese force-pushed the zone-form-automation-testing branch from a589f51 to 8afddae Compare August 13, 2025 07:52
@jrafanie
Copy link
Member

Close / open after revert of #9505 via #9553

@jrafanie jrafanie closed this Aug 13, 2025
@jrafanie jrafanie reopened this Aug 13, 2025
cy.wait('@createZone');
}

function validateFormElements(isEditForm = false) {
Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Member

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.

Copy link
Contributor Author

@asirvadAbrahamVarghese asirvadAbrahamVarghese Sep 29, 2025

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

@jrafanie
Copy link
Member

LGTM so far. Just a few comments above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants