@wordpress/e2e-test-utils
Version:
End-To-End (E2E) test utils for WordPress.
28 lines (27 loc) • 635 B
JavaScript
/**
* Internal dependencies
*/
import { rest, batch } from './rest-api';
/**
* Delete all the widgets in the widgets screen.
*/
export async function deleteAllWidgets() {
const [widgets, sidebars] = await Promise.all([rest({
path: '/wp/v2/widgets'
}), rest({
path: '/wp/v2/sidebars'
})]);
await batch(widgets.map(widget => ({
method: 'DELETE',
path: `/wp/v2/widgets/${widget.id}?force=true`
})));
await batch(sidebars.map(sidebar => ({
method: 'POST',
path: `/wp/v2/sidebars/${sidebar.id}`,
body: {
id: sidebar.id,
widgets: []
}
})));
}
//# sourceMappingURL=widgets.js.map