public void DropdownListFieldTests_SubmitValue_ResponseIsCorrect() { var submitedDropdownValue = Res.Get <FieldResources>().OptionFirstChoice; 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 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, "DropdownListFieldValueTest", "dropdown-list-field-submit-value-test"); ServerOperationsFeather.Forms().AddFormControlToPage(pageId, formId); var dropdownListFieldName = ServerOperationsFeather.Forms().GetFirstFieldName(formManager, form); ServerOperationsFeather.Forms().SubmitField(dropdownListFieldName, submitedDropdownValue, pageManager, pageId); var formEntry = formManager.GetFormEntries(form).LastOrDefault(); Assert.IsNotNull(formEntry, "Form entry has not been submitted."); var submittedValue = formEntry.GetValue(dropdownListFieldName) as string; Assert.AreEqual(submitedDropdownValue, submittedValue, "Form did not persisted the submitted dropdown list value correctly."); } finally { Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Pages().DeleteAllPages(); FormsModuleCodeSnippets.DeleteForm(formId); } }
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 textFieldName = ServerOperationsFeather.Forms().GetFirstFieldName(formManager, form); var result = ServerOperationsFeather.Forms().SubmitField(textFieldName, "Submitted value", 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); } }
public void SetUp() { // Gets the template name from the arrangement context string templateName = ServerArrangementContext.GetCurrent().Values["templateName"]; // Create a page with the corresponding template from the test - Bootstrap, Foundation or Semantic Guid templateId = ServerOperations.Templates().GetTemplateIdByTitle(templateName); Guid parentPageId = ServerOperations.Pages().CreatePage(Page1, templateId); Guid pageNodeId1 = ServerOperations.Pages().GetPageNodeId(parentPageId); // Adds navigation widget to the page FeatherServerOperations.Pages().AddMvcWidgetToPage(pageNodeId1, typeof(NavigationController).FullName, WidgetCaption, PlaceHolderId); // Create another page on root level Guid pageNodeId2 = ServerOperations.Pages().CreatePage(Page2); // Create child page for Page2 Guid childPageId = Guid.NewGuid(); ServerOperations.Pages().CreatePage(ChildPage, childPageId, pageNodeId2); }
public void ResourcePackage_CreateTemplateBasedOnlyOnThePackage_VerifyViewFromThePackage() { string pageName = "FeatherPage"; string widgetCaption = "TestMvcWidget"; string placeHolderId = "Body"; string packageName = "Bootstrap"; string viewFileName = "Default.cshtml"; string widgetName = "MvcTest"; string fileResource = "Telerik.Sitefinity.Frontend.TestUtilities.Data.Default.cshtml"; string templateTitle = "Bootstrap.MyTestTemplate"; string text = "This is a view from package."; try { string filePath = FeatherServerOperations.ResourcePackages().GetResourcePackageMvcViewDestinationFilePath(packageName, widgetName, viewFileName); FeatherServerOperations.ResourcePackages().AddNewResource(fileResource, filePath); Guid templateId = FeatherServerOperations.Pages().CreatePureMvcTemplate(templateTitle); Guid pageId = ServerOperations.Pages().CreatePage(pageName, templateId); pageId = ServerOperations.Pages().GetPageNodeId(pageId); FeatherServerOperations.Pages().AddMvcWidgetToPage(pageId, typeof(MvcTestController).FullName, widgetCaption, placeHolderId); var content = FeatherServerOperations.Pages().GetPageContent(pageId); Assert.IsTrue(content.Contains(text), "Template is not based on the package"); } finally { ServerOperations.Pages().DeleteAllPages(); ServerOperations.Templates().DeletePageTemplate(templateTitle); string filePath = FeatherServerOperations.ResourcePackages().GetResourcePackageMvcViewDestinationFilePath(packageName, widgetName, viewFileName); FileInfo fi = new FileInfo(filePath); DirectoryInfo di = fi.Directory; FeatherServerOperations.ResourcePackages().DeleteDirectory(di.FullName); } }
public void RegisterScript_PureMvcPage_AddedOnce() { string testName = "RegisterScript"; string pageTitle = testName + "PureMvcPage"; string urlName = testName + "PureMvcPage"; string pageUrl = UrlPath.ResolveAbsoluteUrl("~/" + urlName); var pageManager = PageManager.GetManager(); int templatesCount = pageManager.GetTemplates().Count(); try { string filePath = FeatherServerOperations.ResourcePackages().GetResourcePackageDestinationFilePath(ResourcePackages.Constants.PackageName, ResourcePackages.Constants.LayoutFileName); FeatherServerOperations.ResourcePackages().AddNewResource(ResourcePackages.Constants.LayoutFileResource, filePath); FeatherServerOperations.ResourcePackages().WaitForTemplatesCountToIncrease(templatesCount, 1); var template = pageManager.GetTemplates().Where(t => t.Title == ResourcePackages.Constants.TemplateTitle).FirstOrDefault(); Assert.IsNotNull(template, "Template was not found"); this.AddDummyScriptControllerToPage(pageTitle, urlName, template, "TestPlaceHolder"); WebRequestHelper.GetPageWebContent(pageUrl); Assert.AreEqual(2, ActionExecutionRegister.ExecutedActionInfos.Count, "The actions are not executed correctly."); var result1 = ActionExecutionRegister.ExecutedActionInfos[0].Result as ContentResult; Assert.IsTrue(Regex.IsMatch(result1.Content, "<script src=\".*\" type=\"text/javascript\"></script>"), "The script is not added."); var result2 = ActionExecutionRegister.ExecutedActionInfos[1].Result as ContentResult; Assert.IsTrue(string.IsNullOrEmpty(result2.Content), "The script should not be added twice."); } finally { ServerOperations.Pages().DeleteAllPages(); ServerOperations.Templates().DeletePageTemplate(ResourcePackages.Constants.TemplateTitle); string filePath = FeatherServerOperations.ResourcePackages().GetResourcePackageDestinationFilePath(ResourcePackages.Constants.PackageName, ResourcePackages.Constants.LayoutFileName); File.Delete(filePath); } }
public void ResourcePackageLayoutFiles_RenameLayoutFile_VerifyGeneratedTemplate() { string adminUserName = "******"; string adminPass = "******"; int templatesCount = this.PageManager.GetTemplates().Count(); try { FeatherServerOperations.ResourcePackages().AddNewResourcePackage(Constants.PackageResource); FeatherServerOperations.ResourcePackages().WaitForTemplatesCountToIncrease(templatesCount, 3); string[] templateTitles = new string[] { Constants.TemplateTestLayout1, Constants.TemplateTestLayout2, Constants.TemplateTestLayout3 }; foreach (var title in templateTitles) { var template = this.PageManager.GetTemplates().Where(t => t.Title == title).FirstOrDefault(); Assert.IsNotNull(template, "Template was not found"); } FeatherServerOperations.ResourcePackages().RenameLayoutFile(Constants.TestPackageName, Constants.TestLayoutFileName, Constants.NewTestLayoutFileName); FeatherServerOperations.ResourcePackages().WaitForTemplatesCountToIncrease(templatesCount, 4); var renamedTemplate = this.PageManager.GetTemplates().Where(t => t.Title == Constants.TemplateTestLayout1Renamed).FirstOrDefault(); Assert.IsNotNull(renamedTemplate, "Template was not found"); } finally { AuthenticationHelper.AuthenticateUser(adminUserName, adminPass, true); string[] templates = new string[] { Constants.TemplateTestLayout1, Constants.TemplateTestLayout2, Constants.TemplateTestLayout3, Constants.TemplateTestLayout1Renamed }; foreach (var template in templates) { ServerOperations.Templates().DeletePageTemplate(template); } string path = FeatherServerOperations.ResourcePackages().GetResourcePackagesDestination(Constants.TestPackageName); FeatherServerOperations.ResourcePackages().DeleteDirectory(path); } }
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); } }
public void SetUp() { string templateName = ServerArrangementContext.GetCurrent().Values["templateName"]; AuthenticationHelper.AuthenticateUser(AdminUser, AdminPassword); List <string> roles = new List <string>() { Editors, BackendUsers }; Guid templateId = ServerOperations.Templates().GetTemplateIdByTitle(templateName); Guid pageId = ServerOperations.Pages().CreatePage(HomePage, templateId); pageId = ServerOperations.Pages().GetPageNodeId(pageId); ServerOperations.Users().CreateUserWithProfileAndRoles(User, Password, User, User, Email, roles); ServerOperations.Pages().CreatePage(TestPage); ServerOperationsFeather.Pages().DenyPermissionsForRole(Editors, RoleProvider, TestPage); FeatherServerOperations.Pages().AddMvcWidgetToPage(pageId, typeof(NavigationController).FullName, WidgetCaption, PlaceHolderId); }
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 PageOnTestLayoutSetup(string testName) { PageManager pageManager = PageManager.GetManager(); int templatesCount = pageManager.GetTemplates().Count(); this.folderPath = Path.Combine(HostingEnvironment.MapPath("~/"), "MVC", "Views", "Layouts"); if (!Directory.Exists(this.folderPath)) { Directory.CreateDirectory(this.folderPath); } string filePath = Path.Combine(this.folderPath, PageOnTestLayoutSetup.LayoutFileName); FeatherServerOperations.ResourcePackages().AddNewResource(PageOnTestLayoutSetup.LayoutFileResource, filePath); FeatherServerOperations.ResourcePackages().WaitForTemplatesCountToIncrease(templatesCount, 1); var template = pageManager.GetTemplates().Where(t => t.Title == PageOnTestLayoutSetup.LayoutName).FirstOrDefault(); Assert.IsNotNull(template, "Template was not found"); this.pageId = FeatherServerOperations.Pages().CreatePageWithTemplate(template, testName, testName); }
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); } }
public void LayoutTemplates_CreateTemplateBasedOnGeneratedTemplate_VerifyPageContent() { PageManager pageManager = PageManager.GetManager(); int templatesCount = pageManager.GetTemplates().Count(); string folderPath = Path.Combine(this.SfPath, "MVC", "Views", "Layouts"); if (!Directory.Exists(folderPath)) { Directory.CreateDirectory(folderPath); } string filePath = Path.Combine(folderPath, LayoutFileName); string newTemplateTitle = "NewTemplate"; try { FeatherServerOperations.ResourcePackages().AddNewResource(LayoutFileResource, filePath); FeatherServerOperations.ResourcePackages().WaitForTemplatesCountToIncrease(templatesCount, 1); var template = pageManager.GetTemplates().Where(t => t.Title == TemplateTitle).FirstOrDefault(); Assert.IsNotNull(template, "Template was not found"); var newTemplate = FeatherServerOperations.Pages().CreatePureMvcTemplate(newTemplateTitle, TemplateTitle); Guid pageId = FeatherServerOperations.Pages().CreatePageWithTemplate(newTemplate, PageTitle, PageUrl); string pageContent = FeatherServerOperations.Pages().GetPageContent(pageId); Assert.IsTrue(pageContent.Contains(LayoutTemplateText), "Layout template text was not found in the page content"); } finally { ServerOperations.Pages().DeleteAllPages(); ServerOperations.Templates().DeletePageTemplate(newTemplateTitle); ServerOperations.Templates().DeletePageTemplate(TemplateTitle); File.Delete(filePath); } }
private Guid CreatePage(PageTemplateFramework framework, out string pageUrl) { Guid pageId = Guid.Empty; pageUrl = string.Empty; var suffix = Guid.NewGuid().ToString("N"); if (framework == PageTemplateFramework.Hybrid) { var namePrefix = "TestPageName"; var titlePrefix = "TestPageTitle"; var urlPrefix = "test-page-url"; var index = 1; pageId = new PageContentGenerator().CreatePage( string.Format(CultureInfo.InvariantCulture, "{0}{1}", namePrefix + suffix, index.ToString(CultureInfo.InvariantCulture)), string.Format(CultureInfo.InvariantCulture, "{0}{1}", titlePrefix + suffix, index.ToString(CultureInfo.InvariantCulture)), string.Format(CultureInfo.InvariantCulture, "{0}{1}", urlPrefix + suffix, index.ToString(CultureInfo.InvariantCulture))); pageUrl = UrlPath.ResolveAbsoluteUrl("~/" + urlPrefix + suffix + index); } else if (framework == PageTemplateFramework.Mvc) { var pagesOperations = FeatherServerOperations.Pages(); var pageManager = PageManager.GetManager(); var bootstrapTemplate = pageManager.GetTemplates().FirstOrDefault(t => (t.Name == "Bootstrap.default" && t.Title == "default") || t.Title == "Bootstrap.default"); if (bootstrapTemplate == null) { throw new ArgumentException("Bootstrap template not found"); } pageId = pagesOperations.CreatePageWithTemplate(bootstrapTemplate, "FormsPageBootstrap" + suffix, "forms-page-bootstrap" + suffix); pageUrl = RouteHelper.GetAbsoluteUrl(pageManager.GetPageNode(pageId).GetFullUrl()); } return(pageId); }
public void NavigationWidgetOnPageTemplate_JQueryExist_Navigation_Pills() { Guid templateId = default(Guid); Guid pageId = Guid.Empty; FeatherServerOperations.FeatherModule().EnsureFeatherEnabled(); try { templateId = this.templateOperation.DuplicatePageTemplate(OldTemplateName, TemplateName); string url = UrlPath.ResolveAbsoluteUrl("~/" + UrlNamePrefix); var mvcProxy = CreateNavigationController(); this.templateOperation.AddControlToTemplate(templateId, mvcProxy, PlaceHolder, CaptionNavigation); pageId = this.locationGenerator.CreatePage(PageNamePrefix, PageTitlePrefix, UrlNamePrefix, null, null); Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Templates().SetTemplateToPage(pageId, templateId); string responseContent = WebRequestHelper.GetPageWebContent(url); var httpContextWrapper = GetHttpContextWrapper(url); var htmlHelper = GetHtmlHelper(httpContextWrapper); var scriptHtml = ResourceHelper.Script(htmlHelper, ScriptRef.JQuery, "top", true).ToHtmlString(); Assert.IsFalse(!responseContent.Contains(scriptHtml), "The jquery not found!"); } finally { if (pageId != Guid.Empty) { Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Pages().DeletePage(pageId); } if (templateId != Guid.Empty) { Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Templates().DeletePageTemplate(templateId); } } }
public void GridWidget_EditGridWidgetOnPageFromFileSystem() { PageManager pageManager = PageManager.GetManager(); var gridVirtualPath = "~/ResourcePackages/Bootstrap/GridSystem/Templates/grid-9+3.html"; var gridTemplatePath = Path.Combine(this.SfPath, "ResourcePackages", "Bootstrap", "GridSystem", "Templates", "grid-9+3.html"); var newGridTemplatePath = Path.Combine(this.SfPath, "ResourcePackages", "Bootstrap", "GridSystem", "Templates", "grid-9+3-New.html"); File.Copy(gridTemplatePath, newGridTemplatePath); try { var template = pageManager.GetTemplates().Where(t => t.Name == TemplateTitle).FirstOrDefault(); Assert.IsNotNull(template, "Template was not found"); Guid pageId = FeatherServerOperations.Pages().CreatePageWithTemplate(template, PageNamePrefix, UrlNamePrefix); this.AddGridControlToPage(pageId, gridVirtualPath, PlaceHolder, Caption); using (StreamWriter output = File.AppendText(gridTemplatePath)) { output.WriteLine(GridTextEdited); } string pageContent = this.GetPageContent(pageId); Assert.IsTrue(pageContent.Contains(Row3), "Grid row 3 not found in the page content"); Assert.IsTrue(pageContent.Contains(Row9), "Grid row 9 not found in the page content"); Assert.IsTrue(pageContent.Contains(ParagraphText), "Paragraph Text was not found in the page content"); } finally { File.Delete(gridTemplatePath); File.Move(newGridTemplatePath, gridTemplatePath); Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Pages().DeleteAllPages(); } }
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 = ServerOperationsFeather.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 = ServerOperationsFeather.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); } }
public void Setup() { FeatherServerOperations.ResourcePackages().AddNewResourcePackage(Package1Resource); FeatherServerOperations.ResourcePackages().AddNewResourcePackage(Package2Resource); }
public void EditLayoutFile() { string filePath = FeatherServerOperations.ResourcePackages().GetResourcePackageDestinationFilePath(PackageName, LayoutFileName); FeatherServerOperations.ResourcePackages().EditLayoutFile(filePath, LayoutFileText, LayoutFileNewText); }
public void UninstallFeather_PurePageTemplate_Verify() { Guid pageId = Guid.Empty; Guid templateId = Guid.Empty; FeatherServerOperations.FeatherModule().EnsureFeatherEnabled(); var featherActivated = true; try { string pageUrl; templateId = this.CreateTemplateWithWidgetAndBasePageOnIt(PageTemplateFramework.Mvc, new DummyController(), out pageId, out pageUrl); string templateUrl = UrlPath.ResolveAbsoluteUrl(FrontendModuleFilterTests.SitefinityTemplateRoutePrefix + templateId.ToString()); var templateContentBeforeUninstall = this.GetContent(templateUrl); Assert.IsTrue(templateContentBeforeUninstall.Contains(FrontendModuleFilterTests.DummyController.ResponseString)); Assert.IsFalse(templateContentBeforeUninstall.Contains(FrontendModuleFilterTests.FeatherModuleUnavailableMessage)); var backendPageContentBeforeUninstall = this.GetContent(pageUrl, openInEdit: true); Assert.IsTrue(backendPageContentBeforeUninstall.Contains(FrontendModuleFilterTests.DummyController.ResponseString)); Assert.IsFalse(backendPageContentBeforeUninstall.Contains(FrontendModuleFilterTests.FeatherModuleUnavailableMessage)); var frontendPageContentBeforeUninstall = this.GetContent(pageUrl); Assert.IsTrue(frontendPageContentBeforeUninstall.Contains(FrontendModuleFilterTests.DummyController.ResponseString)); Assert.IsFalse(frontendPageContentBeforeUninstall.Contains(FrontendModuleFilterTests.FeatherModuleUnavailableMessage)); FeatherServerOperations.FeatherModule().DeactivateFeather(); featherActivated = false; FeatherServerOperations.FeatherModule().UninstallFeather(); var templateContentAfterUninstall = this.GetContent(templateUrl); Assert.IsFalse(templateContentAfterUninstall.Contains(FrontendModuleFilterTests.DummyController.ResponseString)); Assert.IsTrue(templateContentAfterUninstall.Contains(FrontendModuleFilterTests.FeatherModuleUnavailableMessage)); var backendPageContentAfterUninstall = this.GetContent(pageUrl, openInEdit: true); Assert.IsFalse(backendPageContentAfterUninstall.Contains(FrontendModuleFilterTests.DummyController.ResponseString)); Assert.IsTrue(backendPageContentAfterUninstall.Contains(FrontendModuleFilterTests.FeatherModuleUnavailableMessage)); var frontendPageContentAfterUninstall = this.GetContent(pageUrl); Assert.IsFalse(frontendPageContentAfterUninstall.Contains(FrontendModuleFilterTests.DummyController.ResponseString)); Assert.IsFalse(frontendPageContentAfterUninstall.Contains(FrontendModuleFilterTests.FeatherModuleUnavailableMessage)); FeatherServerOperations.FeatherModule().InstallFeather(); featherActivated = true; var templateContentAfterInstall = this.GetContent(templateUrl); Assert.IsTrue(templateContentAfterInstall.Contains(FrontendModuleFilterTests.DummyController.ResponseString)); Assert.IsFalse(templateContentAfterInstall.Contains(FrontendModuleFilterTests.FeatherModuleUnavailableMessage)); var backendPageContentAfterInstall = this.GetContent(pageUrl, openInEdit: true); Assert.IsTrue(backendPageContentAfterInstall.Contains(FrontendModuleFilterTests.DummyController.ResponseString)); Assert.IsFalse(backendPageContentAfterInstall.Contains(FrontendModuleFilterTests.FeatherModuleUnavailableMessage)); var frontendPageContentAfterInstall = this.GetContent(pageUrl); Assert.IsTrue(frontendPageContentAfterInstall.Contains(FrontendModuleFilterTests.DummyController.ResponseString)); Assert.IsFalse(frontendPageContentAfterInstall.Contains(FrontendModuleFilterTests.FeatherModuleUnavailableMessage)); } finally { if (!featherActivated) { FeatherServerOperations.FeatherModule().ActivateFeather(); } ServerOperations.Pages().DeletePage(pageId); ServerOperations.Templates().DeletePageTemplate(templateId); } }
public void AddNewViewToPackage() { string filePath = FeatherServerOperations.ResourcePackages().GetResourcePackageMvcViewDestinationFilePath(PackageName, WidgetName, ViewFileName); FeatherServerOperations.ResourcePackages().AddNewResource(FileResource, filePath); }
public void TearDown() { FeatherServerOperations.Pages().EnableCombineScriptForPages(true); ServerOperations.Widgets().DeleteWidgetTemplate("NewsWidgetTemplate"); }
public void ResourcePackage_RenameTemplateAndKeepThePackageInTheTitle_VerifyTemplateAndPage() { string pageName = "FeatherPage"; string pageName2 = "FeatherPage2"; string widgetCaption = "TestMvcWidget"; string placeHolderId = "Body"; string packageName = "Package1"; string viewFileName = "Default.cshtml"; string widgetName = "MvcTest"; string fileResource = "Telerik.Sitefinity.Frontend.TestUtilities.Data.Default.cshtml"; string packageResource = "Telerik.Sitefinity.Frontend.TestUtilities.Data.Package1.zip"; string templateTitle = "test-layout"; string viewText = "This is a view from package."; string layoutText = "Package1 - test layout"; string templateRenamed = "TemplateRenamed"; int templatesCount = this.PageManager.GetTemplates().Count(); try { // Add new package to the file system FeatherServerOperations.ResourcePackages().AddNewResourcePackage(packageResource); FeatherServerOperations.ResourcePackages().WaitForTemplatesCountToIncrease(templatesCount, 1); // Verify template is generated successfully var template = this.PageManager.GetTemplates().FirstOrDefault(t => t.Name == templateTitle); Assert.IsNotNull(template, "Template was not found"); // Add new view to the package string filePath = FeatherServerOperations.ResourcePackages().GetResourcePackageMvcViewDestinationFilePath(packageName, widgetName, viewFileName); FeatherServerOperations.ResourcePackages().AddNewResource(fileResource, filePath); // Create page based on the new template from the package Guid pageId = ServerOperations.Pages().CreatePage(pageName, template.Id); this.PageManager.SaveChanges(); pageId = ServerOperations.Pages().GetPageNodeId(pageId); // Verify the page content contains the text from the layout file var content = FeatherServerOperations.Pages().GetPageContent(pageId); Assert.IsTrue(content.Contains(layoutText), "Template is not based on the layout file"); // Rename the template template.Title = templateRenamed; template.Name = templateRenamed; this.PageManager.SaveChanges(); // Create page based on the renamed template Guid pageId2 = ServerOperations.Pages().CreatePage(pageName2, template.Id); pageId2 = ServerOperations.Pages().GetPageNodeId(pageId2); FeatherServerOperations.Pages().AddMvcWidgetToPage(pageId2, typeof(MvcTestController).FullName, widgetCaption, placeHolderId); // Verify the page content contains the text from the view added in the package var content2 = FeatherServerOperations.Pages().GetPageContent(pageId2); Assert.IsFalse(content2.Contains(layoutText), "Template is based on the layout file, but it shouldn't be"); Assert.IsTrue(content2.Contains(viewText), "Template is not based on the package"); } finally { string path = FeatherServerOperations.ResourcePackages().GetResourcePackagesDestination(packageName); ServerOperations.Pages().DeleteAllPages(); ServerOperations.Templates().DeletePageTemplate(templateRenamed); ServerOperations.Templates().DeletePageTemplate(templateTitle); FeatherServerOperations.ResourcePackages().DeleteDirectory(path); } }
public void ModifiedView_RequestPage_ShouldLogCompilation() { string viewFileName = "Default.cshtml"; string widgetName = "ContentBlock"; var widgetText = @"@Html.Raw(Model.Content)"; var widgetTextEdited = @"edited @Html.Raw(Model.Content)"; string filePath = FeatherServerOperations.ResourcePackages().GetResourcePackageMvcViewDestinationFilePath(ResourcePackages.Bootstrap, widgetName, viewFileName); PageNode pageNode = null; try { Guid templateId = Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Templates().GetTemplateIdByTitle(PageTemplateName); var pageId = ServerOperations.Pages().CreatePage("TestPage1", templateId); var pageNodeId = ServerOperations.Pages().GetPageNodeId(pageId); var pageManager = Telerik.Sitefinity.Modules.Pages.PageManager.GetManager(); pageNode = pageManager.GetPageNode(pageNodeId); var fullPageUrl = RouteHelper.GetAbsoluteUrl(pageNode.GetUrl()); int widgetCount = 3; for (var i = 0; i < widgetCount; i++) { ServerOperationsFeather.Pages().AddContentBlockWidgetToPage(pageNodeId, "ContentBlock", "Contentplaceholder1"); } var viewPath = "~/Frontend-Assembly/Telerik.Sitefinity.Frontend.ContentBlock/Mvc/Views/ContentBlock/Default.cshtml"; var fullViewPath = string.Concat(viewPath, "#Bootstrap.cshtml"); FeatherServerOperations.ResourcePackages().EditLayoutFile(filePath, widgetText, widgetTextEdited); this.WaitForAspNetCacheToBeInvalidated(fullViewPath); // Request page this.ExecuteAuthenticatedRequest(fullPageUrl); this.FlushData(); this.AssertWidgetExecutionCount(widgetCount); this.AssertViewCompilationCount(1); // Assert data var rootOperationId = this.GetRequestLogRootOperationId(fullPageUrl); var widgetCompilationText = "Compile view \"Default.cshtml#Bootstrap.cshtml\" of controller \"" + typeof(ContentBlockController).FullName + "\""; this.AssertViewCompilationParams(rootOperationId, viewPath, widgetCompilationText); this.ClearData(); // Request page again this.ExecuteAuthenticatedRequest(fullPageUrl); this.FlushData(); // Assert new data this.AssertWidgetExecutionCount(widgetCount); this.AssertViewCompilationCount(0); } finally { FeatherServerOperations.ResourcePackages().EditLayoutFile(filePath, widgetTextEdited, widgetText); this.DeletePages(pageNode); } }
public void ResourcePackage_RenameMainPackagesFolder_VerifyTemplatesNotBasedOnLayouts() { int templatesCount = this.PageManager.GetTemplates().Count(); string template1Title = "Foundation.TestLayout"; string template2Title = "Bootstrap.TestLayout"; string page2 = "page2"; string filePath = FeatherServerOperations.ResourcePackages().GetResourcePackageDestinationFilePath("Foundation", Constants.LayoutFileNameFoundation); string file2Path = FeatherServerOperations.ResourcePackages().GetResourcePackageDestinationFilePath("Bootstrap", Constants.LayoutFileNameBootstrap); string folderPath = Path.Combine(FeatherServerOperations.ResourcePackages().SfPath, "ResourcePackages"); string folderName = "ResourcePackages"; string newFolderName = "ResourcePackagesRenamed"; string newFolderPath = Path.Combine(FeatherServerOperations.ResourcePackages().SfPath, "ResourcePackagesRenamed"); try { // Add layout file to Foundation package FeatherServerOperations.ResourcePackages().AddNewResource(Constants.LayoutFileResource, filePath); // Verify template is generated successfully FeatherServerOperations.ResourcePackages().WaitForTemplatesCountToIncrease(templatesCount, 1); var template1 = this.PageManager.GetTemplates().FirstOrDefault(t => t.Name == "Foundation." + template1Title); Assert.IsNotNull(template1, "Template was not found"); // Add layout file to Bootstrap package FeatherServerOperations.ResourcePackages().AddNewResource(Constants.LayoutFileResource, file2Path); // Verify template is generated successfully FeatherServerOperations.ResourcePackages().WaitForTemplatesCountToIncrease(templatesCount, 2); var template2 = this.PageManager.GetTemplates().FirstOrDefault(t => t.Name == "Bootstrap." + template2Title); Assert.IsNotNull(template2, "Template was not found"); // Create page with template from Foundation package and verify content Guid page1Id = FeatherServerOperations.Pages().CreatePageWithTemplate(template1, Constants.PageTitle, Constants.PageUrl); var content = FeatherServerOperations.Pages().GetPageContent(page1Id); Assert.IsTrue(content.Contains(Constants.LayoutTemplateText), "Layout text was not found on the page"); // Create page with template from Bootstrap package and verify content Guid page2Id = FeatherServerOperations.Pages().CreatePageWithTemplate(template2, page2, page2); var content2 = FeatherServerOperations.Pages().GetPageContent(page2Id); Assert.IsTrue(content2.Contains(Constants.LayoutTemplateText), "Layout text was not found on the page"); // Rename ResourcePackages folder if (Directory.Exists(folderPath)) { FeatherServerOperations.ResourcePackages().UnlockFolder(folderPath); FileSystem.RenameDirectory(folderPath, newFolderName); } Assert.IsTrue(Directory.Exists(newFolderPath), "Renamed folder was not found"); // Assert templates and pages are not based to layouts content = FeatherServerOperations.Pages().GetPageContent(page1Id); Assert.IsFalse(content.Contains(Constants.LayoutTemplateText), "Layout text was found on the page, but is shouldn't"); content2 = FeatherServerOperations.Pages().GetPageContent(page2Id); Assert.IsFalse(content2.Contains(Constants.LayoutTemplateText), "Layout text was found on the page, but it shouldn't"); } finally { ServerOperations.Pages().DeleteAllPages(); ServerOperations.Templates().DeletePageTemplate(template1Title); ServerOperations.Templates().DeletePageTemplate(template2Title); if (Directory.Exists(newFolderPath)) { FeatherServerOperations.ResourcePackages().UnlockFolder(newFolderPath); FileSystem.RenameDirectory(newFolderPath, folderName); try { File.Delete(filePath); } catch (DirectoryNotFoundException) { FileSystem.RenameDirectory(newFolderPath, folderName); } try { File.Delete(file2Path); } catch (DirectoryNotFoundException) { FileSystem.RenameDirectory(newFolderPath, folderName); } } else if (Directory.Exists(folderPath)) { File.Delete(filePath); File.Delete(file2Path); } } }
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); } }
public void TearDown() { ServerOperations.Pages().DeleteAllPages(); ServerOperations.Taxonomies().ClearAllTags(TaxonomiesConstants.TagsTaxonomyId); FeatherServerOperations.ResourcePackages().DeleteSelectorsData(DesignerViewFileName, JsonFileName, ControllerFileName); }
public void EditViewFromPackage() { string filePath = FeatherServerOperations.ResourcePackages().GetResourcePackageMvcViewDestinationFilePath(PackageName, WidgetName, ViewFileName); FeatherServerOperations.ResourcePackages().EditLayoutFile(filePath, TextToReplace, NewText); }
public void SetUp() { Guid pageId = ServerOperations.Pages().CreatePage(PageName); FeatherServerOperations.Pages().AddMvcWidgetToPage(pageId, typeof(LanguageSelectorController).FullName, WidgetCaption, PlaceHolderId); }
public void AddNewLayoutFile() { string filePath = FeatherServerOperations.ResourcePackages().GetResourcePackageDestinationFilePath(PackageName, LayoutFileName); FeatherServerOperations.ResourcePackages().AddNewResource(FileResource, filePath); }