Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
atm 3 errors, one failled. two from us2 and us3 each
  • Loading branch information
AndrewHarper041 committed Oct 29, 2015
1 parent b527a40 commit 6b0fd20
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 10 deletions.
Binary file modified bin/US1S3SignupSuccess.class
Binary file not shown.
Binary file modified bin/US3S2AddCollaborator.class
Binary file not shown.
Binary file modified bin/US3S5TransferRepo.class
Binary file not shown.
5 changes: 4 additions & 1 deletion tests/US1S3SignupSuccess.java
@@ -1,6 +1,9 @@
//Test for US-1 Scenario-3
//Checks when given a unique user name, a new user will be created
//NOTE: if user name is in use (taken by another user or if the automatic deletion of the new user fails), the test will fail.

//NOTEs:
//If user name is in use (taken by another user or if the automatic deletion of the new user fails), the test will fail.
//Make sure that the user is always deleted at the end, or it will fail without manual intervention

import java.util.regex.Pattern;
import java.util.concurrent.TimeUnit;
Expand Down
33 changes: 24 additions & 9 deletions tests/US3S2AddCollaborator.java
@@ -1,3 +1,9 @@
//Test for US-3 Scenario-1
//Tests that user can add colobarators for a repo

//NOTES:
//Needed js hack
//Must delete collaborator after

import java.util.regex.Pattern;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -39,15 +45,24 @@ public void setUp() throws Exception {

@Test
public void testUS3S2AddCollaborator() throws Exception {
driver.get(baseUrl + "/");
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");
driver.findElement(By.xpath("//div[@id='collaborators']/form/div[4]/ul/li")).click();
driver.findElement(By.cssSelector("button.btn.js-add-new-collab")).click();
assertEquals("Andrew Harper", driver.findElement(By.cssSelector("strong.collab-name")).getText());
driver.findElement(By.cssSelector("span.repo")).click();
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.linkText("Collaborators")).click();
driver.findElement(By.id("search-member")).clear();
driver.findElement(By.id("search-member")).sendKeys("graphitezeppelin");

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

driver.findElement(By.id("search-member")).click();
driver.findElement(By.xpath("//div[@id='collaborators']/form/div[4]/ul/li")).click();
driver.findElement(By.cssSelector("button.btn.js-add-new-collab")).click();
driver.findElement(By.xpath("//button[@type='submit']")).click();

}

@After
Expand Down
25 changes: 25 additions & 0 deletions tests/US3S5TransferRepo.java
Expand Up @@ -36,13 +36,32 @@ private void logIn(String username, String password) {
driver.findElement(By.id("password")).sendKeys(password);
driver.findElement(By.name("commit")).click();
}

private void deleteRepo() {
driver.get(baseUrl + "/");
driver.findElement(By.cssSelector("span.repo")).click();
driver.findElement(By.xpath("(//a[contains(@href, '/cs1632user/temprepo/settings')])[2]")).click();
driver.findElement(By.linkText("Delete this repository")).click();
driver.findElement(By.cssSelector("div.facebox-content.dangerzone > form.js-normalize-submit > p > input[name=\"verify\"]")).clear();
driver.findElement(By.cssSelector("div.facebox-content.dangerzone > form.js-normalize-submit > p > input[name=\"verify\"]")).sendKeys("cs1632user/temprepo");
driver.findElement(By.xpath("(//button[@type='submit'])[5]")).click();
}

private void createRepo() {
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();
}

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

@Test
Expand All @@ -55,12 +74,18 @@ public void testUS3US5TransferRepo() throws Exception {
driver.findElement(By.cssSelector("div.facebox-content.dangerzone > form > dl.form > dd > #confirm_repository_name")).sendKeys("temprepo");
driver.findElement(By.cssSelector("div.facebox-content.dangerzone > form > dl.form > dd > #confirm_new_owner")).clear();
driver.findElement(By.cssSelector("div.facebox-content.dangerzone > form > dl.form > dd > #confirm_new_owner")).sendKeys("graphitezeppelin");

//Hack to trigger the onchange javascript event we are looking for.
JavascriptExecutor jsExecutor = (JavascriptExecutor) driver;
jsExecutor.executeScript("$(arguments[0]).change();", driver.findElement(By.cssSelector("div.facebox-content.dangerzone > form > dl.form > dd > #confirm_new_owner")));

driver.findElement(By.xpath("(//button[@type='submit'])[5]")).click();
assertEquals("This repository is being transferred to @graphitezeppelin.", driver.findElement(By.xpath("//div[@id='options_bucket']/div[4]/div/p[2]")).getText());
}

@After
public void tearDown() throws Exception {
deleteRepo(); //delete temp repo
driver.quit();
String verificationErrorString = verificationErrors.toString();
if (!"".equals(verificationErrorString)) {
Expand Down

0 comments on commit 6b0fd20

Please sign in to comment.