diff --git a/bin/US1S3SignupSuccess.class b/bin/US1S3SignupSuccess.class index 3e2bd3d..c9a8ce3 100644 Binary files a/bin/US1S3SignupSuccess.class and b/bin/US1S3SignupSuccess.class differ diff --git a/bin/US3S2AddCollaborator.class b/bin/US3S2AddCollaborator.class index 2d99746..34ab7ab 100644 Binary files a/bin/US3S2AddCollaborator.class and b/bin/US3S2AddCollaborator.class differ diff --git a/bin/US3S5TransferRepo.class b/bin/US3S5TransferRepo.class index f921176..5eed18a 100644 Binary files a/bin/US3S5TransferRepo.class and b/bin/US3S5TransferRepo.class differ diff --git a/tests/US1S3SignupSuccess.java b/tests/US1S3SignupSuccess.java index 1c6dec2..832ec9c 100644 --- a/tests/US1S3SignupSuccess.java +++ b/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; diff --git a/tests/US3S2AddCollaborator.java b/tests/US3S2AddCollaborator.java index bf672b1..533570d 100644 --- a/tests/US3S2AddCollaborator.java +++ b/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; @@ -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 diff --git a/tests/US3S5TransferRepo.java b/tests/US3S5TransferRepo.java index 246cd84..b053c01 100644 --- a/tests/US3S5TransferRepo.java +++ b/tests/US3S5TransferRepo.java @@ -36,6 +36,24 @@ 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 { @@ -43,6 +61,7 @@ public void setUp() throws Exception { baseUrl = "https://github.com/"; driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); logIn(USERNAME, PASSWORD); //login + createRepo(); //Make temp repo } @Test @@ -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)) {