Feature: Custom Fields Management
As admin
I can create, update and delete custom fields

@auth @createsequence @logout
Scenario: Creation and Update and Delete Custom Field Sequence and check audit logs
	Given I create a CustomField
		| Name    | FieldType | DefaultValue | Sequence     | Glossary |
		| TestCFS | Sequence  |              | sequenceName |          |
	Then I check Custom Field Audit logs
		| Timing | UserName | Comment | EntityDisplayName    | Type   | DisplayName                 | Changes |
		|        |          |         | scenarioDataInstance | Create | formNameFromScenarioContext |         |
	And I check Custom Field Audit logs
		| Timing | UserName | Comment | EntityDisplayName    | Type   | DisplayName                 | Changes |
		|        |          |         | scenarioDataInstance | Create | formNameFromScenarioContext |         |
	Given I create a new Sequence via API
		| Name    |
		| NewName |
	When I edit a CustomField
		| Name               | FieldType | DefaultValue | Sequence     | Glossary |
		| EDITTestCFSequence | Sequence  |              | sequenceName |          |
	Then I check data on Custom Field page
		| FieldType |
		| Sequence  |
	And I check Custom Field Audit logs
		| Timing | UserName | Comment | EntityDisplayName    | Type   | DisplayName                 | Changes |
		|        |          |         | scenarioDataInstance | Update | formNameFromScenarioContext |         |
	When I delete a CustomField
	Then I check Custom Field Audit logs
		| Timing | UserName | Comment | EntityDisplayName    | Type   | DisplayName                 | Changes |
		|        |          |         | scenarioDataInstance | Delete | formNameFromScenarioContext |         |

@auth @logout
Scenario: Creation and Update and Delete Custom Field Glossary and check audit logs
	Given I create a Glossary
		| Name         | Add |
		| TestGlossary |     |
	When I create a CustomField
		| Name           | FieldType | MaxEntries | Required | Glossary |
		| TestCFGlossary | Glossary  | 1          | true     |          |
	Then I check Custom Field Audit logs
		| Timing | UserName | Comment | EntityDisplayName    | Type   | DisplayName                 | Changes |
		|        |          |         | scenarioDataInstance | Create | formNameFromScenarioContext |         |
	And I check data on Custom Field page
		| FieldType |
		| Glossary  |
	When I create a Glossary
		| Name            | Add |
		| NewTestGlossary |     |
	And I edit a CustomField
		| Name               | FieldType | MaxEntries | Required | Glossary |
		| EDITTestCFGlossary | Glossary  | 3          | false    |          |
	Then I check data on Custom Field page
		| FieldType |
		| Glossary  |
	And I check Custom Field Audit logs
		| Timing | UserName | Comment | EntityDisplayName    | Type   | DisplayName                 | Changes |
		|        |          |         | scenarioDataInstance | Update | formNameFromScenarioContext |         |
	When I delete a CustomField
	Then I check Custom Field Audit logs
		| Timing | UserName | Comment | EntityDisplayName    | Type   | DisplayName                 | Changes |
		|        |          |         | scenarioDataInstance | Delete | formNameFromScenarioContext |         |

@auth @logout
Scenario: Creation and Update and Delete Custom Field Form Template and check audit logs
	Given I create a CustomField
		| Name                | FieldType     |
		| TestCFForm Template | Form Template |
	Then I check Custom Field Audit logs
		| Timing | UserName | Comment | EntityDisplayName    | Type   | DisplayName                 | Changes |
		|        |          |         | scenarioDataInstance | Create | formNameFromScenarioContext |         |
	When I edit a CustomField
		| Name                    | FieldType     |
		| EDITTestCFForm Template | Form Template |
	Then I check data on Custom Field page
		| FieldType     |
		| Form Template |
	And I check Custom Field Audit logs
		| Timing | UserName | Comment | EntityDisplayName    | Type   | DisplayName                 | Changes |
		|        |          |         | scenarioDataInstance | Update | formNameFromScenarioContext |         |
	When I delete a CustomField
	Then I check Custom Field Audit logs
		| Timing | UserName | Comment | EntityDisplayName    | Type   | DisplayName                 | Changes |
		|        |          |         | scenarioDataInstance | Delete | formNameFromScenarioContext |         |

@auth @logout
Scenario: Creation and Update and Delete Custom Field Text and check audit logs
	Given I create a CustomField
		| Name       | FieldType | DefaultValue | MultiLine |
		| TestCFText | Text      | Default Text | true      |
	Then I check data on Custom Field page
		| FieldType |
		| Text      |
	And I check Custom Field Audit logs
		| Timing | UserName | Comment | EntityDisplayName    | Type   | DisplayName                 | Changes |
		|        |          |         | scenarioDataInstance | Create | formNameFromScenarioContext |         |
	When I edit a CustomField
		| Name           | FieldType | DefaultValue        | MultiLine |
		| EDITTestCFText | Text      | Edited Default Text | false     |
	Then I check data on Custom Field page
		| FieldType |
		| Text      |
	And I check Custom Field Audit logs
		| Timing | UserName | Comment | EntityDisplayName    | Type   | DisplayName                 | Changes |
		|        |          |         | scenarioDataInstance | Update | formNameFromScenarioContext |         |
	When I delete a CustomField
	Then I check Custom Field Audit logs
		| Timing | UserName | Comment | EntityDisplayName    | Type   | DisplayName                 | Changes |
		|        |          |         | scenarioDataInstance | Delete | formNameFromScenarioContext |         |

@auth @logout
Scenario: Creation and Update and Delete Custom Field Number and check audit logs
	Given I create a CustomField
		| Name         | FieldType | DefaultValue | MinimumValue | MaximumValue | Step | Required |
		| TestCFNumber | Number    | 1            | 1            | 999          | 2    | true     |
	Then I check data on Custom Field page
		| FieldType |
		| Number    |
	And I check Custom Field Audit logs
		| Timing | UserName | Comment | EntityDisplayName    | Type   | DisplayName                 | Changes |
		|        |          |         | scenarioDataInstance | Create | formNameFromScenarioContext |         |
	When I edit a CustomField
		| Name              | FieldType | DefaultValue | MinimumValue | MaximumValue | Step | Required |
		| EDIT_TestCFNumber | Number    | 2            | 2            | 777          | 3    | false    |
	Then I check data on Custom Field page
		| FieldType |
		| Number    |
	And I check Custom Field Audit logs
		| Timing | UserName | Comment | EntityDisplayName    | Type   | DisplayName                 | Changes |
		|        |          |         | scenarioDataInstance | Update | formNameFromScenarioContext |         |
	When I delete a CustomField
	Then I check Custom Field Audit logs
		| Timing | UserName | Comment | EntityDisplayName    | Type   | DisplayName                 | Changes |
		|        |          |         | scenarioDataInstance | Delete | formNameFromScenarioContext |         |

@auth @deletecustomfield @logout
Scenario: Creation and Change Custom Field Type and check audit logs
	Given I create a CustomField
		| Name       | FieldType | DefaultValue | MultiLine |
		| TestCFText | Text      | Default Text | true      |
	Then I check Custom Field Audit logs
		| Timing | UserName | Comment | EntityDisplayName    | Type   | DisplayName                 | Changes |
		|        |          |         | scenarioDataInstance | Create | formNameFromScenarioContext |         |
	When I edit a CustomField
		| Name           | FieldType     |
		| EDITTestCFText | Form Template |
	Then I check data on Custom Field page
		| FieldType     |
		| Form Template |
	And I check Custom Field Audit logs
		| Timing | UserName | Comment | EntityDisplayName    | Type   | DisplayName                 | Changes |
		|        |          |         | scenarioDataInstance | Update | formNameFromScenarioContext |         |
	And I check Custom Field Text Audit logs
		| Timing | UserName | Comment | EntityDisplayName    | Type  | DisplayName                 | Changes |
		|        |          |         | scenarioDataInstance | Purge | formNameFromScenarioContext |         |

@auth @logout
Scenario: Creation and Update and Delete Custom Field Domain and check audit logs
	Given I create a CustomField
		| Name         | FieldType | MaxEntries | Required |
		| TestCFDomain | Domain    | 1          | true     |
	Then I check data on Custom Field page
		| FieldType |
		| Domain    |
	And I check Custom Field Audit logs
		| Timing | UserName | Comment | EntityDisplayName    | Type   | DisplayName                 | Changes |
		|        |          |         | scenarioDataInstance | Create | formNameFromScenarioContext |         |
	When I edit a CustomField
		| Name             | FieldType | MaxEntries | Required |
		| EDITTestCFDomain | Domain    | 22         | false    |
	Then I check data on Custom Field page
		| FieldType |
		| Domain    |
	And I check Custom Field Audit logs
		| Timing | UserName | Comment | EntityDisplayName    | Type   | DisplayName                 | Changes |
		|        |          |         | scenarioDataInstance | Update | formNameFromScenarioContext |         |
	When I delete a CustomField
	Then I check Custom Field Audit logs
		| Timing | UserName | Comment | EntityDisplayName    | Type   | DisplayName                 | Changes |
		|        |          |         | scenarioDataInstance | Delete | formNameFromScenarioContext |         |