Skip to content

Commit

Permalink
Setup E2E tests for Campaign page
Browse files Browse the repository at this point in the history
  • Loading branch information
KarmaKamikaze committed Nov 20, 2023
1 parent c1ee754 commit 493787e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 3 additions & 1 deletion ChatRPGTests/CampaignE2ETests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ public CampaignE2ETests(ChatRPGFixture fixture)
_driver = E2ETestUtility.Setup("/");
_wait = new WebDriverWait(_driver, TimeSpan.FromSeconds(10));

// Login and prepare to test Campaign page
// Login, create test campaign and prepare to test Campaign page
E2ETestUtility.Login(_wait, _testUsername, _testPassword);
E2ETestUtility.CreateTestCampaign(_driver, _wait, true);
}

public void Dispose()
{
E2ETestUtility.RemoveTestCampaign(_driver, _wait);
E2ETestUtility.Teardown(_driver);
_driver.Dispose();
}
Expand Down
9 changes: 6 additions & 3 deletions ChatRPGTests/E2ETestUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static void Login(WebDriverWait wait, string username, string password)
Thread.Sleep(500); // wait for page to load fully
}

public static void CreateTestCampaign(IWebDriver driver, WebDriverWait wait)
public static void CreateTestCampaign(IWebDriver driver, WebDriverWait wait, bool goToCampaign = false)
{
driver.Navigate().GoToUrl("http://localhost:5111/");
Thread.Sleep(500);
Expand All @@ -54,8 +54,11 @@ public static void CreateTestCampaign(IWebDriver driver, WebDriverWait wait)
wait.Until(webDriver => webDriver.FindElement(By.Id("inputCustomStartScenario"))).SendKeys("Test Scenario");
wait.Until(webDriver => webDriver.FindElement(By.Id("create-campaign-button"))).Click();
Thread.Sleep(200); // Wait for page to load
driver.Navigate().GoToUrl("http://localhost:5111/");
Thread.Sleep(500);
if (!goToCampaign)
{
driver.Navigate().GoToUrl("http://localhost:5111/");
Thread.Sleep(500);
}
}

public static void RemoveTestCampaign(IWebDriver driver, WebDriverWait wait)
Expand Down

0 comments on commit 493787e

Please sign in to comment.