package rocketboard;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;

import org.junit.Test;


public class CreateIssueTests extends AbstractRocketboardTests {
	
	
	/** Create an issue and check if the column backlog is correctly incremented */
	@Test
	public void createIssue() throws Exception {
		rocketboardPage.waitingLoading();
		Integer valueBefore = rocketboardPage.getCount("backlog");
		rocketboardPage.createIssue(title, desc, getRandomProject().getName());
		rocketboardPage.waitCreatedIssue(title);
		Integer valueAfter = rocketboardPage.getCount("backlog");
		assertThat(valueAfter, equalTo(valueBefore+1));
		assertThat(rocketboardPage.checkTitleFrame(title), equalTo(Boolean.TRUE));
		}
		
	@Test
	public void CreateIssueNoDescription() throws Exception {
		rocketboardPage.waitingLoading();
		rocketboardPage.createIssue(title,"", getRandomProject().getName());
		rocketboardPage.waitCreatedIssue(title);
		assertThat(rocketboardPage.checkTitleFrame(title), equalTo(Boolean.TRUE));
		}

	@Test
	public void issueAdvancedOption() throws Exception{
		rocketboardPage.waitingLoading();
		rocketboardPage.openModelCreateIssue();
		rocketboardPage.waitingFrameCreateIssueOpen();
		rocketboardPage.clickAdvanced();
		assertThat(rocketboardPage.isGithub().contains("https://github.com/"), equalTo(Boolean.TRUE));
		assertThat(rocketboardPage.isGithub().contains("issues/new"), equalTo(Boolean.TRUE));
	}
	
	@Test
	public void openCloseCreateForm_viaCloseButton() throws Exception {
		rocketboardPage.waitingLoading();
		rocketboardPage.openModelCreateIssue();
		issueModalOpened = rocketboardPage.modelOpened();
		assertThat(issueModalOpened, equalTo(Boolean.TRUE));
		rocketboardPage.closeButton();
		issueModalOpened = rocketboardPage.modelOpened();
		assertThat(issueModalOpened, equalTo(Boolean.FALSE));
	}

	@Test
	public void openCloseCreateForm_viaXButton() throws Exception {
		rocketboardPage.waitingLoading();
		rocketboardPage.openModelCreateIssue();
		assertThat(rocketboardPage.modelOpened(), equalTo(Boolean.TRUE));
		rocketboardPage.xButton();
		assertThat(rocketboardPage.modelOpened(), equalTo(Boolean.FALSE));
	}

	@Test
	public void openCloseCreateForm_typingOutside() throws Exception {
		rocketboardPage.waitingLoading();
		rocketboardPage.openModelCreateIssue();
		rocketboardPage.waitingFrameCreateIssueOpen();
		assertThat(rocketboardPage.modelOpened(), equalTo(Boolean.TRUE));
		rocketboardPage.openModelCreateIssue();
		assertThat(rocketboardPage.modelOpened(), equalTo(Boolean.FALSE));
	}
	
}

@@ -346,44 +346,8 @@
 n %7B%0A
-%09%09rocketboardPage.waitingLoading();%0A
 %09%09In
@@ -711,116 +711,8 @@
 ));%0A
-%09%09%7D%0A%09%09%0A%09@Test%0A%09public void CreateIssueNoDescription() throws Exception %7B%0A%09%09rocketboardPage.waitingLoading();
 %0A%09%09r
@@ -903,1459 +903,197 @@
 ));%0A
-%09%09%7D%0A%0A%09@Test%0A%09public void issueAdvancedOption() throws Exception%7B%0A%09%09rocketboardPage.waitingLoading();%0A%09%09rocketboardPage.openModelCreateIssue();%0A%09%09rocketboardPage.waitingFrameCreateIssueOpen();%0A%09%09rocketboardPage.clickAdvanced();%0A%09%09assertThat(rocketboardPage.isGithub().contains(%22https://github.com/%22), equalTo(Boolean.TRUE));%0A%09%09assertThat(rocketboardPage.isGithub().contains(%22issues/new%22), equalTo(Boolean.TRUE));%0A%09%7D%0A%09%0A%09@Test%0A%09public void openCloseCreateForm_viaCloseButton() throws Exception %7B%0A%09%09rocketboardPage.waitingLoading();%0A%09%09rocketboardPage.openModelCreateIssue();%0A%09%09issueModalOpened = rocketboardPage.modelOpened();%0A%09%09assertThat(issueModalOpened, equalTo(Boolean.TRUE));%0A%09%09rocketboardPage.closeButton();%0A%09%09issueModalOpened = rocketboardPage.modelOpened();%0A%09%09assertThat(issueModalOpened, equalTo(Boolean.FALSE));%0A%09%7D%0A%0A%09@Test%0A%09public void openCloseCreateForm_viaXButton() throws Exception %7B%0A%09%09rocketboardPage.waitingLoading();%0A%09%09rocketboardPage.openModelCreateIssue();%0A%09%09assertThat(rocketboardPage.modelOpened(), equalTo(Boolean.TRUE));%0A%09%09rocketboardPage.xButton();%0A%09%09assertThat(rocketboardPage.modelOpened(), equalTo(Boolean.FALSE));%0A%09%7D%0A%0A%09@Test%0A%09public void openCloseCreateForm_typingOutside() throws Exception %7B%0A%09%09rocketboardPage.waitingLoading();%0A%09%09rocketboardPage.openModelCreateIssue();%0A%09%09rocketboardPage.waitingFrameCreateIssueOpen();%0A%09%09assertThat(rocketboardPage.modelOpened(), equalTo(Boolean.TRUE));%0A%09%09rocketboardPage.openModelCreateIssue
+%0A%09%09rocketboardPage.openModelCreateIssue();%0A%09%09rocketboardPage.waitingFrameCreateIssueOpen();%0A%09%09assertThat(rocketboardPage.modelOpened(), equalTo(Boolean.TRUE));%0A%09%09rocketboardPage.closeButton
 ();%0A

Remove duplicated test and non-sense test.