diff --git a/backend/i18n/frontend_en.json b/backend/i18n/frontend_en.json index ea09a2bcb..83d250a89 100644 --- a/backend/i18n/frontend_en.json +++ b/backend/i18n/frontend_en.json @@ -240,9 +240,11 @@ "common.delete": "Delete", "common.description": "Description", "common.designer": "Designer", + "common.disabled": "Disabled", "common.displayName": "Display Name", "common.edit": "Edit", "common.email": "Email", + "common.enabled": "Enabled", "common.error": "Error", "common.errorBack": "Back to previous page.", "common.errorNoPermission": "You do not have the permissions to do this.", @@ -316,6 +318,7 @@ "common.restore": "Restore", "common.role": "Role", "common.roles": "Roles", + "common.rule": "Rule", "common.rules": "Rules", "common.sampleCodeLabel": "Sample Code at", "common.save": "Save", @@ -621,6 +624,7 @@ "rules.emptyAddRule": "Add Rule", "rules.enableFailed": "Failed to enable rule. Please reload.", "rules.enqueued": "Rule has been added to the queue.", + "rules.itemPageTitle": "Rule", "rules.listPageTitle": "Rules", "rules.loadFailed": "Failed to load Rules. Please reload.", "rules.readMore": "Read More", diff --git a/backend/i18n/frontend_it.json b/backend/i18n/frontend_it.json index a69449f86..7c7f2d19f 100644 --- a/backend/i18n/frontend_it.json +++ b/backend/i18n/frontend_it.json @@ -240,9 +240,11 @@ "common.delete": "Cancella", "common.description": "Descrizione", "common.designer": "Designer", + "common.disabled": "Disabled", "common.displayName": "Nome visualizzato", "common.edit": "Modifica", "common.email": "Email", + "common.enabled": "Enabled", "common.error": "Errore", "common.errorBack": "Torna alla pagina precedente.", "common.errorNoPermission": "Non hai i permessi per questo.", @@ -316,6 +318,7 @@ "common.restore": "Ripristina", "common.role": "Ruolo", "common.roles": "Ruoli", + "common.rule": "Rule", "common.rules": "Regole", "common.sampleCodeLabel": "Esempio di codice per", "common.save": "Salva", @@ -621,6 +624,7 @@ "rules.emptyAddRule": "Aggiungi una regola", "rules.enableFailed": "Non è stato possibile abilitare la regola. Per favore ricarica.", "rules.enqueued": "La regola è stata aggiunta alle code.", + "rules.itemPageTitle": "Rule", "rules.listPageTitle": "Regole", "rules.loadFailed": "Non è stato possibile caricare le regole. Per favore ricarica.", "rules.readMore": "Leggi di più", diff --git a/backend/i18n/frontend_nl.json b/backend/i18n/frontend_nl.json index b6f81061c..572b47cc4 100644 --- a/backend/i18n/frontend_nl.json +++ b/backend/i18n/frontend_nl.json @@ -240,9 +240,11 @@ "common.delete": "Verwijderen", "common.description": "Beschrijving", "common.designer": "Designer", + "common.disabled": "Disabled", "common.displayName": "Weergavenaam", "common.edit": "Bewerken", "common.email": "E-mail", + "common.enabled": "Enabled", "common.error": "Fout", "common.errorBack": "Terug naar de vorige pagina.", "common.errorNoPermission": "Je hebt niet de permissies om dit te doen.", @@ -316,6 +318,7 @@ "common.restore": "Herstellen", "common.role": "Rol", "common.roles": "Rollen", + "common.rule": "Rule", "common.rules": "Regels", "common.sampleCodeLabel": "Voorbeeldcode bij", "common.save": "Opslaan", @@ -621,6 +624,7 @@ "rules.emptyAddRule": "Regel toevoegen", "rules.enableFailed": "Kan regel niet inschakelen. Laad opnieuw.", "rules.enqueued": "Regel is toegevoegd aan de wachtrij.", + "rules.itemPageTitle": "Rule", "rules.listPageTitle": "Regels", "rules.loadFailed": "Laden van regels is mislukt. Laad opnieuw.", "rules.readMore": "Lees meer", diff --git a/backend/i18n/source/frontend_en.json b/backend/i18n/source/frontend_en.json index ea09a2bcb..83d250a89 100644 --- a/backend/i18n/source/frontend_en.json +++ b/backend/i18n/source/frontend_en.json @@ -240,9 +240,11 @@ "common.delete": "Delete", "common.description": "Description", "common.designer": "Designer", + "common.disabled": "Disabled", "common.displayName": "Display Name", "common.edit": "Edit", "common.email": "Email", + "common.enabled": "Enabled", "common.error": "Error", "common.errorBack": "Back to previous page.", "common.errorNoPermission": "You do not have the permissions to do this.", @@ -316,6 +318,7 @@ "common.restore": "Restore", "common.role": "Role", "common.roles": "Roles", + "common.rule": "Rule", "common.rules": "Rules", "common.sampleCodeLabel": "Sample Code at", "common.save": "Save", @@ -621,6 +624,7 @@ "rules.emptyAddRule": "Add Rule", "rules.enableFailed": "Failed to enable rule. Please reload.", "rules.enqueued": "Rule has been added to the queue.", + "rules.itemPageTitle": "Rule", "rules.listPageTitle": "Rules", "rules.loadFailed": "Failed to load Rules. Please reload.", "rules.readMore": "Read More", diff --git a/backend/src/Squidex.Domain.Apps.Entities/Rules/Commands/RuleEditCommand.cs b/backend/src/Squidex.Domain.Apps.Entities/Rules/Commands/RuleEditCommand.cs index 38e778627..67de1a172 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Rules/Commands/RuleEditCommand.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Rules/Commands/RuleEditCommand.cs @@ -11,10 +11,12 @@ namespace Squidex.Domain.Apps.Entities.Rules.Commands { public abstract class RuleEditCommand : RuleCommand { + public string? Name { get; set; } + public RuleTrigger Trigger { get; set; } public RuleAction Action { get; set; } - public string? Name { get; set; } + public bool? IsEnabled { get; set; } } } diff --git a/backend/src/Squidex.Domain.Apps.Entities/Rules/DomainObject/RuleDomainObject.State.cs b/backend/src/Squidex.Domain.Apps.Entities/Rules/DomainObject/RuleDomainObject.State.cs index 26a95a1dc..ed88243ca 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Rules/DomainObject/RuleDomainObject.State.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Rules/DomainObject/RuleDomainObject.State.cs @@ -64,6 +64,15 @@ namespace Squidex.Domain.Apps.Entities.Rules.DomainObject RuleDef = RuleDef.Rename(e.Name); } + if (e.IsEnabled == true) + { + RuleDef = RuleDef.Enable(); + } + else + { + RuleDef = RuleDef.Disable(); + } + break; } diff --git a/backend/src/Squidex.Domain.Apps.Events/Rules/RuleUpdated.cs b/backend/src/Squidex.Domain.Apps.Events/Rules/RuleUpdated.cs index db798c2f3..13e4f93f8 100644 --- a/backend/src/Squidex.Domain.Apps.Events/Rules/RuleUpdated.cs +++ b/backend/src/Squidex.Domain.Apps.Events/Rules/RuleUpdated.cs @@ -14,11 +14,13 @@ namespace Squidex.Domain.Apps.Events.Rules [EventType(nameof(RuleUpdated))] public sealed class RuleUpdated : RuleEvent, IMigrated { - public RuleTrigger Trigger { get; set; } + public string? Name { get; set; } - public RuleAction Action { get; set; } + public RuleTrigger? Trigger { get; set; } - public string Name { get; set; } + public RuleAction? Action { get; set; } + + public bool? IsEnabled { get; set; } public IEvent Migrate() { diff --git a/backend/src/Squidex/Areas/Api/Controllers/Rules/Models/UpdateRuleDto.cs b/backend/src/Squidex/Areas/Api/Controllers/Rules/Models/UpdateRuleDto.cs index 257eedb9a..7c31717be 100644 --- a/backend/src/Squidex/Areas/Api/Controllers/Rules/Models/UpdateRuleDto.cs +++ b/backend/src/Squidex/Areas/Api/Controllers/Rules/Models/UpdateRuleDto.cs @@ -9,6 +9,7 @@ using Newtonsoft.Json; using Squidex.Domain.Apps.Core.Rules; using Squidex.Domain.Apps.Entities.Rules.Commands; using Squidex.Infrastructure; +using Squidex.Infrastructure.Reflection; namespace Squidex.Areas.Api.Controllers.Rules.Models { @@ -30,9 +31,14 @@ namespace Squidex.Areas.Api.Controllers.Rules.Models [JsonConverter(typeof(RuleActionConverter))] public RuleAction Action { get; set; } + /// + /// Enable or disable the rule. + /// + public bool? IsEnabled { get; set; } + public UpdateRule ToCommand(DomainId id) { - var command = new UpdateRule { RuleId = id, Action = Action, Name = Name }; + var command = SimpleMapper.Map(this, new UpdateRule { RuleId = id }); if (Trigger != null) { diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Apps/LanguagesConfigTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Apps/LanguagesConfigTests.cs index f7e26cd60..4ff224fa6 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Apps/LanguagesConfigTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Apps/LanguagesConfigTests.cs @@ -187,7 +187,7 @@ namespace Squidex.Domain.Apps.Core.Model.Apps } [Fact] - public void Should_remove_fallbacks_when_removing_language() + public void Should_remove_fallbacks_if_removing_language() { var config_1 = config_0.Set(Language.DE); var config_2 = config_1.Set(Language.IT, true, Language.UK); diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Contents/ContentDataTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Contents/ContentDataTests.cs index 13f091185..887832653 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Contents/ContentDataTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Contents/ContentDataTests.cs @@ -74,7 +74,7 @@ namespace Squidex.Domain.Apps.Core.Model.Contents } [Fact] - public void Should_be_equal_when_data_have_same_structure() + public void Should_be_equal_if_data_have_same_structure() { var lhs = new ContentData() @@ -100,7 +100,7 @@ namespace Squidex.Domain.Apps.Core.Model.Contents } [Fact] - public void Should_not_be_equal_when_data_have_not_same_structure() + public void Should_not_be_equal_if_data_have_not_same_structure() { var lhs = new ContentData() @@ -126,7 +126,7 @@ namespace Squidex.Domain.Apps.Core.Model.Contents } [Fact] - public void Should_be_equal_fields_when_they_have_same_value() + public void Should_be_equal_fields_if_they_have_same_value() { var lhs = new ContentFieldData() diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Rules/RuleTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Rules/RuleTests.cs index 5120d99a0..21ad9c1a5 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Rules/RuleTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Rules/RuleTests.cs @@ -78,7 +78,7 @@ namespace Squidex.Domain.Apps.Core.Model.Rules } [Fact] - public void Should_set_enabled_to_true_when_enabling() + public void Should_set_enabled_to_true_if_enabling() { var rule_1 = rule_0.Disable(); var rule_2 = rule_1.Enable(); @@ -95,7 +95,7 @@ namespace Squidex.Domain.Apps.Core.Model.Rules } [Fact] - public void Should_set_enabled_to_false_when_disabling() + public void Should_set_enabled_to_false_if_disabling() { var rule_1 = rule_0.Disable(); var rule_2 = rule_1.Disable(); @@ -109,7 +109,7 @@ namespace Squidex.Domain.Apps.Core.Model.Rules } [Fact] - public void Should_replace_name_when_renaming() + public void Should_replace_name_if_renaming() { var rule_1 = rule_0.Rename("MyName"); var rule_2 = rule_1.Rename("MyName"); @@ -122,7 +122,7 @@ namespace Squidex.Domain.Apps.Core.Model.Rules } [Fact] - public void Should_replace_trigger_when_updating() + public void Should_replace_trigger_if_updating() { var newTrigger1 = new ContentChangedTriggerV2 { HandleAll = true }; var newTrigger2 = new ContentChangedTriggerV2 { HandleAll = true }; @@ -138,13 +138,13 @@ namespace Squidex.Domain.Apps.Core.Model.Rules } [Fact] - public void Should_throw_exception_when_new_trigger_has_other_type() + public void Should_throw_exception_if_new_trigger_has_other_type() { Assert.Throws(() => rule_0.Update(new OtherTrigger())); } [Fact] - public void Should_replace_action_when_updating() + public void Should_replace_action_if_updating() { var newAction1 = new TestAction1 { Property = "NewValue" }; var newAction2 = new TestAction1 { Property = "NewValue" }; @@ -160,7 +160,7 @@ namespace Squidex.Domain.Apps.Core.Model.Rules } [Fact] - public void Should_throw_exception_when_new_action_has_other_type() + public void Should_throw_exception_if_new_action_has_other_type() { Assert.Throws(() => rule_0.Update(new TestAction2())); } diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Schemas/SchemaTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Schemas/SchemaTests.cs index 1cf602107..840bed795 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Schemas/SchemaTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Schemas/SchemaTests.cs @@ -366,7 +366,7 @@ namespace Squidex.Domain.Apps.Core.Model.Schemas } [Fact] - public void Should_also_set_list_fields_when_reordered() + public void Should_also_set_list_fields_if_reordered() { var schema_1 = schema_0.SetFieldsInLists("2", "1"); var schema_2 = schema_1.SetFieldsInLists("1", "2"); @@ -388,7 +388,7 @@ namespace Squidex.Domain.Apps.Core.Model.Schemas } [Fact] - public void Should_also_set_reference_fields_when_reordered() + public void Should_also_set_reference_fields_if_reordered() { var schema_1 = schema_0.SetFieldsInReferences("2", "1"); var schema_2 = schema_1.SetFieldsInReferences("1", "2"); diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ConvertContent/ContentConversionTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ConvertContent/ContentConversionTests.cs index a1389b30b..0fa04ce36 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ConvertContent/ContentConversionTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ConvertContent/ContentConversionTests.cs @@ -61,7 +61,7 @@ namespace Squidex.Domain.Apps.Core.Operations.ConvertContent } [Fact] - public void Should_be_equal_fields_when_they_have_same_value() + public void Should_be_equal_fields_if_they_have_same_value() { var lhs = new ContentFieldData() diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ConvertContent/FieldConvertersTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ConvertContent/FieldConvertersTests.cs index b92d1e385..ed75238c6 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ConvertContent/FieldConvertersTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ConvertContent/FieldConvertersTests.cs @@ -46,7 +46,7 @@ namespace Squidex.Domain.Apps.Core.Operations.ConvertContent } [Fact] - public void Should_return_field_data_when_excluding_changed_types_and_all_values_are_valid() + public void Should_return_field_data_if_excluding_changed_types_and_all_values_are_valid() { var field = Fields.Number(1, "number", Partitioning.Invariant); @@ -61,7 +61,7 @@ namespace Squidex.Domain.Apps.Core.Operations.ConvertContent } [Fact] - public void Should_return_null_when_excluding_changed_types_and_one_value_is_invalid() + public void Should_return_null_if_excluding_changed_types_and_one_value_is_invalid() { var field = Fields.Number(1, "number", Partitioning.Invariant); diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ConvertContent/ValueConvertersTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ConvertContent/ValueConvertersTests.cs index 032655651..fda05d303 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ConvertContent/ValueConvertersTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ConvertContent/ValueConvertersTests.cs @@ -73,7 +73,7 @@ namespace Squidex.Domain.Apps.Core.Operations.ConvertContent [Theory] [InlineData("other")] [InlineData("**")] - public void Should_not_convert_asset_ids_when_field_name_does_not_match(string path) + public void Should_not_convert_asset_ids_if_field_name_does_not_match(string path) { var field = Fields.Assets(1, "assets", Partitioning.Invariant); @@ -107,7 +107,7 @@ namespace Squidex.Domain.Apps.Core.Operations.ConvertContent [InlineData("parent")] [InlineData("parent.other")] [InlineData("other.assets")] - public void Should_not_convert_nested_asset_ids_when_field_name_does_not_match(string path) + public void Should_not_convert_nested_asset_ids_if_field_name_does_not_match(string path) { var field = Fields.Array(1, "parent", Partitioning.Invariant, Fields.Assets(11, "assets")); diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/DefaultValues/DefaultValuesTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/DefaultValues/DefaultValuesTests.cs index 30ac33562..3b00b0f5a 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/DefaultValues/DefaultValuesTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/DefaultValues/DefaultValuesTests.cs @@ -62,7 +62,7 @@ namespace Squidex.Domain.Apps.Core.Operations.DefaultValues } [Fact] - public void Should_not_enrich_with_default_values_when_string_is_empty() + public void Should_not_enrich_with_default_values_if_string_is_empty() { var data = new ContentData() @@ -90,7 +90,7 @@ namespace Squidex.Domain.Apps.Core.Operations.DefaultValues } [Fact] - public void Should_get_default_value_from_assets_field_when_set() + public void Should_get_default_value_from_assets_field_if_set() { var field = Fields.Assets(1, "1", Partitioning.Invariant, @@ -100,7 +100,7 @@ namespace Squidex.Domain.Apps.Core.Operations.DefaultValues } [Fact] - public void Should_get_default_value_from_assets_field_when_localized() + public void Should_get_default_value_from_assets_field_if_localized() { var field = Fields.Assets(1, "1", Partitioning.Invariant, @@ -127,7 +127,7 @@ namespace Squidex.Domain.Apps.Core.Operations.DefaultValues } [Fact] - public void Should_get_default_value_from_boolean_field_when_localized() + public void Should_get_default_value_from_boolean_field_if_localized() { var field = Fields.Boolean(1, "1", Partitioning.Invariant, @@ -154,7 +154,7 @@ namespace Squidex.Domain.Apps.Core.Operations.DefaultValues } [Fact] - public void Should_get_default_value_from_datetime_field_when_set_to_today() + public void Should_get_default_value_from_datetime_field_if_set_to_today() { var field = Fields.DateTime(1, "1", Partitioning.Invariant, @@ -164,7 +164,7 @@ namespace Squidex.Domain.Apps.Core.Operations.DefaultValues } [Fact] - public void Should_get_default_value_from_datetime_field_when_set_to_now() + public void Should_get_default_value_from_datetime_field_if_set_to_now() { var field = Fields.DateTime(1, "1", Partitioning.Invariant, @@ -174,7 +174,7 @@ namespace Squidex.Domain.Apps.Core.Operations.DefaultValues } [Fact] - public void Should_get_default_value_from_datetime_field_when_localized() + public void Should_get_default_value_from_datetime_field_if_localized() { var field = Fields.DateTime(1, "1", Partitioning.Invariant, @@ -221,7 +221,7 @@ namespace Squidex.Domain.Apps.Core.Operations.DefaultValues } [Fact] - public void Should_get_default_value_from_number_field_when_localized() + public void Should_get_default_value_from_number_field_if_localized() { var field = Fields.Number(1, "1", Partitioning.Invariant, @@ -248,7 +248,7 @@ namespace Squidex.Domain.Apps.Core.Operations.DefaultValues } [Fact] - public void Should_get_default_value_from_references_field_when_set() + public void Should_get_default_value_from_references_field_if_set() { var field = Fields.References(1, "1", Partitioning.Invariant, @@ -258,7 +258,7 @@ namespace Squidex.Domain.Apps.Core.Operations.DefaultValues } [Fact] - public void Should_get_default_value_from_references_field_when_localized() + public void Should_get_default_value_from_references_field_if_localized() { var field = Fields.References(1, "1", Partitioning.Invariant, @@ -285,7 +285,7 @@ namespace Squidex.Domain.Apps.Core.Operations.DefaultValues } [Fact] - public void Should_get_default_value_from_string_field_when_localized() + public void Should_get_default_value_from_string_field_if_localized() { var field = Fields.String(1, "1", Partitioning.Invariant, @@ -312,7 +312,7 @@ namespace Squidex.Domain.Apps.Core.Operations.DefaultValues } [Fact] - public void Should_get_default_value_from_tags_field_when_localized() + public void Should_get_default_value_from_tags_field_if_localized() { var field = Fields.Tags(1, "1", Partitioning.Invariant, diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ExtractReferenceIds/ReferenceExtractionTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ExtractReferenceIds/ReferenceExtractionTests.cs index 2615ee46b..d5e9cb17c 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ExtractReferenceIds/ReferenceExtractionTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ExtractReferenceIds/ReferenceExtractionTests.cs @@ -146,7 +146,7 @@ namespace Squidex.Domain.Apps.Core.Operations.ExtractReferenceIds [Theory] [MemberData(nameof(ReferencingFields))] - public void Should_return_empty_list_from_field_when_value_item_is_invalid(IField field) + public void Should_return_empty_list_from_field_if_value_item_is_invalid(IField field) { var result = field.GetReferencedIds(JsonValue.Array(1)).ToArray(); @@ -155,7 +155,7 @@ namespace Squidex.Domain.Apps.Core.Operations.ExtractReferenceIds [Theory] [MemberData(nameof(ReferencingFields))] - public void Should_return_empty_list_from_field_when_value_is_empty(IField field) + public void Should_return_empty_list_from_field_if_value_is_empty(IField field) { var result = field.GetReferencedIds(JsonValue.Array()).ToArray(); @@ -164,7 +164,7 @@ namespace Squidex.Domain.Apps.Core.Operations.ExtractReferenceIds [Theory] [MemberData(nameof(ReferencingFields))] - public void Should_return_empty_list_from_field_when_value_is_json_null(IField field) + public void Should_return_empty_list_from_field_if_value_is_json_null(IField field) { var result = field.GetReferencedIds(null).ToArray(); @@ -173,7 +173,7 @@ namespace Squidex.Domain.Apps.Core.Operations.ExtractReferenceIds [Theory] [MemberData(nameof(ReferencingFields))] - public void Should_return_empty_list_from_field_when_value_is_null(IField field) + public void Should_return_empty_list_from_field_if_value_is_null(IField field) { var result = field.GetReferencedIds(null).ToArray(); @@ -196,7 +196,7 @@ namespace Squidex.Domain.Apps.Core.Operations.ExtractReferenceIds [Theory] [MemberData(nameof(ReferencingFields))] - public void Should_return_same_value_from_field_when_value_is_json_null(IField field) + public void Should_return_same_value_from_field_if_value_is_json_null(IField field) { var result = ValueReferencesConverter.CleanReferences(RandomIds())(JsonValue.Null, field, null); diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/HandleRules/RuleEventFormatterCompareTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/HandleRules/RuleEventFormatterCompareTests.cs index 62df9157c..f1301abca 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/HandleRules/RuleEventFormatterCompareTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/HandleRules/RuleEventFormatterCompareTests.cs @@ -314,7 +314,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules "Download at {{event.id | assetContentUrl | default: 'null'}}" )] [InlineData("Liquid(Download at {{event | assetContentUrl | default: 'null'}})")] - public async Task Should_return_null_when_asset_content_url_not_found(string script) + public async Task Should_return_null_if_asset_content_url_not_found(string script) { var @event = new EnrichedContentEvent(); @@ -348,7 +348,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules "Download at {{event.id | assetContentAppUrl | default: 'null'}}" )] [InlineData("Liquid(Download at {{event | assetContentAppUrl | default: 'null'}})")] - public async Task Should_return_null_when_asset_content_app_url_not_found(string script) + public async Task Should_return_null_if_asset_content_app_url_not_found(string script) { var @event = new EnrichedContentEvent(); @@ -382,7 +382,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules "Download at {{event.id | assetContentSlugUrl | default: 'null'}}" )] [InlineData("Liquid(Download at {{event | assetContentSlugUrl | default: 'null'}})")] - public async Task Should_return_null_when_asset_content_slug_url_not_found(string script) + public async Task Should_return_null_if_asset_content_slug_url_not_found(string script) { var @event = new EnrichedContentEvent(); @@ -414,7 +414,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules "Go to ${contentUrl()}", "Go to {{event.id | contentUrl | default: 'null'}}" )] - public async Task Should_return_null_when_content_url_when_not_found(string script) + public async Task Should_return_null_if_content_url_if_not_found(string script) { var @event = new EnrichedAssetEvent(); @@ -430,7 +430,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules "${contentAction()}", "{{event.status}}" )] - public async Task Should_format_content_status_when_found(string script) + public async Task Should_format_content_status_if_found(string script) { var @event = new EnrichedContentEvent { Status = Status.Published }; @@ -446,7 +446,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules "${contentAction()}", "{{event.status | default: 'null'}}" )] - public async Task Should_return_null_when_content_status_not_found(string script) + public async Task Should_return_null_if_content_status_not_found(string script) { var @event = new EnrichedAssetEvent(); @@ -462,7 +462,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules "${event.type}", "{{event.type}}" )] - public async Task Should_format_content_actions_when_found(string script) + public async Task Should_format_content_actions_if_found(string script) { var @event = new EnrichedContentEvent { Type = EnrichedContentEventType.Created }; @@ -478,7 +478,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules "${contentAction()}", null )] - public async Task Should_return_null_when_content_action_not_found(string script) + public async Task Should_return_null_if_content_action_not_found(string script) { var @event = new EnrichedAssetEvent(); @@ -517,7 +517,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules "${event.data.country.iv}", "{{event.data.country.iv | default: 'null'}}" )] - public async Task Should_return_null_when_field_not_found(string script) + public async Task Should_return_null_if_field_not_found(string script) { var @event = new EnrichedContentEvent { @@ -540,7 +540,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules "${event.data.country.iv}", "{{event.data.country.iv | default: 'null'}}" )] - public async Task Should_return_null_when_partition_not_found(string script) + public async Task Should_return_null_if_partition_not_found(string script) { var @event = new EnrichedContentEvent { @@ -563,7 +563,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules "${event.data.country.iv[10]}", "{{event.data.country.iv[10] | default: 'null'}}" )] - public async Task Should_return_null_when_array_item_not_found(string script) + public async Task Should_return_null_if_array_item_not_found(string script) { var @event = new EnrichedContentEvent { @@ -586,7 +586,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules "${event.data.country.iv.Location}", "{{event.data.country.iv.Location | default: 'null'}}" )] - public async Task Should_return_null_when_property_not_found(string script) + public async Task Should_return_null_if_property_not_found(string script) { var @event = new EnrichedContentEvent { @@ -609,7 +609,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules "${event.data.city.iv}", "{{event.data.city.iv}}" )] - public async Task Should_return_plain_value_when_found(string script) + public async Task Should_return_plain_value_if_found(string script) { var @event = new EnrichedContentEvent { @@ -632,7 +632,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules "${event.data.city.iv[0]}", "{{event.data.city.iv[0]}}" )] - public async Task Should_return_plain_value_from_array_when_found(string script) + public async Task Should_return_plain_value_from_array_if_found(string script) { var @event = new EnrichedContentEvent { @@ -655,7 +655,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules "${event.data.city.iv.name}", "{{event.data.city.iv.name}}" )] - public async Task Should_return_plain_value_from_object_when_found(string script) + public async Task Should_return_plain_value_from_object_if_found(string script) { var @event = new EnrichedContentEvent { @@ -678,7 +678,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules "${JSON.stringify(event.data.city.iv)}", "{{event.data.city.iv}}" )] - public async Task Should_return_json_string_when_object(string script) + public async Task Should_return_json_string_if_object(string script) { var @event = new EnrichedContentEvent { @@ -701,7 +701,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules "${JSON.stringify(event.data.city.iv)}", "{{event.data.city.iv}}" )] - public async Task Should_return_json_string_when_array(string script) + public async Task Should_return_json_string_if_array(string script) { var @event = new EnrichedContentEvent { @@ -724,7 +724,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules "${JSON.stringify(event.data)}", null )] - public async Task Should_return_json_string_when_data(string script) + public async Task Should_return_json_string_if_data(string script) { var @event = new EnrichedContentEvent { @@ -778,7 +778,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules "${CONTENT_DATA.time.iv | timestamp}", null, "{{event.data.time.iv | timestamp}}")] - public async Task Should_return_timestamp_when_string(string script) + public async Task Should_return_timestamp_if_string(string script) { var @event = new EnrichedContentEvent { diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/HandleRules/RuleEventFormatterTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/HandleRules/RuleEventFormatterTests.cs index 24e2ff73a..ef0497ace 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/HandleRules/RuleEventFormatterTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/HandleRules/RuleEventFormatterTests.cs @@ -271,7 +271,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules } [Fact] - public async Task Should_return_json_string_when_array() + public async Task Should_return_json_string_if_array() { var @event = new EnrichedContentEvent { diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/HandleRules/RuleServiceTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/HandleRules/RuleServiceTests.cs index ade05dd7e..a43a20fe4 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/HandleRules/RuleServiceTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/HandleRules/RuleServiceTests.cs @@ -491,7 +491,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules } [Fact] - public async Task Should_return_succeeded_job_with_full_dump_when_handler_returns_no_exception() + public async Task Should_return_succeeded_job_with_full_dump_if_handler_returns_no_exception() { A.CallTo(() => ruleActionHandler.ExecuteJobAsync(A.That.Matches(x => x.Value == 10), A._)) .Returns(Result.Success(actionDump)); @@ -505,7 +505,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules } [Fact] - public async Task Should_return_failed_job_with_full_dump_when_handler_returns_exception() + public async Task Should_return_failed_job_with_full_dump_if_handler_returns_exception() { A.CallTo(() => ruleActionHandler.ExecuteJobAsync(A.That.Matches(x => x.Value == 10), A._)) .Returns(Result.Failed(new InvalidOperationException(), actionDump)); @@ -519,7 +519,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules } [Fact] - public async Task Should_return_timedout_job_with_full_dump_when_exception_from_handler_indicates_timeout() + public async Task Should_return_timedout_job_with_full_dump_if_exception_from_handler_indicates_timeout() { A.CallTo(() => ruleActionHandler.ExecuteJobAsync(A.That.Matches(x => x.Value == 10), A._)) .Returns(Result.Failed(new TimeoutException(), actionDump)); @@ -535,7 +535,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules } [Fact] - public async Task Should_create_exception_details_when_job_to_execute_failed() + public async Task Should_create_exception_details_if_job_to_execute_failed() { var ex = new InvalidOperationException(); diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/Scripting/ContentDataObjectTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/Scripting/ContentDataObjectTests.cs index 1125a8769..a50b19a69 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/Scripting/ContentDataObjectTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/Scripting/ContentDataObjectTests.cs @@ -17,7 +17,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting public class ContentDataObjectTests { [Fact] - public void Should_update_data_when_setting_field() + public void Should_update_data_if_setting_field() { var original = new ContentData(); @@ -33,7 +33,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting } [Fact] - public void Should_update_data_when_setting_lazy_field() + public void Should_update_data_if_setting_lazy_field() { var original = new ContentData(); @@ -65,7 +65,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting } [Fact] - public void Should_throw_exception_when_assigning_non_object_as_field() + public void Should_throw_exception_if_assigning_non_object_as_field() { var original = new ContentData(); @@ -73,7 +73,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting } [Fact] - public void Should_update_data_when_deleting_field() + public void Should_update_data_if_deleting_field() { var original = new ContentData() @@ -89,7 +89,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting } [Fact] - public void Should_update_data_when_setting_field_value_with_string() + public void Should_update_data_if_setting_field_value_with_string() { var original = new ContentData() @@ -109,7 +109,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting } [Fact] - public void Should_update_data_when_setting_field_value_with_number() + public void Should_update_data_if_setting_field_value_with_number() { var original = new ContentData() @@ -129,7 +129,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting } [Fact] - public void Should_update_data_when_setting_field_value_with_boolean() + public void Should_update_data_if_setting_field_value_with_boolean() { var original = new ContentData() @@ -149,7 +149,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting } [Fact] - public void Should_update_data_when_setting_field_value_with_array() + public void Should_update_data_if_setting_field_value_with_array() { var original = new ContentData() @@ -169,7 +169,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting } [Fact] - public void Should_update_data_when_setting_field_value_with_object() + public void Should_update_data_if_setting_field_value_with_object() { var original = new ContentData() @@ -189,7 +189,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting } [Fact] - public void Should_throw_when_defining_property_for_field() + public void Should_throw_if_defining_property_for_field() { var original = new ContentData() @@ -208,7 +208,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting } [Fact] - public void Should_update_data_when_deleting_field_value() + public void Should_update_data_if_deleting_field_value() { var original = new ContentData() @@ -259,7 +259,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting } [Fact] - public void Should_throw_exceptions_when_changing_objects() + public void Should_throw_exceptions_if_changing_objects() { var original = new ContentData() @@ -272,7 +272,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting } [Fact] - public void Should_not_throw_exceptions_when_changing_arrays() + public void Should_not_throw_exceptions_if_changing_arrays() { var original = new ContentData() diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/Scripting/JintScriptEngineHelperTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/Scripting/JintScriptEngineHelperTests.cs index 2bfd06608..9ed439965 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/Scripting/JintScriptEngineHelperTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/Scripting/JintScriptEngineHelperTests.cs @@ -185,7 +185,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting } [Fact] - public async Task Should_throw_validation_exception_when_calling_reject() + public async Task Should_throw_validation_exception_if_calling_reject() { const string script = @" reject() @@ -204,7 +204,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting } [Fact] - public async Task Should_throw_validation_exception_when_calling_reject_with_message() + public async Task Should_throw_validation_exception_if_calling_reject_with_message() { const string script = @" reject('Not valid') @@ -223,7 +223,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting } [Fact] - public async Task Should_throw_security_exception_when_calling_reject() + public async Task Should_throw_security_exception_if_calling_reject() { const string script = @" disallow() @@ -242,7 +242,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting } [Fact] - public async Task Should_throw_security_exception_when_calling_reject_with_message() + public async Task Should_throw_security_exception_if_calling_reject_with_message() { const string script = @" disallow('Operation not allowed') @@ -261,7 +261,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting } [Fact] - public async Task Should_throw_exception_when_getJson_url_is_null() + public async Task Should_throw_exception_if_getJson_url_is_null() { const string script = @" getJSON(null, function(result) { @@ -275,7 +275,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting } [Fact] - public async Task Should_throw_exception_when_getJson_callback_is_null() + public async Task Should_throw_exception_if_getJson_callback_is_null() { const string script = @" var url = 'http://squidex.io'; diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/Scripting/JintScriptEngineTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/Scripting/JintScriptEngineTests.cs index 5c1db4e66..362dd6124 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/Scripting/JintScriptEngineTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/Scripting/JintScriptEngineTests.cs @@ -85,7 +85,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting } [Fact] - public async Task TransformAsync_should_return_original_content_when_script_failed() + public async Task TransformAsync_should_return_original_content_if_script_failed() { var content = new ContentData(); var context = new ScriptVars { Data = content }; @@ -148,7 +148,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting } [Fact] - public async Task TransformAsync_should_throw_exception_when_script_failed() + public async Task TransformAsync_should_throw_exception_if_script_failed() { var content = new ContentData(); var context = new ScriptVars { Data = content }; @@ -161,7 +161,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting } [Fact] - public async Task TransformAsync_should_return_original_content_when_not_replaced() + public async Task TransformAsync_should_return_original_content_if_not_replaced() { var content = new ContentData(); var context = new ScriptVars { Data = content }; @@ -176,7 +176,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting } [Fact] - public async Task TransformAsync_should_return_original_content_when_not_replaced_async() + public async Task TransformAsync_should_return_original_content_if_not_replaced_async() { var content = new ContentData(); var context = new ScriptVars { Data = content }; @@ -254,7 +254,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting } [Fact] - public async Task TransformAsync_should_not_ignore_transformation_when_async_not_set() + public async Task TransformAsync_should_not_ignore_transformation_if_async_not_set() { var content = new ContentData(); var context = new ScriptVars { Data = content, Operation = "MyOperation" }; @@ -276,7 +276,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting } [Fact] - public async Task TransformAsync_should_timeout_when_replace_never_called() + public async Task TransformAsync_should_timeout_if_replace_never_called() { var content = new ContentData(); var context = new ScriptVars { Data = content, Operation = "MyOperation" }; @@ -372,7 +372,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting } [Fact] - public void Evaluate_should_return_true_when_expression_match() + public void Evaluate_should_return_true_if_expression_match() { const string script = @" value.i == 2 @@ -389,7 +389,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting } [Fact] - public void Evaluate_should_return_true_when_status_match() + public void Evaluate_should_return_true_if_status_match() { const string script = @" value.status == 'Published' @@ -406,7 +406,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting } [Fact] - public void Evaluate_should_return_false_when_expression_match() + public void Evaluate_should_return_false_if_expression_match() { const string script = @" value.i == 3 @@ -423,7 +423,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Scripting } [Fact] - public void Evaluate_should_return_false_when_script_is_invalid() + public void Evaluate_should_return_false_if_script_is_invalid() { const string script = @" function(); diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/Templates/FluidTemplateEngineTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/Templates/FluidTemplateEngineTests.cs index 1f9abb9c9..adac6fdad 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/Templates/FluidTemplateEngineTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/Templates/FluidTemplateEngineTests.cs @@ -191,7 +191,7 @@ namespace Squidex.Domain.Apps.Core.Operations.Templates } [Fact] - public async Task Should_throw_exception_when_template_invalid() + public async Task Should_throw_exception_if_template_invalid() { var template = "{% for x of event %}"; diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/PatternValidatorTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/PatternValidatorTests.cs index 5e22a47ca..40578abf6 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/PatternValidatorTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/PatternValidatorTests.cs @@ -71,7 +71,7 @@ namespace Squidex.Domain.Apps.Core.Operations.ValidateContent.Validators } [Fact] - public async Task Should_add_timeout_error_when_regex_is_too_slow() + public async Task Should_add_timeout_error_if_regex_is_too_slow() { var sut = new PatternValidator(@"^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$"); diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/AppUISettingsTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/AppUISettingsTests.cs index d36bac0e0..191d80b65 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/AppUISettingsTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/AppUISettingsTests.cs @@ -30,7 +30,7 @@ namespace Squidex.Domain.Apps.Entities.Apps } [Fact] - public async Task Should_call_grain_when_retrieving_settings() + public async Task Should_call_grain_if_retrieving_settings() { var settings = JsonValue.Object(); @@ -43,7 +43,7 @@ namespace Squidex.Domain.Apps.Entities.Apps } [Fact] - public async Task Should_call_grain_when_setting_value() + public async Task Should_call_grain_if_setting_value() { var value = JsonValue.Object(); @@ -54,7 +54,7 @@ namespace Squidex.Domain.Apps.Entities.Apps } [Fact] - public async Task Should_call_grain_when_replacing_settings() + public async Task Should_call_grain_if_replacing_settings() { var value = JsonValue.Object(); @@ -65,7 +65,7 @@ namespace Squidex.Domain.Apps.Entities.Apps } [Fact] - public async Task Should_call_grain_when_removing_value() + public async Task Should_call_grain_if_removing_value() { await sut.RemoveAsync(DomainId.NewGuid(), "user", "the.path"); diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/BackupAppsTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/BackupAppsTests.cs index 6d428070d..c4f2e342d 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/BackupAppsTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/BackupAppsTests.cs @@ -103,7 +103,7 @@ namespace Squidex.Domain.Apps.Entities.Apps } [Fact] - public async Task Should_throw_exception_when_no_reservation_token_returned() + public async Task Should_throw_exception_if_no_reservation_token_returned() { const string appName = "my-app"; @@ -122,7 +122,7 @@ namespace Squidex.Domain.Apps.Entities.Apps } [Fact] - public async Task Should_not_cleanup_reservation_when_no_reservation_token_hold() + public async Task Should_not_cleanup_reservation_if_no_reservation_token_hold() { await sut.CleanupRestoreErrorAsync(appId); @@ -163,7 +163,7 @@ namespace Squidex.Domain.Apps.Entities.Apps } [Fact] - public async Task Should_map_contributor_id_when_assigned() + public async Task Should_map_contributor_id_if_assigned() { var context = CreateRestoreContext(); @@ -179,7 +179,7 @@ namespace Squidex.Domain.Apps.Entities.Apps } [Fact] - public async Task Should_ignore_contributor_event_when_assigned_user_not_mapped() + public async Task Should_ignore_contributor_event_if_assigned_user_not_mapped() { var context = CreateRestoreContext(); @@ -195,7 +195,7 @@ namespace Squidex.Domain.Apps.Entities.Apps } [Fact] - public async Task Should_map_contributor_id_when_revoked() + public async Task Should_map_contributor_id_if_revoked() { var context = CreateRestoreContext(); @@ -211,7 +211,7 @@ namespace Squidex.Domain.Apps.Entities.Apps } [Fact] - public async Task Should_ignore_contributor_event_when_removed_user_not_mapped() + public async Task Should_ignore_contributor_event_if_removed_user_not_mapped() { var context = CreateRestoreContext(); @@ -227,7 +227,7 @@ namespace Squidex.Domain.Apps.Entities.Apps } [Fact] - public async Task Should_ignore_exception_when_app_image_to_backup_does_not_exist() + public async Task Should_ignore_exception_if_app_image_to_backup_does_not_exist() { var imageStream = new MemoryStream(); @@ -275,7 +275,7 @@ namespace Squidex.Domain.Apps.Entities.Apps } [Fact] - public async Task Should_ignore_exception_when_app_image_cannot_be_overriden() + public async Task Should_ignore_exception_if_app_image_cannot_be_overriden() { var imageStream = new MemoryStream(); diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/DomainObject/AppCommandMiddlewareTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/DomainObject/AppCommandMiddlewareTests.cs index 4d1e8523b..5b03b2ca4 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/DomainObject/AppCommandMiddlewareTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/DomainObject/AppCommandMiddlewareTests.cs @@ -75,7 +75,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.DomainObject } [Fact] - public async Task Should_throw_exception_when_file_to_upload_is_not_an_image() + public async Task Should_throw_exception_if_file_to_upload_is_not_an_image() { var file = new NoopAssetFile(); diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/Indexes/AppsIndexTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/Indexes/AppsIndexTests.cs index 249914d99..c3b02bbea 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/Indexes/AppsIndexTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/Indexes/AppsIndexTests.cs @@ -218,7 +218,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.Indexes } [Fact] - public async Task Should_add_app_to_indexes_when_creating() + public async Task Should_add_app_to_indexes_if_creating() { var token = RandomHash.Simple(); @@ -273,7 +273,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.Indexes } [Fact] - public async Task Should_clear_reservation_when_app_creation_failed() + public async Task Should_clear_reservation_if_app_creation_failed() { var token = RandomHash.Simple(); @@ -298,7 +298,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.Indexes } [Fact] - public async Task Should_not_add_to_indexes_when_name_is_taken() + public async Task Should_not_add_to_indexes_if_name_is_taken() { A.CallTo(() => indexByName.ReserveAsync(appId.Id, appId.Name)) .Returns(Task.FromResult(null)); @@ -322,7 +322,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.Indexes } [Fact] - public async Task Should_not_add_to_indexes_when_name_is_invalid() + public async Task Should_not_add_to_indexes_if_name_is_invalid() { var command = Create("INVALID"); @@ -343,7 +343,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.Indexes } [Fact] - public async Task Should_add_app_to_index_when_contributor_assigned() + public async Task Should_add_app_to_index_if_contributor_assigned() { CreateApp(); @@ -360,7 +360,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.Indexes } [Fact] - public async Task Should_update_index_when_app_is_updated() + public async Task Should_update_index_if_app_is_updated() { var (_, appGrain) = CreateApp(); @@ -377,7 +377,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.Indexes } [Fact] - public async Task Should_update_index_with_result_when_app_is_updated() + public async Task Should_update_index_with_result_if_app_is_updated() { var (app, appGrain) = CreateApp(); @@ -394,7 +394,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.Indexes } [Fact] - public async Task Should_remove_from_user_index_when_contributor_removed() + public async Task Should_remove_from_user_index_if_contributor_removed() { CreateApp(); @@ -411,7 +411,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.Indexes } [Fact] - public async Task Should_remove_app_from_indexes_when_app_gets_archived() + public async Task Should_remove_app_from_indexes_if_app_gets_archived() { CreateApp(isArchived: true); @@ -431,7 +431,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.Indexes } [Fact] - public async Task Should_also_remove_app_from_client_index_when_created_by_client() + public async Task Should_also_remove_app_from_client_index_if_created_by_client() { CreateApp(fromClient: true); @@ -454,7 +454,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.Indexes } [Fact] - public async Task Should_forward_call_when_rebuilding_for_contributors1() + public async Task Should_forward_call_if_rebuilding_for_contributors1() { var apps = new HashSet(); @@ -465,7 +465,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.Indexes } [Fact] - public async Task Should_forward_call_when_rebuilding_for_contributors2() + public async Task Should_forward_call_if_rebuilding_for_contributors2() { var users = new HashSet { userId }; @@ -476,7 +476,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.Indexes } [Fact] - public async Task Should_forward_call_when_rebuilding() + public async Task Should_forward_call_if_rebuilding() { var apps = new Dictionary(); diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/Plans/NoopAppPlanBillingManagerTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/Plans/NoopAppPlanBillingManagerTests.cs index 392a50b2d..6d6baf3e1 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/Plans/NoopAppPlanBillingManagerTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/Plans/NoopAppPlanBillingManagerTests.cs @@ -21,7 +21,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.Plans } [Fact] - public async Task Should_do_nothing_when_changing_plan() + public async Task Should_do_nothing_if_changing_plan() { await sut.ChangePlanAsync(null!, null!, null, null); } diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/AssetChangedTriggerHandlerTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/AssetChangedTriggerHandlerTests.cs index 8db66cf86..5e7d9d780 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/AssetChangedTriggerHandlerTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/AssetChangedTriggerHandlerTests.cs @@ -100,7 +100,7 @@ namespace Squidex.Domain.Apps.Entities.Assets } [Fact] - public void Should_not_trigger_precheck_when_event_type_not_correct() + public void Should_not_trigger_precheck_if_event_type_not_correct() { TestForCondition(string.Empty, trigger => { @@ -111,7 +111,7 @@ namespace Squidex.Domain.Apps.Entities.Assets } [Fact] - public void Should_trigger_precheck_when_event_type_correct() + public void Should_trigger_precheck_if_event_type_correct() { TestForCondition(string.Empty, trigger => { @@ -122,7 +122,7 @@ namespace Squidex.Domain.Apps.Entities.Assets } [Fact] - public void Should_not_trigger_check_when_event_type_not_correct() + public void Should_not_trigger_check_if_event_type_not_correct() { TestForCondition(string.Empty, trigger => { @@ -133,7 +133,7 @@ namespace Squidex.Domain.Apps.Entities.Assets } [Fact] - public void Should_trigger_check_when_condition_is_empty() + public void Should_trigger_check_if_condition_is_empty() { TestForCondition(string.Empty, trigger => { @@ -144,7 +144,7 @@ namespace Squidex.Domain.Apps.Entities.Assets } [Fact] - public void Should_trigger_check_when_condition_matchs() + public void Should_trigger_check_if_condition_matchs() { TestForCondition("true", trigger => { @@ -155,7 +155,7 @@ namespace Squidex.Domain.Apps.Entities.Assets } [Fact] - public void Should_not_trigger_check_when_condition_does_not_matchs() + public void Should_not_trigger_check_if_condition_does_not_matchs() { TestForCondition("false", trigger => { diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/AssetPermanentDeleterTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/AssetPermanentDeleterTests.cs index 08e7f50e3..1e47ac5e5 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/AssetPermanentDeleterTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/AssetPermanentDeleterTests.cs @@ -55,7 +55,7 @@ namespace Squidex.Domain.Apps.Entities.Assets } [Fact] - public async Task Should_not_delete_assets_when_event_restored() + public async Task Should_not_delete_assets_if_event_restored() { var @event = new AssetDeleted { AppId = appId, AssetId = DomainId.NewGuid() }; diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/AssetUsageTrackerTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/AssetUsageTrackerTests.cs index 28a64acf1..5874bfe22 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/AssetUsageTrackerTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/AssetUsageTrackerTests.cs @@ -126,7 +126,7 @@ namespace Squidex.Domain.Apps.Entities.Assets [Theory] [MemberData(nameof(EventData))] - public async Task Should_increase_usage_when_asset_created(AssetEvent @event, long sizeDiff, long countDiff) + public async Task Should_increase_usage_if_asset_created(AssetEvent @event, long sizeDiff, long countDiff) { var date = DateTime.UtcNow.Date.AddDays(13); diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/DomainObject/AssetDomainObjectTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/DomainObject/AssetDomainObjectTests.cs index 22cc1a1f5..7b580290b 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/DomainObject/AssetDomainObjectTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/DomainObject/AssetDomainObjectTests.cs @@ -110,7 +110,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.DomainObject } [Fact] - public async Task Upsert_should_create_events_and_set_intitial_state_when_not_found() + public async Task Upsert_should_create_events_and_set_intitial_state_if_not_found() { var command = new UpsertAsset { File = file, FileHash = "NewHash" }; @@ -138,7 +138,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.DomainObject } [Fact] - public async Task Upsert_should_create_events_and_update_file_state_when_found() + public async Task Upsert_should_create_events_and_update_file_state_if_found() { var command = new UpsertAsset { File = file, FileHash = "NewHash" }; diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/DomainObject/AssetsBulkUpdateCommandMiddlewareTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/DomainObject/AssetsBulkUpdateCommandMiddlewareTests.cs index 9bc1733dd..7d5f14d73 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/DomainObject/AssetsBulkUpdateCommandMiddlewareTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/DomainObject/AssetsBulkUpdateCommandMiddlewareTests.cs @@ -70,7 +70,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.DomainObject } [Fact] - public async Task Should_throw_security_exception_when_user_has_no_permission_for_annotating() + public async Task Should_throw_security_exception_if_user_has_no_permission_for_annotating() { SetupContext(Permissions.AppAssetsRead); @@ -106,7 +106,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.DomainObject } [Fact] - public async Task Should_throw_security_exception_when_user_has_no_permission_for_moving() + public async Task Should_throw_security_exception_if_user_has_no_permission_for_moving() { SetupContext(Permissions.AppAssetsRead); @@ -143,7 +143,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.DomainObject } [Fact] - public async Task Should_throw_security_exception_when_user_has_no_permission_for_deletion() + public async Task Should_throw_security_exception_if_user_has_no_permission_for_deletion() { SetupContext(Permissions.AppAssetsRead); diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/DomainObject/Guards/GuardAssetFolderTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/DomainObject/Guards/GuardAssetFolderTests.cs index bd77792c9..f87975bf8 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/DomainObject/Guards/GuardAssetFolderTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/DomainObject/Guards/GuardAssetFolderTests.cs @@ -23,7 +23,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.DomainObject.Guards private readonly NamedId appId = NamedId.Of(DomainId.NewGuid(), "my-app"); [Fact] - public async Task CanCreate_should_throw_exception_when_folder_name_not_defined() + public async Task CanCreate_should_throw_exception_if_folder_name_not_defined() { var command = new CreateAssetFolder { AppId = appId }; @@ -35,7 +35,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.DomainObject.Guards } [Fact] - public async Task CanCreate_should_throw_exception_when_folder_not_found() + public async Task CanCreate_should_throw_exception_if_folder_not_found() { var command = new CreateAssetFolder { AppId = appId, FolderName = "My Folder", ParentId = DomainId.NewGuid() }; @@ -47,7 +47,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.DomainObject.Guards } [Fact] - public async Task CanCreate_should_not_throw_exception_when_folder_found() + public async Task CanCreate_should_not_throw_exception_if_folder_found() { var command = new CreateAssetFolder { AppId = appId, FolderName = "My Folder", ParentId = DomainId.NewGuid() }; @@ -58,7 +58,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.DomainObject.Guards } [Fact] - public async Task CanCreate_should_not_throw_exception_when_added_to_root() + public async Task CanCreate_should_not_throw_exception_if_added_to_root() { var command = new CreateAssetFolder { AppId = appId, FolderName = "My Folder" }; @@ -66,7 +66,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.DomainObject.Guards } [Fact] - public async Task CanMove_should_throw_exception_when_adding_to_its_own_child() + public async Task CanMove_should_throw_exception_if_adding_to_its_own_child() { var id = DomainId.NewGuid(); @@ -84,7 +84,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.DomainObject.Guards } [Fact] - public async Task CanMove_should_throw_exception_when_folder_not_found() + public async Task CanMove_should_throw_exception_if_folder_not_found() { var command = new MoveAssetFolder { AppId = appId, ParentId = DomainId.NewGuid() }; @@ -96,7 +96,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.DomainObject.Guards } [Fact] - public async Task CanMove_should_not_throw_exception_when_folder_found() + public async Task CanMove_should_not_throw_exception_if_folder_found() { var command = new MoveAssetFolder { AppId = appId, ParentId = DomainId.NewGuid() }; @@ -107,7 +107,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.DomainObject.Guards } [Fact] - public async Task CanMove_should_not_throw_exception_when_folder_has_not_changed() + public async Task CanMove_should_not_throw_exception_if_folder_has_not_changed() { var command = new MoveAssetFolder { AppId = appId, ParentId = DomainId.NewGuid() }; @@ -115,7 +115,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.DomainObject.Guards } [Fact] - public async Task CanMove_should_not_throw_exception_when_added_to_root() + public async Task CanMove_should_not_throw_exception_if_added_to_root() { var command = new MoveAssetFolder { AppId = appId }; diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/DomainObject/Guards/GuardAssetTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/DomainObject/Guards/GuardAssetTests.cs index db5c05ec8..5f44484f9 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/DomainObject/Guards/GuardAssetTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/DomainObject/Guards/GuardAssetTests.cs @@ -26,7 +26,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.DomainObject.Guards private readonly NamedId appId = NamedId.Of(DomainId.NewGuid(), "my-app"); [Fact] - public async Task CanMove_should_throw_exception_when_folder_not_found() + public async Task CanMove_should_throw_exception_if_folder_not_found() { var parentId = DomainId.NewGuid(); @@ -40,7 +40,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.DomainObject.Guards } [Fact] - public async Task CanMove_should_not_throw_exception_when_folder_not_found_but_optimized() + public async Task CanMove_should_not_throw_exception_if_folder_not_found_but_optimized() { var parentId = DomainId.NewGuid(); @@ -53,7 +53,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.DomainObject.Guards } [Fact] - public async Task CanMove_should_not_throw_exception_when_folder_found() + public async Task CanMove_should_not_throw_exception_if_folder_found() { var parentId = DomainId.NewGuid(); @@ -66,7 +66,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.DomainObject.Guards } [Fact] - public async Task CanMove_should_not_throw_exception_when_folder_has_not_changed() + public async Task CanMove_should_not_throw_exception_if_folder_has_not_changed() { var parentId = DomainId.NewGuid(); @@ -76,7 +76,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.DomainObject.Guards } [Fact] - public async Task CanMove_should_not_throw_exception_when_added_to_root() + public async Task CanMove_should_not_throw_exception_if_added_to_root() { var command = new MoveAsset { AppId = appId }; diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/Queries/AssetQueryParserTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/Queries/AssetQueryParserTests.cs index c8db0392d..bc0c668b2 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/Queries/AssetQueryParserTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/Queries/AssetQueryParserTests.cs @@ -35,7 +35,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.Queries } [Fact] - public async Task Should_skip_total_when_set_in_context() + public async Task Should_skip_total_if_set_in_context() { var q = await sut.ParseAsync(requestContext.Clone(b => b.WithoutTotal()), Q.Empty); @@ -142,7 +142,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.Queries } [Fact] - public async Task Should_not_fail_when_tags_not_found() + public async Task Should_not_fail_if_tags_not_found() { A.CallTo(() => tagService.GetTagIdsAsync(appId.Id, TagGroups.Assets, A>.That.Contains("name1"))) .Returns(new Dictionary()); diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/RecursiveDeleterTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/RecursiveDeleterTests.cs index 8d003c967..21118de20 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/RecursiveDeleterTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/RecursiveDeleterTests.cs @@ -62,7 +62,7 @@ namespace Squidex.Domain.Apps.Entities.Assets } [Fact] - public async Task Should_Not_invoke_delete_commands_when_event_restored() + public async Task Should_Not_invoke_delete_commands_if_event_restored() { var @event = new AssetFolderDeleted { AppId = appId, AssetFolderId = DomainId.NewGuid() }; diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Backup/BackupServiceTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Backup/BackupServiceTests.cs index e080f53b5..1dfe1bf31 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Backup/BackupServiceTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Backup/BackupServiceTests.cs @@ -31,7 +31,7 @@ namespace Squidex.Domain.Apps.Entities.Backup } [Fact] - public async Task Should_call_grain_when_restoring_backup() + public async Task Should_call_grain_if_restoring_backup() { var grain = A.Fake(); diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Comments/CommentTriggerHandlerTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Comments/CommentTriggerHandlerTests.cs index 4971467da..a52874ef0 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Comments/CommentTriggerHandlerTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Comments/CommentTriggerHandlerTests.cs @@ -45,7 +45,7 @@ namespace Squidex.Domain.Apps.Entities.Comments } [Fact] - public void Should_return_false_when_asking_for_snapshot_support() + public void Should_return_false_if_asking_for_snapshot_support() { Assert.False(sut.CanCreateSnapshotEvents); } @@ -78,7 +78,7 @@ namespace Squidex.Domain.Apps.Entities.Comments } [Fact] - public async Task Should_not_create_enriched_events_when_users_cannot_be_resolved() + public async Task Should_not_create_enriched_events_if_users_cannot_be_resolved() { var user1 = UserMocks.User("1"); var user2 = UserMocks.User("2"); @@ -94,7 +94,7 @@ namespace Squidex.Domain.Apps.Entities.Comments } [Fact] - public async Task Should_not_create_enriched_events_when_mentions_is_null() + public async Task Should_not_create_enriched_events_if_mentions_is_null() { var envelope = Envelope.Create(new CommentCreated { Mentions = null }); @@ -107,7 +107,7 @@ namespace Squidex.Domain.Apps.Entities.Comments } [Fact] - public async Task Should_not_create_enriched_events_when_mentions_is_empty() + public async Task Should_not_create_enriched_events_if_mentions_is_empty() { var envelope = Envelope.Create(new CommentCreated { Mentions = Array.Empty() }); @@ -146,7 +146,7 @@ namespace Squidex.Domain.Apps.Entities.Comments } [Fact] - public void Should_not_trigger_precheck_when_event_type_not_correct() + public void Should_not_trigger_precheck_if_event_type_not_correct() { TestForCondition(string.Empty, trigger => { @@ -157,7 +157,7 @@ namespace Squidex.Domain.Apps.Entities.Comments } [Fact] - public void Should_trigger_precheck_when_event_type_correct() + public void Should_trigger_precheck_if_event_type_correct() { TestForCondition(string.Empty, trigger => { @@ -168,7 +168,7 @@ namespace Squidex.Domain.Apps.Entities.Comments } [Fact] - public void Should_not_trigger_check_when_event_type_not_correct() + public void Should_not_trigger_check_if_event_type_not_correct() { TestForCondition(string.Empty, trigger => { @@ -179,7 +179,7 @@ namespace Squidex.Domain.Apps.Entities.Comments } [Fact] - public void Should_trigger_check_when_condition_is_empty() + public void Should_trigger_check_if_condition_is_empty() { TestForCondition(string.Empty, trigger => { @@ -190,7 +190,7 @@ namespace Squidex.Domain.Apps.Entities.Comments } [Fact] - public void Should_trigger_check_when_condition_matchs() + public void Should_trigger_check_if_condition_matchs() { TestForCondition("true", trigger => { @@ -201,7 +201,7 @@ namespace Squidex.Domain.Apps.Entities.Comments } [Fact] - public void Should_not_trigger_check_when_condition_does_not_matchs() + public void Should_not_trigger_check_if_condition_does_not_matchs() { TestForCondition("false", trigger => { @@ -212,7 +212,7 @@ namespace Squidex.Domain.Apps.Entities.Comments } [Fact] - public void Should_trigger_check_when_email_is_correct() + public void Should_trigger_check_if_email_is_correct() { TestForRealCondition("event.mentionedUser.email == '1@email.com'", (handler, trigger) => { @@ -225,7 +225,7 @@ namespace Squidex.Domain.Apps.Entities.Comments } [Fact] - public void Should_not_trigger_check_when_email_is_correct() + public void Should_not_trigger_check_if_email_is_correct() { TestForRealCondition("event.mentionedUser.email == 'other@squidex.io'", (handler, trigger) => { @@ -238,7 +238,7 @@ namespace Squidex.Domain.Apps.Entities.Comments } [Fact] - public void Should_trigger_check_when_text_is_urgent() + public void Should_trigger_check_if_text_is_urgent() { TestForRealCondition("event.text.indexOf('urgent') >= 0", (handler, trigger) => { @@ -251,7 +251,7 @@ namespace Squidex.Domain.Apps.Entities.Comments } [Fact] - public void Should_not_trigger_check_when_text_is_not_urgent() + public void Should_not_trigger_check_if_text_is_not_urgent() { TestForRealCondition("event.text.indexOf('urgent') >= 0", (handler, trigger) => { diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/ContentChangedTriggerHandlerTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/ContentChangedTriggerHandlerTests.cs index 6aa8035be..38d6f0eaf 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/ContentChangedTriggerHandlerTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/ContentChangedTriggerHandlerTests.cs @@ -60,7 +60,7 @@ namespace Squidex.Domain.Apps.Entities.Contents } [Fact] - public void Should_return_true_when_asking_for_snapshot_support() + public void Should_return_true_if_asking_for_snapshot_support() { Assert.True(sut.CanCreateSnapshotEvents); } @@ -134,7 +134,7 @@ namespace Squidex.Domain.Apps.Entities.Contents } [Fact] - public async Task Should_enrich_with_old_data_when_updated() + public async Task Should_enrich_with_old_data_if_updated() { var @event = new ContentUpdated { AppId = appId, ContentId = DomainId.NewGuid(), SchemaId = schemaMatch }; @@ -158,7 +158,7 @@ namespace Squidex.Domain.Apps.Entities.Contents } [Fact] - public void Should_not_trigger_precheck_when_event_type_not_correct() + public void Should_not_trigger_precheck_if_event_type_not_correct() { TestForTrigger(handleAll: true, schemaId: null, condition: null, action: trigger => { @@ -169,7 +169,7 @@ namespace Squidex.Domain.Apps.Entities.Contents } [Fact] - public void Should_not_trigger_precheck_when_trigger_contains_no_schemas() + public void Should_not_trigger_precheck_if_trigger_contains_no_schemas() { TestForTrigger(handleAll: false, schemaId: null, condition: null, action: trigger => { @@ -180,7 +180,7 @@ namespace Squidex.Domain.Apps.Entities.Contents } [Fact] - public void Should_trigger_precheck_when_handling_all_events() + public void Should_trigger_precheck_if_handling_all_events() { TestForTrigger(handleAll: true, schemaId: schemaMatch, condition: null, action: trigger => { @@ -191,7 +191,7 @@ namespace Squidex.Domain.Apps.Entities.Contents } [Fact] - public void Should_trigger_precheck_when_condition_is_empty() + public void Should_trigger_precheck_if_condition_is_empty() { TestForTrigger(handleAll: false, schemaId: schemaMatch, condition: string.Empty, action: trigger => { @@ -202,7 +202,7 @@ namespace Squidex.Domain.Apps.Entities.Contents } [Fact] - public void Should_not_trigger_precheck_when_schema_id_does_not_match() + public void Should_not_trigger_precheck_if_schema_id_does_not_match() { TestForTrigger(handleAll: false, schemaId: schemaNonMatch, condition: null, action: trigger => { @@ -213,7 +213,7 @@ namespace Squidex.Domain.Apps.Entities.Contents } [Fact] - public void Should_not_trigger_check_when_event_type_not_correct() + public void Should_not_trigger_check_if_event_type_not_correct() { TestForTrigger(handleAll: true, schemaId: null, condition: null, action: trigger => { @@ -224,7 +224,7 @@ namespace Squidex.Domain.Apps.Entities.Contents } [Fact] - public void Should_not_trigger_check_when_trigger_contains_no_schemas() + public void Should_not_trigger_check_if_trigger_contains_no_schemas() { TestForTrigger(handleAll: false, schemaId: null, condition: null, action: trigger => { @@ -235,7 +235,7 @@ namespace Squidex.Domain.Apps.Entities.Contents } [Fact] - public void Should_trigger_check_when_handling_all_events() + public void Should_trigger_check_if_handling_all_events() { TestForTrigger(handleAll: true, schemaId: schemaMatch, condition: null, action: trigger => { @@ -246,7 +246,7 @@ namespace Squidex.Domain.Apps.Entities.Contents } [Fact] - public void Should_trigger_check_when_condition_is_empty() + public void Should_trigger_check_if_condition_is_empty() { TestForTrigger(handleAll: false, schemaId: schemaMatch, condition: string.Empty, action: trigger => { @@ -257,7 +257,7 @@ namespace Squidex.Domain.Apps.Entities.Contents } [Fact] - public void Should_trigger_check_when_condition_matchs() + public void Should_trigger_check_if_condition_matchs() { TestForTrigger(handleAll: false, schemaId: schemaMatch, condition: "true", action: trigger => { @@ -268,7 +268,7 @@ namespace Squidex.Domain.Apps.Entities.Contents } [Fact] - public void Should_not_trigger_check_when_schema_id_does_not_match() + public void Should_not_trigger_check_if_schema_id_does_not_match() { TestForTrigger(handleAll: false, schemaId: schemaNonMatch, condition: null, action: trigger => { @@ -279,7 +279,7 @@ namespace Squidex.Domain.Apps.Entities.Contents } [Fact] - public void Should_not_trigger_check_when_condition_does_not_matchs() + public void Should_not_trigger_check_if_condition_does_not_matchs() { TestForTrigger(handleAll: false, schemaId: schemaMatch, condition: "false", action: trigger => { diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/DomainObject/ContentDomainObjectTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/DomainObject/ContentDomainObjectTests.cs index d58ff451d..568fdfb12 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/DomainObject/ContentDomainObjectTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/DomainObject/ContentDomainObjectTests.cs @@ -155,7 +155,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject } [Fact] - public async Task Create_should_not_change_status_when_set_to_initial() + public async Task Create_should_not_change_status_if_set_to_initial() { var command = new CreateContent { Data = data, Status = Status.Draft }; @@ -178,7 +178,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject } [Fact] - public async Task Create_should_change_status_when_set() + public async Task Create_should_change_status_if_set() { var command = new CreateContent { Data = data, Status = Status.Archived }; @@ -224,7 +224,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject } [Fact] - public async Task Create_should_throw_exception_when_invalid_data_is_passed() + public async Task Create_should_throw_exception_if_invalid_data_is_passed() { var command = new CreateContent { Data = invalidData }; @@ -232,7 +232,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject } [Fact] - public async Task Upsert_should_create_content_when_not_found() + public async Task Upsert_should_create_content_if_not_found() { var command = new UpsertContent { Data = data }; @@ -255,7 +255,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject } [Fact] - public async Task Upsert_should_not_change_status_on_create_when_status_set_to_initial() + public async Task Upsert_should_not_change_status_on_create_if_status_set_to_initial() { var command = new UpsertContent { Data = data }; @@ -278,7 +278,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject } [Fact] - public async Task Upsert_should_change_status_on_create_when_status_set() + public async Task Upsert_should_change_status_on_create_if_status_set() { var command = new UpsertContent { Data = data, Status = Status.Archived }; @@ -302,7 +302,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject } [Fact] - public async Task Upsert_should_update_content_when_found() + public async Task Upsert_should_update_content_if_found() { var command = new UpsertContent { Data = otherData }; @@ -324,7 +324,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject } [Fact] - public async Task Upsert_should_not_change_status_on_update_when_status_set_to_initial() + public async Task Upsert_should_not_change_status_on_update_if_status_set_to_initial() { var command = new UpsertContent { Data = otherData, Status = Status.Draft }; @@ -346,7 +346,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject } [Fact] - public async Task Upsert_should_change_status_on_update_when_status_set() + public async Task Upsert_should_change_status_on_update_if_status_set() { var command = new UpsertContent { Data = otherData, Status = Status.Archived }; @@ -426,7 +426,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject } [Fact] - public async Task Update_should_create_events_and_update_new_version_when_draft_available() + public async Task Update_should_create_events_and_update_new_version_if_draft_available() { var command = new UpdateContent { Data = otherData }; @@ -467,7 +467,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject } [Fact] - public async Task Update_should_throw_exception_when_invalid_data_is_passed() + public async Task Update_should_throw_exception_if_invalid_data_is_passed() { var command = new UpdateContent { Data = invalidData }; @@ -499,7 +499,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject } [Fact] - public async Task Patch_should_create_events_and_update_new_version_when_draft_available() + public async Task Patch_should_create_events_and_update_new_version_if_draft_available() { var command = new PatchContent { Data = patch }; @@ -540,7 +540,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject } [Fact] - public async Task ChangeStatus_should_create_events_and_update_status_when_published() + public async Task ChangeStatus_should_create_events_and_update_status_if_published() { var command = new ChangeContentStatus { Status = Status.Archived }; @@ -562,7 +562,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject } [Fact] - public async Task ChangeStatus_should_create_events_and_update_status_when_changed() + public async Task ChangeStatus_should_create_events_and_update_status_if_changed() { var command = new ChangeContentStatus { Status = Status.Archived }; @@ -584,7 +584,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject } [Fact] - public async Task ChangeStatus_should_create_events_and_update_status_when_unpublished() + public async Task ChangeStatus_should_create_events_and_update_status_if_unpublished() { var command = new ChangeContentStatus { Status = Status.Draft }; @@ -607,7 +607,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject } [Fact] - public async Task ChangeStatus_should_also_update_when_script_changes_data() + public async Task ChangeStatus_should_also_update_if_script_changes_data() { var command = new ChangeContentStatus { Status = Status.Draft }; @@ -635,7 +635,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject } [Fact] - public async Task ChangeStatus_should_create_events_and_update_new_version_when_draft_available() + public async Task ChangeStatus_should_create_events_and_update_new_version_if_draft_available() { var command = new ChangeContentStatus { Status = Status.Archived }; @@ -659,7 +659,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject } [Fact] - public async Task ChangeStatus_should_create_events_and_delete_new_version_when_available() + public async Task ChangeStatus_should_create_events_and_delete_new_version_if_available() { var command = new ChangeContentStatus { Status = Status.Published }; @@ -683,7 +683,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject } [Fact] - public async Task ChangeStatus_create_events_and_set_schedule_when_duetime_set() + public async Task ChangeStatus_create_events_and_set_schedule_if_duetime_set() { var dueTime = Instant.MaxValue; @@ -710,7 +710,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject } [Fact] - public async Task ChangeStatus_should_refresh_properties_and_unset_schedule_when_completed() + public async Task ChangeStatus_should_refresh_properties_and_unset_schedule_if_completed() { var dueTime = Instant.MaxValue; @@ -738,7 +738,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject } [Fact] - public async Task ChangeStatus_should_create_events_and_unset_schedule_when_failed() + public async Task ChangeStatus_should_create_events_and_unset_schedule_if_failed() { var dueTime = Instant.MaxValue; diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/DomainObject/ContentsBulkUpdateCommandMiddlewareTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/DomainObject/ContentsBulkUpdateCommandMiddlewareTests.cs index 1f7adfdae..1379fa343 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/DomainObject/ContentsBulkUpdateCommandMiddlewareTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/DomainObject/ContentsBulkUpdateCommandMiddlewareTests.cs @@ -59,7 +59,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject } [Fact] - public async Task Should_throw_exception_when_content_cannot_be_resolved() + public async Task Should_throw_exception_if_content_cannot_be_resolved() { SetupContext(Permissions.AppContentsUpdateOwn); @@ -77,7 +77,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject } [Fact] - public async Task Should_throw_exception_when_query_resolves_multiple_contents() + public async Task Should_throw_exception_if_query_resolves_multiple_contents() { var requestContext = SetupContext(Permissions.AppContentsUpdateOwn); @@ -207,7 +207,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject } [Fact] - public async Task Should_upsert_content_when_id_defined() + public async Task Should_upsert_content_if_id_defined() { SetupContext(Permissions.AppContentsUpsert); @@ -264,7 +264,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject } [Fact] - public async Task Should_throw_security_exception_when_user_has_no_permission_for_creating() + public async Task Should_throw_security_exception_if_user_has_no_permission_for_creating() { SetupContext(Permissions.AppContentsReadOwn); @@ -301,7 +301,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject } [Fact] - public async Task Should_throw_security_exception_when_user_has_no_permission_for_updating() + public async Task Should_throw_security_exception_if_user_has_no_permission_for_updating() { SetupContext(Permissions.AppContentsReadOwn); @@ -338,7 +338,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject } [Fact] - public async Task Should_throw_security_exception_when_user_has_no_permission_for_patching() + public async Task Should_throw_security_exception_if_user_has_no_permission_for_patching() { SetupContext(Permissions.AppContentsReadOwn); @@ -392,7 +392,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject } [Fact] - public async Task Should_throw_security_exception_when_user_has_no_permission_for_changing_status() + public async Task Should_throw_security_exception_if_user_has_no_permission_for_changing_status() { SetupContext(Permissions.AppContentsReadOwn); @@ -429,7 +429,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject } [Fact] - public async Task Should_throw_security_exception_when_user_has_no_permission_for_validation() + public async Task Should_throw_security_exception_if_user_has_no_permission_for_validation() { SetupContext(Permissions.AppContentsDeleteOwn); @@ -466,7 +466,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject } [Fact] - public async Task Should_throw_security_exception_when_user_has_no_permission_for_deletion() + public async Task Should_throw_security_exception_if_user_has_no_permission_for_deletion() { SetupContext(Permissions.AppContentsReadOwn); diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/DomainObject/Guards/GuardContentTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/DomainObject/Guards/GuardContentTests.cs index 31d636eac..dadfef473 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/DomainObject/Guards/GuardContentTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/DomainObject/Guards/GuardContentTests.cs @@ -107,7 +107,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject.Guards } [Fact] - public void Should_throw_exception_when_draft_already_created() + public void Should_throw_exception_if_draft_already_created() { var context = CreateContext(CreateDraftContent(Status.Draft), normalSchema); @@ -115,7 +115,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject.Guards } [Fact] - public void Should_throw_exception_when_draft_cannot_be_created() + public void Should_throw_exception_if_draft_cannot_be_created() { var context = CreateContext(CreateContent(Status.Draft), normalSchema); @@ -123,7 +123,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject.Guards } [Fact] - public void Should_not_throw_exception_when_draft_can_be_created() + public void Should_not_throw_exception_if_draft_can_be_created() { var context = CreateContext(CreateContent(Status.Published), normalSchema); @@ -131,7 +131,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject.Guards } [Fact] - public void Should_throw_exception_when_draft_cannot_be_deleted() + public void Should_throw_exception_if_draft_cannot_be_deleted() { var context = CreateContext(CreateContent(Status.Published), normalSchema); @@ -139,7 +139,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject.Guards } [Fact] - public void Should_not_throw_exception_when_draft_can_be_deleted() + public void Should_not_throw_exception_if_draft_can_be_deleted() { var context = CreateContext(CreateDraftContent(Status.Draft), normalSchema); @@ -174,7 +174,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject.Guards } [Fact] - public async Task Should_throw_exception_when_workflow_permits_update() + public async Task Should_throw_exception_if_workflow_permits_update() { var context = CreateContext(CreateContent(Status.Draft), normalSchema); @@ -185,7 +185,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject.Guards } [Fact] - public async Task Should_not_throw_exception_when_workflow_allows_update() + public async Task Should_not_throw_exception_if_workflow_allows_update() { var context = CreateContext(CreateContent(Status.Draft), normalSchema); @@ -196,7 +196,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject.Guards } [Fact] - public async Task Should_throw_exception_when_workflow_status_not_valid() + public async Task Should_throw_exception_if_workflow_status_not_valid() { var context = CreateContext(CreateContent(Status.Draft), normalSchema); @@ -207,7 +207,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject.Guards } [Fact] - public async Task Should_not_throw_exception_when_workflow_status_is_valid() + public async Task Should_not_throw_exception_if_workflow_status_is_valid() { var context = CreateContext(CreateContent(Status.Draft), normalSchema); @@ -218,7 +218,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject.Guards } [Fact] - public async Task Should_not_throw_exception_when_workflow_status_is_checked_for_singleton() + public async Task Should_not_throw_exception_if_workflow_status_is_checked_for_singleton() { var context = CreateContext(CreateContent(Status.Draft), singletonSchema); @@ -229,7 +229,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject.Guards } [Fact] - public async Task Should_throw_exception_when_workflow_transition_not_valid() + public async Task Should_throw_exception_if_workflow_transition_not_valid() { var context = CreateContext(CreateContent(Status.Draft), normalSchema); @@ -240,7 +240,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject.Guards } [Fact] - public async Task Should_not_throw_exception_when_workflow_transition_is_valid() + public async Task Should_not_throw_exception_if_workflow_transition_is_valid() { var context = CreateContext(CreateContent(Status.Draft), normalSchema); @@ -251,7 +251,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject.Guards } [Fact] - public async Task Should_not_throw_exception_when_workflow_transition_is_checked_for_singleton() + public async Task Should_not_throw_exception_if_workflow_transition_is_checked_for_singleton() { var context = CreateContext(CreateContent(Status.Draft), singletonSchema); diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/DynamicContentWorkflowTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/DynamicContentWorkflowTests.cs index d8860c934..881bae4b7 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/DynamicContentWorkflowTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/DynamicContentWorkflowTests.cs @@ -381,7 +381,7 @@ namespace Squidex.Domain.Apps.Entities.Contents } [Fact] - public async Task Should_return_all_statuses_for_default_workflow_when_no_workflow_configured() + public async Task Should_return_all_statuses_for_default_workflow_if_no_workflow_configured() { A.CallTo(() => app.Workflows).Returns(Workflows.Empty); diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/GraphQL/GraphQLMutationTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/GraphQL/GraphQLMutationTests.cs index 6395021dc..c35126f64 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/GraphQL/GraphQLMutationTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/GraphQL/GraphQLMutationTests.cs @@ -37,7 +37,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL } [Fact] - public async Task Should_return_error_when_user_has_no_permission_to_create() + public async Task Should_return_error_if_user_has_no_permission_to_create() { var query = @" mutation { @@ -79,7 +79,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL } [Fact] - public async Task Should_return_single_content_when_creating_content() + public async Task Should_return_single_content_if_creating_content() { var query = CreateQuery(@" mutation { @@ -112,7 +112,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL } [Fact] - public async Task Should_return_single_content_when_creating_content_with_custom_id() + public async Task Should_return_single_content_if_creating_content_with_custom_id() { var query = CreateQuery(@" mutation { @@ -146,7 +146,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL } [Fact] - public async Task Should_return_single_content_when_creating_content_with_variable() + public async Task Should_return_single_content_if_creating_content_with_variable() { var query = CreateQuery(@" mutation OP($data: MySchemaDataInputDto!) { @@ -179,7 +179,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL } [Fact] - public async Task Should_return_error_when_user_has_no_permission_to_update() + public async Task Should_return_error_if_user_has_no_permission_to_update() { var query = CreateQuery(@" mutation { @@ -221,7 +221,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL } [Fact] - public async Task Should_return_single_content_when_updating_content() + public async Task Should_return_single_content_if_updating_content() { var query = CreateQuery(@" mutation { @@ -254,7 +254,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL } [Fact] - public async Task Should_return_single_content_when_updating_content_with_variable() + public async Task Should_return_single_content_if_updating_content_with_variable() { var query = CreateQuery(@" mutation OP($data: MySchemaDataInputDto!) { @@ -287,7 +287,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL } [Fact] - public async Task Should_return_error_when_user_has_no_permission_to_upsert() + public async Task Should_return_error_if_user_has_no_permission_to_upsert() { var query = CreateQuery(@" mutation { @@ -329,7 +329,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL } [Fact] - public async Task Should_return_single_content_when_upserting_content() + public async Task Should_return_single_content_if_upserting_content() { var query = CreateQuery(@" mutation { @@ -363,7 +363,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL } [Fact] - public async Task Should_return_single_content_when_upserting_content_with_variable() + public async Task Should_return_single_content_if_upserting_content_with_variable() { var query = CreateQuery(@" mutation OP($data: MySchemaDataInputDto!) { @@ -397,7 +397,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL } [Fact] - public async Task Should_return_error_when_user_has_no_permission_to_patch() + public async Task Should_return_error_if_user_has_no_permission_to_patch() { var query = CreateQuery(@" mutation { @@ -439,7 +439,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL } [Fact] - public async Task Should_return_single_content_when_patching_content() + public async Task Should_return_single_content_if_patching_content() { var query = CreateQuery(@" mutation { @@ -472,7 +472,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL } [Fact] - public async Task Should_return_single_content_when_patching_content_with_variable() + public async Task Should_return_single_content_if_patching_content_with_variable() { var query = CreateQuery(@" mutation OP($data: MySchemaDataInputDto!) { @@ -505,7 +505,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL } [Fact] - public async Task Should_return_error_when_user_has_no_permission_to_change_status() + public async Task Should_return_error_if_user_has_no_permission_to_change_status() { var query = CreateQuery(@" mutation { @@ -547,7 +547,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL } [Fact] - public async Task Should_return_single_content_when_changing_status() + public async Task Should_return_single_content_if_changing_status() { var dueTime = InstantPattern.General.Parse("2021-12-12T11:10:09Z").Value; @@ -583,7 +583,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL } [Fact] - public async Task Should_return_single_content_when_changing_status_without_due_time() + public async Task Should_return_single_content_if_changing_status_without_due_time() { var query = CreateQuery(@" mutation { @@ -617,7 +617,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL } [Fact] - public async Task Should_return_single_content_when_changing_status_with_null_due_time() + public async Task Should_return_single_content_if_changing_status_with_null_due_time() { var query = CreateQuery(@" mutation { @@ -651,7 +651,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL } [Fact] - public async Task Should_return_error_when_user_has_no_permission_to_delete() + public async Task Should_return_error_if_user_has_no_permission_to_delete() { var query = CreateQuery(@" mutation { @@ -693,7 +693,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL } [Fact] - public async Task Should_return_new_version_when_deleting_content() + public async Task Should_return_new_version_if_deleting_content() { var query = CreateQuery(@" mutation { diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/GraphQL/GraphQLQueriesTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/GraphQL/GraphQLQueriesTests.cs index 0796f17f0..91e98a96b 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/GraphQL/GraphQLQueriesTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/GraphQL/GraphQLQueriesTests.cs @@ -48,7 +48,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL } [Fact] - public async Task Should_return_multiple_assets_when_querying_assets() + public async Task Should_return_multiple_assets_if_querying_assets() { var query = CreateQuery(@" query { @@ -80,7 +80,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL } [Fact] - public async Task Should_return_multiple_assets_with_total_when_querying_assets_with_total() + public async Task Should_return_multiple_assets_with_total_if_querying_assets_with_total() { var query = CreateQuery(@" query { @@ -119,7 +119,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL } [Fact] - public async Task Should_return_null_single_asset_when_not_found() + public async Task Should_return_null_single_asset_if_not_found() { var assetId = DomainId.NewGuid(); @@ -147,7 +147,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL } [Fact] - public async Task Should_return_single_asset_when_finding_asset() + public async Task Should_return_single_asset_if_finding_asset() { var assetId = DomainId.NewGuid(); var asset = TestAsset.Create(appId, assetId); @@ -176,7 +176,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL } [Fact] - public async Task Should_return_multiple_flat_contents_when_querying_contents() + public async Task Should_return_multiple_flat_contents_if_querying_contents() { var query = CreateQuery(@" query { @@ -278,7 +278,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL } [Fact] - public async Task Should_return_multiple_contents_when_querying_contents() + public async Task Should_return_multiple_contents_if_querying_contents() { var query = CreateQuery(@" query { @@ -310,7 +310,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL } [Fact] - public async Task Should_return_multiple_contents_with_total_when_querying_contents_with_total() + public async Task Should_return_multiple_contents_with_total_if_querying_contents_with_total() { var query = CreateQuery(@" query { @@ -349,7 +349,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL } [Fact] - public async Task Should_return_null_single_content_when_not_found() + public async Task Should_return_null_single_content_if_not_found() { var contentId = DomainId.NewGuid(); @@ -377,7 +377,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL } [Fact] - public async Task Should_return_single_content_when_finding_content() + public async Task Should_return_single_content_if_finding_content() { var contentId = DomainId.NewGuid(); var content = TestContent.Create(appId, schemaId, contentId, DomainId.Empty, DomainId.Empty); @@ -406,7 +406,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL } [Fact] - public async Task Should_return_single_content_when_finding_content_with_version() + public async Task Should_return_single_content_if_finding_content_with_version() { var contentId = DomainId.NewGuid(); var content = TestContent.Create(appId, schemaId, contentId, DomainId.Empty, DomainId.Empty); @@ -435,7 +435,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL } [Fact] - public async Task Should_also_fetch_referenced_contents_when_field_is_included_in_query() + public async Task Should_also_fetch_referenced_contents_if_field_is_included_in_query() { var contentRefId = DomainId.NewGuid(); var contentRef = TestContent.CreateRef(schemaRefId1, contentRefId, "ref1-field", "ref1"); @@ -505,7 +505,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL } [Fact] - public async Task Should_also_fetch_referencing_contents_when_field_is_included_in_query() + public async Task Should_also_fetch_referencing_contents_if_field_is_included_in_query() { var contentRefId = DomainId.NewGuid(); var contentRef = TestContent.CreateRef(schemaRefId1, contentRefId, "ref1-field", "ref1"); @@ -566,7 +566,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL } [Fact] - public async Task Should_also_fetch_referencing_contents_with_total_when_field_is_included_in_query() + public async Task Should_also_fetch_referencing_contents_with_total_if_field_is_included_in_query() { var contentRefId = DomainId.NewGuid(); var contentRef = TestContent.CreateRef(schemaRefId1, contentRefId, "ref1-field", "ref1"); @@ -634,7 +634,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL } [Fact] - public async Task Should_also_fetch_union_contents_when_field_is_included_in_query() + public async Task Should_also_fetch_union_contents_if_field_is_included_in_query() { var contentRefId = DomainId.NewGuid(); var contentRef = TestContent.CreateRef(schemaRefId1, contentRefId, "ref1-field", "ref1"); @@ -710,7 +710,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL } [Fact] - public async Task Should_also_fetch_referenced_assets_when_field_is_included_in_query() + public async Task Should_also_fetch_referenced_assets_if_field_is_included_in_query() { var assetRefId = DomainId.NewGuid(); var assetRef = TestAsset.Create(appId, assetRefId); @@ -768,7 +768,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL } [Fact] - public async Task Should_not_return_data_when_field_not_part_of_content() + public async Task Should_not_return_data_if_field_not_part_of_content() { var contentId = DomainId.NewGuid(); var content = TestContent.Create(appId, schemaId, contentId, DomainId.Empty, DomainId.Empty, new ContentData()); diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ContentEnricherTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ContentEnricherTests.cs index b7dc334b2..59d3ab974 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ContentEnricherTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ContentEnricherTests.cs @@ -119,7 +119,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Queries } [Fact] - public async Task Should_clone_data_when_requested() + public async Task Should_clone_data_if_requested() { var source = CreateContent(new ContentData()); @@ -131,7 +131,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Queries } [Fact] - public async Task Should_not_clone_data_when_not_requested() + public async Task Should_not_clone_data_if_not_requested() { var source = CreateContent(new ContentData()); diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ContentQueryParserTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ContentQueryParserTests.cs index 6a48880bd..2cada6f86 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ContentQueryParserTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ContentQueryParserTests.cs @@ -52,7 +52,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Queries } [Fact] - public async Task Should_skip_total_when_set_in_context() + public async Task Should_skip_total_if_set_in_context() { var q = await sut.ParseAsync(requestContext.Clone(b => b.WithoutTotal()), Q.Empty); @@ -152,7 +152,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Queries } [Fact] - public async Task Should_convert_full_text_query_to_filter_when_single_id_found() + public async Task Should_convert_full_text_query_to_filter_if_single_id_found() { A.CallTo(() => textIndex.SearchAsync(requestContext.App, A.That.Matches(x => x.Text == "Hello"), requestContext.Scope())) .Returns(new List { DomainId.Create("1") }); @@ -165,7 +165,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Queries } [Fact] - public async Task Should_convert_full_text_query_to_filter_when_index_returns_null() + public async Task Should_convert_full_text_query_to_filter_if_index_returns_null() { A.CallTo(() => textIndex.SearchAsync(requestContext.App, A.That.Matches(x => x.Text == "Hello"), requestContext.Scope())) .Returns(Task.FromResult?>(null)); @@ -178,7 +178,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Queries } [Fact] - public async Task Should_convert_full_text_query_to_filter_when_index_returns_empty() + public async Task Should_convert_full_text_query_to_filter_if_index_returns_empty() { A.CallTo(() => textIndex.SearchAsync(requestContext.App, A.That.Matches(x => x.Text == "Hello"), requestContext.Scope())) .Returns(new List()); @@ -204,7 +204,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Queries } [Fact] - public async Task Should_convert_geo_query_to_filter_when_single_id_found() + public async Task Should_convert_geo_query_to_filter_if_single_id_found() { A.CallTo(() => textIndex.SearchAsync(requestContext.App, new GeoQuery(schemaId.Id, "geo.iv", 10, 20, 30), requestContext.Scope())) .Returns(new List { DomainId.Create("1") }); @@ -217,7 +217,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Queries } [Fact] - public async Task Should_convert_geo_query_to_filter_when_index_returns_null() + public async Task Should_convert_geo_query_to_filter_if_index_returns_null() { A.CallTo(() => textIndex.SearchAsync(requestContext.App, new GeoQuery(schemaId.Id, "geo.iv", 10, 20, 30), requestContext.Scope())) .Returns(Task.FromResult?>(null)); @@ -230,7 +230,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Queries } [Fact] - public async Task Should_convert_geo_query_to_filter_when_index_returns_empty() + public async Task Should_convert_geo_query_to_filter_if_index_returns_empty() { A.CallTo(() => textIndex.SearchAsync(requestContext.App, new GeoQuery(schemaId.Id, "geo.iv", 10, 20, 30), requestContext.Scope())) .Returns(new List()); diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ConvertDataTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ConvertDataTests.cs index 729606f61..b048c7f07 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ConvertDataTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ConvertDataTests.cs @@ -52,7 +52,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Queries } [Fact] - public async Task Should_convert_data_and_data_draft_when_frontend_user() + public async Task Should_convert_data_and_data_draft_if_frontend_user() { var content = CreateContent(new ContentData()); @@ -102,7 +102,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Queries } [Fact] - public async Task Should_cleanup_references_when_everything_deleted() + public async Task Should_cleanup_references_if_everything_deleted() { var id1 = DomainId.NewGuid(); var id2 = DomainId.NewGuid(); diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/EnrichWithSchemaTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/EnrichWithSchemaTests.cs index 74536301d..60167e82a 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/EnrichWithSchemaTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/EnrichWithSchemaTests.cs @@ -44,7 +44,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Queries } [Fact] - public async Task Should_not_enrich_with_reference_fields_when_not_frontend() + public async Task Should_not_enrich_with_reference_fields_if_not_frontend() { var ctx = new Context(Mocks.ApiUser(), Mocks.App(appId)); diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ResolveReferencesTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ResolveReferencesTests.cs index e64730440..5fd6299c2 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ResolveReferencesTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ResolveReferencesTests.cs @@ -180,7 +180,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Queries } [Fact] - public async Task Should_not_enrich_when_content_has_more_items() + public async Task Should_not_enrich_if_content_has_more_items() { var ref1_1 = CreateRefContent(DomainId.NewGuid(), 1, "ref1_1", 13, refSchemaId1); var ref1_2 = CreateRefContent(DomainId.NewGuid(), 2, "ref1_2", 17, refSchemaId1); diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ScriptContentTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ScriptContentTests.cs index 0ca218bd1..a7ab3dbf9 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ScriptContentTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/ScriptContentTests.cs @@ -57,7 +57,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Queries } [Fact] - public async Task Should_not_call_script_engine_when_no_script_configured() + public async Task Should_not_call_script_engine_if_no_script_configured() { var ctx = new Context(Mocks.ApiUser(), Mocks.App(appId)); diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/SingletonCommandMiddlewareTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/SingletonCommandMiddlewareTests.cs index 628c1f7b6..9bf833acb 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/SingletonCommandMiddlewareTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/SingletonCommandMiddlewareTests.cs @@ -21,7 +21,7 @@ namespace Squidex.Domain.Apps.Entities.Contents private readonly SingletonCommandMiddleware sut = new SingletonCommandMiddleware(); [Fact] - public async Task Should_create_content_when_singleton_schema_is_created() + public async Task Should_create_content_if_singleton_schema_is_created() { var command = new CreateSchema { IsSingleton = true, Name = "my-schema" }; @@ -36,7 +36,7 @@ namespace Squidex.Domain.Apps.Entities.Contents } [Fact] - public async Task Should_not_create_content_when_non_singleton_schema_is_created() + public async Task Should_not_create_content_if_non_singleton_schema_is_created() { var command = new CreateSchema { IsSingleton = false }; @@ -51,7 +51,7 @@ namespace Squidex.Domain.Apps.Entities.Contents } [Fact] - public async Task Should_not_create_content_when_singleton_schema_not_created() + public async Task Should_not_create_content_if_singleton_schema_not_created() { var command = new CreateSchema { IsSingleton = true }; diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Text/CachingTextIndexerStateTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Text/CachingTextIndexerStateTests.cs index 159570e7e..0090c78e6 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Text/CachingTextIndexerStateTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Text/CachingTextIndexerStateTests.cs @@ -27,7 +27,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Text } [Fact] - public async Task Should_retrieve_from_inner_when_not_cached() + public async Task Should_retrieve_from_inner_if_not_cached() { var contentIds = HashSet.Of(contentId); @@ -52,7 +52,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Text } [Fact] - public async Task Should_retrieve_from_inner_when_not_cached_and_not_found() + public async Task Should_retrieve_from_inner_if_not_cached_and_not_found() { var contentIds = HashSet.Of(contentId); @@ -70,7 +70,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Text } [Fact] - public async Task Should_not_retrieve_from_inner_when_cached() + public async Task Should_not_retrieve_from_inner_if_cached() { var contentIds = HashSet.Of(contentId); @@ -95,7 +95,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Text } [Fact] - public async Task Should_not_retrieve_from_inner_when_removed() + public async Task Should_not_retrieve_from_inner_if_removed() { var contentIds = HashSet.Of(contentId); diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Notifications/NotificationEmailSenderTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Notifications/NotificationEmailSenderTests.cs index feb57f2b6..098d143af 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Notifications/NotificationEmailSenderTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Notifications/NotificationEmailSenderTests.cs @@ -121,7 +121,7 @@ namespace Squidex.Domain.Apps.Entities.Notifications } [Fact] - public async Task Should_not_send_invitation_email_when_no_consent_given() + public async Task Should_not_send_invitation_email_if_no_consent_given() { var withoutConsent = UserMocks.User("2", "2@email.com", "user", false); @@ -135,7 +135,7 @@ namespace Squidex.Domain.Apps.Entities.Notifications } [Fact] - public async Task Should_send_invitation_email_when_consent_given() + public async Task Should_send_invitation_email_if_consent_given() { var withConsent = UserMocks.User("2", "2@email.com", "user", true); diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Rules/DomainObject/RuleDomainObjectTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Rules/DomainObject/RuleDomainObjectTests.cs index 0fcb9690f..9f6269c0c 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Rules/DomainObject/RuleDomainObjectTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Rules/DomainObject/RuleDomainObjectTests.cs @@ -89,7 +89,7 @@ namespace Squidex.Domain.Apps.Entities.Rules.DomainObject LastEvents .ShouldHaveSameEvents( - CreateRuleEvent(new RuleUpdated { Trigger = command.Trigger, Action = command.Action, Name = "NewName" }) + CreateRuleEvent(new RuleUpdated { Trigger = command.Trigger, Action = command.Action, Name = command.Name }) ); } @@ -113,6 +113,29 @@ namespace Squidex.Domain.Apps.Entities.Rules.DomainObject ); } + [Fact] + public async Task Enable_via_update_should_create_events_and_update_enabled_flag() + { + var command = new UpdateRule + { + IsEnabled = true + }; + + await ExecuteCreateAsync(); + await ExecuteDisableAsync(); + + var result = await PublishIdempotentAsync(command); + + result.ShouldBeEquivalent(sut.Snapshot); + + Assert.True(sut.Snapshot.RuleDef.IsEnabled); + + LastEvents + .ShouldHaveSameEvents( + CreateRuleEvent(new RuleUpdated { IsEnabled = true }) + ); + } + [Fact] public async Task Disable_should_create_events_and_update_enabled_flag() { @@ -132,6 +155,28 @@ namespace Squidex.Domain.Apps.Entities.Rules.DomainObject ); } + [Fact] + public async Task Disable_via_update_should_create_events_and_update_enabled_flag() + { + var command = new UpdateRule + { + IsEnabled = false + }; + + await ExecuteCreateAsync(); + + var result = await PublishIdempotentAsync(command); + + result.ShouldBeEquivalent(sut.Snapshot); + + Assert.False(sut.Snapshot.RuleDef.IsEnabled); + + LastEvents + .ShouldHaveSameEvents( + CreateRuleEvent(new RuleUpdated { IsEnabled = false }) + ); + } + [Fact] public async Task Delete_should_create_events_and_update_deleted_flag() { @@ -198,26 +243,33 @@ namespace Squidex.Domain.Apps.Entities.Rules.DomainObject private static CreateRule MakeCreateCommand() { - var newTrigger = new ContentChangedTriggerV2(); - - var newAction = new TestAction + return new CreateRule { - Value = 123 + Trigger = new ContentChangedTriggerV2 + { + HandleAll = false + }, + Action = new TestAction + { + Value = 123 + } }; - - return new CreateRule { Trigger = newTrigger, Action = newAction }; } private static UpdateRule MakeUpdateCommand() { - var newTrigger = new ContentChangedTriggerV2 { HandleAll = true }; - - var newAction = new TestAction + return new UpdateRule { - Value = 456 + Name = "NewName", + Trigger = new ContentChangedTriggerV2 + { + HandleAll = true + }, + Action = new TestAction + { + Value = 456 + } }; - - return new UpdateRule { Trigger = newTrigger, Action = newAction, Name = "NewName" }; } private Task PublishIdempotentAsync(RuleCommand command) diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Rules/Indexes/RulesIndexTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Rules/Indexes/RulesIndexTests.cs index bf8b5a4a2..411f3c141 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Rules/Indexes/RulesIndexTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Rules/Indexes/RulesIndexTests.cs @@ -108,7 +108,7 @@ namespace Squidex.Domain.Apps.Entities.Rules.Indexes } [Fact] - public async Task Should_forward_call_when_rebuilding() + public async Task Should_forward_call_if_rebuilding() { var rules = new HashSet(); diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Rules/ManualTriggerHandlerTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Rules/ManualTriggerHandlerTests.cs index ae55563fc..cb5822a2b 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Rules/ManualTriggerHandlerTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Rules/ManualTriggerHandlerTests.cs @@ -23,7 +23,7 @@ namespace Squidex.Domain.Apps.Entities.Rules private readonly IRuleTriggerHandler sut = new ManualTriggerHandler(); [Fact] - public void Should_return_false_when_asking_for_snapshot_support() + public void Should_return_false_if_asking_for_snapshot_support() { Assert.False(sut.CanCreateSnapshotEvents); } diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Rules/RuleEnqueuerTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Rules/RuleEnqueuerTests.cs index 2b94341bd..64d715f6b 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Rules/RuleEnqueuerTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Rules/RuleEnqueuerTests.cs @@ -75,7 +75,7 @@ namespace Squidex.Domain.Apps.Entities.Rules } [Fact] - public async Task Should_update_repository_when_enqueing() + public async Task Should_update_repository_if_enqueing() { var @event = Envelope.Create(new ContentCreated { AppId = appId }); @@ -108,7 +108,7 @@ namespace Squidex.Domain.Apps.Entities.Rules } [Fact] - public async Task Should_not_eqneue_when_event_restored() + public async Task Should_not_eqneue_if_event_restored() { var @event = Envelope.Create(new ContentCreated { AppId = appId }); diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Rules/UsageTracking/UsageTriggerHandlerTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Rules/UsageTracking/UsageTriggerHandlerTests.cs index a0113b099..a3414b760 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Rules/UsageTracking/UsageTriggerHandlerTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Rules/UsageTracking/UsageTriggerHandlerTests.cs @@ -24,13 +24,13 @@ namespace Squidex.Domain.Apps.Entities.Rules.UsageTracking private readonly IRuleTriggerHandler sut = new UsageTriggerHandler(); [Fact] - public void Should_return_false_when_asking_for_snapshot_support() + public void Should_return_false_if_asking_for_snapshot_support() { Assert.False(sut.CanCreateSnapshotEvents); } [Fact] - public void Should_not_trigger_precheck_when_event_type_not_correct() + public void Should_not_trigger_precheck_if_event_type_not_correct() { var result = sut.Trigger(new ContentCreated(), new UsageTrigger(), ruleId); @@ -38,7 +38,7 @@ namespace Squidex.Domain.Apps.Entities.Rules.UsageTracking } [Fact] - public void Should_not_trigger_precheck_when_rule_id_not_matchs() + public void Should_not_trigger_precheck_if_rule_id_not_matchs() { var result = sut.Trigger(new AppUsageExceeded { RuleId = DomainId.NewGuid() }, new UsageTrigger(), ruleId); @@ -46,7 +46,7 @@ namespace Squidex.Domain.Apps.Entities.Rules.UsageTracking } [Fact] - public void Should_trigger_precheck_when_event_type_correct_and_rule_id_matchs() + public void Should_trigger_precheck_if_event_type_correct_and_rule_id_matchs() { var result = sut.Trigger(new AppUsageExceeded { RuleId = ruleId }, new UsageTrigger(), ruleId); @@ -54,7 +54,7 @@ namespace Squidex.Domain.Apps.Entities.Rules.UsageTracking } [Fact] - public void Should_not_trigger_check_when_event_type_not_correct() + public void Should_not_trigger_check_if_event_type_not_correct() { var result = sut.Trigger(new EnrichedContentEvent(), new UsageTrigger()); diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Schemas/Indexes/SchemasIndexTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Schemas/Indexes/SchemasIndexTests.cs index f2e269cfb..61dacd5d3 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Schemas/Indexes/SchemasIndexTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Schemas/Indexes/SchemasIndexTests.cs @@ -167,7 +167,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas.Indexes } [Fact] - public async Task Should_add_schema_to_index_when_creating() + public async Task Should_add_schema_to_index_if_creating() { var token = RandomHash.Simple(); @@ -190,7 +190,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas.Indexes } [Fact] - public async Task Should_clear_reservation_when_schema_creation_failed() + public async Task Should_clear_reservation_if_schema_creation_failed() { var token = RandomHash.Simple(); @@ -212,7 +212,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas.Indexes } [Fact] - public async Task Should_not_add_to_indexes_when_name_is_taken() + public async Task Should_not_add_to_indexes_if_name_is_taken() { A.CallTo(() => index.ReserveAsync(schemaId.Id, schemaId.Name)) .Returns(Task.FromResult(null)); @@ -233,7 +233,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas.Indexes } [Fact] - public async Task Should_not_add_to_indexes_when_name_is_invalid() + public async Task Should_not_add_to_indexes_if_name_is_invalid() { var command = Create("INVALID"); @@ -251,7 +251,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas.Indexes } [Fact] - public async Task Should_update_index_when_schema_is_updated() + public async Task Should_update_index_if_schema_is_updated() { var (_, schemaGrain) = SetupSchema(); @@ -268,7 +268,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas.Indexes } [Fact] - public async Task Should_update_index_with_result_when_schema_is_updated() + public async Task Should_update_index_with_result_if_schema_is_updated() { var (schema, schemaGrain) = SetupSchema(); @@ -285,7 +285,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas.Indexes } [Fact] - public async Task Should_remove_schema_from_index_when_deleted_and_exists() + public async Task Should_remove_schema_from_index_if_deleted_and_exists() { var (schema, _) = SetupSchema(isDeleted: true); @@ -302,7 +302,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas.Indexes } [Fact] - public async Task Should_forward_call_when_rebuilding() + public async Task Should_forward_call_if_rebuilding() { var schemas = new Dictionary(); diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Schemas/SchemaChangedTriggerHandlerTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Schemas/SchemaChangedTriggerHandlerTests.cs index cd1d0d9d6..5b4289a28 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Schemas/SchemaChangedTriggerHandlerTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Schemas/SchemaChangedTriggerHandlerTests.cs @@ -49,7 +49,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas } [Fact] - public void Should_return_false_when_asking_for_snapshot_support() + public void Should_return_false_if_asking_for_snapshot_support() { Assert.False(sut.CanCreateSnapshotEvents); } @@ -68,7 +68,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas } [Fact] - public void Should_not_trigger_precheck_when_event_type_not_correct() + public void Should_not_trigger_precheck_if_event_type_not_correct() { TestForCondition(string.Empty, trigger => { @@ -79,7 +79,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas } [Fact] - public void Should_trigger_precheck_when_event_type_correct() + public void Should_trigger_precheck_if_event_type_correct() { TestForCondition(string.Empty, trigger => { @@ -90,7 +90,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas } [Fact] - public void Should_not_trigger_check_when_event_type_not_correct() + public void Should_not_trigger_check_if_event_type_not_correct() { TestForCondition(string.Empty, trigger => { @@ -101,7 +101,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas } [Fact] - public void Should_trigger_check_when_condition_is_empty() + public void Should_trigger_check_if_condition_is_empty() { TestForCondition(string.Empty, trigger => { @@ -112,7 +112,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas } [Fact] - public void Should_trigger_check_when_condition_matchs() + public void Should_trigger_check_if_condition_matchs() { TestForCondition("true", trigger => { @@ -123,7 +123,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas } [Fact] - public void Should_not_trigger_check_when_condition_does_not_matchs() + public void Should_not_trigger_check_if_condition_does_not_matchs() { TestForCondition("false", trigger => { diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Tags/GrainTagServiceTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Tags/GrainTagServiceTests.cs index c50e3a268..9d981d2ce 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Tags/GrainTagServiceTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Tags/GrainTagServiceTests.cs @@ -31,7 +31,7 @@ namespace Squidex.Domain.Apps.Entities.Tags } [Fact] - public async Task Should_call_grain_when_clearing() + public async Task Should_call_grain_if_clearing() { await sut.ClearAsync(appId, TagGroups.Assets); @@ -40,7 +40,7 @@ namespace Squidex.Domain.Apps.Entities.Tags } [Fact] - public async Task Should_call_grain_when_rebuilding() + public async Task Should_call_grain_if_rebuilding() { var tags = new TagsExport(); @@ -51,7 +51,7 @@ namespace Squidex.Domain.Apps.Entities.Tags } [Fact] - public async Task Should_call_grain_when_retrieving_raw_tags() + public async Task Should_call_grain_if_retrieving_raw_tags() { await sut.GetExportableTagsAsync(appId, TagGroups.Assets); @@ -60,7 +60,7 @@ namespace Squidex.Domain.Apps.Entities.Tags } [Fact] - public async Task Should_call_grain_when_retrieving_tags() + public async Task Should_call_grain_if_retrieving_tags() { await sut.GetTagsAsync(appId, TagGroups.Assets); @@ -69,7 +69,7 @@ namespace Squidex.Domain.Apps.Entities.Tags } [Fact] - public async Task Should_call_grain_when_resolving_tag_ids() + public async Task Should_call_grain_if_resolving_tag_ids() { var tagNames = new HashSet(); @@ -80,7 +80,7 @@ namespace Squidex.Domain.Apps.Entities.Tags } [Fact] - public async Task Should_call_grain_when_denormalizing_tags() + public async Task Should_call_grain_if_denormalizing_tags() { var tagIds = new HashSet(); @@ -91,7 +91,7 @@ namespace Squidex.Domain.Apps.Entities.Tags } [Fact] - public async Task Should_call_grain_when_normalizing_tags() + public async Task Should_call_grain_if_normalizing_tags() { var tagIds = new HashSet(); var tagNames = new HashSet(); diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Tags/TagGrainTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Tags/TagGrainTests.cs index fa7919ae1..9df8a1917 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Tags/TagGrainTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Tags/TagGrainTests.cs @@ -33,7 +33,7 @@ namespace Squidex.Domain.Apps.Entities.Tags } [Fact] - public async Task Should_delete_and_reset_state_when_cleaning() + public async Task Should_delete_and_reset_state_if_cleaning() { await sut.NormalizeTagsAsync(HashSet.Of("name1", "name2"), null); await sut.NormalizeTagsAsync(HashSet.Of("name2", "name3"), null); diff --git a/backend/tests/Squidex.Domain.Users.Tests/DefaultUserResolverTests.cs b/backend/tests/Squidex.Domain.Users.Tests/DefaultUserResolverTests.cs index aea99e108..64e25e1fb 100644 --- a/backend/tests/Squidex.Domain.Users.Tests/DefaultUserResolverTests.cs +++ b/backend/tests/Squidex.Domain.Users.Tests/DefaultUserResolverTests.cs @@ -45,7 +45,7 @@ namespace Squidex.Domain.Users } [Fact] - public async Task Should_create_user_and_return_true_when_created() + public async Task Should_create_user_and_return_true_if_created() { var email = "123@email.com"; @@ -60,7 +60,7 @@ namespace Squidex.Domain.Users } [Fact] - public async Task Should_create_user_and_return_false_when_exception_thrown() + public async Task Should_create_user_and_return_false_if_exception_thrown() { var email = "123@email.com"; @@ -78,7 +78,7 @@ namespace Squidex.Domain.Users } [Fact] - public async Task Should_add_claim_when_not_added_yet() + public async Task Should_add_claim_if_not_added_yet() { var id = "123"; @@ -90,7 +90,7 @@ namespace Squidex.Domain.Users } [Fact] - public async Task Should_add_claim_when_not_added_yet_silently() + public async Task Should_add_claim_if_not_added_yet_silently() { var id = "123"; diff --git a/backend/tests/Squidex.Infrastructure.Tests/CollectionExtensionsTests.cs b/backend/tests/Squidex.Infrastructure.Tests/CollectionExtensionsTests.cs index de512be21..ca684e3e1 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/CollectionExtensionsTests.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/CollectionExtensionsTests.cs @@ -16,7 +16,7 @@ namespace Squidex.Infrastructure private readonly Dictionary> listDictionary = new Dictionary>(); [Fact] - public void SetEquals_should_return_false_when_subset() + public void SetEquals_should_return_false_if_subset() { var set1 = new[] { 1, 2 }; var set2 = new[] { 1, 2, 3 }; @@ -36,7 +36,7 @@ namespace Squidex.Infrastructure } [Fact] - public void IndexOf_should_return_index_when_found() + public void IndexOf_should_return_index_if_found() { var source = new List<(int Value, int Other)> { @@ -50,7 +50,7 @@ namespace Squidex.Infrastructure } [Fact] - public void IndexOf_should_return_negative_value_when_not_found() + public void IndexOf_should_return_negative_value_if_not_found() { var source = new List<(int Value, int Other)> { diff --git a/backend/tests/Squidex.Infrastructure.Tests/Commands/CommandContextTests.cs b/backend/tests/Squidex.Infrastructure.Tests/Commands/CommandContextTests.cs index 96e3f11ab..641aa62b3 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/Commands/CommandContextTests.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/Commands/CommandContextTests.cs @@ -35,7 +35,7 @@ namespace Squidex.Infrastructure.Commands } [Fact] - public void Should_be_handled_when_succeeded() + public void Should_be_handled_if_succeeded() { sut.Complete(); @@ -43,7 +43,7 @@ namespace Squidex.Infrastructure.Commands } [Fact] - public void Should_provide_result_when_succeeded_with_value() + public void Should_provide_result_if_succeeded_with_value() { sut.Complete("RESULT"); @@ -51,7 +51,7 @@ namespace Squidex.Infrastructure.Commands } [Fact] - public void Should_provide_plain_result_when_succeeded_with_value() + public void Should_provide_plain_result_if_succeeded_with_value() { sut.Complete("RESULT"); diff --git a/backend/tests/Squidex.Infrastructure.Tests/Commands/DomainObjectTests.cs b/backend/tests/Squidex.Infrastructure.Tests/Commands/DomainObjectTests.cs index 7dd9b6ece..7f325e3f2 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/Commands/DomainObjectTests.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/Commands/DomainObjectTests.cs @@ -36,7 +36,7 @@ namespace Squidex.Infrastructure.Commands } [Fact] - public async Task Should_repair_when_stale() + public async Task Should_repair_if_stale() { A.CallTo(() => persistence.IsSnapshotStale) .Returns(true); @@ -50,7 +50,7 @@ namespace Squidex.Infrastructure.Commands } [Fact] - public async Task Should_not_repair_when_not_stale() + public async Task Should_not_repair_if_not_stale() { A.CallTo(() => persistence.IsSnapshotStale) .Returns(false); @@ -64,7 +64,7 @@ namespace Squidex.Infrastructure.Commands } [Fact] - public async Task Should_write_state_and_events_when_created() + public async Task Should_write_state_and_events_if_created() { SetupEmpty(); @@ -85,7 +85,7 @@ namespace Squidex.Infrastructure.Commands } [Fact] - public async Task Should_recreate_with_create_command_when_deleted_before() + public async Task Should_recreate_with_create_command_if_deleted_before() { sut.Recreate = true; @@ -110,7 +110,7 @@ namespace Squidex.Infrastructure.Commands } [Fact] - public async Task Should_throw_exception_when_recreation_with_create_command_not_allowed() + public async Task Should_throw_exception_if_recreation_with_create_command_not_allowed() { sut.Recreate = false; @@ -124,7 +124,7 @@ namespace Squidex.Infrastructure.Commands } [Fact] - public async Task Should_recreate_with_upsert_command_when_deleted_before() + public async Task Should_recreate_with_upsert_command_if_deleted_before() { sut.Recreate = true; @@ -149,7 +149,7 @@ namespace Squidex.Infrastructure.Commands } [Fact] - public async Task Should_throw_exception_when_recreation_with_upsert_command_not_allowed() + public async Task Should_throw_exception_if_recreation_with_upsert_command_not_allowed() { sut.Recreate = false; @@ -163,7 +163,7 @@ namespace Squidex.Infrastructure.Commands } [Fact] - public async Task Should_write_state_and_events_when_updated_after_creation() + public async Task Should_write_state_and_events_if_updated_after_creation() { SetupEmpty(); @@ -186,7 +186,7 @@ namespace Squidex.Infrastructure.Commands } [Fact] - public async Task Should_write_state_and_events_when_updated() + public async Task Should_write_state_and_events_if_updated() { SetupCreated(4); @@ -246,7 +246,7 @@ namespace Squidex.Infrastructure.Commands } [Fact] - public async Task Should_throw_on_rebuild_when_no_event_found() + public async Task Should_throw_on_rebuild_if_no_event_found() { SetupEmpty(); @@ -265,7 +265,7 @@ namespace Squidex.Infrastructure.Commands } [Fact] - public async Task Should_throw_exception_when_create_command_is_invoked_for_loaded_and_created_object() + public async Task Should_throw_exception_if_create_command_is_invoked_for_loaded_and_created_object() { await sut.ExecuteAsync(new CreateAuto()); @@ -273,7 +273,7 @@ namespace Squidex.Infrastructure.Commands } [Fact] - public async Task Should_throw_exception_when_create_command_not_accepted() + public async Task Should_throw_exception_if_create_command_not_accepted() { SetupEmpty(); @@ -291,7 +291,7 @@ namespace Squidex.Infrastructure.Commands } [Fact] - public async Task Should_throw_exception_when_update_command_invoked_for_empty_object() + public async Task Should_throw_exception_if_update_command_invoked_for_empty_object() { SetupEmpty(); @@ -299,7 +299,7 @@ namespace Squidex.Infrastructure.Commands } [Fact] - public async Task Should_throw_exception_when_update_command_not_accepted() + public async Task Should_throw_exception_if_update_command_not_accepted() { SetupCreated(4); @@ -317,7 +317,7 @@ namespace Squidex.Infrastructure.Commands } [Fact] - public async Task Should_throw_exception_when_other_verison_expected() + public async Task Should_throw_exception_if_other_verison_expected() { SetupCreated(4); @@ -325,7 +325,7 @@ namespace Squidex.Infrastructure.Commands } [Fact] - public async Task Should_not_update_when_snapshot_is_not_changed() + public async Task Should_not_update_if_snapshot_is_not_changed() { SetupCreated(4); @@ -339,7 +339,7 @@ namespace Squidex.Infrastructure.Commands } [Fact] - public async Task Should_reset_state_when_writing_snapshot_for_create_failed() + public async Task Should_reset_state_if_writing_snapshot_for_create_failed() { SetupEmpty(); @@ -353,7 +353,7 @@ namespace Squidex.Infrastructure.Commands } [Fact] - public async Task Should_reset_state_when_writing_snapshot_for_update_failed() + public async Task Should_reset_state_if_writing_snapshot_for_update_failed() { SetupCreated(4); @@ -392,7 +392,7 @@ namespace Squidex.Infrastructure.Commands } [Fact] - public async Task Should_get_old_versions_when_cached() + public async Task Should_get_old_versions_if_cached() { sut.VersionsToKeep = int.MaxValue; @@ -415,7 +415,7 @@ namespace Squidex.Infrastructure.Commands } [Fact] - public async Task Should_get_old_versions_from_query_when_not_cached() + public async Task Should_get_old_versions_from_query_if_not_cached() { sut.VersionsToKeep = 1; diff --git a/backend/tests/Squidex.Infrastructure.Tests/DisposableObjectBaseTests.cs b/backend/tests/Squidex.Infrastructure.Tests/DisposableObjectBaseTests.cs index 4d008c9fb..91568d6da 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/DisposableObjectBaseTests.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/DisposableObjectBaseTests.cs @@ -28,7 +28,7 @@ namespace Squidex.Infrastructure } [Fact] - public void Should_not_throw_exception_when_not_disposed() + public void Should_not_throw_exception_if_not_disposed() { var sut = new MyDisposableObject(); @@ -49,7 +49,7 @@ namespace Squidex.Infrastructure } [Fact] - public void Should_throw_exception_when_disposed() + public void Should_throw_exception_if_disposed() { var sut = new MyDisposableObject(); diff --git a/backend/tests/Squidex.Infrastructure.Tests/EventSourcing/Grains/EventConsumerGrainTests.cs b/backend/tests/Squidex.Infrastructure.Tests/EventSourcing/Grains/EventConsumerGrainTests.cs index 75e073d74..5b9672639 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/EventSourcing/Grains/EventConsumerGrainTests.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/EventSourcing/Grains/EventConsumerGrainTests.cs @@ -107,7 +107,7 @@ namespace Squidex.Infrastructure.EventSourcing.Grains } [Fact] - public async Task Should_not_subscribe_to_event_store_when_stopped_in_db() + public async Task Should_not_subscribe_to_event_store_if_stopped_in_db() { grainState.Value = grainState.Value.Stopped(); @@ -123,7 +123,7 @@ namespace Squidex.Infrastructure.EventSourcing.Grains } [Fact] - public async Task Should_subscribe_to_event_store_when_not_found_in_db() + public async Task Should_subscribe_to_event_store_if_not_found_in_db() { await sut.ActivateAsync(consumerName); await sut.ActivateAsync(); @@ -137,7 +137,7 @@ namespace Squidex.Infrastructure.EventSourcing.Grains } [Fact] - public async Task Should_subscribe_to_event_store_when_failed() + public async Task Should_subscribe_to_event_store_if_failed() { grainState.Value = grainState.Value.Stopped(new InvalidOperationException()); @@ -153,7 +153,7 @@ namespace Squidex.Infrastructure.EventSourcing.Grains } [Fact] - public async Task Should_subscribe_to_event_store_when_not_stopped_in_db() + public async Task Should_subscribe_to_event_store_if_not_stopped_in_db() { await sut.ActivateAsync(consumerName); await sut.ActivateAsync(); @@ -167,7 +167,7 @@ namespace Squidex.Infrastructure.EventSourcing.Grains } [Fact] - public async Task Should_stop_subscription_when_stopped() + public async Task Should_stop_subscription_if_stopped() { await sut.ActivateAsync(consumerName); await sut.ActivateAsync(); @@ -186,7 +186,7 @@ namespace Squidex.Infrastructure.EventSourcing.Grains } [Fact] - public async Task Should_reset_consumer_when_resetting() + public async Task Should_reset_consumer_if_resetting() { await sut.ActivateAsync(consumerName); await sut.ActivateAsync(); @@ -214,7 +214,7 @@ namespace Squidex.Infrastructure.EventSourcing.Grains } [Fact] - public async Task Should_invoke_and_update_position_when_event_received() + public async Task Should_invoke_and_update_position_if_event_received() { var @event = new StoredEvent("Stream", Guid.NewGuid().ToString(), 123, eventData); @@ -235,7 +235,7 @@ namespace Squidex.Infrastructure.EventSourcing.Grains } [Fact] - public async Task Should_invoke_and_update_position_when_event_received_one_by_one() + public async Task Should_invoke_and_update_position_if_event_received_one_by_one() { var @event = new StoredEvent("Stream", Guid.NewGuid().ToString(), 123, eventData); @@ -263,7 +263,7 @@ namespace Squidex.Infrastructure.EventSourcing.Grains } [Fact] - public async Task Should_invoke_and_update_position_when_event_received_batched() + public async Task Should_invoke_and_update_position_if_event_received_batched() { var @event = new StoredEvent("Stream", Guid.NewGuid().ToString(), 123, eventData); @@ -291,7 +291,7 @@ namespace Squidex.Infrastructure.EventSourcing.Grains } [Fact] - public async Task Should_not_invoke_but_update_position_when_consumer_does_not_want_to_handle() + public async Task Should_not_invoke_but_update_position_if_consumer_does_not_want_to_handle() { var @event = new StoredEvent("Stream", Guid.NewGuid().ToString(), 123, eventData); @@ -339,7 +339,7 @@ namespace Squidex.Infrastructure.EventSourcing.Grains } [Fact] - public async Task Should_not_invoke_and_update_position_when_event_is_from_another_subscription() + public async Task Should_not_invoke_and_update_position_if_event_is_from_another_subscription() { var @event = new StoredEvent("Stream", Guid.NewGuid().ToString(), 123, eventData); @@ -378,7 +378,7 @@ namespace Squidex.Infrastructure.EventSourcing.Grains } [Fact] - public async Task Should_not_make_error_handling_when_exception_is_from_another_subscription() + public async Task Should_not_make_error_handling_if_exception_is_from_another_subscription() { var ex = new InvalidOperationException(); @@ -396,7 +396,7 @@ namespace Squidex.Infrastructure.EventSourcing.Grains } [Fact] - public async Task Should_wakeup_when_already_subscribed() + public async Task Should_wakeup_if_already_subscribed() { await sut.ActivateAsync(consumerName); await sut.ActivateAsync(); @@ -490,7 +490,7 @@ namespace Squidex.Infrastructure.EventSourcing.Grains } [Fact] - public async Task Should_start_after_stop_when_handling_failed() + public async Task Should_start_after_stop_if_handling_failed() { var exception = new InvalidOperationException(); diff --git a/backend/tests/Squidex.Infrastructure.Tests/EventSourcing/Grains/EventConsumerManagerGrainTests.cs b/backend/tests/Squidex.Infrastructure.Tests/EventSourcing/Grains/EventConsumerManagerGrainTests.cs index a5d5e5f19..49f1c71b6 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/EventSourcing/Grains/EventConsumerManagerGrainTests.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/EventSourcing/Grains/EventConsumerManagerGrainTests.cs @@ -90,7 +90,7 @@ namespace Squidex.Infrastructure.EventSourcing.Grains } [Fact] - public async Task Should_activate_matching_grains_when_stream_name_defined() + public async Task Should_activate_matching_grains_if_stream_name_defined() { await sut.ActivateAsync("a-123"); diff --git a/backend/tests/Squidex.Infrastructure.Tests/EventSourcing/RetrySubscriptionTests.cs b/backend/tests/Squidex.Infrastructure.Tests/EventSourcing/RetrySubscriptionTests.cs index fe97c3f56..5b8e77f61 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/EventSourcing/RetrySubscriptionTests.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/EventSourcing/RetrySubscriptionTests.cs @@ -51,7 +51,7 @@ namespace Squidex.Infrastructure.EventSourcing } [Fact] - public async Task Should_reopen_subscription_once_when_exception_is_retrieved() + public async Task Should_reopen_subscription_once_if_exception_is_retrieved() { await OnErrorAsync(eventSubscription, new InvalidOperationException()); @@ -70,7 +70,7 @@ namespace Squidex.Infrastructure.EventSourcing } [Fact] - public async Task Should_forward_error_from_inner_subscription_when_failed_often() + public async Task Should_forward_error_from_inner_subscription_if_failed_often() { var ex = new InvalidOperationException(); @@ -108,7 +108,7 @@ namespace Squidex.Infrastructure.EventSourcing } [Fact] - public async Task Should_not_forward_error_when_exception_is_raised_after_unsubscribe() + public async Task Should_not_forward_error_if_exception_is_raised_after_unsubscribe() { var ex = new InvalidOperationException(); @@ -134,7 +134,7 @@ namespace Squidex.Infrastructure.EventSourcing } [Fact] - public async Task Should_forward_event_when_message_is_from_another_subscription() + public async Task Should_forward_event_if_message_is_from_another_subscription() { var ev = new StoredEvent("Stream", "1", 2, new EventData("Type", new EnvelopeHeaders(), "Payload")); diff --git a/backend/tests/Squidex.Infrastructure.Tests/Json/Objects/JsonObjectTests.cs b/backend/tests/Squidex.Infrastructure.Tests/Json/Objects/JsonObjectTests.cs index 7f69ca517..ab4bdab26 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/Json/Objects/JsonObjectTests.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/Json/Objects/JsonObjectTests.cs @@ -353,7 +353,7 @@ namespace Squidex.Infrastructure.Json.Objects } [Fact] - public void Should_create_null_when_adding_null_to_array() + public void Should_create_null_if_adding_null_to_array() { var array = JsonValue.Array(); @@ -363,7 +363,7 @@ namespace Squidex.Infrastructure.Json.Objects } [Fact] - public void Should_create_null_when_replacing_to_null_in_array() + public void Should_create_null_if_replacing_to_null_in_array() { var array = JsonValue.Array(1); @@ -373,7 +373,7 @@ namespace Squidex.Infrastructure.Json.Objects } [Fact] - public void Should_create_null_when_adding_null_to_object() + public void Should_create_null_if_adding_null_to_object() { var obj = JsonValue.Object(); @@ -383,7 +383,7 @@ namespace Squidex.Infrastructure.Json.Objects } [Fact] - public void Should_create_null_when_replacing_to_null_object() + public void Should_create_null_if_replacing_to_null_object() { var obj = JsonValue.Object(); @@ -435,13 +435,13 @@ namespace Squidex.Infrastructure.Json.Objects } [Fact] - public void Should_throw_exception_when_creation_value_from_invalid_type() + public void Should_throw_exception_if_creation_value_from_invalid_type() { Assert.Throws(() => JsonValue.Create(default(TimeSpan))); } [Fact] - public void Should_return_null_when_getting_value_by_path_segment_from_null() + public void Should_return_null_if_getting_value_by_path_segment_from_null() { var json = JsonValue.Null; @@ -452,7 +452,7 @@ namespace Squidex.Infrastructure.Json.Objects } [Fact] - public void Should_return_null_when_getting_value_by_path_segment_from_string() + public void Should_return_null_if_getting_value_by_path_segment_from_string() { var json = JsonValue.Create("string"); @@ -463,7 +463,7 @@ namespace Squidex.Infrastructure.Json.Objects } [Fact] - public void Should_return_null_when_getting_value_by_path_segment_from_boolean() + public void Should_return_null_if_getting_value_by_path_segment_from_boolean() { var json = JsonValue.True; @@ -474,7 +474,7 @@ namespace Squidex.Infrastructure.Json.Objects } [Fact] - public void Should_return_null_when_getting_value_by_path_segment_from_number() + public void Should_return_null_if_getting_value_by_path_segment_from_number() { var json = JsonValue.Create(12); @@ -485,7 +485,7 @@ namespace Squidex.Infrastructure.Json.Objects } [Fact] - public void Should_return_same_object_when_path_is_null() + public void Should_return_same_object_if_path_is_null() { var json = JsonValue.Object().Add("property", 12); @@ -496,7 +496,7 @@ namespace Squidex.Infrastructure.Json.Objects } [Fact] - public void Should_return_same_object_when_path_is_empty() + public void Should_return_same_object_if_path_is_empty() { var json = JsonValue.Object().Add("property", 12); @@ -524,7 +524,7 @@ namespace Squidex.Infrastructure.Json.Objects } [Fact] - public void Should_return_null_when_property_not_found() + public void Should_return_null_if_property_not_found() { var json = JsonValue.Object() @@ -537,7 +537,7 @@ namespace Squidex.Infrastructure.Json.Objects } [Fact] - public void Should_return_null_when_out_of_index1() + public void Should_return_null_if_out_of_index1() { var json = JsonValue.Array(12, 14); @@ -548,7 +548,7 @@ namespace Squidex.Infrastructure.Json.Objects } [Fact] - public void Should_return_null_when_out_of_index2() + public void Should_return_null_if_out_of_index2() { var json = JsonValue.Array(12, 14); diff --git a/backend/tests/Squidex.Infrastructure.Tests/Migrations/MigratorTests.cs b/backend/tests/Squidex.Infrastructure.Tests/Migrations/MigratorTests.cs index b433d0b2a..ec49dab44 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/Migrations/MigratorTests.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/Migrations/MigratorTests.cs @@ -159,7 +159,7 @@ namespace Squidex.Infrastructure.Migrations } [Fact] - public async Task Should_unlock_when_migration_failed() + public async Task Should_unlock_if_migration_failed() { var migrator_0_1 = BuildMigration(0, 1); var migrator_1_2 = BuildMigration(1, 2); @@ -194,7 +194,7 @@ namespace Squidex.Infrastructure.Migrations } [Fact] - public async Task Should_log_exception_when_migration_failed() + public async Task Should_log_exception_if_migration_failed() { var migrator_0_1 = BuildMigration(0, 1); var migrator_1_2 = BuildMigration(1, 2); diff --git a/backend/tests/Squidex.Infrastructure.Tests/MongoDb/MongoExtensionsTests.cs b/backend/tests/Squidex.Infrastructure.Tests/MongoDb/MongoExtensionsTests.cs index c2742c05b..7c08c10ef 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/MongoDb/MongoExtensionsTests.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/MongoDb/MongoExtensionsTests.cs @@ -88,7 +88,7 @@ namespace Squidex.Infrastructure.MongoDb } [Fact] - public async Task Should_break_when_cursor_failed() + public async Task Should_break_if_cursor_failed() { var ex = new InvalidOperationException(); @@ -110,7 +110,7 @@ namespace Squidex.Infrastructure.MongoDb } [Fact] - public async Task Should_break_when_handler_failed() + public async Task Should_break_if_handler_failed() { var ex = new InvalidOperationException(); @@ -137,7 +137,7 @@ namespace Squidex.Infrastructure.MongoDb } [Fact] - public async Task Should_stop_when_cancelled1() + public async Task Should_stop_if_cancelled1() { using (var cts = new CancellationTokenSource()) { diff --git a/backend/tests/Squidex.Infrastructure.Tests/Queries/QueryFromJsonTests.cs b/backend/tests/Squidex.Infrastructure.Tests/Queries/QueryFromJsonTests.cs index 87a771971..5727a5cd3 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/Queries/QueryFromJsonTests.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/Queries/QueryFromJsonTests.cs @@ -480,7 +480,7 @@ namespace Squidex.Infrastructure.Queries } [Fact] - public void Should_add_error_when_using_array_value_for_non_allowed_operator() + public void Should_add_error_if_using_array_value_for_non_allowed_operator() { var json = new { path = "string", op = "eq", value = new[] { "Hello" } }; @@ -545,7 +545,7 @@ namespace Squidex.Infrastructure.Queries } [Fact] - public void Should_throw_exception_when_parsing_invalid_json() + public void Should_throw_exception_if_parsing_invalid_json() { var json = "invalid"; diff --git a/backend/tests/Squidex.Infrastructure.Tests/Queries/QueryFromODataTests.cs b/backend/tests/Squidex.Infrastructure.Tests/Queries/QueryFromODataTests.cs index 634edbdd6..4bcdd9a40 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/Queries/QueryFromODataTests.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/Queries/QueryFromODataTests.cs @@ -68,7 +68,7 @@ namespace Squidex.Infrastructure.Queries [InlineData("createdNullable")] [InlineData("properties/datetime")] [InlineData("properties/nested/datetime")] - public void Should_parse_filter_when_type_is_datetime(string field) + public void Should_parse_filter_if_type_is_datetime(string field) { var i = _Q($"$filter={field} eq 1988-01-19T12:00:00Z"); var o = _C($"Filter: {field} == 1988-01-19T12:00:00Z"); @@ -81,7 +81,7 @@ namespace Squidex.Infrastructure.Queries [InlineData("createdNullable")] [InlineData("properties/datetime")] [InlineData("properties/nested/datetime")] - public void Should_parse_filter_when_type_is_datetime_and_value_is_null(string field) + public void Should_parse_filter_if_type_is_datetime_and_value_is_null(string field) { var i = _Q($"$filter={field} eq null"); var o = _C($"Filter: {field} == null"); @@ -90,7 +90,7 @@ namespace Squidex.Infrastructure.Queries } [Fact] - public void Should_parse_filter_when_type_is_datetime_list() + public void Should_parse_filter_if_type_is_datetime_list() { var i = _Q("$filter=created in ('1988-01-19T12:00:00Z')"); var o = _C("Filter: created in [1988-01-19T12:00:00Z]"); @@ -99,7 +99,7 @@ namespace Squidex.Infrastructure.Queries } [Fact] - public void Should_parse_filter_when_type_is_datetime_and_and_value_is_date() + public void Should_parse_filter_if_type_is_datetime_and_and_value_is_date() { var i = _Q("$filter=created eq 1988-01-19"); var o = _C("Filter: created == 1988-01-19T00:00:00Z"); @@ -112,7 +112,7 @@ namespace Squidex.Infrastructure.Queries [InlineData("birthdayNullable")] [InlineData("properties/date")] [InlineData("properties/nested/date")] - public void Should_parse_filter_when_type_is_date(string field) + public void Should_parse_filter_if_type_is_date(string field) { var i = _Q($"$filter={field} eq 1988-01-19"); var o = _C($"Filter: {field} == 1988-01-19T00:00:00Z"); @@ -121,7 +121,7 @@ namespace Squidex.Infrastructure.Queries } [Fact] - public void Should_parse_filter_when_type_is_date_list() + public void Should_parse_filter_if_type_is_date_list() { var i = _Q("$filter=birthday in ('1988-01-19')"); var o = _C("Filter: birthday in [1988-01-19T00:00:00Z]"); @@ -134,7 +134,7 @@ namespace Squidex.Infrastructure.Queries [InlineData("idNullable")] [InlineData("properties/uid")] [InlineData("properties/nested/guid")] - public void Should_parse_filter_when_type_is_guid(string field) + public void Should_parse_filter_if_type_is_guid(string field) { var i = _Q($"$filter={field} eq B5FE25E3-B262-4B17-91EF-B3772A6B62BB"); var o = _C($"Filter: {field} == b5fe25e3-b262-4b17-91ef-b3772a6b62bb"); @@ -147,7 +147,7 @@ namespace Squidex.Infrastructure.Queries [InlineData("idNullable")] [InlineData("properties/uid")] [InlineData("properties/nested/guid")] - public void Should_parse_filter_when_type_is_guid_and_value_is_null(string field) + public void Should_parse_filter_if_type_is_guid_and_value_is_null(string field) { var i = _Q($"$filter={field} eq null"); var o = _C($"Filter: {field} == null"); @@ -156,7 +156,7 @@ namespace Squidex.Infrastructure.Queries } [Fact] - public void Should_parse_filter_when_type_is_guid_list() + public void Should_parse_filter_if_type_is_guid_list() { var i = _Q("$filter=id in ('B5FE25E3-B262-4B17-91EF-B3772A6B62BB')"); var o = _C("Filter: id in [b5fe25e3-b262-4b17-91ef-b3772a6b62bb]"); @@ -165,7 +165,7 @@ namespace Squidex.Infrastructure.Queries } [Fact] - public void Should_parse_filter_when_type_is_null() + public void Should_parse_filter_if_type_is_null() { var i = _Q("$filter=firstName eq null"); var o = _C("Filter: firstName == null"); @@ -178,7 +178,7 @@ namespace Squidex.Infrastructure.Queries [InlineData("firstNameNullable")] [InlineData("properties/string")] [InlineData("properties/nested/string")] - public void Should_parse_filter_when_type_is_string(string field) + public void Should_parse_filter_if_type_is_string(string field) { var i = _Q($"$filter={field} eq 'Dagobert'"); var o = _C($"Filter: {field} == 'Dagobert'"); @@ -187,7 +187,7 @@ namespace Squidex.Infrastructure.Queries } [Fact] - public void Should_parse_filter_when_type_is_string_list() + public void Should_parse_filter_if_type_is_string_list() { var i = _Q("$filter=firstName in ('Dagobert')"); var o = _C("Filter: firstName in ['Dagobert']"); @@ -200,7 +200,7 @@ namespace Squidex.Infrastructure.Queries [InlineData("isComicFigureNullable")] [InlineData("properties/boolean")] [InlineData("properties/nested/boolean")] - public void Should_parse_filter_when_type_is_boolean(string field) + public void Should_parse_filter_if_type_is_boolean(string field) { var i = _Q($"$filter={field} eq true"); var o = _C($"Filter: {field} == True"); @@ -213,7 +213,7 @@ namespace Squidex.Infrastructure.Queries [InlineData("isComicFigureNullable")] [InlineData("properties/boolean")] [InlineData("properties/nested/boolean")] - public void Should_parse_filter_when_type_is_boolean_and_value_is_null(string field) + public void Should_parse_filter_if_type_is_boolean_and_value_is_null(string field) { var i = _Q($"$filter={field} eq null"); var o = _C($"Filter: {field} == null"); @@ -222,7 +222,7 @@ namespace Squidex.Infrastructure.Queries } [Fact] - public void Should_parse_filter_when_type_is_boolean_list() + public void Should_parse_filter_if_type_is_boolean_list() { var i = _Q("$filter=isComicFigure in (true)"); var o = _C("Filter: isComicFigure in [True]"); @@ -235,7 +235,7 @@ namespace Squidex.Infrastructure.Queries [InlineData("ageNullable")] [InlineData("properties/int")] [InlineData("properties/nested/int")] - public void Should_parse_filter_when_type_is_int32(string field) + public void Should_parse_filter_if_type_is_int32(string field) { var i = _Q($"$filter={field} eq 60"); var o = _C($"Filter: {field} == 60"); @@ -244,7 +244,7 @@ namespace Squidex.Infrastructure.Queries } [Fact] - public void Should_parse_filter_when_type_is_int32_list() + public void Should_parse_filter_if_type_is_int32_list() { var i = _Q("$filter=age in (60)"); var o = _C("Filter: age in [60]"); @@ -257,7 +257,7 @@ namespace Squidex.Infrastructure.Queries [InlineData("incomeCentsNullable")] [InlineData("properties/long")] [InlineData("properties/nested/long")] - public void Should_parse_filter_when_type_is_int64(string field) + public void Should_parse_filter_if_type_is_int64(string field) { var i = _Q($"$filter={field} eq 31543143513456789"); var o = _C($"Filter: {field} == 31543143513456789"); @@ -266,7 +266,7 @@ namespace Squidex.Infrastructure.Queries } [Fact] - public void Should_parse_filter_when_type_is_int64_list() + public void Should_parse_filter_if_type_is_int64_list() { var i = _Q("$filter=incomeCents in (31543143513456789)"); var o = _C("Filter: incomeCents in [31543143513456789]"); @@ -279,7 +279,7 @@ namespace Squidex.Infrastructure.Queries [InlineData("incomeMioNullable")] [InlineData("properties/double")] [InlineData("properties/nested/double")] - public void Should_parse_filter_when_type_is_double(string field) + public void Should_parse_filter_if_type_is_double(string field) { var i = _Q($"$filter={field} eq 5634474356.1233"); var o = _C($"Filter: {field} == 5634474356.1233"); @@ -292,7 +292,7 @@ namespace Squidex.Infrastructure.Queries [InlineData("geoNullable")] [InlineData("properties/geo")] [InlineData("properties/nested/geo")] - public void Should_parse_filter_when_type_is_geograph(string field) + public void Should_parse_filter_if_type_is_geograph(string field) { var i = _Q($"$filter=geo.distance({field}, geography'POINT(10 20)') lt 30.0"); var o = _C($"Filter: {field} < Radius(10, 20, 30)"); @@ -301,7 +301,7 @@ namespace Squidex.Infrastructure.Queries } [Fact] - public void Should_parse_filter_when_type_is_double_list() + public void Should_parse_filter_if_type_is_double_list() { var i = _Q("$filter=incomeMio in (5634474356.1233)"); var o = _C("Filter: incomeMio in [5634474356.1233]"); diff --git a/backend/tests/Squidex.Infrastructure.Tests/Queries/QueryJsonTests.cs b/backend/tests/Squidex.Infrastructure.Tests/Queries/QueryJsonTests.cs index b00871e9e..af0f8e3e0 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/Queries/QueryJsonTests.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/Queries/QueryJsonTests.cs @@ -166,7 +166,7 @@ namespace Squidex.Infrastructure.Queries } [Fact] - public void Should_not_throw_exception_when_filter_has_unknown_property() + public void Should_not_throw_exception_if_filter_has_unknown_property() { var json = new { diff --git a/backend/tests/Squidex.Infrastructure.Tests/Queries/QueryOptimizationTests.cs b/backend/tests/Squidex.Infrastructure.Tests/Queries/QueryOptimizationTests.cs index 47a5ba1f5..8905236ad 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/Queries/QueryOptimizationTests.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/Queries/QueryOptimizationTests.cs @@ -32,7 +32,7 @@ namespace Squidex.Infrastructure.Queries } [Fact] - public void Should_return_null_when_filters_of_logical_filter_get_optimized_away() + public void Should_return_null_if_filters_of_logical_filter_get_optimized_away() { var source = ClrFilter.And(ClrFilter.And()); @@ -42,7 +42,7 @@ namespace Squidex.Infrastructure.Queries } [Fact] - public void Should_return_null_when_logical_filter_has_no_filter() + public void Should_return_null_if_logical_filter_has_no_filter() { var source = ClrFilter.And(); @@ -52,7 +52,7 @@ namespace Squidex.Infrastructure.Queries } [Fact] - public void Should_return_null_when_filter_of_negation_get_optimized_away() + public void Should_return_null_if_filter_of_negation_get_optimized_away() { var source = ClrFilter.Not(ClrFilter.And()); diff --git a/backend/tests/Squidex.Infrastructure.Tests/Reflection/SimpleMapperTests.cs b/backend/tests/Squidex.Infrastructure.Tests/Reflection/SimpleMapperTests.cs index 5221d9840..9f3677c75 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/Reflection/SimpleMapperTests.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/Reflection/SimpleMapperTests.cs @@ -115,7 +115,7 @@ namespace Squidex.Infrastructure.Reflection } [Fact] - public void Should_map_when_convertible_is_null() + public void Should_map_if_convertible_is_null() { var obj1 = new Class1 { diff --git a/backend/tests/Squidex.Infrastructure.Tests/Security/PermissionTests.cs b/backend/tests/Squidex.Infrastructure.Tests/Security/PermissionTests.cs index 6286f0223..d5bea06a9 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/Security/PermissionTests.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/Security/PermissionTests.cs @@ -23,7 +23,7 @@ namespace Squidex.Infrastructure.Security } [Fact] - public void Should_allow_and_include_when_permissions_are_equal() + public void Should_allow_and_include_if_permissions_are_equal() { var g = new Permission("app.contents"); var r = new Permission("app.contents"); @@ -33,7 +33,7 @@ namespace Squidex.Infrastructure.Security } [Fact] - public void Should_not_allow_and_include_when_permissions_are_not_equal() + public void Should_not_allow_and_include_if_permissions_are_not_equal() { var g = new Permission("app.contents"); var r = new Permission("app.assets"); @@ -43,7 +43,7 @@ namespace Squidex.Infrastructure.Security } [Fact] - public void Should_allow_and_include_when_permissions_have_same_wildcards() + public void Should_allow_and_include_if_permissions_have_same_wildcards() { var g = new Permission("app.*"); var r = new Permission("app.*"); @@ -53,7 +53,7 @@ namespace Squidex.Infrastructure.Security } [Fact] - public void Should_allow_and_include_when_given_is_parent_of_requested() + public void Should_allow_and_include_if_given_is_parent_of_requested() { var g = new Permission("app"); var r = new Permission("app.contents"); @@ -63,7 +63,7 @@ namespace Squidex.Infrastructure.Security } [Fact] - public void Should_not_allow_but_include_when_requested_is_parent_of_given() + public void Should_not_allow_but_include_if_requested_is_parent_of_given() { var g = new Permission("app.contents"); var r = new Permission("app"); @@ -73,7 +73,7 @@ namespace Squidex.Infrastructure.Security } [Fact] - public void Should_allow_and_include_when_given_is_wildcard_of_requested() + public void Should_allow_and_include_if_given_is_wildcard_of_requested() { var g = new Permission("app.*"); var r = new Permission("app.contents"); @@ -83,7 +83,7 @@ namespace Squidex.Infrastructure.Security } [Fact] - public void Should_not_allow_but_include_when_given_is_wildcard_of_requested() + public void Should_not_allow_but_include_if_given_is_wildcard_of_requested() { var g = new Permission("app.contents"); var r = new Permission("app.*"); @@ -93,7 +93,7 @@ namespace Squidex.Infrastructure.Security } [Fact] - public void Should_allow_and_include_when_given_has_alternatives_of_requested() + public void Should_allow_and_include_if_given_has_alternatives_of_requested() { var g = new Permission("app.contents|schemas"); var r = new Permission("app.contents"); @@ -103,7 +103,7 @@ namespace Squidex.Infrastructure.Security } [Fact] - public void Should_allow_and_include_when_given_has_not_excluded_requested() + public void Should_allow_and_include_if_given_has_not_excluded_requested() { var g = new Permission("app.^schemas"); var r = new Permission("app.contents"); @@ -113,7 +113,7 @@ namespace Squidex.Infrastructure.Security } [Fact] - public void Should_allow_and_include_when_requested_has_not_excluded_given() + public void Should_allow_and_include_if_requested_has_not_excluded_given() { var g = new Permission("app.contents"); var r = new Permission("app.^schemas"); @@ -123,7 +123,7 @@ namespace Squidex.Infrastructure.Security } [Fact] - public void Should_not_allow_and_include_when_given_has_excluded_requested() + public void Should_not_allow_and_include_if_given_has_excluded_requested() { var g = new Permission("app.^contents"); var r = new Permission("app.contents"); @@ -133,7 +133,7 @@ namespace Squidex.Infrastructure.Security } [Fact] - public void Should_not_allow_and_include_when_given_and_requested_have_same_exclusion() + public void Should_not_allow_and_include_if_given_and_requested_have_same_exclusion() { var g = new Permission("app.^contents"); var r = new Permission("app.^contents"); @@ -143,7 +143,7 @@ namespace Squidex.Infrastructure.Security } [Fact] - public void Should_allow_and_include_when_requested_is_has_alternatives_of_given() + public void Should_allow_and_include_if_requested_is_has_alternatives_of_given() { var g = new Permission("app.contents"); var r = new Permission("app.contents|schemas"); diff --git a/backend/tests/Squidex.Infrastructure.Tests/States/PersistenceEventSourcingTests.cs b/backend/tests/Squidex.Infrastructure.Tests/States/PersistenceEventSourcingTests.cs index 57c61d288..4d01b0b67 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/States/PersistenceEventSourcingTests.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/States/PersistenceEventSourcingTests.cs @@ -106,7 +106,7 @@ namespace Squidex.Infrastructure.States } [Fact] - public async Task Should_mark_as_stale_when_snapshot_old_than_events() + public async Task Should_mark_as_stale_if_snapshot_old_than_events() { A.CallTo(() => snapshotStore.ReadAsync(key)) .Returns(("2", true, 1L)); @@ -264,7 +264,7 @@ namespace Squidex.Infrastructure.States } [Fact] - public async Task Should_write_snapshot_to_store_when_not_read_before() + public async Task Should_write_snapshot_to_store_if_not_read_before() { A.CallTo(() => snapshotStore.ReadAsync(key)) .Returns((null!, true, EtagVersion.Empty)); @@ -290,7 +290,7 @@ namespace Squidex.Infrastructure.States } [Fact] - public async Task Should_not_write_snapshot_to_store_when_not_changed() + public async Task Should_not_write_snapshot_to_store_if_not_changed() { A.CallTo(() => snapshotStore.ReadAsync(key)) .Returns(("0", true, 2)); @@ -310,7 +310,7 @@ namespace Squidex.Infrastructure.States } [Fact] - public async Task Should_wrap_exception_when_writing_to_store_with_previous_version() + public async Task Should_wrap_exception_if_writing_to_store_with_previous_version() { SetupEventStore(3); @@ -326,7 +326,7 @@ namespace Squidex.Infrastructure.States } [Fact] - public async Task Should_delete_events_but_not_snapshot_when_deleted_snapshot_only() + public async Task Should_delete_events_but_not_snapshot_if_deleted_snapshot_only() { var persistence = sut.WithEventSourcing(None.Type, key, null); @@ -340,7 +340,7 @@ namespace Squidex.Infrastructure.States } [Fact] - public async Task Should_delete_events_and_snapshot_when_deleted() + public async Task Should_delete_events_and_snapshot_if_deleted() { var persistence = sut.WithSnapshotsAndEventSourcing(None.Type, key, null, null); diff --git a/backend/tests/Squidex.Infrastructure.Tests/States/PersistenceSnapshotTests.cs b/backend/tests/Squidex.Infrastructure.Tests/States/PersistenceSnapshotTests.cs index 87e395be3..c81d67daa 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/States/PersistenceSnapshotTests.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/States/PersistenceSnapshotTests.cs @@ -43,7 +43,7 @@ namespace Squidex.Infrastructure.States } [Fact] - public async Task Should_not_read_from_store_when_not_valid() + public async Task Should_not_read_from_store_if_not_valid() { A.CallTo(() => snapshotStore.ReadAsync(key)) .Returns((20, false, 10)); @@ -58,7 +58,7 @@ namespace Squidex.Infrastructure.States } [Fact] - public async Task Should_return_empty_version_when_version_negative() + public async Task Should_return_empty_version_if_version_negative() { A.CallTo(() => snapshotStore.ReadAsync(key)) .Returns((20, true, -10)); @@ -72,7 +72,7 @@ namespace Squidex.Infrastructure.States } [Fact] - public async Task Should_set_to_empty_when_store_returns_not_found() + public async Task Should_set_to_empty_if_store_returns_not_found() { A.CallTo(() => snapshotStore.ReadAsync(key)) .Returns((20, true, EtagVersion.Empty)); @@ -142,7 +142,7 @@ namespace Squidex.Infrastructure.States } [Fact] - public async Task Should_not_wrap_exception_when_writing_to_store_with_previous_version() + public async Task Should_not_wrap_exception_if_writing_to_store_with_previous_version() { A.CallTo(() => snapshotStore.ReadAsync(key)) .Returns((20, true, 10)); @@ -159,7 +159,7 @@ namespace Squidex.Infrastructure.States } [Fact] - public async Task Should_delete_snapshot_but_not_events_when_deleted() + public async Task Should_delete_snapshot_but_not_events_if_deleted() { var persistedState = Save.Snapshot(0); var persistence = sut.WithSnapshots(None.Type, key, persistedState.Write); diff --git a/backend/tests/Squidex.Infrastructure.Tests/StringExtensionsTests.cs b/backend/tests/Squidex.Infrastructure.Tests/StringExtensionsTests.cs index a149a60e6..00b2c22c7 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/StringExtensionsTests.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/StringExtensionsTests.cs @@ -63,7 +63,7 @@ namespace Squidex.Infrastructure } [Fact] - public void Should_join_non_empty_when_all_are_valid() + public void Should_join_non_empty_if_all_are_valid() { var result = StringExtensions.JoinNonEmpty("_", "1", "2", "3"); @@ -71,7 +71,7 @@ namespace Squidex.Infrastructure } [Fact] - public void Should_join_non_empty_when_first_invalid() + public void Should_join_non_empty_if_first_invalid() { var result = StringExtensions.JoinNonEmpty("_", null, "2", "3"); @@ -79,7 +79,7 @@ namespace Squidex.Infrastructure } [Fact] - public void Should_join_non_empty_when_middle_invalid() + public void Should_join_non_empty_if_middle_invalid() { var result = StringExtensions.JoinNonEmpty("_", "1", null, "3"); @@ -87,7 +87,7 @@ namespace Squidex.Infrastructure } [Fact] - public void Should_join_non_empty_when_last_invalid() + public void Should_join_non_empty_if_last_invalid() { var result = StringExtensions.JoinNonEmpty("_", "1", "2", null); diff --git a/backend/tests/Squidex.Infrastructure.Tests/UsageTracking/BackgroundUsageTrackerTests.cs b/backend/tests/Squidex.Infrastructure.Tests/UsageTracking/BackgroundUsageTrackerTests.cs index 304ff68e1..14f2c73ad 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/UsageTracking/BackgroundUsageTrackerTests.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/UsageTracking/BackgroundUsageTrackerTests.cs @@ -61,7 +61,7 @@ namespace Squidex.Infrastructure.UsageTracking } [Fact] - public async Task Should_sum_up_when_getting_monthly_calls() + public async Task Should_sum_up_if_getting_monthly_calls() { var dateFrom = new DateTime(date.Year, date.Month, 1); var dateTo = dateFrom.AddMonths(1).AddDays(-1); @@ -87,7 +87,7 @@ namespace Squidex.Infrastructure.UsageTracking } [Fact] - public async Task Should_sum_up_when_getting_last_calls_calls() + public async Task Should_sum_up_if_getting_last_calls_calls() { var dateFrom = date; var dateTo = dateFrom.AddDays(10); diff --git a/backend/tests/Squidex.Web.Tests/ApiPermissionAttributeTests.cs b/backend/tests/Squidex.Web.Tests/ApiPermissionAttributeTests.cs index f2ae1b074..ac7b4e13c 100644 --- a/backend/tests/Squidex.Web.Tests/ApiPermissionAttributeTests.cs +++ b/backend/tests/Squidex.Web.Tests/ApiPermissionAttributeTests.cs @@ -95,7 +95,7 @@ namespace Squidex.Web } [Fact] - public async Task Should_return_forbidden_when_user_has_wrong_permission() + public async Task Should_return_forbidden_if_user_has_wrong_permission() { actionExecutingContext.HttpContext.Features.Set(new AppFeature(NamedId.Of(DomainId.NewGuid(), "my-app"))); @@ -112,7 +112,7 @@ namespace Squidex.Web } [Fact] - public async Task Should_return_forbidden_when_route_data_has_no_value() + public async Task Should_return_forbidden_if_route_data_has_no_value() { user.AddClaim(new Claim(SquidexClaimTypes.Permissions, "squidex.apps.other-app")); @@ -127,7 +127,7 @@ namespace Squidex.Web } [Fact] - public async Task Should_return_forbidden_when_user_has_no_permission() + public async Task Should_return_forbidden_if_user_has_no_permission() { SetContext(); diff --git a/backend/tests/Squidex.Web.Tests/CommandMiddlewares/ETagCommandMiddlewareTests.cs b/backend/tests/Squidex.Web.Tests/CommandMiddlewares/ETagCommandMiddlewareTests.cs index 095f834a4..3cf4af8dc 100644 --- a/backend/tests/Squidex.Web.Tests/CommandMiddlewares/ETagCommandMiddlewareTests.cs +++ b/backend/tests/Squidex.Web.Tests/CommandMiddlewares/ETagCommandMiddlewareTests.cs @@ -33,7 +33,7 @@ namespace Squidex.Web.CommandMiddlewares } [Fact] - public async Task Should_do_nothing_when_context_is_null() + public async Task Should_do_nothing_if_context_is_null() { A.CallTo(() => httpContextAccessor.HttpContext) .Returns(null!); diff --git a/backend/tests/Squidex.Web.Tests/CommandMiddlewares/EnrichWithActorCommandMiddlewareTests.cs b/backend/tests/Squidex.Web.Tests/CommandMiddlewares/EnrichWithActorCommandMiddlewareTests.cs index 99a7ef987..226e4bb3c 100644 --- a/backend/tests/Squidex.Web.Tests/CommandMiddlewares/EnrichWithActorCommandMiddlewareTests.cs +++ b/backend/tests/Squidex.Web.Tests/CommandMiddlewares/EnrichWithActorCommandMiddlewareTests.cs @@ -33,13 +33,13 @@ namespace Squidex.Web.CommandMiddlewares } [Fact] - public async Task Should_throw_security_exception_when_no_subject_or_client_is_found() + public async Task Should_throw_security_exception_if_no_subject_or_client_is_found() { await Assert.ThrowsAsync(() => HandleAsync(new CreateContent())); } [Fact] - public async Task Should_do_nothing_when_context_is_null() + public async Task Should_do_nothing_if_context_is_null() { A.CallTo(() => httpContextAccessor.HttpContext) .Returns(null!); diff --git a/backend/tests/Squidex.Web.Tests/Pipeline/ApiPermissionUnifierTests.cs b/backend/tests/Squidex.Web.Tests/Pipeline/ApiPermissionUnifierTests.cs index 265658925..74728452c 100644 --- a/backend/tests/Squidex.Web.Tests/Pipeline/ApiPermissionUnifierTests.cs +++ b/backend/tests/Squidex.Web.Tests/Pipeline/ApiPermissionUnifierTests.cs @@ -21,7 +21,7 @@ namespace Squidex.Web.Pipeline [Theory] [InlineData("administrator")] [InlineData("ADMINISTRATOR")] - public async Task Should_add_admin_permission_when_user_is_in_role(string role) + public async Task Should_add_admin_permission_if_user_is_in_role(string role) { var userIdentity = new ClaimsIdentity(); var userPrinicpal = new ClaimsPrincipal(userIdentity); @@ -35,7 +35,7 @@ namespace Squidex.Web.Pipeline } [Fact] - public async Task Should_not_add_admin_persmission_when_user_has_other_role() + public async Task Should_not_add_admin_persmission_if_user_has_other_role() { var userIdentity = new ClaimsIdentity(); var userPrinicpal = new ClaimsPrincipal(userIdentity); @@ -48,7 +48,7 @@ namespace Squidex.Web.Pipeline } [Fact] - public async Task Should_not_add_admin_persmission_when_user_has_no_role() + public async Task Should_not_add_admin_persmission_if_user_has_no_role() { var userIdentity = new ClaimsIdentity(); var userPrinicpal = new ClaimsPrincipal(userIdentity); diff --git a/backend/tests/Squidex.Web.Tests/Pipeline/CachingKeysMiddlewareTests.cs b/backend/tests/Squidex.Web.Tests/Pipeline/CachingKeysMiddlewareTests.cs index 43dddac49..a521badf5 100644 --- a/backend/tests/Squidex.Web.Tests/Pipeline/CachingKeysMiddlewareTests.cs +++ b/backend/tests/Squidex.Web.Tests/Pipeline/CachingKeysMiddlewareTests.cs @@ -102,7 +102,7 @@ namespace Squidex.Web.Pipeline } [Fact] - public async Task Should_append_authorization_as_header_when_user_has_subject() + public async Task Should_append_authorization_as_header_if_user_has_subject() { var identity = (ClaimsIdentity)httpContext.User.Identity!; @@ -114,7 +114,7 @@ namespace Squidex.Web.Pipeline } [Fact] - public async Task Should_append_client_id_as_header_when_user_has_client_but_no_subject() + public async Task Should_append_client_id_as_header_if_user_has_client_but_no_subject() { var identity = (ClaimsIdentity)httpContext.User.Identity!; @@ -299,7 +299,7 @@ namespace Squidex.Web.Pipeline } [Fact] - public async Task Should_not_generate_etag_when_already_added() + public async Task Should_not_generate_etag_if_already_added() { var id1 = DomainId.NewGuid(); var id2 = DomainId.NewGuid(); diff --git a/frontend/app/features/administration/declarations.ts b/frontend/app/features/administration/declarations.ts index a32a9196b..41eaef0b4 100644 --- a/frontend/app/features/administration/declarations.ts +++ b/frontend/app/features/administration/declarations.ts @@ -6,7 +6,6 @@ */ export * from './administration-area.component'; -export * from './guards/unset-user.guard'; export * from './guards/user-must-exist.guard'; export * from './internal'; export * from './pages/cluster/cluster-page.component'; diff --git a/frontend/app/features/administration/guards/unset-user.guard.spec.ts b/frontend/app/features/administration/guards/unset-user.guard.spec.ts deleted file mode 100644 index 0bb971fbc..000000000 --- a/frontend/app/features/administration/guards/unset-user.guard.spec.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Squidex Headless CMS - * - * @license - * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. - */ - -import { UsersState } from '@app/features/administration/internal'; -import { of } from 'rxjs'; -import { IMock, Mock, Times } from 'typemoq'; -import { UnsetUserGuard } from './unset-user.guard'; - -describe('UnsetUserGuard', () => { - let usersState: IMock; - let userGuard: UnsetUserGuard; - - beforeEach(() => { - usersState = Mock.ofType(); - userGuard = new UnsetUserGuard(usersState.object); - }); - - it('should unset user', () => { - usersState.setup(x => x.select(null)) - .returns(() => of(null)); - - let result: boolean; - - userGuard.canActivate().subscribe(x => { - result = x; - }).unsubscribe(); - - expect(result!).toBeTruthy(); - - usersState.verify(x => x.select(null), Times.once()); - }); -}); \ No newline at end of file diff --git a/frontend/app/features/administration/guards/unset-user.guard.ts b/frontend/app/features/administration/guards/unset-user.guard.ts deleted file mode 100644 index 5efff84df..000000000 --- a/frontend/app/features/administration/guards/unset-user.guard.ts +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Squidex Headless CMS - * - * @license - * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. - */ - -import { Injectable } from '@angular/core'; -import { CanActivate } from '@angular/router'; -import { UsersState } from '@app/features/administration/internal'; -import { Observable } from 'rxjs'; -import { map } from 'rxjs/operators'; - -@Injectable() -export class UnsetUserGuard implements CanActivate { - constructor( - private readonly usersState: UsersState - ) { - } - - public canActivate(): Observable { - return this.usersState.select(null).pipe(map(u => u === null)); - } -} \ No newline at end of file diff --git a/frontend/app/features/administration/guards/user-must-exist.guard.spec.ts b/frontend/app/features/administration/guards/user-must-exist.guard.spec.ts index eb1e97109..b01b0df17 100644 --- a/frontend/app/features/administration/guards/user-must-exist.guard.spec.ts +++ b/frontend/app/features/administration/guards/user-must-exist.guard.spec.ts @@ -12,11 +12,6 @@ import { IMock, Mock, Times } from 'typemoq'; import { UserMustExistGuard } from './user-must-exist.guard'; describe('UserMustExistGuard', () => { - const route: any = { - params: { - userId: '123' - } - }; let usersState: IMock; let router: IMock; @@ -28,12 +23,18 @@ describe('UserMustExistGuard', () => { userGuard = new UserMustExistGuard(usersState.object, router.object); }); - it('should load user and return true when found', () => { + it('should load user and return true if found', () => { usersState.setup(x => x.select('123')) .returns(() => of({})); let result: boolean; + const route: any = { + params: { + userId: '123' + } + }; + userGuard.canActivate(route).subscribe(x => { result = x; }).unsubscribe(); @@ -43,12 +44,18 @@ describe('UserMustExistGuard', () => { usersState.verify(x => x.select('123'), Times.once()); }); - it('should load user and return false when not found', () => { + it('should load user and return false if not found', () => { usersState.setup(x => x.select('123')) .returns(() => of(null)); let result: boolean; + const route: any = { + params: { + userId: '123' + } + }; + userGuard.canActivate(route).subscribe(x => { result = x; }).unsubscribe(); @@ -57,4 +64,46 @@ describe('UserMustExistGuard', () => { router.verify(x => x.navigate(['/404']), Times.once()); }); + + it('should unset user if user id is undefined', () => { + usersState.setup(x => x.select(null)) + .returns(() => of(null)); + + let result: boolean; + + const route: any = { + params: { + userId: undefined + } + }; + + userGuard.canActivate(route).subscribe(x => { + result = x; + }).unsubscribe(); + + expect(result!).toBeTruthy(); + + usersState.verify(x => x.select(null), Times.once()); + }); + + it('should unset user if user id is ', () => { + usersState.setup(x => x.select(null)) + .returns(() => of(null)); + + let result: boolean; + + const route: any = { + params: { + userId: 'new' + } + }; + + userGuard.canActivate(route).subscribe(x => { + result = x; + }).unsubscribe(); + + expect(result!).toBeTruthy(); + + usersState.verify(x => x.select(null), Times.once()); + }); }); \ No newline at end of file diff --git a/frontend/app/features/administration/guards/user-must-exist.guard.ts b/frontend/app/features/administration/guards/user-must-exist.guard.ts index bba3213d7..0939f33ca 100644 --- a/frontend/app/features/administration/guards/user-must-exist.guard.ts +++ b/frontend/app/features/administration/guards/user-must-exist.guard.ts @@ -23,6 +23,10 @@ export class UserMustExistGuard implements CanActivate { public canActivate(route: ActivatedRouteSnapshot): Observable { const userId = allParams(route)['userId']; + if (!userId || userId === 'new') { + return this.usersState.select(null).pipe(map(u => u === null)); + } + const result = this.usersState.select(userId).pipe( tap(dto => { diff --git a/frontend/app/features/administration/module.ts b/frontend/app/features/administration/module.ts index 959deb130..071efedc9 100644 --- a/frontend/app/features/administration/module.ts +++ b/frontend/app/features/administration/module.ts @@ -10,7 +10,7 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; import { SqxFrameworkModule, SqxSharedModule } from '@app/shared'; -import { AdministrationAreaComponent, ClusterPageComponent, EventConsumerComponent, EventConsumersPageComponent, EventConsumersService, EventConsumersState, RestorePageComponent, UnsetUserGuard, UserComponent, UserMustExistGuard, UserPageComponent, UsersPageComponent, UsersService, UsersState } from './declarations'; +import { AdministrationAreaComponent, ClusterPageComponent, EventConsumerComponent, EventConsumersPageComponent, EventConsumersService, EventConsumersState, RestorePageComponent, UserComponent, UserMustExistGuard, UserPageComponent, UsersPageComponent, UsersService, UsersState } from './declarations'; const routes: Routes = [ { @@ -36,11 +36,6 @@ const routes: Routes = [ path: 'users', component: UsersPageComponent, children: [ - { - path: 'new', - component: UserPageComponent, - canActivate: [UnsetUserGuard] - }, { path: ':userId', component: UserPageComponent, @@ -73,7 +68,6 @@ const routes: Routes = [ providers: [ EventConsumersService, EventConsumersState, - UnsetUserGuard, UserMustExistGuard, UsersService, UsersState diff --git a/frontend/app/features/administration/state/event-consumers.state.spec.ts b/frontend/app/features/administration/state/event-consumers.state.spec.ts index e8af21d2f..decaf28c7 100644 --- a/frontend/app/features/administration/state/event-consumers.state.spec.ts +++ b/frontend/app/features/administration/state/event-consumers.state.spec.ts @@ -46,7 +46,7 @@ describe('EventConsumersState', () => { dialogs.verify(x => x.notifyInfo(It.isAnyString()), Times.never()); }); - it('should reset loading when loading failed', () => { + it('should reset loading state if loading failed', () => { eventConsumersService.setup(x => x.getEventConsumers()) .returns(() => throwError('error')); @@ -55,7 +55,7 @@ describe('EventConsumersState', () => { expect(eventConsumersState.snapshot.isLoading).toBeFalsy(); }); - it('should show notification on load when reload is true', () => { + it('should show notification on load if reload is true', () => { eventConsumersService.setup(x => x.getEventConsumers()) .returns(() => of(new EventConsumersDto([eventConsumer1, eventConsumer2]))).verifiable(); @@ -66,7 +66,7 @@ describe('EventConsumersState', () => { dialogs.verify(x => x.notifyInfo(It.isAnyString()), Times.once()); }); - it('should show notification on load error when silent is false', () => { + it('should show notification on load error if silent is false', () => { eventConsumersService.setup(x => x.getEventConsumers()) .returns(() => throwError({})).verifiable(); @@ -86,7 +86,7 @@ describe('EventConsumersState', () => { eventConsumersState.load().subscribe(); }); - it('should update event consumer when started', () => { + it('should update event consumer if started', () => { const updated = createEventConsumer(2, '_new'); eventConsumersService.setup(x => x.putStart(eventConsumer2)) @@ -94,12 +94,10 @@ describe('EventConsumersState', () => { eventConsumersState.start(eventConsumer2).subscribe(); - const newConsumer2 = eventConsumersState.snapshot.eventConsumers[1]; - - expect(newConsumer2).toEqual(updated); + expect(eventConsumersState.snapshot.eventConsumers).toEqual([eventConsumer1, updated]); }); - it('should update event consumer when stopped', () => { + it('should update event consumer if stopped', () => { const updated = createEventConsumer(2, '_new'); eventConsumersService.setup(x => x.putStop(eventConsumer2)) @@ -107,12 +105,10 @@ describe('EventConsumersState', () => { eventConsumersState.stop(eventConsumer2).subscribe(); - const newConsumer2 = eventConsumersState.snapshot.eventConsumers[1]; - - expect(newConsumer2).toEqual(updated); + expect(eventConsumersState.snapshot.eventConsumers).toEqual([eventConsumer1, updated]); }); - it('should update event consumer when reset', () => { + it('should update event consumer if reset', () => { const updated = createEventConsumer(2, '_new'); eventConsumersService.setup(x => x.putReset(eventConsumer2)) @@ -120,9 +116,7 @@ describe('EventConsumersState', () => { eventConsumersState.reset(eventConsumer2).subscribe(); - const newConsumer2 = eventConsumersState.snapshot.eventConsumers[1]; - - expect(newConsumer2).toEqual(updated); + expect(eventConsumersState.snapshot.eventConsumers).toEqual([eventConsumer1, updated]); }); }); }); \ No newline at end of file diff --git a/frontend/app/features/administration/state/event-consumers.state.ts b/frontend/app/features/administration/state/event-consumers.state.ts index 954eef91a..4d975b6ac 100644 --- a/frontend/app/features/administration/state/event-consumers.state.ts +++ b/frontend/app/features/administration/state/event-consumers.state.ts @@ -99,7 +99,7 @@ export class EventConsumersState extends State { private replaceEventConsumer(eventConsumer: EventConsumerDto) { this.next(s => { - const eventConsumers = s.eventConsumers.replaceBy('name', eventConsumer); + const eventConsumers = s.eventConsumers.replacedBy('name', eventConsumer); return { ...s, eventConsumers }; }, 'Updated'); diff --git a/frontend/app/features/administration/state/users.state.spec.ts b/frontend/app/features/administration/state/users.state.spec.ts index 5be60d7f8..e0ea23ce3 100644 --- a/frontend/app/features/administration/state/users.state.spec.ts +++ b/frontend/app/features/administration/state/users.state.spec.ts @@ -51,7 +51,7 @@ describe('UsersState', () => { dialogs.verify(x => x.notifyInfo(It.isAnyString()), Times.never()); }); - it('should reset loading when loading failed', () => { + it('should reset loading state if loading failed', () => { usersService.setup(x => x.getUsers(10, 0, undefined)) .returns(() => throwError('error')); @@ -60,7 +60,7 @@ describe('UsersState', () => { expect(usersState.snapshot.isLoading).toBeFalsy(); }); - it('should show notification on load when reload is true', () => { + it('should show notification on load if reload is true', () => { usersService.setup(x => x.getUsers(10, 0, undefined)) .returns(() => of(oldUsers)).verifiable(); @@ -71,26 +71,7 @@ describe('UsersState', () => { dialogs.verify(x => x.notifyInfo(It.isAnyString()), Times.once()); }); - it('should replace selected user when reloading', () => { - const newUsers = [ - createUser(1, '_new'), - createUser(2, '_new') - ]; - - usersService.setup(x => x.getUsers(10, 0, undefined)) - .returns(() => of(oldUsers)).verifiable(Times.exactly(2)); - - usersService.setup(x => x.getUsers(10, 0, undefined)) - .returns(() => of(new UsersDto(200, newUsers))); - - usersState.load().subscribe(); - usersState.select(user1.id).subscribe(); - usersState.load().subscribe(); - - expect(usersState.snapshot.selectedUser).toEqual(newUsers[0]); - }); - - it('should load with new pagination when paging', () => { + it('should load with new pagination if paging', () => { usersService.setup(x => x.getUsers(10, 10, undefined)) .returns(() => of(new UsersDto(200, []))).verifiable(); @@ -99,7 +80,7 @@ describe('UsersState', () => { expect().nothing(); }); - it('should load with query when searching', () => { + it('should load with query if searching', () => { usersService.setup(x => x.getUsers(10, 0, 'my-query')) .returns(() => of(new UsersDto(0, []))).verifiable(); @@ -117,7 +98,7 @@ describe('UsersState', () => { usersState.load().subscribe(); }); - it('should return user on select and not load when already loaded', () => { + it('should return user on select and not load if already loaded', () => { let selectedUser: UserDto; usersState.select(user1.id).subscribe(x => { @@ -128,104 +109,93 @@ describe('UsersState', () => { expect(usersState.snapshot.selectedUser).toEqual(user1); }); - it('should return user on select and load when not loaded', () => { + it('should return user on select and load if not loaded', () => { usersService.setup(x => x.getUser('id3')) .returns(() => of(newUser)); - let selectedUser: UserDto; + let userSelected: UserDto; usersState.select('id3').subscribe(x => { - selectedUser = x!; + userSelected = x!; }); - expect(selectedUser!).toEqual(newUser); + expect(userSelected!).toEqual(newUser); expect(usersState.snapshot.selectedUser).toEqual(newUser); }); - it('should return null on select when unselecting user', () => { - let selectedUser: UserDto; + it('should return null on select if unselecting user', () => { + let userSelected: UserDto; usersState.select(null).subscribe(x => { - selectedUser = x!; + userSelected = x!; }); - expect(selectedUser!).toBeNull(); + expect(userSelected!).toBeNull(); expect(usersState.snapshot.selectedUser).toBeNull(); }); - it('should return null on select when user is not found', () => { + it('should return null on select if user is not found', () => { usersService.setup(x => x.getUser('unknown')) .returns(() => throwError({})).verifiable(); - let selectedUser: UserDto; + let userSelected: UserDto; usersState.select('unknown').subscribe(x => { - selectedUser = x!; + userSelected = x!; }).unsubscribe(); - expect(selectedUser!).toBeNull(); + expect(userSelected!).toBeNull(); expect(usersState.snapshot.selectedUser).toBeNull(); }); - it('should update user and selected user when locked', () => { - const updated = createUser(2, '_new'); - - usersService.setup(x => x.lockUser(user2)) - .returns(() => of(updated)).verifiable(); + it('should add user to snapshot if created', () => { + const request = { ...newUser, password: 'password' }; - usersState.select(user2.id).subscribe(); - usersState.lock(user2).subscribe(); + usersService.setup(x => x.postUser(request)) + .returns(() => of(newUser)).verifiable(); - const user2New = usersState.snapshot.users[1]; + usersState.create(request).subscribe(); - expect(user2New).toBe(usersState.snapshot.selectedUser!); + expect(usersState.snapshot.users).toEqual([newUser, user1, user2]); + expect(usersState.snapshot.total).toBe(201); }); - it('should update user and selected user when unlocked', () => { + it('should update user if updated', () => { + const request = {}; + const updated = createUser(2, '_new'); - usersService.setup(x => x.unlockUser(user2)) + usersService.setup(x => x.putUser(user2, request)) .returns(() => of(updated)).verifiable(); - usersState.select(user2.id).subscribe(); - usersState.unlock(user2).subscribe(); - - const user2New = usersState.snapshot.users[1]; + usersState.update(user2, request).subscribe(); - expect(user2New).toEqual(updated); - expect(user2New).toBe(usersState.snapshot.selectedUser!); + expect(usersState.snapshot.users).toEqual([user1, updated]); }); - it('should update user and selected user when updated', () => { - const request = { email: 'new@mail.com', displayName: 'New', permissions: ['Permission1'] }; - + it('should update user if locked', () => { const updated = createUser(2, '_new'); - usersService.setup(x => x.putUser(user2, request)) + usersService.setup(x => x.lockUser(user2)) .returns(() => of(updated)).verifiable(); - usersState.select(user2.id).subscribe(); - usersState.update(user2, request).subscribe(); - - const user2New = usersState.snapshot.users[1]; + usersState.lock(user2).subscribe(); - expect(user2New).toEqual(updated); - expect(user2New).toBe(usersState.snapshot.selectedUser!); + expect(usersState.snapshot.users).toEqual([user1, updated]); }); - it('should add user to snapshot when created', () => { - const request = { ...newUser, password: 'password' }; + it('should update user if locked', () => { + const updated = createUser(2, '_new'); - usersService.setup(x => x.postUser(request)) - .returns(() => of(newUser)).verifiable(); + usersService.setup(x => x.unlockUser(user2)) + .returns(() => of(updated)).verifiable(); - usersState.create(request).subscribe(); + usersState.unlock(user2).subscribe(); - expect(usersState.snapshot.users).toEqual([newUser, user1, user2]); - expect(usersState.snapshot.total).toBe(201); + expect(usersState.snapshot.users).toEqual([user1, updated]); }); - it('should remove user from snapshot when delete', () => { + it('should remove user from snapshot if delete', () => { usersService.setup(x => x.deleteUser(user1)) .returns(() => of(newUser)).verifiable(); @@ -235,7 +205,7 @@ describe('UsersState', () => { expect(usersState.snapshot.total).toBe(199); }); - it('should truncate users when page size reached', () => { + it('should truncate users if page size reached', () => { const request = { ...newUser, password: 'password' }; usersService.setup(x => x.getUsers(2, 0, undefined)) @@ -251,4 +221,50 @@ describe('UsersState', () => { expect(usersState.snapshot.total).toBe(201); }); }); + + describe('Selection', () => { + beforeEach(() => { + usersService.setup(x => x.getUsers(10, 0, undefined)) + .returns(() => of(oldUsers)).verifiable(Times.atLeastOnce()); + + usersState.load().subscribe(); + usersState.select(user2.id).subscribe(); + }); + + it('should update selected user if reloaded', () => { + const newUsers = [ + createUser(1, '_new'), + createUser(2, '_new') + ]; + + usersService.setup(x => x.getUsers(10, 0, undefined)) + .returns(() => of(new UsersDto(2, newUsers))); + + usersState.load().subscribe(); + + expect(usersState.snapshot.selectedUser).toEqual(newUsers[1]); + }); + + it('should update selected user if updated', () => { + const request = {}; + + const updated = createUser(2, '_new'); + + usersService.setup(x => x.putUser(user2, request)) + .returns(() => of(updated)).verifiable(); + + usersState.update(user2, request).subscribe(); + + expect(usersState.snapshot.selectedUser).toEqual(updated); + }); + + it('should remove selected user from snapshot if deleted', () => { + usersService.setup(x => x.deleteUser(user2)) + .returns(() => of(true)).verifiable(); + + usersState.delete(user2).subscribe(); + + expect(usersState.snapshot.selectedUser).toBeNull(); + }); + }); }); \ No newline at end of file diff --git a/frontend/app/features/administration/state/users.state.ts b/frontend/app/features/administration/state/users.state.ts index 23764f32c..a03d8f937 100644 --- a/frontend/app/features/administration/state/users.state.ts +++ b/frontend/app/features/administration/state/users.state.ts @@ -170,7 +170,12 @@ export class UsersState extends State { this.next(s => { const users = s.users.filter(x => x.id !== user.id); - return { ...s, users, total: s.total - 1 }; + const selectedUser = + s.selectedUser?.id !== user.id ? + s.selectedUser : + null; + + return { ...s, users, total: s.total - 1, selectedUser }; }, 'Delete'); }), shareSubscribed(this.dialogs)); @@ -199,7 +204,7 @@ export class UsersState extends State { const selectedUser = s.selectedUser?.id !== user.id ? s.selectedUser : - users.find(x => x.id === user.id); + user; return { ...s, users, selectedUser }; }, 'Updated'); diff --git a/frontend/app/features/content/module.ts b/frontend/app/features/content/module.ts index 062d34ccc..491776fb1 100644 --- a/frontend/app/features/content/module.ts +++ b/frontend/app/features/content/module.ts @@ -9,7 +9,7 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; -import { CanDeactivateGuard, ContentMustExistGuard, LoadLanguagesGuard, SchemaMustExistPublishedGuard, SchemaMustNotBeSingletonGuard, SqxFrameworkModule, SqxSharedModule, UnsetContentGuard } from '@app/shared'; +import { CanDeactivateGuard, ContentMustExistGuard, LoadLanguagesGuard, SchemaMustExistPublishedGuard, SchemaMustNotBeSingletonGuard, SqxFrameworkModule, SqxSharedModule } from '@app/shared'; import { ArrayEditorComponent, ArrayItemComponent, ArraySectionComponent, AssetsEditorComponent, CommentsPageComponent, ContentComponent, ContentCreatorComponent, ContentEditorComponent, ContentEventComponent, ContentFieldComponent, ContentHistoryPageComponent, ContentListCellDirective, ContentListFieldComponent, ContentListHeaderComponent, ContentListWidthPipe, ContentPageComponent, ContentReferencesComponent, ContentsColumnsPipe, ContentSectionComponent, ContentSelectorComponent, ContentSelectorItemComponent, ContentsFiltersPageComponent, ContentsPageComponent, ContentStatusComponent, ContentValueComponent, ContentValueEditorComponent, CustomViewEditorComponent, DueTimeSelectorComponent, FieldEditorComponent, FieldLanguagesComponent, PreviewButtonComponent, ReferenceItemComponent, ReferencesEditorComponent, SchemasPageComponent, SidebarPageComponent, StockPhotoEditorComponent } from './declarations'; import { ContentExtensionComponent } from './shared/content-extension.component'; import { IFrameEditorComponent } from './shared/forms/iframe-editor.component'; @@ -30,7 +30,7 @@ const routes: Routes = [ { path: '', component: ContentsPageComponent, - canActivate: [SchemaMustNotBeSingletonGuard, UnsetContentGuard], + canActivate: [SchemaMustNotBeSingletonGuard, ContentMustExistGuard], canDeactivate: [CanDeactivateGuard], children: [ { @@ -46,7 +46,7 @@ const routes: Routes = [ { path: 'new', component: ContentPageComponent, - canActivate: [SchemaMustNotBeSingletonGuard, UnsetContentGuard], + canActivate: [SchemaMustNotBeSingletonGuard, ContentMustExistGuard], canDeactivate: [CanDeactivateGuard] }, { diff --git a/frontend/app/features/content/shared/forms/assets-editor.component.ts b/frontend/app/features/content/shared/forms/assets-editor.component.ts index a1fe99660..591783af8 100644 --- a/frontend/app/features/content/shared/forms/assets-editor.component.ts +++ b/frontend/app/features/content/shared/forms/assets-editor.component.ts @@ -94,7 +94,7 @@ export class AssetsEditorComponent extends StatefulControlComponent { if (event.source !== this) { - this.setAssets(this.snapshot.assets.replaceBy('id', event.asset)); + this.setAssets(this.snapshot.assets.replacedBy('id', event.asset)); } })); } diff --git a/frontend/app/features/rules/declarations.ts b/frontend/app/features/rules/declarations.ts index 8ec9a27ad..07763a929 100644 --- a/frontend/app/features/rules/declarations.ts +++ b/frontend/app/features/rules/declarations.ts @@ -7,14 +7,14 @@ export * from './pages/events/pipes'; export * from './pages/events/rule-events-page.component'; -export * from './pages/rules/actions/generic-action.component'; -export * from './pages/rules/rule-element.component'; -export * from './pages/rules/rule-icon.component'; -export * from './pages/rules/rule-wizard.component'; +export * from './pages/rule/rule-page.component'; export * from './pages/rules/rule.component'; export * from './pages/rules/rules-page.component'; -export * from './pages/rules/triggers/asset-changed-trigger.component'; -export * from './pages/rules/triggers/comment-trigger.component'; -export * from './pages/rules/triggers/content-changed-trigger.component'; -export * from './pages/rules/triggers/schema-changed-trigger.component'; -export * from './pages/rules/triggers/usage-trigger.component'; \ No newline at end of file +export * from './shared/actions/generic-action.component'; +export * from './shared/rule-element.component'; +export * from './shared/rule-icon.component'; +export * from './shared/triggers/asset-changed-trigger.component'; +export * from './shared/triggers/comment-trigger.component'; +export * from './shared/triggers/content-changed-trigger.component'; +export * from './shared/triggers/schema-changed-trigger.component'; +export * from './shared/triggers/usage-trigger.component'; \ No newline at end of file diff --git a/frontend/app/features/rules/module.ts b/frontend/app/features/rules/module.ts index 29298fb4f..c760b6a18 100644 --- a/frontend/app/features/rules/module.ts +++ b/frontend/app/features/rules/module.ts @@ -9,8 +9,9 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; -import { HelpComponent, SqxFrameworkModule, SqxSharedModule } from '@app/shared'; -import { AssetChangedTriggerComponent, CommentTriggerComponent, ContentChangedTriggerComponent, GenericActionComponent, RuleComponent, RuleElementComponent, RuleEventBadgeClassPipe, RuleEventsPageComponent, RuleIconComponent, RulesPageComponent, RuleWizardComponent, SchemaChangedTriggerComponent, UsageTriggerComponent } from './declarations'; +import { HelpComponent, RuleMustExistGuard, SqxFrameworkModule, SqxSharedModule } from '@app/shared'; +import { AssetChangedTriggerComponent, CommentTriggerComponent, ContentChangedTriggerComponent, GenericActionComponent, RuleComponent, RuleElementComponent, RuleEventBadgeClassPipe, RuleEventsPageComponent, RuleIconComponent, RulesPageComponent, SchemaChangedTriggerComponent, UsageTriggerComponent } from './declarations'; +import { RulePageComponent } from './pages/rule/rule-page.component'; const routes: Routes = [ { @@ -29,6 +30,23 @@ const routes: Routes = [ } } ] + }, { + path: ':ruleId', + component: RulePageComponent, + canActivate: [RuleMustExistGuard], + children: [ + { + path: 'events', + component: RuleEventsPageComponent + }, + { + path: 'help', + component: HelpComponent, + data: { + helpPage: '05-integrated/rules' + } + } + ] } ]; @@ -48,8 +66,8 @@ const routes: Routes = [ RuleEventBadgeClassPipe, RuleEventsPageComponent, RuleIconComponent, + RulePageComponent, RulesPageComponent, - RuleWizardComponent, SchemaChangedTriggerComponent, UsageTriggerComponent ] diff --git a/frontend/app/features/rules/pages/events/rule-events-page.component.html b/frontend/app/features/rules/pages/events/rule-events-page.component.html index 120caacd1..ad7cd915f 100644 --- a/frontend/app/features/rules/pages/events/rule-events-page.component.html +++ b/frontend/app/features/rules/pages/events/rule-events-page.component.html @@ -1,6 +1,6 @@ - + {{ 'common.events' | sqxTranslate }} diff --git a/frontend/app/features/rules/pages/rule/rule-page.component.html b/frontend/app/features/rules/pages/rule/rule-page.component.html new file mode 100644 index 000000000..b207b83af --- /dev/null +++ b/frontend/app/features/rules/pages/rule/rule-page.component.html @@ -0,0 +1,172 @@ + + +
+ + + {{ 'common.rule' | sqxTranslate }} + + + +
+ + {{ 'common.enabled' | sqxTranslate }} + + + + {{ 'common.disabled' | sqxTranslate }} + + + +
+ + +
+ + +
+
+
+
+
+

{{ 'rules.ruleSyntax.if' | sqxTranslate }}

+
+ +
+ +
+ +
+ +
+ +
+

...

+
+
+
+
+ + + {{ 'rules.wizard.triggerHint' | sqxTranslate }} + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ +
+
+
+
+
+
+ +
+
+
+
+

{{ 'rules.ruleSyntax.then' | sqxTranslate }}

+
+ +
+ +
+ +
+ +
+ +
+

...

+
+
+
+ +
+ + + {{ 'rules.wizard.actionHint' | sqxTranslate }} + + + + + + + +
+
+
+ +
+
+
+
+
+
+
+
+ + +
+ + + + + + + + + + + +
+
+
+
+ + \ No newline at end of file diff --git a/frontend/app/features/rules/pages/rule/rule-page.component.scss b/frontend/app/features/rules/pages/rule/rule-page.component.scss new file mode 100644 index 000000000..db5b71c16 --- /dev/null +++ b/frontend/app/features/rules/pages/rule/rule-page.component.scss @@ -0,0 +1,25 @@ +.summary-row { + @include force-height(4rem); + + h3 { + margin: 0; + } + + .col-syntax { + width: 4rem; + } + + .col-icon { + max-width: 15rem; + } +} + +.card-body { + &:empty { + display: none; + } +} + +.btn-enabled { + border-color: $color-border; +} \ No newline at end of file diff --git a/frontend/app/features/rules/pages/rule/rule-page.component.ts b/frontend/app/features/rules/pages/rule/rule-page.component.ts new file mode 100644 index 000000000..064a3b815 --- /dev/null +++ b/frontend/app/features/rules/pages/rule/rule-page.component.ts @@ -0,0 +1,180 @@ +/* + * Squidex Headless CMS + * + * @license + * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. + */ + +import { Component, OnInit } from '@angular/core'; +import { FormGroup } from '@angular/forms'; +import { ActivatedRoute, Router } from '@angular/router'; +import { ALL_TRIGGERS, Form, ResourceOwner, RuleDto, RuleElementDto, RulesService, RulesState, SchemasState, TriggerType } from '@app/shared'; + +@Component({ + selector: 'sqx-rule-page', + styleUrls: ['./rule-page.component.scss'], + templateUrl: './rule-page.component.html' +}) +export class RulePageComponent extends ResourceOwner implements OnInit { + public supportedActions: { [name: string]: RuleElementDto }; + public supportedTriggers = ALL_TRIGGERS; + + public rule?: RuleDto | null; + + public formAction?: Form; + public formTrigger?: Form; + + public actionProperties?: any; + public actionType: string; + + public triggerProperties?: any; + public triggerType: string; + + public isEnabled = false; + + public get actionElement() { + return this.supportedActions[this.actionType]; + } + + public get triggerElement() { + return this.supportedTriggers[this.triggerType]; + } + + public isEditable = false; + + constructor( + public readonly rulesState: RulesState, + public readonly rulesService: RulesService, + public readonly schemasState: SchemasState, + private readonly route: ActivatedRoute, + private readonly router: Router + ) { + super(); + } + + public ngOnInit() { + this.rulesState.load(); + + this.rulesService.getActions() + .subscribe(actions => { + this.supportedActions = actions; + }); + + this.own( + this.rulesState.selectedRule + .subscribe(rule => { + this.rule = rule; + + if (rule) { + this.isEditable = rule.canUpdate; + this.isEnabled = rule.isEnabled; + + this.selectAction(rule.action); + this.selectTrigger(rule.trigger); + } else { + this.isEditable = true; + this.isEnabled = false; + + this.resetAction(); + this.resetTrigger(); + } + + this.formTrigger?.setEnabled(this.isEditable); + })); + + this.schemasState.loadIfNotLoaded(); + } + + public selectActionType(actionType: string) { + this.selectAction({ actionType }); + } + + public selectTriggerType(triggerType: TriggerType) { + this.selectTrigger({ triggerType }); + } + + public resetAction() { + this.actionProperties = undefined; + this.actionType = undefined!; + + this.formAction = undefined; + } + + public resetTrigger() { + this.triggerProperties = undefined; + this.triggerType = undefined!; + + this.formTrigger = undefined; + } + + private selectAction(target: { actionType: string } & any) { + const { actionType, ...properties } = target; + + this.actionProperties = properties; + this.actionType = actionType; + + this.formAction = new Form(new FormGroup({})); + this.formAction.setEnabled(this.isEditable); + } + + private selectTrigger(target: { triggerType: string } & any) { + const { triggerType, ...properties } = target; + + this.triggerProperties = properties; + this.triggerType = triggerType; + + this.formTrigger = new Form(new FormGroup({})); + this.formTrigger.setEnabled(this.isEditable); + } + + public save() { + if (!this.isEditable || !this.formAction || !this.formTrigger) { + return; + } + + const ruleTrigger = this.formTrigger.submit(); + const ruleAction = this.formAction.submit(); + + if (!ruleTrigger || !ruleAction) { + return; + } + + const request = { + trigger: { + triggerType: this.triggerType, + ...ruleTrigger + }, + action: { + actionType: this.actionType, + ...ruleAction + }, + isEnabled: this.isEnabled + }; + + if (this.rule) { + this.rulesState.update(this.rule, request) + .subscribe(() => { + this.formAction?.submitCompleted({ noReset: true }); + this.formTrigger?.submitCompleted({ noReset: true }); + }, error => { + this.formAction?.submitFailed(error); + this.formTrigger?.submitFailed(error); + }); + } else { + this.rulesState.create(request) + .subscribe(rule => { + this.formAction?.submitCompleted({ noReset: true }); + this.formTrigger?.submitCompleted({ noReset: true }); + + this.router.navigate([rule.id], { relativeTo: this.route.parent, replaceUrl: true }); + }, error => { + this.formAction?.submitFailed(error); + this.formTrigger?.submitFailed(error); + }); + } + } + + public back() { + this.router.navigate(['../'], { relativeTo: this.route, replaceUrl: true }); + } +} diff --git a/frontend/app/features/rules/pages/rules/actions/generic-action.component.ts b/frontend/app/features/rules/pages/rules/actions/generic-action.component.ts deleted file mode 100644 index 72e112951..000000000 --- a/frontend/app/features/rules/pages/rules/actions/generic-action.component.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Squidex Headless CMS - * - * @license - * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. - */ - -import { Component, Input, OnInit } from '@angular/core'; -import { FormControl, FormGroup, Validators } from '@angular/forms'; -import { RuleElementDto } from '@app/shared'; - -@Component({ - selector: 'sqx-generic-action', - styleUrls: ['./generic-action.component.scss'], - templateUrl: './generic-action.component.html' -}) -export class GenericActionComponent implements OnInit { - @Input() - public definition: RuleElementDto; - - @Input() - public action: any; - - @Input() - public actionForm: FormGroup; - - public ngOnInit() { - for (const property of this.definition.properties) { - const validators = []; - - if (property.isRequired) { - validators.push(Validators.required); - } - - const control = new FormControl(this.action[property.name] || '', validators); - - this.actionForm.setControl(property.name, control); - } - } -} \ No newline at end of file diff --git a/frontend/app/features/rules/pages/rules/rule-wizard.component.html b/frontend/app/features/rules/pages/rules/rule-wizard.component.html deleted file mode 100644 index 5da2109bd..000000000 --- a/frontend/app/features/rules/pages/rules/rule-wizard.component.html +++ /dev/null @@ -1,128 +0,0 @@ - - - - {{ 'rules.triggerEdit' | sqxTranslate }} - - - {{ 'rules.actionEdit' | sqxTranslate }} - - - {{ 'rules.create' | sqxTranslate }} - - - - - - - - - - {{ 'rules.wizard.triggerHint' | sqxTranslate }} - - -
-
-
- -
-
-
-
- -
-

- {{triggerElement.display}} -

- - - - - - - - - - - - - - - - - - - - - - - -
-
- - - {{ 'rules.wizard.actionHint' | sqxTranslate }} - - -
-
-
- -
-
-
-
- -
-

- {{actionElement.display}} -

- - -
-
-
-
- - - - - - - - - - - - - - -
\ No newline at end of file diff --git a/frontend/app/features/rules/pages/rules/rule-wizard.component.scss b/frontend/app/features/rules/pages/rules/rule-wizard.component.scss deleted file mode 100644 index f413e0562..000000000 --- a/frontend/app/features/rules/pages/rules/rule-wizard.component.scss +++ /dev/null @@ -1,7 +0,0 @@ -.rule-element { - margin: .25rem; -} - -.wizard-title { - margin-bottom: 2rem; -} diff --git a/frontend/app/features/rules/pages/rules/rule-wizard.component.ts b/frontend/app/features/rules/pages/rules/rule-wizard.component.ts deleted file mode 100644 index c2a40e229..000000000 --- a/frontend/app/features/rules/pages/rules/rule-wizard.component.ts +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Squidex Headless CMS - * - * @license - * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. - */ - -import { AfterViewInit, Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; -import { FormGroup } from '@angular/forms'; -import { Form, RuleDto, RuleElementDto, RulesState, SchemaDto, TriggerType } from '@app/shared'; - -const MODE_WIZARD = 'Wizard'; -const MODE_EDIT_TRIGGER = 'EditTrigger'; -const MODE_EDIT_ACTION = 'EditAction'; - -@Component({ - selector: 'sqx-rule-wizard', - styleUrls: ['./rule-wizard.component.scss'], - templateUrl: './rule-wizard.component.html' -}) -export class RuleWizardComponent implements AfterViewInit, OnInit { - @Output() - public complete = new EventEmitter(); - - @Input() - public ruleActions: { [name: string]: RuleElementDto }; - - @Input() - public ruleTriggers: { [name: string]: RuleElementDto }; - - @Input() - public schemas: ReadonlyArray; - - @Input() - public rule?: RuleDto | null; - - @Input() - public mode = MODE_WIZARD; - - public actionForm = new Form(new FormGroup({})); - public action: any = {}; - - public triggerForm = new Form(new FormGroup({})); - public trigger: any = {}; - - public get isWizard() { - return this.mode === MODE_WIZARD; - } - - public get actionElement() { - return this.ruleActions[this.action.actionType]; - } - - public get triggerElement() { - return this.ruleTriggers[this.trigger.triggerType]; - } - - public isEditable = false; - - public step = 1; - - constructor( - private readonly rulesState: RulesState - ) { - } - - public ngOnInit() { - this.isEditable = !this.rule || this.rule.canUpdate; - - if (this.mode === MODE_EDIT_ACTION) { - this.step = 4; - - this.action = this.rule?.action; - } else if (this.mode === MODE_EDIT_TRIGGER) { - this.step = 2; - - this.trigger = this.rule?.trigger; - } - } - - public ngAfterViewInit() { - this.actionForm.setEnabled(this.isEditable); - - this.triggerForm.setEnabled(this.isEditable); - } - - public emitComplete() { - this.complete.emit(); - } - - public go(step: number) { - this.step = step; - } - - public selectActionType(type: string) { - this.action = { actionType: type }; - this.actionForm = new Form(new FormGroup({})); - - this.step++; - } - - public selectTriggerType(type: TriggerType) { - this.trigger = { triggerType: type }; - this.triggerForm = new Form(new FormGroup({})); - - if (type === 'Manual') { - this.step += 2; - } else { - this.step++; - } - } - - public saveTrigger() { - const value = this.triggerForm.submit(); - - if (value) { - this.trigger = { ...value, triggerType: this.trigger.triggerType }; - - if (this.mode === MODE_WIZARD) { - this.step++; - } else { - this.updateTrigger(); - } - } - } - - public saveAction() { - const value = this.actionForm.submit(); - - if (value) { - this.action = { ...value, actionType: this.action.actionType }; - - if (this.mode === MODE_WIZARD) { - this.createRule(); - } else { - this.updateAction(); - } - } - } - - private createRule() { - const requestDto = { trigger: this.trigger, action: this.action }; - - this.rulesState.create(requestDto) - .subscribe(() => { - this.emitComplete(); - }, error => { - this.actionForm.submitFailed(error); - - this.triggerForm.submitFailed(error); - }); - } - - private updateTrigger() { - if (!this.isEditable || !this.rule) { - return; - } - - this.rulesState.updateTrigger(this.rule, this.trigger) - .subscribe(() => { - this.emitComplete(); - - this.triggerForm.submitCompleted({ noReset: true }); - }, error => { - this.triggerForm.submitFailed(error); - }); - } - - private updateAction() { - if (!this.isEditable || !this.rule) { - return; - } - - this.rulesState.updateAction(this.rule, this.action) - .subscribe(() => { - this.emitComplete(); - - this.actionForm.submitCompleted({ noReset: true }); - }, error => { - this.actionForm.submitFailed(error); - }); - } -} \ No newline at end of file diff --git a/frontend/app/features/rules/pages/rules/rule.component.html b/frontend/app/features/rules/pages/rules/rule.component.html index 6ef0b33f5..585296494 100644 --- a/frontend/app/features/rules/pages/rules/rule.component.html +++ b/frontend/app/features/rules/pages/rules/rule.component.html @@ -17,21 +17,33 @@
- - - +

{{ 'rules.ruleSyntax.then' | sqxTranslate }}

- - - +
diff --git a/frontend/app/features/rules/pages/rules/rule.component.ts b/frontend/app/features/rules/pages/rules/rule.component.ts index d40c7101c..468137ce2 100644 --- a/frontend/app/features/rules/pages/rules/rule.component.ts +++ b/frontend/app/features/rules/pages/rules/rule.component.ts @@ -7,7 +7,7 @@ // tslint:disable: component-selector -import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core'; +import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; import { ActionsDto, fadeAnimation, ModalModel, RuleDto, RulesState, TriggersDto } from '@app/shared'; @Component({ @@ -20,12 +20,6 @@ import { ActionsDto, fadeAnimation, ModalModel, RuleDto, RulesState, TriggersDto changeDetection: ChangeDetectionStrategy.OnPush }) export class RuleComponent { - @Output() - public editTrigger = new EventEmitter(); - - @Output() - public editAction = new EventEmitter(); - @Input() public ruleTriggers: TriggersDto; @@ -59,28 +53,14 @@ export class RuleComponent { } public rename(name: string) { - this.rulesState.rename(this.rule, name); - } - - public trigger() { - this.rulesState.trigger(this.rule); + this.rulesState.update(this.rule, { name }); } - public emitEditAction() { - this.editAction.emit(); - } - - public emitEditTrigger() { - if (!this.isManual) { - this.editTrigger.emit(); - } + public toggle() { + this.rulesState.update(this.rule, { isEnabled: !this.rule.isEnabled }); } - public toggle() { - if (this.rule.isEnabled) { - this.rulesState.disable(this.rule); - } else { - this.rulesState.enable(this.rule); - } + public trigger() { + this.rulesState.trigger(this.rule); } } \ No newline at end of file diff --git a/frontend/app/features/rules/pages/rules/rules-page.component.html b/frontend/app/features/rules/pages/rules/rules-page.component.html index 1219480a7..6d0e2a227 100644 --- a/frontend/app/features/rules/pages/rules/rules-page.component.html +++ b/frontend/app/features/rules/pages/rules/rules-page.component.html @@ -15,9 +15,9 @@ - + @@ -34,11 +34,11 @@
- +
{{ 'rules.empty' | sqxTranslate }} -
@@ -46,24 +46,12 @@
- - - - -
diff --git a/frontend/app/features/rules/pages/rules/rules-page.component.ts b/frontend/app/features/rules/pages/rules/rules-page.component.ts index 498c8781b..68acf0f00 100644 --- a/frontend/app/features/rules/pages/rules/rules-page.component.ts +++ b/frontend/app/features/rules/pages/rules/rules-page.component.ts @@ -6,7 +6,7 @@ */ import { Component, OnInit } from '@angular/core'; -import { ALL_TRIGGERS, DialogModel, RuleDto, RuleElementDto, RulesService, RulesState, SchemasState } from '@app/shared'; +import { ALL_TRIGGERS, RuleDto, RuleElementDto, RulesService, RulesState, SchemasState } from '@app/shared'; @Component({ selector: 'sqx-rules-page', @@ -14,13 +14,8 @@ import { ALL_TRIGGERS, DialogModel, RuleDto, RuleElementDto, RulesService, Rules templateUrl: './rules-page.component.html' }) export class RulesPageComponent implements OnInit { - public addRuleDialog = new DialogModel(); - - public wizardMode = 'Wizard'; - public wizardRule: RuleDto | null; - - public ruleActions: { [name: string]: RuleElementDto }; - public ruleTriggers = ALL_TRIGGERS; + public supportedActions: { [name: string]: RuleElementDto }; + public supportedTriggers = ALL_TRIGGERS; constructor( public readonly rulesState: RulesState, @@ -34,7 +29,7 @@ export class RulesPageComponent implements OnInit { this.rulesService.getActions() .subscribe(actions => { - this.ruleActions = actions; + this.supportedActions = actions; }); this.schemasState.loadIfNotLoaded(); @@ -53,32 +48,7 @@ export class RulesPageComponent implements OnInit { } public toggle(rule: RuleDto) { - if (rule.isEnabled) { - this.rulesState.disable(rule); - } else { - this.rulesState.enable(rule); - } - } - - public createNew() { - this.wizardMode = 'Wizard'; - this.wizardRule = null; - - this.addRuleDialog.show(); - } - - public editTrigger(rule: RuleDto) { - this.wizardMode = 'EditTrigger'; - this.wizardRule = rule; - - this.addRuleDialog.show(); - } - - public editAction(rule: RuleDto) { - this.wizardMode = 'EditAction'; - this.wizardRule = rule; - - this.addRuleDialog.show(); + this.rulesState.update(rule, { isEnabled: !rule.isEnabled }); } public trackByRule(_index: number, rule: RuleDto) { diff --git a/frontend/app/features/rules/pages/rules/triggers/usage-trigger.component.ts b/frontend/app/features/rules/pages/rules/triggers/usage-trigger.component.ts deleted file mode 100644 index 6e4536f4c..000000000 --- a/frontend/app/features/rules/pages/rules/triggers/usage-trigger.component.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Squidex Headless CMS - * - * @license - * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. - */ - -import { Component, Input, OnInit } from '@angular/core'; -import { FormControl, FormGroup, Validators } from '@angular/forms'; -import { ValidatorsEx } from '@app/shared'; - -@Component({ - selector: 'sqx-usage-trigger', - styleUrls: ['./usage-trigger.component.scss'], - templateUrl: './usage-trigger.component.html' -}) -export class UsageTriggerComponent implements OnInit { - @Input() - public trigger: any; - - @Input() - public triggerForm: FormGroup; - - public ngOnInit() { - this.triggerForm.setControl('limit', - new FormControl(this.trigger.limit || 20000, [ - Validators.required - ])); - - this.triggerForm.setControl('numDays', - new FormControl(this.trigger.numDays, [ - ValidatorsEx.between(1, 30) - ])); - } -} \ No newline at end of file diff --git a/frontend/app/features/rules/pages/rules/actions/generic-action.component.html b/frontend/app/features/rules/shared/actions/generic-action.component.html similarity index 100% rename from frontend/app/features/rules/pages/rules/actions/generic-action.component.html rename to frontend/app/features/rules/shared/actions/generic-action.component.html diff --git a/frontend/app/features/rules/pages/rules/actions/generic-action.component.scss b/frontend/app/features/rules/shared/actions/generic-action.component.scss similarity index 100% rename from frontend/app/features/rules/pages/rules/actions/generic-action.component.scss rename to frontend/app/features/rules/shared/actions/generic-action.component.scss diff --git a/frontend/app/features/rules/shared/actions/generic-action.component.ts b/frontend/app/features/rules/shared/actions/generic-action.component.ts new file mode 100644 index 000000000..22d8ee0ae --- /dev/null +++ b/frontend/app/features/rules/shared/actions/generic-action.component.ts @@ -0,0 +1,43 @@ +/* + * Squidex Headless CMS + * + * @license + * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. + */ + +import { Component, Input, OnChanges, SimpleChanges } from '@angular/core'; +import { FormControl, FormGroup, Validators } from '@angular/forms'; +import { RuleElementDto } from '@app/shared'; + +@Component({ + selector: 'sqx-generic-action', + styleUrls: ['./generic-action.component.scss'], + templateUrl: './generic-action.component.html' +}) +export class GenericActionComponent implements OnChanges { + @Input() + public definition: RuleElementDto; + + @Input() + public action: any; + + @Input() + public actionForm: FormGroup; + + public ngOnChanges(changes: SimpleChanges) { + if (changes['actionForm'] || changes['definition']) { + for (const property of this.definition.properties) { + const validator = + property.isRequired ? + Validators.required : + Validators.nullValidator; + + const control = new FormControl('', validator); + + this.actionForm.setControl(property.name, control); + } + } + + this.actionForm.patchValue(this.action); + } +} \ No newline at end of file diff --git a/frontend/app/features/rules/pages/rules/rule-element.component.html b/frontend/app/features/rules/shared/rule-element.component.html similarity index 80% rename from frontend/app/features/rules/pages/rules/rule-element.component.html rename to frontend/app/features/rules/shared/rule-element.component.html index 7ab9bc8cd..46eae5e8b 100644 --- a/frontend/app/features/rules/pages/rules/rule-element.component.html +++ b/frontend/app/features/rules/shared/rule-element.component.html @@ -1,5 +1,5 @@ -
+
@@ -10,7 +10,7 @@ -
+
diff --git a/frontend/app/features/rules/pages/rules/rule-element.component.scss b/frontend/app/features/rules/shared/rule-element.component.scss similarity index 95% rename from frontend/app/features/rules/pages/rules/rule-element.component.scss rename to frontend/app/features/rules/shared/rule-element.component.scss index 06fd8cbaa..997acb8e5 100644 --- a/frontend/app/features/rules/pages/rules/rule-element.component.scss +++ b/frontend/app/features/rules/shared/rule-element.component.scss @@ -5,10 +5,6 @@ transition: background-color .4s ease; } - &.editable { - cursor: pointer; - } - &-text { @include absolute(0, 0, 0, 3rem); @include truncate; diff --git a/frontend/app/features/rules/pages/rules/rule-element.component.ts b/frontend/app/features/rules/shared/rule-element.component.ts similarity index 92% rename from frontend/app/features/rules/pages/rules/rule-element.component.ts rename to frontend/app/features/rules/shared/rule-element.component.ts index 00826c2ec..821a4efec 100644 --- a/frontend/app/features/rules/pages/rules/rule-element.component.ts +++ b/frontend/app/features/rules/shared/rule-element.component.ts @@ -23,7 +23,4 @@ export class RuleElementComponent { @Input() public isSmall?: boolean | null = true; - - @Input() - public disabled?: boolean | null; } \ No newline at end of file diff --git a/frontend/app/features/rules/pages/rules/rule-icon.component.html b/frontend/app/features/rules/shared/rule-icon.component.html similarity index 100% rename from frontend/app/features/rules/pages/rules/rule-icon.component.html rename to frontend/app/features/rules/shared/rule-icon.component.html diff --git a/frontend/app/features/rules/pages/rules/rule-icon.component.scss b/frontend/app/features/rules/shared/rule-icon.component.scss similarity index 100% rename from frontend/app/features/rules/pages/rules/rule-icon.component.scss rename to frontend/app/features/rules/shared/rule-icon.component.scss diff --git a/frontend/app/features/rules/pages/rules/rule-icon.component.ts b/frontend/app/features/rules/shared/rule-icon.component.ts similarity index 100% rename from frontend/app/features/rules/pages/rules/rule-icon.component.ts rename to frontend/app/features/rules/shared/rule-icon.component.ts diff --git a/frontend/app/features/rules/pages/rules/triggers/asset-changed-trigger.component.html b/frontend/app/features/rules/shared/triggers/asset-changed-trigger.component.html similarity index 100% rename from frontend/app/features/rules/pages/rules/triggers/asset-changed-trigger.component.html rename to frontend/app/features/rules/shared/triggers/asset-changed-trigger.component.html diff --git a/frontend/app/features/rules/pages/rules/triggers/asset-changed-trigger.component.scss b/frontend/app/features/rules/shared/triggers/asset-changed-trigger.component.scss similarity index 100% rename from frontend/app/features/rules/pages/rules/triggers/asset-changed-trigger.component.scss rename to frontend/app/features/rules/shared/triggers/asset-changed-trigger.component.scss diff --git a/frontend/app/features/rules/pages/rules/triggers/asset-changed-trigger.component.ts b/frontend/app/features/rules/shared/triggers/asset-changed-trigger.component.ts similarity index 54% rename from frontend/app/features/rules/pages/rules/triggers/asset-changed-trigger.component.ts rename to frontend/app/features/rules/shared/triggers/asset-changed-trigger.component.ts index 31959bd99..494ec3977 100644 --- a/frontend/app/features/rules/pages/rules/triggers/asset-changed-trigger.component.ts +++ b/frontend/app/features/rules/shared/triggers/asset-changed-trigger.component.ts @@ -5,7 +5,7 @@ * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. */ -import { Component, Input, OnInit } from '@angular/core'; +import { Component, Input, OnChanges, SimpleChanges } from '@angular/core'; import { FormControl, FormGroup } from '@angular/forms'; @Component({ @@ -13,15 +13,19 @@ import { FormControl, FormGroup } from '@angular/forms'; styleUrls: ['./asset-changed-trigger.component.scss'], templateUrl: './asset-changed-trigger.component.html' }) -export class AssetChangedTriggerComponent implements OnInit { +export class AssetChangedTriggerComponent implements OnChanges { @Input() public trigger: any; @Input() public triggerForm: FormGroup; - public ngOnInit() { - this.triggerForm.setControl('condition', - new FormControl(this.trigger.condition || '')); + public ngOnChanges(changes: SimpleChanges) { + if (changes['triggerForm']) { + this.triggerForm.setControl('condition', + new FormControl()); + } + + this.triggerForm.patchValue(this.trigger); } } \ No newline at end of file diff --git a/frontend/app/features/rules/pages/rules/triggers/comment-trigger.component.html b/frontend/app/features/rules/shared/triggers/comment-trigger.component.html similarity index 100% rename from frontend/app/features/rules/pages/rules/triggers/comment-trigger.component.html rename to frontend/app/features/rules/shared/triggers/comment-trigger.component.html diff --git a/frontend/app/features/rules/pages/rules/triggers/comment-trigger.component.scss b/frontend/app/features/rules/shared/triggers/comment-trigger.component.scss similarity index 100% rename from frontend/app/features/rules/pages/rules/triggers/comment-trigger.component.scss rename to frontend/app/features/rules/shared/triggers/comment-trigger.component.scss diff --git a/frontend/app/features/rules/pages/rules/triggers/comment-trigger.component.ts b/frontend/app/features/rules/shared/triggers/comment-trigger.component.ts similarity index 53% rename from frontend/app/features/rules/pages/rules/triggers/comment-trigger.component.ts rename to frontend/app/features/rules/shared/triggers/comment-trigger.component.ts index 5a832722d..eff96065e 100644 --- a/frontend/app/features/rules/pages/rules/triggers/comment-trigger.component.ts +++ b/frontend/app/features/rules/shared/triggers/comment-trigger.component.ts @@ -5,7 +5,7 @@ * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. */ -import { Component, Input, OnInit } from '@angular/core'; +import { Component, Input, OnChanges, SimpleChanges } from '@angular/core'; import { FormControl, FormGroup } from '@angular/forms'; @Component({ @@ -13,15 +13,19 @@ import { FormControl, FormGroup } from '@angular/forms'; styleUrls: ['./comment-trigger.component.scss'], templateUrl: './comment-trigger.component.html' }) -export class CommentTriggerComponent implements OnInit { +export class CommentTriggerComponent implements OnChanges { @Input() public trigger: any; @Input() public triggerForm: FormGroup; - public ngOnInit() { - this.triggerForm.setControl('condition', - new FormControl(this.trigger.condition || '')); + public ngOnChanges(changes: SimpleChanges) { + if (changes['triggerForm']) { + this.triggerForm.setControl('condition', + new FormControl()); + } + + this.triggerForm.patchValue(this.trigger); } } \ No newline at end of file diff --git a/frontend/app/features/rules/pages/rules/triggers/content-changed-trigger.component.html b/frontend/app/features/rules/shared/triggers/content-changed-trigger.component.html similarity index 100% rename from frontend/app/features/rules/pages/rules/triggers/content-changed-trigger.component.html rename to frontend/app/features/rules/shared/triggers/content-changed-trigger.component.html diff --git a/frontend/app/features/rules/pages/rules/triggers/content-changed-trigger.component.scss b/frontend/app/features/rules/shared/triggers/content-changed-trigger.component.scss similarity index 100% rename from frontend/app/features/rules/pages/rules/triggers/content-changed-trigger.component.scss rename to frontend/app/features/rules/shared/triggers/content-changed-trigger.component.scss diff --git a/frontend/app/features/rules/pages/rules/triggers/content-changed-trigger.component.ts b/frontend/app/features/rules/shared/triggers/content-changed-trigger.component.ts similarity index 63% rename from frontend/app/features/rules/pages/rules/triggers/content-changed-trigger.component.ts rename to frontend/app/features/rules/shared/triggers/content-changed-trigger.component.ts index c21e0af5b..c31f98e08 100644 --- a/frontend/app/features/rules/pages/rules/triggers/content-changed-trigger.component.ts +++ b/frontend/app/features/rules/shared/triggers/content-changed-trigger.component.ts @@ -5,9 +5,11 @@ * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. */ -import { Component, Input, OnInit } from '@angular/core'; +// tslint:disable: readonly-array + +import { Component, Input, OnChanges, SimpleChanges } from '@angular/core'; import { FormControl, FormGroup } from '@angular/forms'; -import { SchemaDto, Types } from '@app/shared'; +import { SchemaDto } from '@app/shared'; export interface TriggerSchemaForm { schema: SchemaDto; @@ -20,9 +22,9 @@ export interface TriggerSchemaForm { styleUrls: ['./content-changed-trigger.component.scss'], templateUrl: './content-changed-trigger.component.html' }) -export class ContentChangedTriggerComponent implements OnInit { +export class ContentChangedTriggerComponent implements OnChanges { @Input() - public schemas: ReadonlyArray; + public schemas?: ReadonlyArray | null; @Input() public trigger: any; @@ -30,7 +32,7 @@ export class ContentChangedTriggerComponent implements OnInit { @Input() public triggerForm: FormGroup; - public triggerSchemas: ReadonlyArray; + public triggerSchemas: TriggerSchemaForm[] = []; public schemaToAdd: SchemaDto; public schemasToAdd: ReadonlyArray; @@ -39,16 +41,20 @@ export class ContentChangedTriggerComponent implements OnInit { return !!this.schemaToAdd; } - public ngOnInit() { - this.triggerForm.setControl('schemas', - new FormControl(this.trigger.schemas || [])); + public ngOnChanges(changes: SimpleChanges) { + if (changes['triggerForm']) { + this.triggerForm.setControl('schemas', + new FormControl([])); + + this.triggerForm.setControl('handleAll', + new FormControl()); + } - this.triggerForm.setControl('handleAll', - new FormControl(Types.isBoolean(this.trigger.handleAll) ? this.trigger.handleAll : false)); + this.triggerForm.patchValue(this.trigger); const schemas: TriggerSchemaForm[] = []; - if (this.trigger.schemas) { + if (this.trigger.schemas && this.schemas) { for (const triggerSchema of this.trigger.schemas) { const schema = this.schemas.find(s => s.id === triggerSchema.schemaId); @@ -60,20 +66,22 @@ export class ContentChangedTriggerComponent implements OnInit { } } - this.triggerSchemas = schemas.sortedByString(s => s.schema.name); + this.triggerSchemas = schemas; + this.triggerSchemas.sortByString(x => x.schema.name); this.updateSchemaToAdd(); } public removeSchema(schemaForm: TriggerSchemaForm) { - this.triggerSchemas = this.triggerSchemas.removed(schemaForm); + this.triggerSchemas.remove(schemaForm); this.updateValue(); this.updateSchemaToAdd(); } public addSchema() { - this.triggerSchemas = [{ schema: this.schemaToAdd }, ...this.triggerSchemas].sortedByString(x => x.schema.name); + this.triggerSchemas.push({ schema: this.schemaToAdd }); + this.triggerSchemas.sortByString(x => x.schema.name); this.updateValue(); this.updateSchemaToAdd(); @@ -92,7 +100,7 @@ export class ContentChangedTriggerComponent implements OnInit { } private updateSchemaToAdd() { - this.schemasToAdd = this.schemas.filter(schema => !this.triggerSchemas.find(s => s.schema.id === schema.id)).sortedByString(x => x.name); + this.schemasToAdd = this.schemas?.filter(schema => !this.triggerSchemas.find(s => s.schema.id === schema.id)).sortByString(x => x.name) || []; this.schemaToAdd = this.schemasToAdd[0]; } diff --git a/frontend/app/features/rules/pages/rules/triggers/schema-changed-trigger.component.html b/frontend/app/features/rules/shared/triggers/schema-changed-trigger.component.html similarity index 100% rename from frontend/app/features/rules/pages/rules/triggers/schema-changed-trigger.component.html rename to frontend/app/features/rules/shared/triggers/schema-changed-trigger.component.html diff --git a/frontend/app/features/rules/pages/rules/triggers/schema-changed-trigger.component.scss b/frontend/app/features/rules/shared/triggers/schema-changed-trigger.component.scss similarity index 100% rename from frontend/app/features/rules/pages/rules/triggers/schema-changed-trigger.component.scss rename to frontend/app/features/rules/shared/triggers/schema-changed-trigger.component.scss diff --git a/frontend/app/features/rules/pages/rules/triggers/schema-changed-trigger.component.ts b/frontend/app/features/rules/shared/triggers/schema-changed-trigger.component.ts similarity index 54% rename from frontend/app/features/rules/pages/rules/triggers/schema-changed-trigger.component.ts rename to frontend/app/features/rules/shared/triggers/schema-changed-trigger.component.ts index f087db798..010c3ab2f 100644 --- a/frontend/app/features/rules/pages/rules/triggers/schema-changed-trigger.component.ts +++ b/frontend/app/features/rules/shared/triggers/schema-changed-trigger.component.ts @@ -5,7 +5,7 @@ * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. */ -import { Component, Input, OnInit } from '@angular/core'; +import { Component, Input, OnChanges, SimpleChanges } from '@angular/core'; import { FormControl, FormGroup } from '@angular/forms'; @Component({ @@ -13,15 +13,19 @@ import { FormControl, FormGroup } from '@angular/forms'; styleUrls: ['./schema-changed-trigger.component.scss'], templateUrl: './schema-changed-trigger.component.html' }) -export class SchemaChangedTriggerComponent implements OnInit { +export class SchemaChangedTriggerComponent implements OnChanges { @Input() public trigger: any; @Input() public triggerForm: FormGroup; - public ngOnInit() { - this.triggerForm.setControl('condition', - new FormControl(this.trigger.condition || '')); + public ngOnChanges(changes: SimpleChanges) { + if (changes['triggerForm']) { + this.triggerForm.setControl('condition', + new FormControl()); + } + + this.triggerForm.patchValue(this.trigger); } } \ No newline at end of file diff --git a/frontend/app/features/rules/pages/rules/triggers/usage-trigger.component.html b/frontend/app/features/rules/shared/triggers/usage-trigger.component.html similarity index 100% rename from frontend/app/features/rules/pages/rules/triggers/usage-trigger.component.html rename to frontend/app/features/rules/shared/triggers/usage-trigger.component.html diff --git a/frontend/app/features/rules/pages/rules/triggers/usage-trigger.component.scss b/frontend/app/features/rules/shared/triggers/usage-trigger.component.scss similarity index 100% rename from frontend/app/features/rules/pages/rules/triggers/usage-trigger.component.scss rename to frontend/app/features/rules/shared/triggers/usage-trigger.component.scss diff --git a/frontend/app/features/rules/shared/triggers/usage-trigger.component.ts b/frontend/app/features/rules/shared/triggers/usage-trigger.component.ts new file mode 100644 index 000000000..ddf0ddb47 --- /dev/null +++ b/frontend/app/features/rules/shared/triggers/usage-trigger.component.ts @@ -0,0 +1,39 @@ +/* + * Squidex Headless CMS + * + * @license + * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. + */ + +import { Component, Input, OnChanges, SimpleChanges } from '@angular/core'; +import { FormControl, FormGroup, Validators } from '@angular/forms'; +import { ValidatorsEx } from '@app/shared'; + +@Component({ + selector: 'sqx-usage-trigger', + styleUrls: ['./usage-trigger.component.scss'], + templateUrl: './usage-trigger.component.html' +}) +export class UsageTriggerComponent implements OnChanges { + @Input() + public trigger: any; + + @Input() + public triggerForm: FormGroup; + + public ngOnChanges(changes: SimpleChanges) { + if (changes['triggerForm']) { + this.triggerForm.setControl('limit', + new FormControl(20000, [ + Validators.required + ])); + + this.triggerForm.setControl('numDays', + new FormControl(3, [ + ValidatorsEx.between(1, 30) + ])); + } + + this.triggerForm.patchValue(this.trigger); + } +} \ No newline at end of file diff --git a/frontend/app/features/schemas/pages/schema/common/schema-edit-form.component.html b/frontend/app/features/schemas/pages/schema/common/schema-edit-form.component.html index 34c875264..7ce641734 100644 --- a/frontend/app/features/schemas/pages/schema/common/schema-edit-form.component.html +++ b/frontend/app/features/schemas/pages/schema/common/schema-edit-form.component.html @@ -7,7 +7,7 @@
- +
diff --git a/frontend/app/features/schemas/pages/schema/common/schema-edit-form.component.ts b/frontend/app/features/schemas/pages/schema/common/schema-edit-form.component.ts index b45d51fa9..b0bb91caa 100644 --- a/frontend/app/features/schemas/pages/schema/common/schema-edit-form.component.ts +++ b/frontend/app/features/schemas/pages/schema/common/schema-edit-form.component.ts @@ -15,14 +15,12 @@ import { EditSchemaForm, SchemaDetailsDto, SchemasState } from '@app/shared'; templateUrl: './schema-edit-form.component.html' }) export class SchemaEditFormComponent implements OnChanges { - public readonly standalone = { standalone: true }; - @Input() public schema: SchemaDetailsDto; public fieldForm = new EditSchemaForm(this.formBuilder); - public isEditable ?: boolean | null; + public isEditable?: boolean | null; constructor( private readonly formBuilder: FormBuilder, diff --git a/frontend/app/features/schemas/pages/schema/fields/forms/field-form-common.component.html b/frontend/app/features/schemas/pages/schema/fields/forms/field-form-common.component.html index c2e4cb78f..256b274ad 100644 --- a/frontend/app/features/schemas/pages/schema/fields/forms/field-form-common.component.html +++ b/frontend/app/features/schemas/pages/schema/fields/forms/field-form-common.component.html @@ -3,7 +3,7 @@
- + {{ 'schemas.field.nameHint' | sqxTranslate }} diff --git a/frontend/app/features/schemas/pages/schema/fields/forms/field-form-common.component.ts b/frontend/app/features/schemas/pages/schema/fields/forms/field-form-common.component.ts index a225924fb..e87b8d195 100644 --- a/frontend/app/features/schemas/pages/schema/fields/forms/field-form-common.component.ts +++ b/frontend/app/features/schemas/pages/schema/fields/forms/field-form-common.component.ts @@ -15,8 +15,6 @@ import { FieldDto } from '@app/shared'; templateUrl: './field-form-common.component.html' }) export class FieldFormCommonComponent { - public readonly standalone = { standalone: true }; - @Input() public fieldForm: FormGroup; diff --git a/frontend/app/features/schemas/pages/schema/fields/types/array-validation.component.ts b/frontend/app/features/schemas/pages/schema/fields/types/array-validation.component.ts index a99ddaa44..3f0bcea91 100644 --- a/frontend/app/features/schemas/pages/schema/fields/types/array-validation.component.ts +++ b/frontend/app/features/schemas/pages/schema/fields/types/array-validation.component.ts @@ -5,7 +5,7 @@ * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. */ -import { Component, Input, OnInit } from '@angular/core'; +import { Component, Input, OnChanges, SimpleChanges } from '@angular/core'; import { FormControl, FormGroup } from '@angular/forms'; import { ArrayFieldPropertiesDto, FieldDto, SchemaTagSource } from '@app/shared'; @@ -14,7 +14,7 @@ import { ArrayFieldPropertiesDto, FieldDto, SchemaTagSource } from '@app/shared' styleUrls: ['array-validation.component.scss'], templateUrl: 'array-validation.component.html' }) -export class ArrayValidationComponent implements OnInit { +export class ArrayValidationComponent implements OnChanges { @Input() public fieldForm: FormGroup; @@ -29,11 +29,15 @@ export class ArrayValidationComponent implements OnInit { ) { } - public ngOnInit() { - this.fieldForm.setControl('maxItems', - new FormControl(this.properties.maxItems)); + public ngOnChanges(changes: SimpleChanges) { + if (changes['fieldForm']) { + this.fieldForm.setControl('maxItems', + new FormControl()); - this.fieldForm.setControl('minItems', - new FormControl(this.properties.minItems)); + this.fieldForm.setControl('minItems', + new FormControl()); + } + + this.fieldForm.patchValue(this.properties); } } \ No newline at end of file diff --git a/frontend/app/features/schemas/pages/schema/fields/types/assets-ui.component.ts b/frontend/app/features/schemas/pages/schema/fields/types/assets-ui.component.ts index bda7b27e5..601a96a19 100644 --- a/frontend/app/features/schemas/pages/schema/fields/types/assets-ui.component.ts +++ b/frontend/app/features/schemas/pages/schema/fields/types/assets-ui.component.ts @@ -5,7 +5,7 @@ * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. */ -import { Component, Input, OnInit } from '@angular/core'; +import { Component, Input, OnChanges, SimpleChanges } from '@angular/core'; import { FormControl, FormGroup } from '@angular/forms'; import { AssetsFieldPropertiesDto, FieldDto } from '@app/shared'; @@ -14,7 +14,7 @@ import { AssetsFieldPropertiesDto, FieldDto } from '@app/shared'; styleUrls: ['assets-ui.component.scss'], templateUrl: 'assets-ui.component.html' }) -export class AssetsUIComponent implements OnInit { +export class AssetsUIComponent implements OnChanges { @Input() public fieldForm: FormGroup; @@ -24,14 +24,18 @@ export class AssetsUIComponent implements OnInit { @Input() public properties: AssetsFieldPropertiesDto; - public ngOnInit() { - this.fieldForm.setControl('previewMode', - new FormControl(this.properties.previewMode)); + public ngOnChanges(changes: SimpleChanges) { + if (changes['fieldForm']) { + this.fieldForm.setControl('previewMode', + new FormControl()); - this.fieldForm.setControl('resolveFirst', - new FormControl(this.properties.resolveFirst)); + this.fieldForm.setControl('resolveFirst', + new FormControl()); - this.fieldForm.setControl('folderId', - new FormControl(this.properties.folderId)); + this.fieldForm.setControl('folderId', + new FormControl()); + } + + this.fieldForm.patchValue(this.properties); } } \ No newline at end of file diff --git a/frontend/app/features/schemas/pages/schema/fields/types/assets-validation.component.ts b/frontend/app/features/schemas/pages/schema/fields/types/assets-validation.component.ts index 8fb9c17ef..08a297442 100644 --- a/frontend/app/features/schemas/pages/schema/fields/types/assets-validation.component.ts +++ b/frontend/app/features/schemas/pages/schema/fields/types/assets-validation.component.ts @@ -5,7 +5,7 @@ * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. */ -import { Component, Input, OnInit } from '@angular/core'; +import { Component, Input, OnChanges, SimpleChanges } from '@angular/core'; import { FormControl, FormGroup } from '@angular/forms'; import { AssetsFieldPropertiesDto, FieldDto, LanguageDto } from '@app/shared'; @@ -14,7 +14,7 @@ import { AssetsFieldPropertiesDto, FieldDto, LanguageDto } from '@app/shared'; styleUrls: ['assets-validation.component.scss'], templateUrl: 'assets-validation.component.html' }) -export class AssetsValidationComponent implements OnInit { +export class AssetsValidationComponent implements OnChanges { @Input() public fieldForm: FormGroup; @@ -30,50 +30,54 @@ export class AssetsValidationComponent implements OnInit { @Input() public isLocalizable?: boolean | null; - public ngOnInit() { - this.fieldForm.setControl('minItems', - new FormControl(this.properties.minItems)); + public ngOnChanges(changes: SimpleChanges) { + if (changes['fieldForm']) { + this.fieldForm.setControl('minItems', + new FormControl()); - this.fieldForm.setControl('maxItems', - new FormControl(this.properties.maxItems)); + this.fieldForm.setControl('maxItems', + new FormControl()); - this.fieldForm.setControl('minSize', - new FormControl(this.properties.minSize)); + this.fieldForm.setControl('minSize', + new FormControl()); - this.fieldForm.setControl('maxSize', - new FormControl(this.properties.maxSize)); + this.fieldForm.setControl('maxSize', + new FormControl()); - this.fieldForm.setControl('allowedExtensions', - new FormControl(this.properties.allowedExtensions)); + this.fieldForm.setControl('allowedExtensions', + new FormControl()); - this.fieldForm.setControl('mustBeImage', - new FormControl(this.properties.mustBeImage)); + this.fieldForm.setControl('mustBeImage', + new FormControl()); - this.fieldForm.setControl('minWidth', - new FormControl(this.properties.minWidth)); + this.fieldForm.setControl('minWidth', + new FormControl()); - this.fieldForm.setControl('maxWidth', - new FormControl(this.properties.maxWidth)); + this.fieldForm.setControl('maxWidth', + new FormControl()); - this.fieldForm.setControl('minHeight', - new FormControl(this.properties.minHeight)); + this.fieldForm.setControl('minHeight', + new FormControl()); - this.fieldForm.setControl('maxHeight', - new FormControl(this.properties.maxHeight)); + this.fieldForm.setControl('maxHeight', + new FormControl()); - this.fieldForm.setControl('aspectWidth', - new FormControl(this.properties.aspectWidth)); + this.fieldForm.setControl('aspectWidth', + new FormControl()); - this.fieldForm.setControl('aspectHeight', - new FormControl(this.properties.aspectHeight)); + this.fieldForm.setControl('aspectHeight', + new FormControl()); - this.fieldForm.setControl('allowDuplicates', - new FormControl(this.properties.allowDuplicates)); + this.fieldForm.setControl('allowDuplicates', + new FormControl()); - this.fieldForm.setControl('defaultValue', - new FormControl(this.properties.defaultValue)); + this.fieldForm.setControl('defaultValue', + new FormControl()); - this.fieldForm.setControl('defaultValues', - new FormControl(this.properties.defaultValues)); + this.fieldForm.setControl('defaultValues', + new FormControl()); + } + + this.fieldForm.patchValue(this.properties); } } \ No newline at end of file diff --git a/frontend/app/features/schemas/pages/schema/fields/types/boolean-ui.component.ts b/frontend/app/features/schemas/pages/schema/fields/types/boolean-ui.component.ts index da7c676e3..245defc49 100644 --- a/frontend/app/features/schemas/pages/schema/fields/types/boolean-ui.component.ts +++ b/frontend/app/features/schemas/pages/schema/fields/types/boolean-ui.component.ts @@ -5,7 +5,7 @@ * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. */ -import { Component, Input, OnInit } from '@angular/core'; +import { Component, Input, OnChanges, SimpleChanges } from '@angular/core'; import { FormControl, FormGroup, Validators } from '@angular/forms'; import { BooleanFieldPropertiesDto, BOOLEAN_FIELD_EDITORS, FieldDto } from '@app/shared'; @@ -14,7 +14,7 @@ import { BooleanFieldPropertiesDto, BOOLEAN_FIELD_EDITORS, FieldDto } from '@app styleUrls: ['boolean-ui.component.scss'], templateUrl: 'boolean-ui.component.html' }) -export class BooleanUIComponent implements OnInit { +export class BooleanUIComponent implements OnChanges { @Input() public fieldForm: FormGroup; @@ -26,13 +26,15 @@ export class BooleanUIComponent implements OnInit { public editors = BOOLEAN_FIELD_EDITORS; - public ngOnInit() { - this.fieldForm.setControl('editor', - new FormControl(this.properties.editor, [ - Validators.required - ])); + public ngOnChanges(changes: SimpleChanges) { + if (changes['fieldForm']) { + this.fieldForm.setControl('editor', + new FormControl(undefined, Validators.required)); - this.fieldForm.setControl('inlineEditable', - new FormControl(this.properties.inlineEditable)); + this.fieldForm.setControl('inlineEditable', + new FormControl()); + } + + this.fieldForm.patchValue(this.field.properties); } } \ No newline at end of file diff --git a/frontend/app/features/schemas/pages/schema/fields/types/boolean-validation.component.ts b/frontend/app/features/schemas/pages/schema/fields/types/boolean-validation.component.ts index 177106f9b..317150ff1 100644 --- a/frontend/app/features/schemas/pages/schema/fields/types/boolean-validation.component.ts +++ b/frontend/app/features/schemas/pages/schema/fields/types/boolean-validation.component.ts @@ -5,7 +5,7 @@ * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. */ -import { Component, Input, OnInit } from '@angular/core'; +import { Component, Input, OnChanges, SimpleChanges } from '@angular/core'; import { FormControl, FormGroup } from '@angular/forms'; import { BooleanFieldPropertiesDto, FieldDto, hasNoValue$, LanguageDto } from '@app/shared'; import { Observable } from 'rxjs'; @@ -15,7 +15,7 @@ import { Observable } from 'rxjs'; styleUrls: ['boolean-validation.component.scss'], templateUrl: 'boolean-validation.component.html' }) -export class BooleanValidationComponent implements OnInit { +export class BooleanValidationComponent implements OnChanges { @Input() public fieldForm: FormGroup; @@ -33,17 +33,21 @@ export class BooleanValidationComponent implements OnInit { public showDefaultValue: Observable; - public ngOnInit() { - this.fieldForm.setControl('defaultValue', - new FormControl(this.properties.defaultValue)); + public ngOnChanges(changes: SimpleChanges) { + if (changes['fieldForm']) { + this.fieldForm.setControl('defaultValue', + new FormControl()); - this.fieldForm.setControl('defaultValues', - new FormControl(this.properties.defaultValues)); + this.fieldForm.setControl('defaultValues', + new FormControl()); - this.fieldForm.setControl('inlineEditable', - new FormControl(this.properties.inlineEditable)); + this.fieldForm.setControl('inlineEditable', + new FormControl()); - this.showDefaultValue = - hasNoValue$(this.fieldForm.controls['isRequired']); + this.showDefaultValue = + hasNoValue$(this.fieldForm.controls['isRequired']); + } + + this.fieldForm.patchValue(this.properties); } } \ No newline at end of file diff --git a/frontend/app/features/schemas/pages/schema/fields/types/date-time-ui.component.ts b/frontend/app/features/schemas/pages/schema/fields/types/date-time-ui.component.ts index f4c5f3a91..bc427738f 100644 --- a/frontend/app/features/schemas/pages/schema/fields/types/date-time-ui.component.ts +++ b/frontend/app/features/schemas/pages/schema/fields/types/date-time-ui.component.ts @@ -5,7 +5,7 @@ * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. */ -import { Component, Input, OnInit } from '@angular/core'; +import { Component, Input, OnChanges, SimpleChanges } from '@angular/core'; import { FormControl, FormGroup, Validators } from '@angular/forms'; import { DateTimeFieldPropertiesDto, DATETIME_FIELD_EDITORS, FieldDto, FloatConverter } from '@app/shared'; import { Observable } from 'rxjs'; @@ -15,7 +15,7 @@ import { Observable } from 'rxjs'; styleUrls: ['date-time-ui.component.scss'], templateUrl: 'date-time-ui.component.html' }) -export class DateTimeUIComponent implements OnInit { +export class DateTimeUIComponent implements OnChanges { public readonly converter = FloatConverter.INSTANCE; @Input() @@ -31,10 +31,12 @@ export class DateTimeUIComponent implements OnInit { public hideAllowedValues: Observable; - public ngOnInit() { - this.fieldForm.setControl('editor', - new FormControl(this.properties.editor, [ - Validators.required - ])); + public ngOnChanges(changes: SimpleChanges) { + if (changes['fieldForm']) { + this.fieldForm.setControl('editor', + new FormControl(undefined, Validators.required)); + } + + this.fieldForm.patchValue(this.properties); } } \ No newline at end of file diff --git a/frontend/app/features/schemas/pages/schema/fields/types/date-time-validation.component.ts b/frontend/app/features/schemas/pages/schema/fields/types/date-time-validation.component.ts index 957316cbb..eedada1c6 100644 --- a/frontend/app/features/schemas/pages/schema/fields/types/date-time-validation.component.ts +++ b/frontend/app/features/schemas/pages/schema/fields/types/date-time-validation.component.ts @@ -5,7 +5,7 @@ * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. */ -import { Component, Input, OnInit } from '@angular/core'; +import { Component, Input, OnChanges, SimpleChanges } from '@angular/core'; import { FormControl, FormGroup } from '@angular/forms'; import { DateTimeFieldPropertiesDto, FieldDto, hasNoValue$, LanguageDto, ValidatorsEx } from '@app/shared'; import { Observable } from 'rxjs'; @@ -15,7 +15,7 @@ import { Observable } from 'rxjs'; styleUrls: ['date-time-validation.component.scss'], templateUrl: 'date-time-validation.component.html' }) -export class DateTimeValidationComponent implements OnInit { +export class DateTimeValidationComponent implements OnChanges { @Input() public fieldForm: FormGroup; @@ -36,30 +36,30 @@ export class DateTimeValidationComponent implements OnInit { public calculatedDefaultValues: ReadonlyArray = ['Now', 'Today']; - public ngOnInit() { - this.fieldForm.setControl('calculatedDefaultValue', - new FormControl(this.properties.calculatedDefaultValue)); + public ngOnChanges(changes: SimpleChanges) { + if (changes['fieldForm']) { + this.fieldForm.setControl('calculatedDefaultValue', + new FormControl()); - this.fieldForm.setControl('maxValue', - new FormControl(this.properties.maxValue, [ - ValidatorsEx.validDateTime() - ])); + this.fieldForm.setControl('maxValue', + new FormControl(undefined, ValidatorsEx.validDateTime())); - this.fieldForm.setControl('minValue', - new FormControl(this.properties.minValue, [ - ValidatorsEx.validDateTime() - ])); + this.fieldForm.setControl('minValue', + new FormControl(undefined, ValidatorsEx.validDateTime())); - this.fieldForm.setControl('defaultValue', - new FormControl(this.properties.defaultValue)); + this.fieldForm.setControl('defaultValue', + new FormControl()); - this.fieldForm.setControl('defaultValues', - new FormControl(this.properties.defaultValues)); + this.fieldForm.setControl('defaultValues', + new FormControl()); - this.showDefaultValues = - hasNoValue$(this.fieldForm.controls['isRequired']); + this.showDefaultValues = + hasNoValue$(this.fieldForm.controls['isRequired']); - this.showDefaultValue = - hasNoValue$(this.fieldForm.controls['calculatedDefaultValue']); + this.showDefaultValue = + hasNoValue$(this.fieldForm.controls['calculatedDefaultValue']); + } + + this.fieldForm.patchValue(this.properties); } } \ No newline at end of file diff --git a/frontend/app/features/schemas/pages/schema/fields/types/geolocation-ui.component.ts b/frontend/app/features/schemas/pages/schema/fields/types/geolocation-ui.component.ts index cac0e1177..25632858d 100644 --- a/frontend/app/features/schemas/pages/schema/fields/types/geolocation-ui.component.ts +++ b/frontend/app/features/schemas/pages/schema/fields/types/geolocation-ui.component.ts @@ -5,7 +5,7 @@ * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. */ -import { Component, Input, OnInit } from '@angular/core'; +import { Component, Input, OnChanges, SimpleChanges } from '@angular/core'; import { FormControl, FormGroup, Validators } from '@angular/forms'; import { FieldDto, GeolocationFieldPropertiesDto } from '@app/shared'; @@ -14,7 +14,7 @@ import { FieldDto, GeolocationFieldPropertiesDto } from '@app/shared'; styleUrls: ['geolocation-ui.component.scss'], templateUrl: 'geolocation-ui.component.html' }) -export class GeolocationUIComponent implements OnInit { +export class GeolocationUIComponent implements OnChanges { @Input() public fieldForm: FormGroup; @@ -24,10 +24,12 @@ export class GeolocationUIComponent implements OnInit { @Input() public properties: GeolocationFieldPropertiesDto; - public ngOnInit() { - this.fieldForm.setControl('editor', - new FormControl(this.properties.editor, [ - Validators.required - ])); + public ngOnChanges(changes: SimpleChanges) { + if (changes['fieldForm']) { + this.fieldForm.setControl('editor', + new FormControl(undefined, Validators.required)); + } + + this.fieldForm.patchValue(this.field.properties); } } \ No newline at end of file diff --git a/frontend/app/features/schemas/pages/schema/fields/types/number-ui.component.ts b/frontend/app/features/schemas/pages/schema/fields/types/number-ui.component.ts index 1659754e6..7ace56d71 100644 --- a/frontend/app/features/schemas/pages/schema/fields/types/number-ui.component.ts +++ b/frontend/app/features/schemas/pages/schema/fields/types/number-ui.component.ts @@ -5,7 +5,7 @@ * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. */ -import { Component, Input, OnInit } from '@angular/core'; +import { Component, Input, OnChanges, SimpleChanges } from '@angular/core'; import { FormControl, FormGroup, Validators } from '@angular/forms'; import { FieldDto, FloatConverter, NumberFieldPropertiesDto, NUMBER_FIELD_EDITORS, ResourceOwner, value$ } from '@app/shared'; import { Observable } from 'rxjs'; @@ -16,7 +16,7 @@ import { map } from 'rxjs/operators'; styleUrls: ['number-ui.component.scss'], templateUrl: 'number-ui.component.html' }) -export class NumberUIComponent extends ResourceOwner implements OnInit { +export class NumberUIComponent extends ResourceOwner implements OnChanges { public readonly converter = FloatConverter.INSTANCE; @Input() @@ -33,36 +33,38 @@ export class NumberUIComponent extends ResourceOwner implements OnInit { public hideAllowedValues: Observable; public hideInlineEditable: Observable; - public ngOnInit() { - this.fieldForm.setControl('editor', - new FormControl(this.properties.editor, [ - Validators.required - ])); + public ngOnChanges(changes: SimpleChanges) { + if (changes['fieldForm']) { + this.fieldForm.setControl('editor', + new FormControl(undefined, Validators.required)); - this.fieldForm.setControl('allowedValues', - new FormControl(this.properties.allowedValues, [])); + this.fieldForm.setControl('allowedValues', + new FormControl()); - this.fieldForm.setControl('inlineEditable', - new FormControl(this.properties.inlineEditable)); + this.fieldForm.setControl('inlineEditable', + new FormControl()); - this.hideAllowedValues = - value$(this.fieldForm.controls['editor']).pipe(map(x => !(x && (x === 'Radio' || x === 'Dropdown')))); + this.hideAllowedValues = + value$(this.fieldForm.controls['editor']).pipe(map(x => !(x && (x === 'Radio' || x === 'Dropdown')))); - this.hideInlineEditable = - value$(this.fieldForm.controls['editor']).pipe(map(x => x === 'Radio')); + this.hideInlineEditable = + value$(this.fieldForm.controls['editor']).pipe(map(x => x === 'Radio')); - this.own( - this.hideAllowedValues.subscribe(isSelection => { - if (isSelection) { - this.fieldForm.controls['allowedValues'].setValue(undefined); - } - })); + this.own( + this.hideAllowedValues.subscribe(isSelection => { + if (isSelection) { + this.fieldForm.controls['allowedValues'].setValue(undefined); + } + })); - this.own( - this.hideInlineEditable.subscribe(isSelection => { - if (isSelection) { - this.fieldForm.controls['inlineEditable'].setValue(false); - } - })); + this.own( + this.hideInlineEditable.subscribe(isSelection => { + if (isSelection) { + this.fieldForm.controls['inlineEditable'].setValue(false); + } + })); + } + + this.fieldForm.patchValue(this.field.properties); } } \ No newline at end of file diff --git a/frontend/app/features/schemas/pages/schema/fields/types/number-validation.component.ts b/frontend/app/features/schemas/pages/schema/fields/types/number-validation.component.ts index 63336a473..b5bb876e5 100644 --- a/frontend/app/features/schemas/pages/schema/fields/types/number-validation.component.ts +++ b/frontend/app/features/schemas/pages/schema/fields/types/number-validation.component.ts @@ -5,7 +5,7 @@ * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. */ -import { Component, Input, OnInit } from '@angular/core'; +import { Component, Input, OnChanges, SimpleChanges } from '@angular/core'; import { FormControl, FormGroup } from '@angular/forms'; import { FieldDto, LanguageDto, NumberFieldPropertiesDto, RootFieldDto, Types } from '@app/shared'; @@ -14,7 +14,7 @@ import { FieldDto, LanguageDto, NumberFieldPropertiesDto, RootFieldDto, Types } styleUrls: ['number-validation.component.scss'], templateUrl: 'number-validation.component.html' }) -export class NumberValidationComponent implements OnInit { +export class NumberValidationComponent implements OnChanges { @Input() public fieldForm: FormGroup; @@ -32,24 +32,30 @@ export class NumberValidationComponent implements OnInit { public showUnique: boolean; - public ngOnInit() { - this.showUnique = Types.is(this.field, RootFieldDto) && !this.field.isLocalizable; - - if (this.showUnique) { - this.fieldForm.setControl('isUnique', - new FormControl(this.properties.isUnique)); + public ngOnChanges(changes: SimpleChanges) { + if (changes['field']) { + this.showUnique = Types.is(this.field, RootFieldDto) && !this.field.isLocalizable; } - this.fieldForm.setControl('maxValue', - new FormControl(this.properties.maxValue)); + if (changes['fieldForm']) { + if (this.showUnique) { + this.fieldForm.setControl('isUnique', + new FormControl()); + } + + this.fieldForm.setControl('maxValue', + new FormControl()); - this.fieldForm.setControl('minValue', - new FormControl(this.properties.minValue)); + this.fieldForm.setControl('minValue', + new FormControl()); - this.fieldForm.setControl('defaultValue', - new FormControl(this.properties.defaultValue)); + this.fieldForm.setControl('defaultValue', + new FormControl()); + + this.fieldForm.setControl('defaultValues', + new FormControl()); + } - this.fieldForm.setControl('defaultValues', - new FormControl(this.properties.defaultValues)); + this.fieldForm.patchValue(this.field.properties); } } \ No newline at end of file diff --git a/frontend/app/features/schemas/pages/schema/fields/types/references-ui.component.ts b/frontend/app/features/schemas/pages/schema/fields/types/references-ui.component.ts index 74b092d4c..c0b15e2cb 100644 --- a/frontend/app/features/schemas/pages/schema/fields/types/references-ui.component.ts +++ b/frontend/app/features/schemas/pages/schema/fields/types/references-ui.component.ts @@ -5,7 +5,7 @@ * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. */ -import { Component, Input, OnInit } from '@angular/core'; +import { Component, Input, OnChanges, SimpleChanges } from '@angular/core'; import { FormControl, FormGroup, Validators } from '@angular/forms'; import { FieldDto, ReferencesFieldPropertiesDto, REFERENCES_FIELD_EDITORS } from '@app/shared'; @@ -14,7 +14,7 @@ import { FieldDto, ReferencesFieldPropertiesDto, REFERENCES_FIELD_EDITORS } from styleUrls: ['references-ui.component.scss'], templateUrl: 'references-ui.component.html' }) -export class ReferencesUIComponent implements OnInit { +export class ReferencesUIComponent implements OnChanges { @Input() public fieldForm: FormGroup; @@ -26,13 +26,15 @@ export class ReferencesUIComponent implements OnInit { public editors = REFERENCES_FIELD_EDITORS; - public ngOnInit() { - this.fieldForm.setControl('editor', - new FormControl(this.properties.editor, [ - Validators.required - ])); + public ngOnChanges(changes: SimpleChanges) { + if (changes['fieldForm']) { + this.fieldForm.setControl('editor', + new FormControl(this.properties.editor, Validators.required)); - this.fieldForm.setControl('resolveReference', - new FormControl(this.properties.resolveReference)); + this.fieldForm.setControl('resolveReference', + new FormControl()); + } + + this.fieldForm.patchValue(this.field.properties); } } \ No newline at end of file diff --git a/frontend/app/features/schemas/pages/schema/fields/types/references-validation.component.ts b/frontend/app/features/schemas/pages/schema/fields/types/references-validation.component.ts index 5f1cd8f17..9584340af 100644 --- a/frontend/app/features/schemas/pages/schema/fields/types/references-validation.component.ts +++ b/frontend/app/features/schemas/pages/schema/fields/types/references-validation.component.ts @@ -5,7 +5,7 @@ * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. */ -import { Component, Input, OnInit } from '@angular/core'; +import { Component, Input, OnChanges, SimpleChanges } from '@angular/core'; import { FormControl, FormGroup } from '@angular/forms'; import { FieldDto, LanguageDto, ReferencesFieldPropertiesDto, SchemaTagSource } from '@app/shared'; @@ -14,7 +14,7 @@ import { FieldDto, LanguageDto, ReferencesFieldPropertiesDto, SchemaTagSource } styleUrls: ['references-validation.component.scss'], templateUrl: 'references-validation.component.html' }) -export class ReferencesValidationComponent implements OnInit { +export class ReferencesValidationComponent implements OnChanges { @Input() public fieldForm: FormGroup; @@ -35,26 +35,30 @@ export class ReferencesValidationComponent implements OnInit { ) { } - public ngOnInit() { - this.fieldForm.setControl('allowDuplicates', - new FormControl(this.properties.allowDuplicates)); + public ngOnChanges(changes: SimpleChanges) { + if (changes['fieldForm']) { + this.fieldForm.setControl('allowDuplicates', + new FormControl()); - this.fieldForm.setControl('maxItems', - new FormControl(this.properties.maxItems)); + this.fieldForm.setControl('maxItems', + new FormControl()); - this.fieldForm.setControl('minItems', - new FormControl(this.properties.minItems)); + this.fieldForm.setControl('minItems', + new FormControl()); - this.fieldForm.setControl('schemaIds', - new FormControl(this.properties.schemaIds)); + this.fieldForm.setControl('schemaIds', + new FormControl()); - this.fieldForm.setControl('defaultValue', - new FormControl(this.properties.defaultValue)); + this.fieldForm.setControl('defaultValue', + new FormControl()); - this.fieldForm.setControl('defaultValues', - new FormControl(this.properties.defaultValues)); + this.fieldForm.setControl('defaultValues', + new FormControl()); - this.fieldForm.setControl('mustBePublished', - new FormControl(this.properties.mustBePublished)); + this.fieldForm.setControl('mustBePublished', + new FormControl()); + } + + this.fieldForm.patchValue(this.field.properties); } } \ No newline at end of file diff --git a/frontend/app/features/schemas/pages/schema/fields/types/string-ui.component.ts b/frontend/app/features/schemas/pages/schema/fields/types/string-ui.component.ts index 050612ef2..a0c9be298 100644 --- a/frontend/app/features/schemas/pages/schema/fields/types/string-ui.component.ts +++ b/frontend/app/features/schemas/pages/schema/fields/types/string-ui.component.ts @@ -5,7 +5,7 @@ * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. */ -import { Component, Input, OnInit } from '@angular/core'; +import { Component, Input, OnChanges, SimpleChanges } from '@angular/core'; import { FormControl, FormGroup, Validators } from '@angular/forms'; import { FieldDto, ResourceOwner, StringFieldPropertiesDto, STRING_FIELD_EDITORS, value$ } from '@app/shared'; import { Observable } from 'rxjs'; @@ -16,7 +16,7 @@ import { map } from 'rxjs/operators'; styleUrls: ['string-ui.component.scss'], templateUrl: 'string-ui.component.html' }) -export class StringUIComponent extends ResourceOwner implements OnInit { +export class StringUIComponent extends ResourceOwner implements OnChanges { @Input() public fieldForm: FormGroup; @@ -31,39 +31,41 @@ export class StringUIComponent extends ResourceOwner implements OnInit { public hideAllowedValues: Observable; public hideInlineEditable: Observable; - public ngOnInit() { - this.fieldForm.setControl('editor', - new FormControl(this.properties.editor, [ - Validators.required - ])); + public ngOnChanges(changes: SimpleChanges) { + if (changes['fieldForm']) { + this.fieldForm.setControl('editor', + new FormControl(this.properties.editor, Validators.required)); - this.fieldForm.setControl('allowedValues', - new FormControl(this.properties.allowedValues)); + this.fieldForm.setControl('allowedValues', + new FormControl()); - this.fieldForm.setControl('inlineEditable', - new FormControl(this.properties.inlineEditable)); + this.fieldForm.setControl('inlineEditable', + new FormControl()); - this.fieldForm.setControl('folderId', - new FormControl(this.properties.folderId)); + this.fieldForm.setControl('folderId', + new FormControl()); - this.hideAllowedValues = - value$(this.fieldForm.controls['editor']).pipe(map(x => !(x && (x === 'Radio' || x === 'Dropdown')))); + this.hideAllowedValues = + value$(this.fieldForm.controls['editor']).pipe(map(x => !(x && (x === 'Radio' || x === 'Dropdown')))); - this.hideInlineEditable = - value$(this.fieldForm.controls['editor']).pipe(map(x => !(x && (x === 'Input' || x === 'Dropdown' || x === 'Slug')))); + this.hideInlineEditable = + value$(this.fieldForm.controls['editor']).pipe(map(x => !(x && (x === 'Input' || x === 'Dropdown' || x === 'Slug')))); - this.own( - this.hideAllowedValues.subscribe(isSelection => { - if (isSelection) { - this.fieldForm.controls['allowedValues'].setValue(undefined); - } - })); + this.own( + this.hideAllowedValues.subscribe(isSelection => { + if (isSelection) { + this.fieldForm.controls['allowedValues'].setValue(undefined); + } + })); - this.own( - this.hideInlineEditable.subscribe(isSelection => { - if (isSelection) { - this.fieldForm.controls['inlineEditable'].setValue(false); - } - })); + this.own( + this.hideInlineEditable.subscribe(isSelection => { + if (isSelection) { + this.fieldForm.controls['inlineEditable'].setValue(false); + } + })); + } + + this.fieldForm.patchValue(this.field.properties); } } \ No newline at end of file diff --git a/frontend/app/features/schemas/pages/schema/fields/types/string-validation.component.ts b/frontend/app/features/schemas/pages/schema/fields/types/string-validation.component.ts index 0d6fb7b8a..3f34b47f6 100644 --- a/frontend/app/features/schemas/pages/schema/fields/types/string-validation.component.ts +++ b/frontend/app/features/schemas/pages/schema/fields/types/string-validation.component.ts @@ -5,7 +5,7 @@ * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. */ -import { Component, Input, OnChanges, OnInit } from '@angular/core'; +import { Component, Input, OnChanges, SimpleChanges } from '@angular/core'; import { FormControl, FormGroup } from '@angular/forms'; import { AppSettingsDto, fadeAnimation, FieldDto, hasNoValue$, hasValue$, LanguageDto, ModalModel, PatternDto, ResourceOwner, RootFieldDto, StringFieldPropertiesDto, STRING_CONTENT_TYPES, Types, value$ } from '@app/shared'; import { Observable } from 'rxjs'; @@ -18,7 +18,7 @@ import { Observable } from 'rxjs'; fadeAnimation ] }) -export class StringValidationComponent extends ResourceOwner implements OnChanges, OnInit { +export class StringValidationComponent extends ResourceOwner implements OnChanges { @Input() public fieldForm: FormGroup; @@ -47,71 +47,73 @@ export class StringValidationComponent extends ResourceOwner implements OnChange public showUnique: boolean; - public ngOnInit() { - this.showUnique = Types.is(this.field, RootFieldDto) && !this.field.isLocalizable; - - if (this.showUnique) { - this.fieldForm.setControl('isUnique', - new FormControl(this.properties.isUnique)); + public ngOnChanges(changes: SimpleChanges) { + if (changes['field']) { + this.showUnique = Types.is(this.field, RootFieldDto) && !this.field.isLocalizable; } - this.fieldForm.setControl('maxLength', - new FormControl(this.properties.maxLength)); + if (changes['fieldForm']) { + if (this.showUnique) { + this.fieldForm.setControl('isUnique', + new FormControl()); + } - this.fieldForm.setControl('minLength', - new FormControl(this.properties.minLength)); + this.fieldForm.setControl('maxLength', + new FormControl()); - this.fieldForm.setControl('maxWords', - new FormControl(this.properties.maxWords)); + this.fieldForm.setControl('minLength', + new FormControl()); - this.fieldForm.setControl('minWords', - new FormControl(this.properties.minWords)); + this.fieldForm.setControl('maxWords', + new FormControl()); - this.fieldForm.setControl('maxCharacters', - new FormControl(this.properties.maxCharacters)); + this.fieldForm.setControl('minWords', + new FormControl()); - this.fieldForm.setControl('minCharacters', - new FormControl(this.properties.minCharacters)); + this.fieldForm.setControl('maxCharacters', + new FormControl()); - this.fieldForm.setControl('contentType', - new FormControl(this.properties.contentType)); + this.fieldForm.setControl('minCharacters', + new FormControl()); - this.fieldForm.setControl('pattern', - new FormControl(this.properties.pattern)); + this.fieldForm.setControl('contentType', + new FormControl()); - this.fieldForm.setControl('patternMessage', - new FormControl(this.properties.patternMessage)); + this.fieldForm.setControl('pattern', + new FormControl()); - this.fieldForm.setControl('defaultValue', - new FormControl(this.properties.defaultValue)); + this.fieldForm.setControl('patternMessage', + new FormControl()); - this.fieldForm.setControl('defaultValues', - new FormControl(this.properties.defaultValues)); + this.fieldForm.setControl('defaultValue', + new FormControl()); - this.showPatternSuggestions = - hasNoValue$(this.fieldForm.controls['pattern']); + this.fieldForm.setControl('defaultValues', + new FormControl()); - this.showPatternSuggestions = - hasNoValue$(this.fieldForm.controls['pattern']); + this.showPatternSuggestions = + hasNoValue$(this.fieldForm.controls['pattern']); - this.showPatternMessage = - hasValue$(this.fieldForm.controls['pattern']); + this.showPatternSuggestions = + hasNoValue$(this.fieldForm.controls['pattern']); - this.own( - value$(this.fieldForm.controls['pattern']) - .subscribe((value: string) => { - if (!value) { - this.fieldForm.controls['patternMessage'].setValue(undefined); - } + this.showPatternMessage = + hasValue$(this.fieldForm.controls['pattern']); - this.setPatternName(); - })); + this.own( + value$(this.fieldForm.controls['pattern']) + .subscribe((value: string) => { + if (!value) { + this.fieldForm.controls['patternMessage'].setValue(undefined); + } - this.setPatternName(); - } + this.setPatternName(); + })); + } - public ngOnChanges() { this.setPatternName(); + + this.fieldForm.patchValue(this.field.properties); } public setPattern(pattern: PatternDto) { @@ -120,12 +122,12 @@ export class StringValidationComponent extends ResourceOwner implements OnChange } private setPatternName() { - const value = this.fieldForm.controls['pattern']?.value; + const regex = this.fieldForm.controls['pattern']?.value; - if (!value) { + if (!regex) { this.patternName = ''; } else { - const matchingPattern = this.settings.patterns.find(x => x.regex === this.fieldForm.controls['pattern'].value); + const matchingPattern = this.settings.patterns.find(x => x.regex === regex); if (matchingPattern) { this.patternName = matchingPattern.name; diff --git a/frontend/app/features/schemas/pages/schema/fields/types/tags-ui.component.ts b/frontend/app/features/schemas/pages/schema/fields/types/tags-ui.component.ts index f9629c9ad..40f71f1c7 100644 --- a/frontend/app/features/schemas/pages/schema/fields/types/tags-ui.component.ts +++ b/frontend/app/features/schemas/pages/schema/fields/types/tags-ui.component.ts @@ -5,7 +5,7 @@ * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. */ -import { Component, Input, OnInit } from '@angular/core'; +import { Component, Input, OnChanges, SimpleChanges } from '@angular/core'; import { FormControl, FormGroup, Validators } from '@angular/forms'; import { FieldDto, TagsFieldPropertiesDto, TAGS_FIELD_EDITORS } from '@app/shared'; @@ -14,7 +14,7 @@ import { FieldDto, TagsFieldPropertiesDto, TAGS_FIELD_EDITORS } from '@app/share styleUrls: ['tags-ui.component.scss'], templateUrl: 'tags-ui.component.html' }) -export class TagsUIComponent implements OnInit { +export class TagsUIComponent implements OnChanges { @Input() public fieldForm: FormGroup; @@ -26,13 +26,15 @@ export class TagsUIComponent implements OnInit { public editors = TAGS_FIELD_EDITORS; - public ngOnInit() { - this.fieldForm.setControl('editor', - new FormControl(this.properties.editor, [ - Validators.required - ])); + public ngOnChanges(changes: SimpleChanges) { + if (changes['fieldForm']) { + this.fieldForm.setControl('editor', + new FormControl(undefined, Validators.required)); - this.fieldForm.setControl('allowedValues', - new FormControl(this.properties.allowedValues)); + this.fieldForm.setControl('allowedValues', + new FormControl()); + } + + this.fieldForm.patchValue(this.field.properties); } } \ No newline at end of file diff --git a/frontend/app/features/schemas/pages/schema/fields/types/tags-validation.component.ts b/frontend/app/features/schemas/pages/schema/fields/types/tags-validation.component.ts index a21c0ac22..33c12c2ad 100644 --- a/frontend/app/features/schemas/pages/schema/fields/types/tags-validation.component.ts +++ b/frontend/app/features/schemas/pages/schema/fields/types/tags-validation.component.ts @@ -5,7 +5,7 @@ * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. */ -import { Component, Input, OnInit } from '@angular/core'; +import { Component, Input, OnChanges, SimpleChanges } from '@angular/core'; import { FormControl, FormGroup } from '@angular/forms'; import { FieldDto, LanguageDto, TagsFieldPropertiesDto } from '@app/shared'; @@ -14,7 +14,7 @@ import { FieldDto, LanguageDto, TagsFieldPropertiesDto } from '@app/shared'; styleUrls: ['tags-validation.component.scss'], templateUrl: 'tags-validation.component.html' }) -export class TagsValidationComponent implements OnInit { +export class TagsValidationComponent implements OnChanges { @Input() public fieldForm: FormGroup; @@ -30,17 +30,21 @@ export class TagsValidationComponent implements OnInit { @Input() public isLocalizable?: boolean | null; - public ngOnInit() { - this.fieldForm.setControl('maxItems', - new FormControl(this.properties.maxItems)); + public ngOnChanges(changes: SimpleChanges) { + if (changes['fieldForm']) { + this.fieldForm.setControl('maxItems', + new FormControl()); - this.fieldForm.setControl('minItems', - new FormControl(this.properties.minItems)); + this.fieldForm.setControl('minItems', + new FormControl()); - this.fieldForm.setControl('defaultValue', - new FormControl(this.properties.defaultValue)); + this.fieldForm.setControl('defaultValue', + new FormControl()); - this.fieldForm.setControl('defaultValues', - new FormControl(this.properties.defaultValues)); + this.fieldForm.setControl('defaultValues', + new FormControl()); + } + + this.fieldForm.patchValue(this.field.properties); } } \ No newline at end of file diff --git a/frontend/app/features/schemas/pages/schema/rules/schema-field-rules-form.component.ts b/frontend/app/features/schemas/pages/schema/rules/schema-field-rules-form.component.ts index 81dd7683f..67c34842b 100644 --- a/frontend/app/features/schemas/pages/schema/rules/schema-field-rules-form.component.ts +++ b/frontend/app/features/schemas/pages/schema/rules/schema-field-rules-form.component.ts @@ -46,7 +46,7 @@ export class SchemaFieldRulesFormComponent implements OnChanges { } } - this.fieldNames = fieldNames.sorted(); + this.fieldNames = fieldNames.sort(); this.isEditable = this.schema.canUpdateUrls; diff --git a/frontend/app/features/settings/pages/contributors/import-contributors-dialog.component.html b/frontend/app/features/settings/pages/contributors/import-contributors-dialog.component.html index 810a366b7..bfec5205f 100644 --- a/frontend/app/features/settings/pages/contributors/import-contributors-dialog.component.html +++ b/frontend/app/features/settings/pages/contributors/import-contributors-dialog.component.html @@ -25,7 +25,7 @@
-
diff --git a/frontend/app/features/settings/pages/contributors/import-contributors-dialog.component.ts b/frontend/app/features/settings/pages/contributors/import-contributors-dialog.component.ts index 39b149bd1..cfac2f91d 100644 --- a/frontend/app/features/settings/pages/contributors/import-contributors-dialog.component.ts +++ b/frontend/app/features/settings/pages/contributors/import-contributors-dialog.component.ts @@ -24,8 +24,6 @@ type ImportStatus = { templateUrl: './import-contributors-dialog.component.html' }) export class ImportContributorsDialogComponent { - public readonly standalone = { standalone: true }; - @Output() public close = new EventEmitter(); diff --git a/frontend/app/features/settings/pages/languages/language.component.ts b/frontend/app/features/settings/pages/languages/language.component.ts index 47c39cdb9..daed10670 100644 --- a/frontend/app/features/settings/pages/languages/language.component.ts +++ b/frontend/app/features/settings/pages/languages/language.component.ts @@ -80,13 +80,13 @@ export class LanguageComponent implements OnChanges { public removeFallbackLanguage(language: LanguageDto) { this.fallbackLanguages = this.fallbackLanguages.removed(language); - this.fallbackLanguagesNew = [...this.fallbackLanguagesNew, language].sortedByString(x => x.iso2Code); + this.fallbackLanguagesNew = [...this.fallbackLanguagesNew, language].sortByString(x => x.iso2Code); this.otherLanguage = this.fallbackLanguagesNew[0]; } public addFallbackLanguage() { - this.fallbackLanguages = [...this.fallbackLanguages, this.otherLanguage].sortedByString(x => x.iso2Code); + this.fallbackLanguages = [...this.fallbackLanguages, this.otherLanguage].sortByString(x => x.iso2Code); this.fallbackLanguagesNew = this.fallbackLanguagesNew.removed(this.otherLanguage); this.otherLanguage = this.fallbackLanguagesNew[0]; diff --git a/frontend/app/features/settings/pages/roles/role.component.html b/frontend/app/features/settings/pages/roles/role.component.html index d61da1182..09b047540 100644 --- a/frontend/app/features/settings/pages/roles/role.component.html +++ b/frontend/app/features/settings/pages/roles/role.component.html @@ -104,7 +104,7 @@ [disabled]="!isEditable" [ngModel]="getProperty(property.key)" (ngModelChange)="setProperty(property.key, $event)" - [ngModelOptions]="standalone"> + [ngModelOptions]="{ standalone: true }"> @@ -121,7 +121,7 @@ [disabled]="!isEditable" [ngModel]="getProperty(propertiesList.HIDE_CONTENTS(schema.name))" (ngModelChange)="setProperty(propertiesList.HIDE_CONTENTS(schema.name), $event)" - [ngModelOptions]="standalone"> + [ngModelOptions]="{ standalone: true }">