@wordpress/e2e-test-utils
Version:
End-To-End (E2E) test utils for WordPress.
37 lines (35 loc) • 1.29 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.setOption = setOption;
var _switchUserToAdmin = require("./switch-user-to-admin");
var _visitAdminPage = require("./visit-admin-page");
var _switchUserToTest = require("./switch-user-to-test");
var _pressKeyWithModifier = require("./press-key-with-modifier");
/**
* Internal dependencies
*/
/**
* Sets a site option, from the options-general admin page.
*
* @param {string} setting The option, used to get the option by id.
* @param {string} value The value to set the option to.
*
* @return {string} The previous value of the option.
*/
async function setOption(setting, value) {
await (0, _switchUserToAdmin.switchUserToAdmin)();
await (0, _visitAdminPage.visitAdminPage)('options.php');
await page.waitForSelector(`#${setting}`);
const previousValue = await page.$eval(`#${setting}`, element => element.value);
await page.focus(`#${setting}`);
await (0, _pressKeyWithModifier.pressKeyWithModifier)('primary', 'a');
await page.type(`#${setting}`, value);
await Promise.all([page.click('#Update'), page.waitForNavigation({
waitUntil: 'networkidle0'
})]);
await (0, _switchUserToTest.switchUserToTest)();
return previousValue;
}
//# sourceMappingURL=set-option.js.map