public void RepoAdminCannotRemoveThemselves() { var user = ITH.CreateUsers().Single(); var repoId = ITH.CreateRepositoryOnWebInterface(ITH.MakeName()); app.NavigateTo <RepositoryController>(c => c.Edit(repoId)); var form = app.FindFormFor <RepositoryDetailModel>(); // Set User0 to be admin for this repo var adminBox = form.WebApp.Browser.FindElementsByCssSelector( string.Format("input[name=PostedSelectedAdministrators][value=\"{0}\"]", user.Id)).Single(); ITH.SetCheckbox(adminBox, true); form.Submit(); ITH.AssertThatNoValidationErrorOccurred(); // Now, log in as the ordinary user ITH.LoginAsUser(user); app.NavigateTo <RepositoryController>(c => c.Edit(repoId)); form = app.FindFormFor <RepositoryDetailModel>(); var chkboxes = form.WebApp.Browser.FindElementsByCssSelector("input[name=PostedSelectedAdministrators]"); ITH.SetCheckboxes(chkboxes, false); form.Submit(); app.WaitForElementToBeVisible(By.CssSelector("div.validation-summary-errors"), TimeSpan.FromSeconds(1)); ITH.AssertThatValidationErrorContains(Resources.Repository_Edit_CantRemoveYourself); }
public void UsernameEnsureDuplicationDetectionStillAllowsEditOtherProperties() { var ids = ITH.CreateUsers().ToList(); var id1 = ids[0]; app.NavigateTo <AccountController>(c => c.Edit(id1.Id)); app.FindFormFor <UserCreateModel>() .Field(f => f.Name).SetValueTo("somename") .Submit(); app.NavigateTo <AccountController>(c => c.Edit(id1.Id)); // force refresh app.FindFormFor <UserCreateModel>() .Field(f => f.Name).ValueShouldEqual("somename"); }
public void UsernameEnsureDuplicationDetectionAsYouTypeWorksOnCreation() { var id1 = ITH.CreateUsers().Single(); app.NavigateTo <AccountController>(c => c.Create()); var form = app.FindFormFor <UserCreateModel>() .Field(f => f.Username).SetValueTo(id1.Username) .Field(f => f.Name).Click(); // Set focus var validation = app.WaitForElementToBeVisible(By.CssSelector("input#Username~span.field-validation-error>span"), TimeSpan.FromSeconds(1), true); Assert.AreEqual(Resources.Validation_Duplicate_Name, validation.Text); var input = app.Browser.FindElementByCssSelector("input#Username"); Assert.IsTrue(input.GetAttribute("class").Contains("input-validation-error")); }
public void EnsureCheckboxesStayCheckOnCreateError() { ITH.CreateUsers(1); app.NavigateTo <RepositoryController>(c => c.Create()); var form = app.FindFormFor <RepositoryDetailModel>(); var chkboxes = form.WebApp.Browser.FindElementsByCssSelector("form.pure-form>fieldset>div.pure-control-group.checkboxlist>input"); foreach (var chk in chkboxes) { ITH.SetCheckbox(chk, true); } form.Submit(); form = app.FindFormFor <RepositoryDetailModel>(); chkboxes = form.WebApp.Browser.FindElementsByCssSelector("form.pure-form>fieldset>div.pure-control-group.checkboxlist>input"); foreach (var chk in chkboxes) { Assert.AreEqual(true, chk.Selected, "A message box was unselected eventhough we selected all!"); } }