Skip to content

Commit

Permalink
new comments, fixed some tests, 4 more fail atm. Hopefully no merge i…
Browse files Browse the repository at this point in the history
…ssues as I touched US2 tests
  • Loading branch information
AndrewHarper041 committed Oct 29, 2015
1 parent d572b0c commit b527a40
Show file tree
Hide file tree
Showing 19 changed files with 136 additions and 48 deletions.
Binary file modified bin/US1S4NameExists.class
Binary file not shown.
Binary file modified bin/US1S5InvalidPassword.class
Binary file not shown.
Binary file modified bin/US2S2MakeNewRepo.class
Binary file not shown.
Binary file modified bin/US3S1FeaturesToggle.class
Binary file not shown.
Binary file modified bin/US3S2AddCollaborator.class
Binary file not shown.
Binary file modified bin/US3S3AddWebhook.class
Binary file not shown.
Binary file modified bin/US3S4AddDeployKey.class
Binary file not shown.
Binary file added bin/US3S5TransferRepo.class
Binary file not shown.
Binary file added bin/US3S6DeleteRepo.class
Binary file not shown.
Binary file removed bin/US3US5TransferRepo.class
Binary file not shown.
Binary file removed bin/US3US6DeleteRepo.class
Binary file not shown.
5 changes: 5 additions & 0 deletions tests/US1S4NameExists.java
Expand Up @@ -31,6 +31,11 @@ public void testNameExists() throws Exception {
driver.findElement(By.linkText("Sign up")).click();
driver.findElement(By.id("user_login")).clear();
driver.findElement(By.id("user_login")).sendKeys("laboon");

//Hack to trigger the onchange javascript event we are looking for.
JavascriptExecutor jsExecutor = (JavascriptExecutor) driver;
jsExecutor.executeScript("$(arguments[0]).change();", driver.findElement(By.id("user_login")));

assertEquals("Username is already taken", driver.findElement(By.cssSelector("dd.error")).getText());
}

Expand Down
8 changes: 8 additions & 0 deletions tests/US1S5InvalidPassword.java
@@ -1,6 +1,9 @@
//Test for US-1 Scenario-5
//Tests that the new user sign up page successfully notifies user when they attempt to use an invalid password

//Notes:
//Failed before adding a hack to induce onchange() JS events

import java.util.regex.Pattern;
import java.util.concurrent.TimeUnit;
import org.junit.*;
Expand Down Expand Up @@ -31,6 +34,11 @@ public void testInvalidPassword() throws Exception {
driver.findElement(By.id("user_login")).sendKeys("uniqueusername32");
driver.findElement(By.id("user_password")).clear();
driver.findElement(By.id("user_password")).sendKeys("abd");

//Hack to trigger the onchange javascript event we are looking for.
JavascriptExecutor jsExecutor = (JavascriptExecutor) driver;
jsExecutor.executeScript("$(arguments[0]).change();", driver.findElement(By.id("user_password")));

assertEquals("Password is too short (minimum is 7 characters) and needs at least one number", driver.findElement(By.cssSelector("dd.error")).getText());
}

Expand Down
79 changes: 36 additions & 43 deletions tests/US3S1FeaturesToggle.java
@@ -1,5 +1,9 @@
//Test for US-3 Scenario-1
//Tests that user can toggle is repo's options in the features field
//Tests that user can toggle its repo's options in the features field

//NOTES:
//Does not assert against settings actually being changed
//Asserts against a JS generated small image, had issues with asserting against value

import java.util.regex.Pattern;
import java.util.concurrent.TimeUnit;
Expand All @@ -15,58 +19,47 @@ public class US3S1FeaturesToggle {
private String baseUrl;
private boolean acceptNextAlert = true;
private StringBuffer verificationErrors = new StringBuffer();

//Hardcoded auth for 'permenent' user. Hopefully a bot doesn't steal this account.
private static final String USERNAME = "cs1632user";
private static final String PASSWORD = "cs1632pass";

//Utility function
private void logIn(String username, String password) {
driver.get(baseUrl + "/");
driver.findElement(By.linkText("Sign in")).click();
driver.findElement(By.id("login_field")).clear();
driver.findElement(By.id("login_field")).sendKeys(username);
driver.findElement(By.id("password")).clear();
driver.findElement(By.id("password")).sendKeys(password);
driver.findElement(By.name("commit")).click();
}

@Before
public void setUp() throws Exception {
driver = new FirefoxDriver();
baseUrl = "https://github.com/";
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
logIn(USERNAME, PASSWORD); //login
}

@Test
public void testUS3S1FeaturesToggle() throws Exception {
driver.get(baseUrl + "/");
driver.findElement(By.xpath("//div[@id='your_repos']/div/a")).click();
driver.findElement(By.id("repository_name")).clear();
driver.findElement(By.id("repository_name")).sendKeys("temprepo");
driver.findElement(By.xpath("//button[@type='submit']")).click();
driver.findElement(By.xpath("//ul[3]/li/a/span[2]")).click();
driver.findElement(By.id("wiki-feature")).click();
try {
assertEquals("off", driver.findElement(By.id("wiki-feature")).getAttribute("value"));
} catch (Error e) {
verificationErrors.append(e.toString());
}
driver.findElement(By.id("wiki-feature")).click();
try {
assertEquals("on", driver.findElement(By.id("wiki-feature")).getAttribute("value"));
} catch (Error e) {
verificationErrors.append(e.toString());
}
driver.findElement(By.id("wiki-pusher-access")).click();
try {
assertEquals("on", driver.findElement(By.id("wiki-pusher-access")).getAttribute("value"));
} catch (Error e) {
verificationErrors.append(e.toString());
}
driver.findElement(By.id("wiki-pusher-access")).click();
try {
assertEquals("off", driver.findElement(By.id("wiki-pusher-access")).getAttribute("value"));
} catch (Error e) {
verificationErrors.append(e.toString());
}
driver.findElement(By.id("issue-feature")).click();
try {
assertEquals("off", driver.findElement(By.id("issue-feature")).getAttribute("value"));
} catch (Error e) {
verificationErrors.append(e.toString());
}
driver.findElement(By.id("issue-feature")).click();
try {
assertEquals("on", driver.findElement(By.id("issue-feature")).getAttribute("value"));
} catch (Error e) {
verificationErrors.append(e.toString());
}
driver.get(baseUrl + "/");
driver.findElement(By.id("your-repos-filter")).clear();
driver.findElement(By.id("your-repos-filter")).sendKeys("newrepo");
driver.findElement(By.xpath("//ul[@id='repo_listing']/li[2]/a/span[2]/span")).click();
driver.findElement(By.xpath("//ul[3]/li/a/span[2]")).click();
driver.findElement(By.id("wiki-feature")).click();
driver.findElement(By.id("wiki-feature")).click();
assertTrue(isElementPresent(By.xpath("//div[@id='options_bucket']/div[2]/div/form/div[2]/span")));
driver.findElement(By.id("wiki-pusher-access")).click();
driver.findElement(By.id("wiki-pusher-access")).click();
assertTrue(isElementPresent(By.xpath("//div[@id='options_bucket']/div[2]/div/form/div[3]/span")));
driver.findElement(By.id("issue-feature")).click();
driver.findElement(By.id("issue-feature")).click();
assertTrue(isElementPresent(By.xpath("//div[@id='options_bucket']/div[2]/div/form/div[4]/span")));

}

@After
Expand Down
18 changes: 17 additions & 1 deletion tests/US3S2AddCollaborator.java
Expand Up @@ -14,17 +14,33 @@ public class US3S2AddCollaborator {
private boolean acceptNextAlert = true;
private StringBuffer verificationErrors = new StringBuffer();

//Hardcoded auth for 'permenent' user. Hopefully a bot doesn't steal this account.
private static final String USERNAME = "cs1632user";
private static final String PASSWORD = "cs1632pass";

//Utility function
private void logIn(String username, String password) {
driver.get(baseUrl + "/");
driver.findElement(By.linkText("Sign in")).click();
driver.findElement(By.id("login_field")).clear();
driver.findElement(By.id("login_field")).sendKeys(username);
driver.findElement(By.id("password")).clear();
driver.findElement(By.id("password")).sendKeys(password);
driver.findElement(By.name("commit")).click();
}

@Before
public void setUp() throws Exception {
driver = new FirefoxDriver();
baseUrl = "https://github.com/";
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
logIn(USERNAME, PASSWORD); //login
}

@Test
public void testUS3S2AddCollaborator() throws Exception {
driver.get(baseUrl + "/");
driver.findElement(By.xpath("(//a[contains(@href, '/cs1632user/temprepo/settings')])[2]")).click();
driver.findElement(By.xpath("(//a[contains(@href, '/cs1632user/newrepo/settings')])[2]")).click(); //failed on temprepo, switched to newrepo
driver.findElement(By.linkText("Collaborators")).click();
driver.findElement(By.id("search-member")).clear();
driver.findElement(By.id("search-member")).sendKeys("graphitezep");
Expand Down
16 changes: 16 additions & 0 deletions tests/US3S3AddWebhook.java
Expand Up @@ -16,11 +16,27 @@ public class US3S3AddWebhook {
private boolean acceptNextAlert = true;
private StringBuffer verificationErrors = new StringBuffer();

//Hardcoded auth for 'permenent' user. Hopefully a bot doesn't steal this account.
private static final String USERNAME = "cs1632user";
private static final String PASSWORD = "cs1632pass";

//Utility function
private void logIn(String username, String password) {
driver.get(baseUrl + "/");
driver.findElement(By.linkText("Sign in")).click();
driver.findElement(By.id("login_field")).clear();
driver.findElement(By.id("login_field")).sendKeys(username);
driver.findElement(By.id("password")).clear();
driver.findElement(By.id("password")).sendKeys(password);
driver.findElement(By.name("commit")).click();
}

@Before
public void setUp() throws Exception {
driver = new FirefoxDriver();
baseUrl = "https://github.com/";
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
logIn(USERNAME, PASSWORD); //login
}

@Test
Expand Down
21 changes: 19 additions & 2 deletions tests/US3S4AddDeployKey.java
@@ -1,6 +1,7 @@
//Test for US-3 Scenario-4
//Tests that user can add a deploy key to their repo

//Notes:
//Key used is a non used 'dummy' key generated by me

import java.util.regex.Pattern;
Expand All @@ -17,19 +18,35 @@ public class US3S4AddDeployKey {
private String baseUrl;
private boolean acceptNextAlert = true;
private StringBuffer verificationErrors = new StringBuffer();

//Hardcoded auth for 'permenent' user. Hopefully a bot doesn't steal this account.
private static final String USERNAME = "cs1632user";
private static final String PASSWORD = "cs1632pass";

//Utility function
private void logIn(String username, String password) {
driver.get(baseUrl + "/");
driver.findElement(By.linkText("Sign in")).click();
driver.findElement(By.id("login_field")).clear();
driver.findElement(By.id("login_field")).sendKeys(username);
driver.findElement(By.id("password")).clear();
driver.findElement(By.id("password")).sendKeys(password);
driver.findElement(By.name("commit")).click();
}

@Before
public void setUp() throws Exception {
driver = new FirefoxDriver();
baseUrl = "https://github.com/";
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
logIn(USERNAME, PASSWORD); //login
}

@Test
public void testUS3S4AddDeployKey() throws Exception {
driver.get(baseUrl + "/");
driver.findElement(By.linkText("temprepo")).click();
driver.findElement(By.xpath("(//a[contains(@href, '/cs1632user/temprepo/settings')])[2]")).click();
driver.findElement(By.linkText("newrepo")).click();
driver.findElement(By.xpath("(//a[contains(@href, '/cs1632user/newrepo/settings')])[2]")).click();
driver.findElement(By.linkText("Deploy keys")).click();
driver.findElement(By.linkText("Add deploy key")).click();
assertTrue(isElementPresent(By.id("public_key_read_only")));
Expand Down
19 changes: 18 additions & 1 deletion tests/US3US5TransferRepo.java → tests/US3S5TransferRepo.java
@@ -1,6 +1,7 @@
//Test for US-3 Scenario-5
//Tests that user can transfer the repo's ownership to another

//Notes:
//The test transfer ownership to my own github account, but will be ignored until it is deleted so ownership does not technically leave the user.
//In order to actually test the transfer, one would have to log onto the existing user that it is transferred to in order to accept,
//and then back to the original temp user. Thus the hacky solution of only testing that that the user is prompted that their half of
Expand All @@ -15,17 +16,33 @@
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;

public class US3US5TransferRepo {
public class US3S5TransferRepo {
private WebDriver driver;
private String baseUrl;
private boolean acceptNextAlert = true;
private StringBuffer verificationErrors = new StringBuffer();

//Hardcoded auth for 'permenent' user. Hopefully a bot doesn't steal this account.
private static final String USERNAME = "cs1632user";
private static final String PASSWORD = "cs1632pass";

//Utility function
private void logIn(String username, String password) {
driver.get(baseUrl + "/");
driver.findElement(By.linkText("Sign in")).click();
driver.findElement(By.id("login_field")).clear();
driver.findElement(By.id("login_field")).sendKeys(username);
driver.findElement(By.id("password")).clear();
driver.findElement(By.id("password")).sendKeys(password);
driver.findElement(By.name("commit")).click();
}

@Before
public void setUp() throws Exception {
driver = new FirefoxDriver();
baseUrl = "https://github.com/";
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
logIn(USERNAME, PASSWORD); //login
}

@Test
Expand Down
18 changes: 17 additions & 1 deletion tests/US3US6DeleteRepo.java → tests/US3S6DeleteRepo.java
Expand Up @@ -14,17 +14,33 @@
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;

public class US3US6DeleteRepo {
public class US3S6DeleteRepo {
private WebDriver driver;
private String baseUrl;
private boolean acceptNextAlert = true;
private StringBuffer verificationErrors = new StringBuffer();

//Hardcoded auth for 'permenent' user. Hopefully a bot doesn't steal this account.
private static final String USERNAME = "cs1632user";
private static final String PASSWORD = "cs1632pass";

//Utility function
private void logIn(String username, String password) {
driver.get(baseUrl + "/");
driver.findElement(By.linkText("Sign in")).click();
driver.findElement(By.id("login_field")).clear();
driver.findElement(By.id("login_field")).sendKeys(username);
driver.findElement(By.id("password")).clear();
driver.findElement(By.id("password")).sendKeys(password);
driver.findElement(By.name("commit")).click();
}

@Before
public void setUp() throws Exception {
driver = new FirefoxDriver();
baseUrl = "https://github.com/";
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
logIn(USERNAME, PASSWORD); //login
}

@Test
Expand Down

0 comments on commit b527a40

Please sign in to comment.