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

[RFR] automate MTA-382--assess application with multiple questionnaires #828

Merged
merged 20 commits into from
Nov 27, 2023

Conversation

midays
Copy link
Collaborator

@midays midays commented Nov 22, 2023

Signed-off-by: mohamed idays [email protected]

@midays midays changed the title [WIP][AT] MTA-382--assess application with multiple questionnaires [WIP] automate MTA-382--assess application with multiple questionnaires Nov 22, 2023
@midays midays changed the title [WIP] automate MTA-382--assess application with multiple questionnaires [RFR] automate MTA-382--assess application with multiple questionnaires Nov 26, 2023
updated timeout to 15 seconds
changed 2000 to 2 * SEC
@sshveta
Copy link
Collaborator

sshveta commented Nov 26, 2023

Please attach a jenkins run @midays

Comment on lines 151 to 181
} else if (risk === "medium") {
cy.wrap($question)
.children()
.find("div.pf-v5-l-split__item")
.then(($questionLine) => {
/* These 3 questions generate high risk with mean options,
hence to keep risk to medium, select last options for these set of specific questions */
if (
$questionLine.text() ===
"Does the application have legal and/or licensing requirements?" ||
$questionLine.text() ===
"Does the application require specific hardware?" ||
$questionLine.text() ===
"How is the application clustering managed?"
) {
optionToSelect = totalOptions - 1;
} else {
optionToSelect = Math.floor(totalOptions / 2);
}
this.clickRadioOption($question, optionToSelect);
});
} else {
optionToSelect = 1;
this.clickRadioOption($question, optionToSelect);
}
});
if (i === 4) {
clickJs(commonView.nextButton);
} else {
clickJs(commonView.nextButton);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This method is too complex right now, some considerations:

  1. low and high risk conditions are almost equal, so they can be combined with something like:
if(risk === "medium") {
    ...
} else {
    this.clickRadioOption($question, risk === "high"  ?  1 : totalOptions - 1);
}
  1. Those 3 special questions are making the if condition too long, and in the future some questions may change, be added or removed.

In order to make the code more maintainable, an idea could be to save the questions in an array at the start of the method and use includes instead of doing multipleConditions:

const specialHighRiskQuestions = [
    "Does the application have legal and/or licensing requirements?",
    "Does the application require specific hardware?",
    "How is the application clustering managed?"
];
...
...

if(specialHighRiskQuestions.includes($questionLine.text())) {
    ...
}
  1. The last if-else looks identical to me:
 if (i === 4) {
    clickJs(commonView.nextButton);
} else {
    clickJs(commonView.nextButton);
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

At least point 3 should be fixed before merging.

Copy link
Collaborator Author

@midays midays Nov 27, 2023

Choose a reason for hiding this comment

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

all of the points you mentioned are change worthy, but I dind't write any of them, I just wrapped it in a cy tag, and I don't intend to change anything in it for now, so I opened a ticket for it, and I'll work on it in the next PR

Copy link
Collaborator

Choose a reason for hiding this comment

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

@midays as discussed , implement point 3 . refactoring of answering questionnaire can be done in a separate PR . It will need thorough testing . Please open a card for it and assign it to me .

For this PR attach a jenkins run with this test

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

changed timeout to 30 seconds
changed undefined to null
reload the page after opening the application page
enable the questioneer only when needed
changed execution order

const stakeholdersList: Array<Stakeholders> = [];
const stakeholdersNameList: Array<string> = [];
const fileName = "Legacy Pathfinder";
const yamlFilePath = "questionnaire_import/cloud-native.yaml";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please rename this to "yamlFile"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@sshveta sshveta merged commit cf2ddd3 into konveyor:main Nov 27, 2023
4 checks passed
@midays midays deleted the MTA-382---Assessment branch July 29, 2024 09:21
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.

5 participants