UNPKG

umbraco-cypress-testhelpers

Version:

Test helpers for making Cypress tests for Umbraco solutions

28 lines (25 loc) 832 B
import CommandBase from './commandBase'; import { JsonHelper } from '../../helpers/jsonHelper'; export default class DeleteAllContent extends CommandBase { commandName = 'deleteAllContent'; method() { const cy = this.cy; return cy.getCookie('UMB-XSRF-TOKEN', { log: false }).then((token) => { cy.request({ method: 'GET', url: `${this.relativeBackOfficePath}/backoffice/UmbracoTrees/ApplicationTree/GetApplicationTrees?application=content&tree=&use=main`, headers: { 'X-UMB-XSRF-TOKEN': token.value, }, }).then((response) => { const content = JsonHelper.getBody(response); for (const child of content.children) { if (child.id > 0) { cy.deleteContentById(child.id); } } return; }); }); } }