UNPKG

@wordpress/e2e-test-utils

Version:
31 lines (29 loc) 1.32 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.togglePreferencesOption = togglePreferencesOption; var _clickOnCloseModalButton = require("./click-on-close-modal-button"); var _clickOnMoreMenuItem = require("./click-on-more-menu-item"); /** * Internal dependencies */ /** * Toggles a preference option with the given tab label and the option label. * * @param {string} tabLabel The preferences tab label to click. * @param {string} optionLabel The option label to search the button for. * @param {boolean} [shouldBeChecked] If true, turns the option on. If false, off. If not provided, the option will be toggled. */ async function togglePreferencesOption(tabLabel, optionLabel, shouldBeChecked) { await (0, _clickOnMoreMenuItem.clickOnMoreMenuItem)('Preferences'); const [tabHandle] = await page.$x(`//button[contains(text(), "${tabLabel}")]`); await tabHandle.click(); const [optionHandle] = await page.$x(`//label[contains(text(), "${optionLabel}")]`); const isChecked = await page.evaluate(element => element.control.checked, optionHandle); if (isChecked !== shouldBeChecked) { await optionHandle.click(); } await (0, _clickOnCloseModalButton.clickOnCloseModalButton)(); } //# sourceMappingURL=toggle-preferences-option.js.map