Skip to content

Commit

Permalink
Updated upperair map test
Browse files Browse the repository at this point in the history
  • Loading branch information
mollybsmith-noaa committed Aug 27, 2024
1 parent 5fe6ce0 commit 7a58ce6
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tests/src/features/upperair/basic/addRemoveMap.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ Feature: Add Remove Map
Then the plot type should be "Map"
When I change the "data-source" parameter to "HRRR_OPS"
Then the "data-source" parameter value matches "HRRR_OPS"
When I change the "sites" parameter to "GRAND JUNCTION (GJT)"
Then the "sites" parameter value matches "GRAND JUNCTION (GJT)"
When I select all options in the "sites" parameter
Then the "sites" parameter value matches "999 .. ZHENGZHOU (ZHCC)"
When I change the "top" number parameter to "500"
Then the "top" parameter value matches "500"
When I change the "bottom" number parameter to "500"
Then the "bottom" parameter value matches "500"
When I set the dates to "08/12/2024 00:00 - 08/12/2024 23:59"
Then the dates value is "08/12/2024 00:00 - 08/12/2024 23:59"
Then I click the "Add Curve" button
Expand Down
12 changes: 12 additions & 0 deletions tests/src/steps/when.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ import setScatterDateRange from '../support/action/setScatterDateRange';
import setMatsPlotType from '../support/action/setMatsPlotType';
import setMatsPlotFormat from '../support/action/setMatsPlotFormat';
import clickMatsButton from '../support/action/clickMatsButton';
import setMatsAllSelectedOptions from '../support/action/setMatsAllSelectedOptions';
import setMatsSelectedOption from '../support/action/setMatsSelectedOption';
import setMatsSelectedNumberSpinner from '../support/action/setMatsSelectedNumberSpinner';
import matsRefreshBrowser from '../support/action/matsRefreshBrowser';
import matsRefreshPage from '../support/action/matsRefreshPage';
import matsClearParameter from '../support/action/matsClearParameter';
Expand Down Expand Up @@ -54,11 +56,21 @@ When(
clickMatsButton
);

When(
/^I select all options in the "([^"]*)" parameter$/, { wrapperOptions: { retry: 2 } },
setMatsAllSelectedOptions
);

When(
/^I change the "([^"]*)" parameter to "([^"]*)"$/, { wrapperOptions: { retry: 2 } },
setMatsSelectedOption
);

When(
/^I change the "([^"]*)" number parameter to "([^"]*)"$/, { wrapperOptions: { retry: 2 } },
setMatsSelectedNumberSpinner
);

When(
/^I set the plot type to "([^"]*)?"$/,
setMatsPlotType
Expand Down
29 changes: 29 additions & 0 deletions tests/src/support/action/setMatsAllSelectedOptions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* Select an option of a select element
* @param {String} parameter Element selector label
*/

export default (parameter) => {
/**
* The method to use for selecting the option
* @type {String}
*/

// noinspection JSJQueryEfficiency
$(`#controlButton-${parameter}`).waitForDisplayed();
$(`#controlButton-${parameter}`).scrollIntoView();
$(`#controlButton-${parameter}`).click();
if ($(`#${parameter}-select-clear`).isDisplayed()) {
$(`#${parameter}-select-clear`).waitForClickable();
$(`#${parameter}-select-clear`).click();
}
if ($(`#${parameter}-select-all`).isDisplayed()) {
$(`#${parameter}-select-all`).waitForClickable();
$(`#${parameter}-select-all`).click();
}
if ($(`#${parameter}-select-done`).isDisplayed()) {
// if it is a multi-select selector, have to click the done button
$(`#${parameter}-select-done`).waitForClickable();
$(`#${parameter}-select-done`).click();
}
};
44 changes: 44 additions & 0 deletions tests/src/support/action/setMatsSelectedNumberSpinner.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* Select an option of a text or number spinner element
* @param {String} parameter Element selector label
* @param {String} selectionValue Value to select by
*/
import pause from "./pause";

export default (parameter, selectionValue) => {
/**
* The method to use for selecting the option
* @type {String}
*/

// noinspection JSJQueryEfficiency
$(`#controlButton-${parameter}`).waitForDisplayed();
$(`#controlButton-${parameter}`).scrollIntoView();
$(`#controlButton-${parameter}`).waitForClickable();
$(`#controlButton-${parameter}`).click();
$(`#${parameter}-numberSpinner`).waitForDisplayed();
$(`#${parameter}-numberSpinner`).setValue(parseInt(selectionValue));
$(`#controlButton-${parameter}`).waitForClickable();
$(`#controlButton-${parameter}`).click();

let matchValue = selectionValue;
let text = "";
let count = 0;
// this is essentially giving the parameter 20 seconds to show the new value
// this is mostly for when it is really busy doing parallel instances
while (count < 20 && text !== matchValue) {
text = $(`#controlButton-${parameter}-value`).getText();
if (text !== matchValue) {
pause(2000);
}
count += 1;
}
if (text !== matchValue) {
console.log(`parameter is ${parameter}, selectionValue is ${selectionValue}`);
// browser.debug();
}
expect(text).toEqual(
matchValue,
`Expexted ${text} to be ${matchValue} for parameter: ${parameter}`
);
};

0 comments on commit 7a58ce6

Please sign in to comment.