@Test
  @Restore("xml/TestSubtasksInCreateIssue.xml")
  public void testSubtaskIssueType() {
    jira.gotoLoginPage().loginAsSysAdmin(DashboardPage.class);

    // homosapien project - check no subtasks in issue types
    CreateIssueDialog createIssueDialog = pageBinder.bind(JiraHeader.class).createIssue();
    createIssueDialog.selectProject("homosapien");

    List<String> issueTypes = getIssueTypes("HSP");
    Assert.assertEquals(issueTypes.size(), createIssueDialog.getIssueTypes().size());
    assertEquals(
        new HashSet<String>(issueTypes), new HashSet<String>(createIssueDialog.getIssueTypes()));

    createIssueDialog.close();

    // homosapien project - check only subtasks in issue types
    ViewIssuePage viewIssuePage = jira.goToViewIssue("HSP-1");
    final MoreActionsMenu moreActionsMenu = viewIssuePage.getMoreActionsMenu();
    moreActionsMenu.open().clickItem(IssueActions.CREATE_SUBTASK);
    final CreateIssueDialog createSubtaskDialog =
        pageBinder.bind(CreateIssueDialog.class, CreateIssueDialog.Type.SUBTASK);

    List<String> issueSubtasks = getSubtaskTypes("HSP");
    Assert.assertEquals(issueSubtasks.size(), createSubtaskDialog.getIssueTypes().size());
    assertEquals(
        new HashSet<String>(issueSubtasks),
        new HashSet<String>(createSubtaskDialog.getIssueTypes()));
  }
 @Test
 public void testAddingAndRemovingFields() {
   jira.gotoLoginPage().loginAsSysAdmin(DashboardPage.class);
   jira.goToViewIssue("HSP-1");
   CreateIssueDialog createIssueDialog = pageBinder.bind(JiraHeader.class).createIssue();
   createIssueDialog
       .switchToCustomMode()
       .removeFields("priority", "description")
       .addFields("fixVersions", "reporter");
   createIssueDialog.close();
   jira.gotoHomePage();
   createIssueDialog = pageBinder.bind(JiraHeader.class).createIssue();
   assertEquals(
       createIssueDialog.getVisibleFields(),
       asList("summary", "components", "versions", "fixVersions", "reporter"));
 }
  @Test
  public void testCreateWithEscGivesDirtyFormWarning() {
    jira.gotoLoginPage().loginAsSysAdmin(DashboardPage.class);
    CreateIssueDialog createIssueDialog = pageBinder.bind(JiraHeader.class).createIssue();
    createIssueDialog.fill("summary", "A sample Summary");
    createIssueDialog.escape();

    assertTrue(createIssueDialog.acceptDirtyFormWarning());

    // Hitting Cancel should not provide a dirty form warning though.
    createIssueDialog = pageBinder.bind(JiraHeader.class).createIssue();
    createIssueDialog.fill("summary", "A sample Summary");
    createIssueDialog.close();

    assertFalse(createIssueDialog.acceptDirtyFormWarning());
  }
  public EditIssueTypePage setAvatar(final String id) {
    avatarPickerTrigger.click();
    final AvatarDialog avatarDialog = binder.bind(AvatarDialog.class, "project-avatar-picker");
    avatarDialog.setAvatar(id);

    return this;
  }
 @Test
 public void testCustomFieldIsDisplayedAndJavaScriptExecutesWhenChecked() {
   jira.gotoLoginPage().loginAsSysAdmin(DashboardPage.class);
   final CreateIssueDialog createIssueDialog = pageBinder.bind(JiraHeader.class).createIssue();
   createIssueDialog.switchToCustomMode().addFields("customfield_10000");
   assertTrue(finder.find(By.id("customfield_10000")).hasClass("custom-field-js-applied"));
 }
  @Test
  @Restore("xml/TestProjectSelectForCreate.xml")
  public void testProjectSelectInFullMode() {
    List<String> issueTypesString;

    jira.gotoLoginPage().loginAsSysAdmin(DashboardPage.class);
    jira.goToViewIssue("HSP-1");
    CreateIssueDialog createIssueDialog = pageBinder.bind(JiraHeader.class).createIssue();
    createIssueDialog.switchToFullMode();

    // homosapien project
    issueTypesString = getIssueTypes("HSP");
    Assert.assertEquals(issueTypesString.size(), createIssueDialog.getIssueTypes().size());
    assertEquals(
        new HashSet<String>(issueTypesString),
        new HashSet<String>(createIssueDialog.getIssueTypes()));

    // gorilla project
    createIssueDialog.selectProject("gorilla");
    issueTypesString = getIssueTypes("GRL");
    Assert.assertEquals(issueTypesString.size(), createIssueDialog.getIssueTypes().size());
    assertEquals(
        new HashSet<String>(issueTypesString),
        new HashSet<String>(createIssueDialog.getIssueTypes()));

    // monkey project
    createIssueDialog.selectProject("monkey");
    issueTypesString = getIssueTypes("MKY");
    Assert.assertEquals(issueTypesString.size(), createIssueDialog.getIssueTypes().size());
    assertEquals(
        new HashSet<String>(issueTypesString),
        new HashSet<String>(createIssueDialog.getIssueTypes()));
  }
 @Test
 public void testNoPermission() {
   backdoor
       .permissionSchemes()
       .removeGroupPermission(0, 11, "jira-users"); // Remove create permissions
   jira.gotoLoginPage().login("fred", "fred", DashboardPage.class);
   assertFalse(pageBinder.bind(JiraHeader.class).hasCreateLink());
 }
  @Test
  public void testProjectPreselect() {
    // Should select first project in list as we have no history
    jira.gotoLoginPage().login("fred", "fred", DashboardPage.class);
    CreateIssueDialog createIssueDialog = pageBinder.bind(JiraHeader.class).createIssue();
    assertEquals("homosapien", createIssueDialog.getProject());

    // We create an issue in monkey so the next time it should be a preselected on monkey
    createIssueDialog.selectProject("monkey");
    createIssueDialog.fill("summary", "test").submit(GlobalMessage.class);
    createIssueDialog = pageBinder.bind(JiraHeader.class).createIssue();
    assertEquals("monkey", createIssueDialog.getProject());

    jira.goToViewIssue("HSP-1");
    createIssueDialog = pageBinder.bind(JiraHeader.class).createIssue();
    assertEquals("homosapien", createIssueDialog.getProject());
  }
 @Test
 public void testDefaultIssueTypePreselect() {
   jira.gotoLoginPage().login("fred", "fred", DashboardPage.class);
   backdoor.project().setDefaultIssueType(10000, "2");
   JiraHeader header = pageBinder.bind(JiraHeader.class);
   CreateIssueDialog createIssueDialog = header.createIssue();
   assertEquals("New Feature", createIssueDialog.getIssueType());
 }
 public PressureDialog gotoPressureDialog() {
   WebElement pressureLink = webDriver.findElement(By.id("pressure-link"));
   Actions builder = new Actions(webDriver);
   System.out.println(pressureLink.getAttribute("href"));
   builder.moveToElement(pressureLink).perform();
   System.out.println(pressureLink.getAttribute("href"));
   pressureLink.click();
   return pageBinder.bind(PressureDialog.class);
 }
 @Init
 public void init() {
   formElement = locator.find(formLocator);
   nameElement = formElement.find(By.name("name"));
   descriptionElement = formElement.find(By.name("description"));
   addButton = formElement.find(By.name("Add"));
   issueTypeRadio = formElement.find(By.cssSelector("input.radio[value='']"));
   subtaskRadio = formElement.find(By.cssSelector("input.radio[value='jira_subtask']"));
   cancelLink = formElement.find(By.cssSelector("a.cancel"));
   iconPicker = pageBinder.bind(IconPicker.class, "issue-type-icon-picker");
 }
  @Test
  public void testIssueTypePreselect() {
    // Should select first issue type in list as we have no history
    jira.gotoLoginPage().login("fred", "fred", DashboardPage.class);
    backdoor.project().setDefaultIssueType(10000, null);
    JiraHeader header = pageBinder.bind(JiraHeader.class);

    CreateIssueDialog createIssueDialog = header.createIssue();
    assertEquals("Bug", createIssueDialog.getIssueType());
    createIssueDialog.close();
  }
  @Test
  public void testCreatedIssuesGetAddedToHistory() {
    jira.gotoLoginPage().login("fred", "fred", DashboardPage.class);
    CreateIssueDialog createIssueDialog = pageBinder.bind(JiraHeader.class).createIssue();
    createIssueDialog.fill("summary", "My Summary").submit(DashboardPage.class);
    JiraHeader header = pageBinder.bind(JiraHeader.class);

    IssuesMenu issuesMenu = header.getIssuesMenu().open();
    List<String> recentIssues = issuesMenu.getRecentIssues();

    assertTrue(recentIssues.get(0).endsWith("My Summary"));
    issuesMenu.createIssue().fill("summary", "My Summary 2").submit(DashboardPage.class);

    header = pageBinder.bind(JiraHeader.class);
    issuesMenu = header.getIssuesMenu().open();
    recentIssues = issuesMenu.getRecentIssues();

    assertTrue(recentIssues.get(0).endsWith("My Summary 2"));
    assertTrue(recentIssues.get(1).endsWith("My Summary"));
  }
 @Test
 @Restore("xml/TestIssueTypesForCreate.xml")
 public void testIssueTypeSelectInFullMode() {
   jira.gotoLoginPage().loginAsSysAdmin(DashboardPage.class);
   CreateIssueDialog createIssueDialog = pageBinder.bind(JiraHeader.class).createIssue();
   createIssueDialog.switchToFullMode();
   createIssueDialog.selectIssueType("Bug");
   assertEquals(asList("versions", "summary"), createIssueDialog.getVisibleFields());
   createIssueDialog.selectIssueType("New Feature");
   assertEquals(asList("summary", "components"), createIssueDialog.getVisibleFields());
   createIssueDialog.selectIssueType("Task");
   assertEquals(asList("assignee", "summary"), createIssueDialog.getVisibleFields());
 }
 @Test
 public void testValidationErrorsInFullMode() {
   jira.gotoLoginPage().loginAsSysAdmin(DashboardPage.class);
   jira.goToViewIssue("HSP-1");
   CreateIssueDialog createIssueDialog = pageBinder.bind(JiraHeader.class).createIssue();
   createIssueDialog.switchToFullMode();
   final Map<String, String> formErrors =
       createIssueDialog
           .submit(CreateIssueDialog.class, CreateIssueDialog.Type.ISSUE)
           .waitForFormErrors()
           .getFormErrors();
   assertTrue(
       "Expected inline errror for summary as it is a required field and has no value",
       formErrors.containsKey("summary"));
 }
  @Test
  public void testCreatingSimpleIssueInFullMode() {
    jira.gotoLoginPage().loginAsSysAdmin(DashboardPage.class);
    jira.goToViewIssue("HSP-1");
    final CreateIssueDialog createIssueDialog = pageBinder.bind(JiraHeader.class).createIssue();
    createIssueDialog.switchToFullMode();
    createIssueDialog.fill("summary", "Scott's Issue").fill("description", "I own this issue!");

    GlobalMessage successMsg = createIssueDialog.submit(GlobalMessage.class);

    assertTrue(
        "Expected message to be of type success",
        successMsg.getType() == GlobalMessage.Type.SUCCESS);
    assertTrue(
        "Expected success message to contain issue summary",
        successMsg.getMessage().contains("Scott's Issue"));
  }
  @Test
  public void testCreateMultipleInCustomMode() {
    jira.gotoLoginPage().loginAsSysAdmin(DashboardPage.class);
    jira.goToViewIssue("HSP-1");
    CreateIssueDialog createIssueDialog =
        pageBinder
            .bind(JiraHeader.class)
            .createIssue()
            .fill("summary", "Issue 1")
            .fill("description", "my description")
            .checkCreateMultiple()
            .submit(CreateIssueDialog.class, CreateIssueDialog.Type.ISSUE);

    assertEquals(AuiMessage.Type.SUCCESS, createIssueDialog.getAuiMessage().getType());

    assertEquals("", createIssueDialog.getFieldValue("summary"));
    assertEquals("my description", createIssueDialog.getFieldValue("description"));

    createIssueDialog =
        createIssueDialog
            .fill("summary", "Issue 2")
            .fill("description", "a different description")
            .submit(CreateIssueDialog.class, CreateIssueDialog.Type.ISSUE);

    AuiMessage auiMessage = createIssueDialog.getAuiMessage();
    assertEquals(AuiMessage.Type.SUCCESS, auiMessage.getType());
    auiMessage.dismiss();

    assertEquals("", createIssueDialog.getFieldValue("summary"));
    assertEquals("a different description", createIssueDialog.getFieldValue("description"));

    GlobalMessage successMsg =
        createIssueDialog
            .uncheckCreateMultiple()
            .fill("summary", "Issue 3")
            .submit(GlobalMessage.class);

    assertTrue(
        "Expected message to be of type success",
        successMsg.getType() == GlobalMessage.Type.SUCCESS);
    assertTrue(
        "Expected success message to contain issue summary",
        successMsg.getMessage().contains("Issue 3"));
  }
  @Test
  public void testTogglingModesRetainsValues() {
    jira.gotoLoginPage().loginAsSysAdmin(DashboardPage.class);
    ViewIssuePage viewIssuePage = jira.goToViewIssue("HSP-1");
    viewIssuePage.execKeyboardShortcut("c");

    CreateIssueDialog createIssueDialog =
        pageBinder
            .bind(CreateIssueDialog.class, CreateIssueDialog.Type.ISSUE)
            .switchToFullMode()
            .fill("summary", "test");

    createIssueDialog = createIssueDialog.switchToCustomMode();
    assertEquals("test", createIssueDialog.getFieldValue("summary"));
    createIssueDialog.fill("description", "test another switch");
    createIssueDialog = createIssueDialog.switchToFullMode();
    assertEquals("test another switch", createIssueDialog.getFieldValue("description"));
    assertEquals("test", createIssueDialog.getFieldValue("summary"));
  }
 public SpeakeasyUserPage restoreEnabledPlugins() {
   driver.findElement(By.id("restore-enabled")).click();
   driver.waitUntilElementIsLocated(By.className("success"));
   return pageBinder.navigateToAndBind(SpeakeasyUserPage.class);
 }
 public SpeakeasyUserPage unsubscribeFromAllPlugins() {
   driver.findElement(By.id("unsubscribe-all")).click();
   driver.waitUntilElementIsLocated(By.className("success"));
   return pageBinder.navigateToAndBind(SpeakeasyUserPage.class);
 }
 public CommonJsModulesTab viewCommonJsModulesTab() {
   jsdocTab.click();
   return pageBinder.bind(CommonJsModulesTab.class);
 }
  public ForkDialog openForkDialog(String pluginKey) {
    clickActionLink(pluginKey, ExtensionOperations.FORK);

    return pageBinder.bind(ForkDialog.class, pluginKey);
  }
  public IdeDialog openEditDialog(String pluginKey) {
    clickActionLink(pluginKey, ExtensionOperations.EDIT);

    return pageBinder.bind(IdeDialog.class, pluginKey, false);
  }
 public InstallDialog openInstallDialog() throws IOException {
   driver.findElement(By.id("sp-install")).click();
   return pageBinder.bind(InstallDialog.class);
 }
 public DownloadDialog openDownloadDialog(String pluginKey) throws IOException {
   clickActionLink(pluginKey, ExtensionOperations.DOWNLOAD);
   return pageBinder.bind(DownloadDialog.class, pluginKey);
 }
 public ViewIssueTypesPage submit() {
   submitButton.click();
   return binder.bind(ViewIssueTypesPage.class);
 }
 public DeleteOperation clickDelete() {
   rootMenuElement.find(By.className("project-config-operations-delete")).click();
   return binder.bind(DeleteOperation.class, id);
 }
  public IdeDialog openViewSourceDialog(String pluginKey) {
    clickActionLink(pluginKey, ExtensionOperations.VIEWSOURCE);

    return pageBinder.bind(IdeDialog.class, pluginKey, true);
  }
 @Init
 public void init() {
   messagesBar = pageBinder.bind(MessagesBar.class);
 }
 public BrowseVersionSummaryPage getBrowseVersionSummaryPage() {
   return pageBinder.navigateToAndBind(BrowseVersionSummaryPage.class, this);
 }