Beispiel #1
0
        public void Navigation_MarkupIsCorrect()
        {
            var controller = new NavigationFieldController();

            var control = new MvcWidgetProxy();

            control.ControllerName = typeof(NavigationFieldController).FullName;
            control.Settings       = new ControllerSettings(controller);

            var formId      = ServerOperationsFeather.Forms().CreateFormWithWidget(control);
            var pageManager = PageManager.GetManager();

            try
            {
                var template = pageManager.GetTemplates().FirstOrDefault(t => t.Name == "SemanticUI.default" && t.Title == "default");
                Assert.IsNotNull(template, "Template was not found");

                var pageId = FeatherServerOperations.Pages().CreatePageWithTemplate(template, "NavigationFieldValueTest", "section-header-field-value-test");
                ServerOperationsFeather.Forms().AddFormControlToPage(pageId, formId);

                var pageContent = ServerOperationsFeather.Pages().GetPageContent(pageId);

                var pageName = Res.Get <FieldResources>().PageName + "1";
                Assert.IsTrue(pageContent.Contains(pageName), "Form did not render navigation field pages");
            }
            finally
            {
                Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Pages().DeleteAllPages();
                FormsModuleCodeSnippets.DeleteForm(formId);
            }
        }
        public void FormsWidget_AddWidgetToFormDescription_FormIsUpdated()
        {
            var gridVirtualPath = "~/Frontend-Assembly/Telerik.Sitefinity.Frontend/GridSystem/Templates/grid-3+9.html";
            var control = new GridControl();
            control.Layout = gridVirtualPath;
            var formId = ServerOperationsFeather.Forms().CreateFormWithWidget(control);

            var pageManager = PageManager.GetManager();

            try
            {
                var template = pageManager.GetTemplates().FirstOrDefault(t => t.Name == "SemanticUI.default" && t.Title == "default");
                Assert.IsNotNull(template, "Template was not found");

                var pageId = FeatherServerOperations.Pages().CreatePageWithTemplate(template, "FormsPageCacheTest", "forms-page-cache-test");
                ServerOperationsFeather.Forms().AddFormControlToPage(pageId, formId);

                string pageContent = FeatherServerOperations.Pages().GetPageContent(pageId);

                Assert.IsTrue(pageContent.Contains("class=\"sf_colsIn four wide column\""), "SemanticUI grid content not found.");

                ServerOperationsFeather.Forms().AddFormWidget(formId, new GridControl() { Layout = "<div class=\"sf_colsIn\">Funny widget.</div>" });
                pageContent = FeatherServerOperations.Pages().GetPageContent(pageId);

                Assert.IsTrue(pageContent.Contains("Funny widget."), "Form did not render the new control.");
            }
            finally
            {
                Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Pages().DeleteAllPages();
                FormsModuleCodeSnippets.DeleteForm(formId);
            }
        }
Beispiel #3
0
        public void DropdownListFieldTests_EditDefaultValue_MarkupIsCorrect()
        {
            var controller = new DropdownListFieldController();

            var control = new MvcWidgetProxy();

            control.Settings       = new ControllerSettings(controller);
            control.ControllerName = typeof(DropdownListFieldController).FullName;

            var formId = ServerOperationsFeather.Forms().CreateFormWithWidget(control);

            var pageManager = PageManager.GetManager();

            try
            {
                var template = pageManager.GetTemplates().FirstOrDefault(t => t.Name == "SemanticUI.default" && t.Title == "default");
                Assert.IsNotNull(template, "Template was not found");

                var pageId = FeatherServerOperations.Pages().CreatePageWithTemplate(template, "DropdownListFieldSubmitValueTest", "dropdown-list-field-value-test");
                ServerOperationsFeather.Forms().AddFormControlToPage(pageId, formId);

                var pageContent = ServerOperationsFeather.Pages().GetPageContent(pageId);
                Assert.IsTrue(pageContent.Contains(Res.Get <FieldResources>().OptionSelect), "Form did not render the select default choice in the dropdown list field.");
                Assert.IsTrue(pageContent.Contains(Res.Get <FieldResources>().OptionFirstChoice), "Form did not render the first default choice in the dropdown list field.");
                Assert.IsTrue(pageContent.Contains(Res.Get <FieldResources>().OptionSecondChoice), "Form did not render the second default choice in the dropdown list field.");
            }
            finally
            {
                Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Pages().DeleteAllPages();
                FormsModuleCodeSnippets.DeleteForm(formId);
            }
        }
Beispiel #4
0
        public void TextField_EditInputType_MarkupIsCorrect()
        {
            var control = new MvcWidgetProxy();

            control.ControllerName = typeof(TextFieldController).FullName;
            var controller = new TextFieldController();

            controller.Model.InputType = Telerik.Sitefinity.Frontend.Forms.Mvc.Models.Fields.TextField.TextType.DateTimeLocal;
            control.Settings           = new ControllerSettings(controller);

            var formId = ServerOperationsFeather.Forms().CreateFormWithWidget(control);

            var pageManager = PageManager.GetManager();

            try
            {
                var template = pageManager.GetTemplates().FirstOrDefault(t => t.Name == "SemanticUI.default" && t.Title == "default");
                Assert.IsNotNull(template, "Template was not found");

                var pageId = FeatherServerOperations.Pages().CreatePageWithTemplate(template, "TextFieldTypeTest", "text-field-type-test");
                ServerOperationsFeather.Forms().AddFormControlToPage(pageId, formId);

                var pageContent = ServerOperationsFeather.Pages().GetPageContent(pageId);

                Assert.IsTrue(pageContent.Contains("type=\"datetime-local\""), "Form did not render the input type in the text field.");
            }
            finally
            {
                Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Pages().DeleteAllPages();
                FormsModuleCodeSnippets.DeleteForm(formId);
            }
        }
Beispiel #5
0
        public void ParagraphTextFieldTests_EditDefaultValue_MarkupIsCorrect()
        {
            const string DefaultText = "My default text";

            var controller = new ParagraphTextFieldController();

            controller.MetaField.DefaultValue = DefaultText;

            var control = new MvcWidgetProxy();

            control.Settings       = new ControllerSettings(controller);
            control.ControllerName = typeof(ParagraphTextFieldController).FullName;

            var formId = ServerOperationsFeather.Forms().CreateFormWithWidget(control);

            var pageManager = PageManager.GetManager();

            try
            {
                var template = pageManager.GetTemplates().FirstOrDefault(t => t.Name == "SemanticUI.default" && t.Title == "default");
                Assert.IsNotNull(template, "Template was not found");

                var pageId = FeatherServerOperations.Pages().CreatePageWithTemplate(template, "ParagraphTextFieldSubmitValueTest", "paragraph-text-field-value-test");
                ServerOperationsFeather.Forms().AddFormControlToPage(pageId, formId);

                var pageContent = ServerOperationsFeather.Pages().GetPageContent(pageId);
                Assert.IsTrue(pageContent.Contains(DefaultText), "Form did not render the default text in the paragraph text field.");
            }
            finally
            {
                Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Pages().DeleteAllPages();
                FormsModuleCodeSnippets.DeleteForm(formId);
            }
        }
Beispiel #6
0
        public void PageBreak_SeparatorsMarkupIsCorrect()
        {
            var controller = new PageBreakController();

            var control = new MvcWidgetProxy();

            control.ControllerName = typeof(PageBreakController).FullName;
            control.Settings       = new ControllerSettings(controller);

            var formId = ServerOperationsFeather.Forms().CreateFormWithWidget(control);

            var pageManager = PageManager.GetManager();

            try
            {
                var template = pageManager.GetTemplates().FirstOrDefault(t => t.Name == "SemanticUI.default" && t.Title == "default");
                Assert.IsNotNull(template, "Template was not found");

                var pageId = FeatherServerOperations.Pages().CreatePageWithTemplate(template, "PageBreakValueTest", "page-break-value-test");
                ServerOperationsFeather.Forms().AddFormControlToPage(pageId, formId);

                var pageContent            = ServerOperationsFeather.Pages().GetPageContent(pageId);
                var formMultipageDecorator = ObjectFactory.Resolve <IFormMultipageDecorator>();
                Assert.IsTrue(pageContent.Contains(formMultipageDecorator.SeparatorBegin), "Form did not render page separators");
            }
            finally
            {
                Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Pages().DeleteAllPages();
                FormsModuleCodeSnippets.DeleteForm(formId);
            }
        }
        private void ExecuteResponsesSearchTextTest(string[,] responsesFieldsValues, string searchedText, int expectedResultsCount)
        {
            var fieldsPerResponse = responsesFieldsValues.GetLength(1);
            var controls          = new MvcWidgetProxy[fieldsPerResponse];

            for (int i = 0; i < controls.Length; i++)
            {
                var control = new MvcWidgetProxy();
                control.ControllerName = typeof(TextFieldController).FullName;

                var controller = new TextFieldController();
                control.Settings = new ControllerSettings(controller);
                controls[i]      = control;
            }

            var formId = ServerOperationsFeather.Forms().CreateFormWithWidgets(controls);

            var manager = FormsManager.GetManager();
            var form    = manager.GetForm(formId);

            var masterDetailView = new FormsMasterDetailView();

            masterDetailView.FormDescription = form;
            var masterDetailDefinition = new MasterGridViewDefinition();

            typeof(FormsMasterDetailView).GetMethod("ConfigureSearchFields", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(masterDetailView, new object[] { masterDetailDefinition });
            var fields = masterDetailDefinition.SearchFields.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

            Assert.AreEqual(fieldsPerResponse, fields.Length, string.Format(CultureInfo.InvariantCulture, "The produced search fields count ({0}) is not equal to the actual fields count on the form ({1})", fields.Length, fieldsPerResponse));

            var service = new FormsService();

            try
            {
                using (var fluent = App.WorkWith())
                {
                    for (int responseIndex = 0; responseIndex < responsesFieldsValues.GetLength(0); responseIndex++)
                    {
                        var formEntry = fluent.Forms().Form(form.Name).Entry().CreateNew(Guid.NewGuid());

                        for (int fieldValueIndex = 0; fieldValueIndex < responsesFieldsValues.GetLength(1); fieldValueIndex++)
                        {
                            formEntry.SetFieldValue(fields[fieldValueIndex], responsesFieldsValues[responseIndex, fieldValueIndex]);
                        }

                        formEntry.SaveChanges();
                    }
                }

                var filterClauses = fields.Select(f => string.Format(CultureInfo.InvariantCulture, "{0}.ToUpper().Contains(\"{1}\".ToUpper())", f, searchedText));
                var filter        = "(" + string.Join(" OR ", filterClauses) + ")";
                var entries       = service.GetFormEntries(form.Name, null, "Title ASC", 0, 50, filter, manager.Provider.FormsNamespace + "." + form.Name, null, Guid.Empty);

                Assert.AreEqual(expectedResultsCount, entries.TotalCount, string.Format(CultureInfo.InvariantCulture, "The returned search results ({0}) do not match the expected ones ({1})", entries.TotalCount, expectedResultsCount));
            }
            finally
            {
                FormsModuleCodeSnippets.DeleteForm(formId);
            }
        }
Beispiel #8
0
        public void ParagraphTextField_SubmitValue_ResponseIsCorrect()
        {
            const string SubmitedParagraphValue = "Submitted paragraph value";

            var controller = new ParagraphTextFieldController();

            var control = new MvcWidgetProxy();

            control.Settings       = new ControllerSettings(controller);
            control.ControllerName = typeof(ParagraphTextFieldController).FullName;

            var formId = ServerOperationsFeather.Forms().CreateFormWithWidget(control);

            var formManager = FormsManager.GetManager();
            var form        = formManager.GetForms().FirstOrDefault(f => f.Id == formId);

            var pageManager = PageManager.GetManager();

            try
            {
                var template = pageManager.GetTemplates().FirstOrDefault(t => t.Name == "SemanticUI.default" && t.Title == "default");
                Assert.IsNotNull(template, "Template was not found");

                var pageId = FeatherServerOperations.Pages().CreatePageWithTemplate(template, "ParagraphTextFieldValueTest", "paragraph-text-field-submit-value-test");
                ServerOperationsFeather.Forms().AddFormControlToPage(pageId, formId);
                var pageDataId = pageManager.GetPageNode(pageId).GetPageData().Id;
                var paragraphTextFieldControlData = form.Controls.Where(c => c.PlaceHolder == "Body" && !c.IsLayoutControl).FirstOrDefault();
                var mvcFieldProxy = formManager.LoadControl(paragraphTextFieldControlData) as MvcWidgetProxy;

                var paragraphTextField = mvcFieldProxy.Controller as ParagraphTextFieldController;
                Assert.IsNotNull(paragraphTextField, "The paragraph text field was not found.");

                var paragraphTextFieldName = paragraphTextField.MetaField.FieldName;
                var formCollection         = new FormCollection();
                formCollection.Add(paragraphTextFieldName, SubmitedParagraphValue);
                var formControllerProxy = pageManager.LoadPageControls <MvcControllerProxy>(pageDataId).Where(contr => contr.Controller.GetType() == typeof(FormController)).FirstOrDefault();
                var formController      = formControllerProxy.Controller as FormController;
                formController.ControllerContext             = new ControllerContext();
                formController.ControllerContext.HttpContext = new HttpContextWrapper(HttpContext.Current);
                formController.Index(formCollection);

                var formEntry = formManager.GetFormEntries(form).LastOrDefault();
                Assert.IsNotNull(formEntry, "Form entry has not been submitted.");

                var submittedValue = formEntry.GetValue(paragraphTextFieldName) as string;
                Assert.AreEqual(SubmitedParagraphValue, submittedValue, "Form did not persisted the submitted paragraph text value correctly.");
            }
            finally
            {
                Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Pages().DeleteAllPages();
                FormsModuleCodeSnippets.DeleteForm(formId);
            }
        }
Beispiel #9
0
        public void PageBreak_HeaderAndFooterFieldsInitialized()
        {
            var controllerForBody = new PageBreakController();
            var controlForBody    = new MvcWidgetProxy();

            controlForBody.ControllerName = typeof(PageBreakController).FullName;
            controlForBody.Settings       = new ControllerSettings(controllerForBody);

            var controllerForHeader = new TextFieldController();
            var controlForHeader    = new MvcWidgetProxy();

            controlForHeader.ControllerName = typeof(TextFieldController).FullName;
            controlForHeader.Settings       = new ControllerSettings(controllerForHeader);

            var controllerForFooter = new ParagraphTextFieldController();
            var controlForFooter    = new MvcWidgetProxy();

            controlForFooter.ControllerName = typeof(ParagraphTextFieldController).FullName;
            controlForFooter.Settings       = new ControllerSettings(controllerForFooter);

            var formId = ServerOperationsFeather.Forms().CreateFormWithWidgets(new List <Control>()
            {
                controlForHeader
            }, new List <Control>()
            {
                controlForBody
            }, new List <Control>()
            {
                controlForFooter
            }, null);
            var pageManager = PageManager.GetManager();

            try
            {
                var template = pageManager.GetTemplates().FirstOrDefault(t => t.Name == "SemanticUI.default" && t.Title == "default");
                Assert.IsNotNull(template, "Template was not found");

                var pageId = FeatherServerOperations.Pages().CreatePageWithTemplate(template, "PageBreakValueTest", "section-header-field-value-test");
                ServerOperationsFeather.Forms().AddFormControlToPage(pageId, formId);

                var pageContent            = ServerOperationsFeather.Pages().GetPageContent(pageId);
                var formMultipageDecorator = ObjectFactory.Resolve <IFormMultipageDecorator>();
                Assert.IsTrue(pageContent.Contains(formMultipageDecorator.SeparatorBegin), "Form did not render page separators");
                Assert.IsTrue(pageContent.Contains("data-sf-role=\"text-field-container\""), "Form did not render page header");
                Assert.IsTrue(pageContent.Contains("data-sf-role=\"paragraph-text-field-container\""), "Form did not render page footer");
            }
            finally
            {
                Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Pages().DeleteAllPages();
                FormsModuleCodeSnippets.DeleteForm(formId);
            }
        }
Beispiel #10
0
        public void ParagraphTextFieldUrl_SubmitIncorrectValue_ServerValidationFails()
        {
            var controller = new ParagraphTextFieldController();

            controller.Model.ValidatorDefinition.Required = true;

            var control = new MvcWidgetProxy();

            control.ControllerName = typeof(ParagraphTextFieldController).FullName;
            control.Settings       = new ControllerSettings(controller);

            var formId = ServerOperationsFeather.Forms().CreateFormWithWidget(control);

            var formManager = FormsManager.GetManager();
            var form        = formManager.GetForms().FirstOrDefault(f => f.Id == formId);

            var pageManager = PageManager.GetManager();

            try
            {
                var template = pageManager.GetTemplates().FirstOrDefault(t => t.Name == "SemanticUI.default" && t.Title == "default");
                Assert.IsNotNull(template, "Template was not found");

                var pageId = FeatherServerOperations.Pages().CreatePageWithTemplate(template, "ParagraphTextFieldValidationTest", "paragraph-text-field-validation-test");
                ServerOperationsFeather.Forms().AddFormControlToPage(pageId, formId);
                var pageDataId = pageManager.GetPageNode(pageId).GetPageData().Id;
                var paragraphTextFieldControlData = form.Controls.Where(c => c.PlaceHolder == "Body" && !c.IsLayoutControl).FirstOrDefault();
                var mvcFieldProxy = formManager.LoadControl(paragraphTextFieldControlData) as MvcWidgetProxy;

                var paragraphTextField = mvcFieldProxy.Controller as ParagraphTextFieldController;
                Assert.IsNotNull(paragraphTextField, "The paragraph text field was not found.");

                var paragraphTextFieldName = paragraphTextField.MetaField.FieldName;
                var formCollection         = new FormCollection();
                formCollection.Add(paragraphTextFieldName, string.Empty);
                var formControllerProxy = pageManager.LoadPageControls <MvcControllerProxy>(pageDataId).Where(contr => contr.Controller.GetType() == typeof(FormController)).FirstOrDefault();
                var formController      = formControllerProxy.Controller as FormController;
                formController.ControllerContext             = new ControllerContext();
                formController.ControllerContext.HttpContext = new HttpContextWrapper(HttpContext.Current);

                formController.Index(formCollection);
                Assert.IsFalse((bool)formController.TempData["sfSubmitSuccess"], "The Submit result was not correct");

                var formEntry = formManager.GetFormEntries(form).LastOrDefault();
                Assert.IsNull(formEntry, "Form entry has been submitted even when the form is not valid.");
            }
            finally
            {
                Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Pages().DeleteAllPages();
                FormsModuleCodeSnippets.DeleteForm(formId);
            }
        }
        public void FormsWidget_SubmitFormWithForumWidgetOnPageBasedOnCustomHybridPage_NoExceptionIsThrown()
        {
            var testName     = MethodInfo.GetCurrentMethod().Name;
            var templateName = testName + "template";
            var pageName     = testName + "page";

            var submitButtonControl = new MvcWidgetProxy();

            submitButtonControl.ControllerName = typeof(SubmitButtonController).FullName;
            submitButtonControl.Settings       = new ControllerSettings(new SubmitButtonController());
            var formId = ServerOperationsFeather.Forms().CreateFormWithWidget(submitButtonControl);

            var forumControl = new ForumsView();

            var  pageManager = PageManager.GetManager();
            Guid templateId  = Guid.Empty;
            Guid pageId      = Guid.Empty;

            try
            {
                templateId = Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Templates().CreateHybridMVCPageTemplate(templateName);
                pageId     = FeatherServerOperations.Pages().CreatePageWithTemplate(pageManager.GetTemplate(templateId), pageName, pageName);
                ServerOperationsFeather.Forms().AddFormControlToPage(pageId, formId, "TestForm", "Body");
                PageContentGenerator.AddControlToPage(pageId, forumControl, "TestForum", "Body");

                var page    = pageManager.GetPageNode(pageId);
                var pageUrl = page.GetFullUrl();
                pageUrl = RouteHelper.GetAbsoluteUrl(pageUrl);

                var webRequest = (HttpWebRequest)WebRequest.Create(pageUrl);
                var dataString = "------WebKitFormBoundaryPIB6p73K1Y0L0ha5--";
                var dataBytes  = (new ASCIIEncoding()).GetBytes(dataString);
                webRequest.Method        = "POST";
                webRequest.ContentLength = dataBytes.Length;
                webRequest.ContentType   = "multipart/form-data";
                webRequest.Timeout       = 120 * 1000;
                webRequest.GetRequestStream().Write(dataBytes, 0, dataBytes.Length);
                Assert.DoesNotThrow(() => webRequest.GetResponse(), "Submitting a form on custom hybrid page with a forum widget on it throws error");
            }
            finally
            {
                Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Pages().DeletePage(pageId);
                Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Templates().DeletePageTemplate(templateId);
                FormsModuleCodeSnippets.DeleteForm(formId);
            }
        }
        public void FormsWidget_LoadingMvcForm_UnpublishPublish()
        {
            var  testName = MethodInfo.GetCurrentMethod().Name;
            var  pageName = testName + "page";
            Guid pageId   = Guid.Empty;
            var  formId   = Guid.Empty;

            try
            {
                var fields = new FeatherWidgets.TestUtilities.CommonOperations.Forms.FormFieldType[]
                {
                    FeatherWidgets.TestUtilities.CommonOperations.Forms.FormFieldType.TextField,
                    FeatherWidgets.TestUtilities.CommonOperations.Forms.FormFieldType.SubmitButton
                };

                formId = ServerOperationsFeather.Forms().CreateFormWithWidgets(fields, "NewForm");
                pageId = ServerOperations.Pages().CreatePage(pageName);
                string url = UrlPath.ResolveAbsoluteUrl("~/" + pageName);
                ServerOperationsFeather.Forms().AddFormControlToPage(pageId, formId, FeatherGlobals.FormName, "Body");

                var formManager = FormsManager.GetManager();
                var form        = formManager.GetForms().FirstOrDefault(f => f.Id == formId);

                Assert.IsFalse(form == null, "Testing form is missing");

                var errorMessage = new FormsResources().TheSpecifiedFormNoLongerExists;

                string publishFormPageContentFirst = WebRequestHelper.GetPageWebContent(url);
                Assert.IsFalse(publishFormPageContentFirst.Contains(errorMessage), string.Format(CultureInfo.InvariantCulture, "Unexpected message in page: {0}", errorMessage));

                formManager.UnpublishForm(formId);
                formManager.SaveChanges();
                string unpublishFormPageContent = WebRequestHelper.GetPageWebContent(url);
                Assert.IsTrue(unpublishFormPageContent.Contains(errorMessage), string.Format(CultureInfo.InvariantCulture, "Expected message in page: {0}", errorMessage));

                formManager.PublishForm(form);
                formManager.SaveChanges();
                string publishFormPageContentSecond = WebRequestHelper.GetPageWebContent(url);
                Assert.IsFalse(publishFormPageContentSecond.Contains(errorMessage), string.Format(CultureInfo.InvariantCulture, "Unexpected message in page: {0}", errorMessage));
            }
            finally
            {
                ServerOperations.Pages().DeletePage(pageId);
                FormsModuleCodeSnippets.DeleteForm(formId);
            }
        }
Beispiel #13
0
        public Guid CreateFormWithWidget(Control widget)
        {
            var formId = Guid.NewGuid();

            string formSuccessMessage = "Test form success message";

            var formControls = new Dictionary <Control, string>();

            formControls.Add(widget, "Body");

            FormsModuleCodeSnippets.CreateForm(formId, "form_" + formId.ToString("N"), formId.ToString("N"), formSuccessMessage, formControls);

            SystemManager.ClearCurrentTransactions();
            SystemManager.RestartApplication(false);
            System.Threading.Thread.Sleep(1000);

            return(formId);
        }
Beispiel #14
0
        public void CheckboxesFieldTests_SubmitIncorrectValue_ServerValidationFails()
        {
            var controller = new CheckboxesFieldController();

            controller.Model.ValidatorDefinition.Required = true;

            var control = new MvcWidgetProxy();

            control.ControllerName = typeof(CheckboxesFieldController).FullName;
            control.Settings       = new ControllerSettings(controller);

            var formId = ServerOperationsFeather.Forms().CreateFormWithWidget(control);

            var formManager = FormsManager.GetManager();
            var form        = formManager.GetForms().FirstOrDefault(f => f.Id == formId);

            var pageManager = PageManager.GetManager();

            try
            {
                var template = pageManager.GetTemplates().FirstOrDefault(t => t.Name == "SemanticUI.default" && t.Title == "default");
                Assert.IsNotNull(template, "Template was not found");

                var pageId = FeatherServerOperations.Pages().CreatePageWithTemplate(template, "CheckboxesFieldValidationTest", "checkboxes-field-validation-test");
                ServerOperationsFeather.Forms().AddFormControlToPage(pageId, formId);

                var checkboxesFieldName = ServerOperationsFeather.Forms().GetFirstFieldName(formManager, form);
                var result        = ServerOperationsFeather.Forms().SubmitField(checkboxesFieldName, string.Empty, pageManager, pageId);
                var contentResult = result as ViewResult;
                Assert.IsNotNull(contentResult, "Submit should return content result.");
                Assert.AreEqual(Res.Get <FormResources>().UnsuccessfullySubmittedMessage, contentResult.ViewBag.SubmitMessage, "The Submit didn't result in error as expected!");
                Assert.AreEqual("Form.SubmitResultView", contentResult.ViewName);

                var formEntry = formManager.GetFormEntries(form).LastOrDefault();
                Assert.IsNull(formEntry, "Form entry has been submitted even when the form is not valid.");
            }
            finally
            {
                Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Pages().DeleteAllPages();
                FormsModuleCodeSnippets.DeleteForm(formId);
            }
        }
Beispiel #15
0
        public void ParagraphTextField_SubmitValue_ResponseIsCorrect()
        {
            const string SubmitedParagraphValue = "Submitted paragraph value";

            var controller = new ParagraphTextFieldController();

            var control = new MvcWidgetProxy();

            control.Settings       = new ControllerSettings(controller);
            control.ControllerName = typeof(ParagraphTextFieldController).FullName;

            var formId = ServerOperationsFeather.Forms().CreateFormWithWidget(control);

            var formManager = FormsManager.GetManager();
            var form        = formManager.GetForms().FirstOrDefault(f => f.Id == formId);

            var pageManager = PageManager.GetManager();

            try
            {
                var template = pageManager.GetTemplates().FirstOrDefault(t => t.Name == "SemanticUI.default" && t.Title == "default");
                Assert.IsNotNull(template, "Template was not found");

                var pageId = FeatherServerOperations.Pages().CreatePageWithTemplate(template, "ParagraphTextFieldValueTest", "paragraph-text-field-submit-value-test");
                ServerOperationsFeather.Forms().AddFormControlToPage(pageId, formId);

                var paragraphTextFieldName = ServerOperationsFeather.Forms().GetFirstFieldName(formManager, form);
                ServerOperationsFeather.Forms().SubmitField(paragraphTextFieldName, SubmitedParagraphValue, pageManager, pageId);

                var formEntry = formManager.GetFormEntries(form).LastOrDefault();
                Assert.IsNotNull(formEntry, "Form entry has not been submitted.");

                var submittedValue = formEntry.GetValue(paragraphTextFieldName) as string;
                Assert.AreEqual(SubmitedParagraphValue, submittedValue, "Form did not persisted the submitted paragraph text value correctly.");
            }
            finally
            {
                Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Pages().DeleteAllPages();
                FormsModuleCodeSnippets.DeleteForm(formId);
            }
        }
        public void CheckboxesFieldTests_EditDefaultChoices_MarkupIsCorrect()
        {
            var choice1 = "Choice1";
            var choice2 = "Choice2";
            var choice3 = "Choice3";

            var controller = new CheckboxesFieldController();

            controller.Model.SerializedChoices = "[\"{0}\",\"{1}\",\"{2}\"]".Arrange(choice1, choice2, choice3);
            controller.Model.HasOtherChoice    = true;

            var control = new MvcWidgetProxy();

            control.Settings       = new ControllerSettings(controller);
            control.ControllerName = typeof(CheckboxesFieldController).FullName;

            var formId = ServerOperationsFeather.Forms().CreateFormWithWidget(control);

            var pageManager = PageManager.GetManager();

            try
            {
                var template = pageManager.GetTemplates().FirstOrDefault(t => t.Name == "SemanticUI.default" && t.Title == "default");
                Assert.IsNotNull(template, "Template was not found");

                var pageId = FeatherServerOperations.Pages().CreatePageWithTemplate(template, "CheckboxesFieldDefaultValueTest", "checkboxes-field-value-test");
                ServerOperationsFeather.Forms().AddFormControlToPage(pageId, formId);

                var pageContent = ServerOperationsFeather.Pages().GetPageContent(pageId);
                Assert.IsTrue(pageContent.Contains(choice1), "Form did not render the first choice in the checkboxes field.");
                Assert.IsTrue(pageContent.Contains(choice2), "Form did not render the second choice in the checkboxes field.");
                Assert.IsTrue(pageContent.Contains(choice3), "Form did not render the third choice in the checkboxes field.");
                Assert.IsTrue(pageContent.Contains(Res.Get <FieldResources>().Other), "Form did not render the 'Other' choice in the checkboxes field.");
            }
            finally
            {
                Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Pages().DeleteAllPages();
                FormsModuleCodeSnippets.DeleteForm(formId);
            }
        }
Beispiel #17
0
        public void TextFieldUrl_SubmitIncorrectValue_ServerValidationFails()
        {
            var control = new MvcWidgetProxy();

            control.ControllerName = typeof(TextFieldController).FullName;
            var controller = new TextFieldController();

            controller.Model.InputType = Telerik.Sitefinity.Frontend.Forms.Mvc.Models.Fields.TextField.TextType.Url;
            control.Settings           = new ControllerSettings(controller);

            var formId = ServerOperationsFeather.Forms().CreateFormWithWidget(control);

            var formManager = FormsManager.GetManager();
            var form        = formManager.GetForms().FirstOrDefault(f => f.Id == formId);

            var pageManager = PageManager.GetManager();

            try
            {
                var template = pageManager.GetTemplates().FirstOrDefault(t => t.Name == "SemanticUI.default" && t.Title == "default");
                Assert.IsNotNull(template, "Template was not found");

                var pageId = FeatherServerOperations.Pages().CreatePageWithTemplate(template, "TextFieldValidationTest", "text-field-validation-test");
                ServerOperationsFeather.Forms().AddFormControlToPage(pageId, formId);
                var pageDataId = pageManager.GetPageNode(pageId).GetPageData().Id;

                var textFieldName  = this.GetTextFieldName(formManager, form);
                var formController = this.FindAndSubmitForm(pageManager, pageDataId, textFieldName);
                Assert.IsFalse((bool)formController.TempData["sfSubmitSuccess"], "The Submit result was not correct");

                var formEntry = formManager.GetFormEntries(form).LastOrDefault();
                Assert.IsNull(formEntry, "Form entry has been submitted even when the form is not valid.");
            }
            finally
            {
                Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Pages().DeleteAllPages();
                FormsModuleCodeSnippets.DeleteForm(formId);
            }
        }
        public void FormsWidget_WithGridWidget_AdaptsToPackage()
        {
            var gridVirtualPath = "~/Frontend-Assembly/Telerik.Sitefinity.Frontend/GridSystem/Templates/grid-3+9.html";
            var control         = new GridControl();

            control.Layout = gridVirtualPath;
            var formId = ServerOperationsFeather.Forms().CreateFormWithWidget(control);

            var pageManager = PageManager.GetManager();

            try
            {
                var semanticTemplate = pageManager.GetTemplates().FirstOrDefault(t => (t.Name == "SemanticUI.default" && t.Title == "default") || t.Title == "SemanticUI.default");
                Assert.IsNotNull(semanticTemplate, "Template was not found");

                var semanticPageId = FeatherServerOperations.Pages().CreatePageWithTemplate(semanticTemplate, "FormsPageSemantic", "forms-page-semantic");
                ServerOperationsFeather.Forms().AddFormControlToPage(semanticPageId, formId);

                string semanticPageContent = ServerOperationsFeather.Pages().GetPageContent(semanticPageId);

                Assert.IsTrue(semanticPageContent.Contains("class=\"sf_colsIn four wide column\""), "SemanticUI grid content not found.");

                var bootstrapTemplate = pageManager.GetTemplates().FirstOrDefault(t => (t.Name == "Bootstrap.default" && t.Title == "default") || t.Title == "Bootstrap.default");
                Assert.IsNotNull(bootstrapTemplate, "Template was not found");

                var bootstrapPageId = FeatherServerOperations.Pages().CreatePageWithTemplate(bootstrapTemplate, "FormsPageBootstrap", "forms-page-bootstrap");
                ServerOperationsFeather.Forms().AddFormControlToPage(bootstrapPageId, formId);

                string bootstrapPageContent = ServerOperationsFeather.Pages().GetPageContent(bootstrapPageId);

                Assert.IsTrue(bootstrapPageContent.Contains("class=\"sf_colsIn col-md-3\""), "Bootstrap grid content not found.");
            }
            finally
            {
                Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Pages().DeleteAllPages();
                FormsModuleCodeSnippets.DeleteForm(formId);
            }
        }
Beispiel #19
0
 public void Teardown()
 {
     FormsModuleCodeSnippets.DeleteForm(FormEventsTests.formId);
 }
Beispiel #20
0
        public void Navigation_FieldIsCorrectlyInitializedOnReload()
        {
            var controller = new PageBreakController();
            var control    = new MvcWidgetProxy();

            control.ControllerName = typeof(PageBreakController).FullName;
            control.Settings       = new ControllerSettings(controller);

            var navigationController = new NavigationFieldController();
            var navigationControl    = new MvcWidgetProxy();

            navigationControl.ControllerName = typeof(NavigationFieldController).FullName;
            navigationControl.Settings       = new ControllerSettings(navigationController);

            var controls = new List <Control>()
            {
                control, navigationControl
            };

            var formId = ServerOperationsFeather.Forms().CreateFormWithWidgets(controls);

            var pageManager  = PageManager.GetManager();
            var formsManager = FormsManager.GetManager();

            try
            {
                var culture  = SystemManager.CurrentContext.AppSettings.DefaultFrontendLanguage;
                var tempForm = formsManager.EditForm(formId, culture);
                formsManager.SaveChanges();

                var controlInForm = tempForm.Controls
                                    .FirstOrDefault(c => c.Properties.FirstOrDefault(pr => pr.Name == "ControllerName").Value == typeof(NavigationFieldController).FullName);
                var zoneEditorService = new ZoneEditorService();
                var parameters        = new Dictionary <string, string>();
                parameters["ControllerName"] = typeof(NavigationFieldController).FullName;

                zoneEditorService.UpdateControlState(
                    new Telerik.Sitefinity.Web.UI.ZoneEditorWebServiceArgs()
                {
                    Id            = controlInForm.Id,
                    ControlType   = typeof(MvcControllerProxy).FullName,
                    PageId        = tempForm.Id,
                    PlaceholderId = "Body",
                    Parameters    = parameters,
                    MediaType     = DesignMediaType.Form,
                    Attributes    = new Dictionary <string, string>(),
                    CommandName   = "reload",
                    Url           = "/Sitefinity/Forms/" + tempForm.Name
                });

                formsManager.SaveChanges();

                var masterForm = formsManager.Lifecycle.CheckIn(tempForm, culture);
                formsManager.Lifecycle.Publish(masterForm, culture);
                formsManager.SaveChanges();

                var template = pageManager.GetTemplates().FirstOrDefault(t => t.Name == "SemanticUI.default" && t.Title == "default");
                Assert.IsNotNull(template, "Template was not found");

                var pageId = FeatherServerOperations.Pages().CreatePageWithTemplate(template, "NavigationFieldInitializationTest", "section-header-field-value-test");
                ServerOperationsFeather.Forms().AddFormControlToPage(pageId, formId);

                var pageContent = ServerOperationsFeather.Pages().GetPageContent(pageId);

                var pageName1 = Res.Get <FieldResources>().PageName + "1";
                var pageName2 = Res.Get <FieldResources>().PageName + "2";
                Assert.IsTrue(pageContent.Contains(pageName1), "Form did not render navigation field pages");
                Assert.IsTrue(pageContent.Contains(pageName2), "Form did not render navigation field pages");
            }
            finally
            {
                Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Pages().DeleteAllPages();
                FormsModuleCodeSnippets.DeleteForm(formId);
            }
        }