-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Labels
Description
In many cases, all you need for your test is a completely empty content, with some name.
Currently this is a bit of pain to do:
Create doctype:
const rootDocType = new DocumentTypeBuilder()
.withName(rootDocTypeName)
.withAllowAsRoot(true)
.build()
const createdRootDocType = await umbracoApi.documentTypes.save(rootDocType);
Then create content:
const rootContentNode = new ContentBuilder()
.withContentTypeAlias(createdRootDocType.alias)
.withAction("saveNew")
.addVariant()
.withName(firstRootNodeName)
.withSave(true)
.done()
.build();
const savedRootNode = await umbracoApi.content.save(rootContentNode);
This seems like a lot of code for empty content which you mostly need, instead I propose we use some helper methods like CreateBasicContentType
, so it could look something like this:
// Create doctype
const rootDocType = new DocumentTypeBuilder().CreateBasicContentType("MyBasicContentType");
const createdRootDocType = await umbracoApi.documentTypes.save(rootDocType);
// Create content
const rootContentNode = new ContentBuilder().CreateBasicContent("MyBasicContent", createdRootDocType.alias);
const savedRootNode = await umbracoApi.content.save(rootContentNode);