Socket
Socket
Sign inDemoInstall

umbraco-cypress-testhelpers

Package Overview
Dependencies
169
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    umbraco-cypress-testhelpers

Test helpers for making Cypress tests for Umbraco solutions


Version published
Weekly downloads
10
increased by25%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Umbraco Cypress TestHelpers

Build Status Tests Coverage License

Usage

First you need to install the package as a dev dependency

npm install umbraco-cypress-testhelpers --save-dev

When used in you tests you need to import the Builder

import {Builder} from 'umbraco-cypress-testhelpers'

And in your tests you can do something like this for a minimal version filled with default/random values

const actual = new Builder().Form().build();

with the following output, when serialized to json:

{
  "created": "2019-10-18T07:13:45.226Z",
  "cssClass": null,
  "datasource": null,
  "disableDefaultStylesheet": false,
  "fieldIndicationType": "MarkMandatoryFields",
  "formWorkflows": {
    "onApprove": [],
    "onSubmit": []
  },
  "goToPageOnSubmit": 0,
  "hideFieldValidation": false,
  "id": "00000000-0000-0000-0000-000000000000",
  "indicator": "*",
  "invalidErrorMessage": "Please provide a valid value for {0}",
  "manualApproval": false,
  "messageOnSubmit": "Thank you",
  "name": "no name",
  "nextLabel": "Next",
  "pages": [],
  "prevLabel": "Previous",
  "requiredErrorMessage": "Please provide a value for {0}",
  "showValidationSummary": false,
  "storeRecordsLocally": true,
  "submitLabel": "Submit",
  "useClientDependency": false,
  "workflows": [],
  "xPathOnSubmit": null
}

or you can build the type with the values you want, and the rest filled with default/random values

const actual = new Builder().Form()
            .addPage()
                .addFieldSet()
                    .addContainer()
                        .addShortAnswerField()
                            .withId("8bd3477b-68db-4b3d-837c-5e2322e88e30")
                        .done()
                        .addShortAnswerField()
                            .addShowAllConditions()
                                .addRule()
                                    .withContainsRule("8bd3477b-68db-4b3d-837c-5e2322e88e30","test")
                                .done()
                            .done()
                        .done()
                    .done()
                .done()
            .done()
        .build();

with the following serialized data:

{
  "created": "2019-10-18T07:13:45.224Z",
  "cssClass": null,
  "datasource": null,
  "disableDefaultStylesheet": false,
  "fieldIndicationType": "MarkMandatoryFields",
  "formWorkflows": {
    "onApprove": [],
    "onSubmit": []
  },
  "goToPageOnSubmit": 0,
  "hideFieldValidation": false,
  "id": "00000000-0000-0000-0000-000000000000",
  "indicator": "*",
  "invalidErrorMessage": "Please provide a valid value for {0}",
  "manualApproval": false,
  "messageOnSubmit": "Thank you",
  "name": "no name",
  "nextLabel": "Next",
  "pages": [
    {
      "caption": null,
      "fieldSets": [
        {
          "caption": null,
          "containers": [
            {
              "caption": null,
              "fields": [
                {
                  "alias": "a8bd3477b-68db-4b3d-837c-5e2322e88e30",
                  "caption": "8bd3477b-68db-4b3d-837c-5e2322e88e30",
                  "fieldTypeId": "3f92e01b-29e2-4a30-bf33-9df5580ed52c",
                  "id": "8bd3477b-68db-4b3d-837c-5e2322e88e30",
                  "preValues": [],
                  "removePrevalueEditor": false,
                  "settings": {},
                  "condition": null
                },
                {
                  "alias": "a7bef9758-Cd2f-49d3-98af-0781a933f55e",
                  "caption": "7bef9758-cd2f-49d3-98af-0781a933f55e",
                  "fieldTypeId": "3f92e01b-29e2-4a30-bf33-9df5580ed52c",
                  "id": "7bef9758-cd2f-49d3-98af-0781a933f55e",
                  "preValues": [],
                  "removePrevalueEditor": false,
                  "settings": {},
                  "condition": {
                    "enabled": true,
                    "actionType": "Show",
                    "logicType": "All",
                    "rules": [
                      {
                        "field": "8bd3477b-68db-4b3d-837c-5e2322e88e30",
                        "operator": "Contains",
                        "value": "test"
                      }
                    ]
                  }
                }
              ]
            }
          ]
        }
      ]
    }
  ],
  "prevLabel": "Previous",
  "requiredErrorMessage": "Please provide a value for {0}",
  "showValidationSummary": false,
  "storeRecordsLocally": true,
  "submitLabel": "Submit",
  "useClientDependency": false,
  "workflows": [],
  "xPathOnSubmit": null
}

All builders available

const content = new Builder().Content().build();

const documentType = new Builder().DocumentType().build();

const form = new Builder().Form().build();

const formPickerDataType = new Builder().FormPicker().build();

const template = new Builder().LabeTemplatel().build();

const label = new Builder().Label().build();

Keywords

FAQs

Last updated on 25 Aug 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc