UNPKG

@wordpress/e2e-test-utils

Version:
50 lines (47 loc) 1.97 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.deleteTheme = deleteTheme; var _activateTheme = require("./activate-theme"); var _installTheme = require("./install-theme"); var _switchUserToAdmin = require("./switch-user-to-admin"); var _switchUserToTest = require("./switch-user-to-test"); var _visitAdminPage = require("./visit-admin-page"); var _themeInstalled = require("./theme-installed"); /** * Internal dependencies */ /** * Deletes a theme from the site, activating another theme if necessary. * * @param {string} slug Theme slug. * @param {?Object} settings Optional settings object. * @param {?string} settings.newThemeSlug A theme to switch to if the theme to delete is active. Required if the theme to delete is active. * @param {?string} settings.newThemeSearchTerm A search term to use if the new theme is not findable by its slug. */ async function deleteTheme(slug, { newThemeSlug, newThemeSearchTerm } = {}) { await (0, _switchUserToAdmin.switchUserToAdmin)(); if (newThemeSlug) { await (0, _installTheme.installTheme)(newThemeSlug, newThemeSearchTerm); await (0, _activateTheme.activateTheme)(newThemeSlug); } else { await (0, _visitAdminPage.visitAdminPage)('themes.php'); } if (!(await (0, _themeInstalled.isThemeInstalled)(slug))) { await (0, _switchUserToTest.switchUserToTest)(); return; } await page.click(`[data-slug="${slug}"]`); await page.waitForSelector('.theme-actions .delete-theme'); await page.click('.theme-actions .delete-theme'); await page.waitForSelector('body:not(.modal-open)'); // Wait for the theme to be removed from the page. // eslint-disable-next-line no-restricted-syntax await page.waitForFunction(themeSlug => !document.querySelector(`[data-slug="${themeSlug}"]`), slug); await (0, _switchUserToTest.switchUserToTest)(); } //# sourceMappingURL=delete-theme.js.map