Skip to content

Make it easier to create default content #4

@nikolajlauridsen

Description

@nikolajlauridsen

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);

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions