Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Browser tests #2356

Closed
wants to merge 47 commits into from
Closed
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
228ae12
Resolved NETSDK1059 warning caused by migration from 2.0 to 2.1
oneolddev Feb 23, 2019
545b653
Removed javascript files generated from typescript
oneolddev Feb 26, 2019
22f4d96
Updated - PSSQL replaced with SqlServer
oneolddev Mar 13, 2019
ce202d1
Fixed #2348 campaign end date
oneolddev Feb 22, 2019
8879ec6
Fixed datetimepicker related test problems
oneolddev Feb 28, 2019
208cc9d
Migrated to Canopy 2 and core 2.1
oneolddev Feb 28, 2019
b377c8c
Updated AppVeyor to for core 2.1 version of integration test
oneolddev Mar 8, 2019
1683468
Fixes NPM issues
oneolddev Feb 26, 2019
83bceae
Fixed appveyor.yml for Gulp 4 changes
oneolddev Mar 14, 2019
b8e76a7
Created AllReady.BrowserTest
oneolddev Apr 2, 2019
c7bfef2
Added AllReadyAdminHappyPath
oneolddev Apr 2, 2019
b89213e
Added AllReady.BrowserTest to appveyor.yml
oneolddev Apr 2, 2019
f229ddd
Fixed - build debug version of BrowserTest
oneolddev Apr 2, 2019
cc9a1c5
Fixed - run integration test only once
oneolddev Apr 2, 2019
e2531ac
Added tests for creating events and tasks for AllReadyAdmin
oneolddev Apr 4, 2019
4166dad
Moved configuration information to json file
oneolddev Apr 4, 2019
99c8359
Refactored - access json configuration in BrowserFixture
oneolddev Apr 4, 2019
7179ee7
Refactored configuration for better separation of concerns
oneolddev Apr 4, 2019
5fe31da
Refactored to page oriented model
oneolddev Apr 5, 2019
0191e18
Continued refactoring
oneolddev Apr 6, 2019
0d44841
Renamed some tests
oneolddev Apr 7, 2019
a66afec
Additional work to make tests fluent
oneolddev Apr 7, 2019
c35eeab
Added extensions to support fluent
oneolddev Apr 8, 2019
0a76616
Added fluent based tests
oneolddev Apr 8, 2019
6e51d0d
Moved controls
oneolddev Apr 8, 2019
f7e8056
Moved controls into their own namespace
oneolddev Apr 8, 2019
4ed105f
Added user role testing
oneolddev Apr 9, 2019
0ac354c
Renamed to HappyPathShould
oneolddev Apr 9, 2019
50765d8
Changed appveyor script to run unit tests separately
oneolddev Apr 9, 2019
9db6804
Fixed HappyPathShould.LogonAndLogoff test
oneolddev Apr 9, 2019
b8c114a
Refactor - started adding Title property to derived pages to simplify…
oneolddev Apr 9, 2019
2d62d8d
Made CreateNewOrganization test data driven
oneolddev Apr 10, 2019
de307b9
Added CreateNewCampaign test
oneolddev Apr 11, 2019
0040575
Refactor extract common login task
oneolddev Apr 11, 2019
d6a78e9
Refactor
oneolddev Apr 11, 2019
dce5fa5
Refactor - improve readability - fluent style not as helpful as origi…
oneolddev Apr 11, 2019
b85fadb
Added event creation test
oneolddev Apr 11, 2019
8cbc97a
Added task creation test
oneolddev Apr 12, 2019
9a289bf
Ordered tests
oneolddev Apr 12, 2019
0a4e949
Added ability to take screenshots
oneolddev Apr 13, 2019
3594b9e
Removed fixed dates
oneolddev Apr 16, 2019
72e9367
Fixed typo in yml file
oneolddev Apr 30, 2019
688ea2b
Fixed appveyor.yml
oneolddev Apr 30, 2019
f6d904b
Updated to support Chrome 75
oneolddev Jun 9, 2019
4c518e9
Updated yml file to copy matching version of chromedriver
oneolddev Jun 9, 2019
9eeb11e
Updated to latest Selenium.WebDriver.ChromeDriver package
oneolddev Jun 21, 2019
4ee83cf
Changed due to intellisense recommendations
oneolddev Sep 1, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -240,4 +240,8 @@ bower_components
/smoke-alarm-requests-sample-data-INVALID.csv
/smoke-alarm-requests-sample-data-EMPTY.csv
/smoke-alarm-requests-sample-data-DUPLICATE.csv
/AllReadyApp/Web-App/AllReady/wwwroot/upload
/AllReadyApp/Web-App/AllReady/wwwroot/upload
/AllReadyApp/Web-App/AllReady/wwwroot/ts/shapes.js
/AllReadyApp/Web-App/AllReady/wwwroot/ts/shapelist.js
/AllReadyApp/Web-App/AllReady/wwwroot/ts/mappingTools.js
/AllReadyApp/Web-App/AllReady/wwwroot/js/site.js
30 changes: 30 additions & 0 deletions AllReadyApp/AllReady.BrowserTest/AllReady.BrowserTest.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.2.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.1" />
<PackageReference Include="Selenium.Support" Version="3.141.0" />
<PackageReference Include="Selenium.WebDriver" Version="3.141.0" />
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="73.0.3683.68" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<None Update="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
259 changes: 259 additions & 0 deletions AllReadyApp/AllReady.BrowserTest/AllReadyAdminHappyPathShould.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,259 @@
using AllReady.BrowserTest.Pages;
using Microsoft.Extensions.Configuration;
using OpenQA.Selenium;
using System;
using System.Collections.Generic;
using System.Text;
using Xunit;

namespace AllReady.BrowserTest
{
/// <summary>
/// Happy path for AllReady Admin
/// <para>
/// This set of tests are stateful and run in priority order.
/// Preconditions of individual test are dependent on the previous
/// test being successful.
/// </para>
/// </summary>
[TestCaseOrderer("AllReady.BrowserTest.PriorityOrderer", "AllReady.BrowserTest")]
public class AllReadyAdminHappyPathShould : IClassFixture<BrowserFixture>
{
IWebDriver _driver;
IConfiguration _config;

public AllReadyAdminHappyPathShould(BrowserFixture fixture)
{
_driver = fixture._driver;
_config = new ConfigurationFixture().Config;
}

[Fact, TestPriority(1)]
public void OpenHomePage()
{
_driver.Navigate().GoToUrl(_config["HomePageURL"]);

var expected = "Home Page - allReady";
var actual = _driver.Title;
Assert.Equal(expected, actual);
}

[Fact, TestPriority(2)]
public void OpenLoginPage()
{
var page = new Page(_driver);
page.Menu.LoginMenuItem.Click();

var expected = "Log in - allReady";
var actual = _driver.Title;
Assert.Equal(expected, actual);
}

[Fact, TestPriority(3)]
public void Login()
{
var loginPage = new AccountLoginPage(_driver);

loginPage.UserEmail.SendKeys(_config["AllReadyAdministratorUserEmail"]);
loginPage.UserPassword.SendKeys(_config["AllReadyAdministratorPassword"]);
loginPage.LoginButton.Click();

var expected = "Site Admin - allReady";
var actual = _driver.Title;
Assert.Equal(expected, actual);
}

[Fact, TestPriority(4)]
public void OpenCurrentlyActiveOrganizationsPage()
{
var page = new Page(_driver);
page.Menu.AdminOrganizationsMenuItem.Click();

var expected = "Currently active organizations - allReady";
var actual = _driver.Title;
Assert.Equal(expected, actual);
}

[Fact, TestPriority(5)]
public void OpenCreateOrganizationPage()
{
var adminOrganizationPage = new AdminOgranizationPage(_driver);
adminOrganizationPage.CreateOrgranizationButton.Click();

var expected = "Create Organization - allReady";
var actual = _driver.Title;
Assert.Equal(expected, actual);
}

string UniqueName(string s)
{
string tag = DateTime.Now.ToString("yyyyMMddHHmmss");
string name = $"[ST] {s} {tag}";

return name;
}

[Fact, TestPriority(6)]
public void CreateOrganization()
{
string organizationName = UniqueName("Organization");

var adminOrganizationCreatePage = new AdminOrganizationCreatePage(_driver);

adminOrganizationCreatePage.Name.SendKeys(organizationName);

// choose to enter privacy policy text
adminOrganizationCreatePage.PrivacyPolicyTextButton.Click();
adminOrganizationCreatePage.PrivacyPolicy.SendKeys("Privacy for all");

/// enter primary location information
adminOrganizationCreatePage.LocationAddress1.SendKeys("123 Main St");
adminOrganizationCreatePage.LocationCity.SendKeys("Hollywood");
adminOrganizationCreatePage.LocationState.SendKeys("CA");
adminOrganizationCreatePage.LocationPostalCode.SendKeys("99120");
adminOrganizationCreatePage.LocationCountry.SendKeys("USA");

/// enter primary contact information
//

/// submit form
adminOrganizationCreatePage.Submit();

var expected = $"{organizationName} - allReady";
var actual = _driver.Title;
Assert.Equal(expected, actual);
}

[Fact, TestPriority(7)]
public void OpenCampaignsAdminPage()
{
var page = new Page(_driver);
page.Menu.AdminCampaignsMenuItem.Click();

var expected = "Campaigns - Admin - allReady";
var actual = _driver.Title;
Assert.Equal(expected, actual);
}

[Fact, TestPriority(8)]
public void OpenCreateCampaignPage()
{
var adminCampaignPage = new AdminCampaignPage(_driver);
adminCampaignPage.CreateCampaignButton.Click();

var expected = "Create Campaign - allReady";
var actual = _driver.Title;
Assert.Equal(expected, actual);
}

[Fact, TestPriority(9)]
public void CreateCampaign()
{
string campaignName = UniqueName("Campaign");

var adminCampaignCreatePage = new AdminCampaignCreatePage(_driver);

adminCampaignCreatePage.Name.SendKeys(campaignName);
adminCampaignCreatePage.Description.SendKeys("Description");
adminCampaignCreatePage.Headline.SendKeys("Headline");
adminCampaignCreatePage.FullDesciption.SendKeys("Longer desription of the campaign");
adminCampaignCreatePage.TimeZone.SelectByText("Pacific", true);
adminCampaignCreatePage.StartDate.SendKeys(DateTime.Now.AddDays(1).ToString("MM/dd/yyyy"));
adminCampaignCreatePage.Organization.SelectLastItem();
adminCampaignCreatePage.Published.Checked(true);
adminCampaignCreatePage.CopyContactInfoButton.Click();
adminCampaignCreatePage.CopyConfirmDialog.ClickOK();

adminCampaignCreatePage.Submit();

var expected = $"{campaignName} - allReady";
var actual = _driver.Title;
Assert.Equal(expected, actual);
}

[Fact, TestPriority(10)]
public void OpenCreateEventPage()
{
// pre-condition - /Admin/Campaign/Details/
Assert.Contains(@"/Admin/Campaign/Details/", _driver.Url);

// do the work
var adminCampaignDetailsPage = new AdminCampaignDetailsPage(_driver);
adminCampaignDetailsPage.CreateNewEvent.Click();

// check that we got there
const string partialDestinationUrl = @"/Admin/Event/Create/";
Assert.Contains(partialDestinationUrl, _driver.Url);
}

[Fact, TestPriority(11)]
public void CreateEvent()
{
string eventName = UniqueName("Event");

var adminEventCreatePage = new AdminEventCreatePage(_driver);
adminEventCreatePage.Name.SendKeys(eventName);
adminEventCreatePage.Description.SendKeys("Description");
adminEventCreatePage.Headline.SendKeys("Headline");
adminEventCreatePage.EventType.SelectByText("Itinerary", true);
adminEventCreatePage.IsLimitVolunteers.Checked(true);
adminEventCreatePage.TimeZone.SelectByText("Pacific", true);
adminEventCreatePage.StartDateTime.SendKeys(DateTime.Now.AddDays(1).ToString("MM/dd/yyyy 9:00 AM"));
adminEventCreatePage.CopyLocationFromCampaignButton.Click();
adminEventCreatePage.CopyConfirmDialog.ClickOK();
adminEventCreatePage.Submit();

var expected = $"{eventName} - allReady";
var actual = _driver.Title;
Assert.Equal(expected, actual);
}

[Fact, TestPriority(12)]
public void OpenCreateVolunteerTaskPage()
{
// pre-condition
Assert.Contains(@"/Admin/Event/Details/", _driver.Url);

// do work
var adminEventDetailsPage = new AdminEventDetailsPage(_driver);
adminEventDetailsPage.CreateNewTask.Click();

// post-condition
const string partialDestinationUrl = @"/Admin/VolunteerTask/Create/";
Assert.Contains(partialDestinationUrl, _driver.Url);
}

[Fact, TestPriority(13)]
public void CreateVolunteerTask()
{
string volunteerTaskName = UniqueName("Task");

var adminVolunteerTaskCreatePage = new AdminVolunteerTaskCreatePage(_driver);

adminVolunteerTaskCreatePage.Name.SendKeys(volunteerTaskName);
adminVolunteerTaskCreatePage.Description.SendKeys("Description");
adminVolunteerTaskCreatePage.NumberOfVolunteersRequired.SendKeys("2");
adminVolunteerTaskCreatePage.StartDateTime.SendKeys(DateTime.Now.AddDays(1).ToString("MM/dd/yyyy 9:00 AM"));

var eventName = _driver.FindElement(By.XPath(@"//div[contains(@class,'form-group')]//label[contains(@for,'EventName')]/following-sibling::div[1]")).Text;

/// submit form
adminVolunteerTaskCreatePage.Submit();

var expected = $"{eventName} - allReady";
var actual = _driver.Title;
Assert.Equal(expected, actual);
}

[Fact, TestPriority(99)]
public void Logoff()
{
var homePage = new HomePage(_driver);
homePage.Menu.LogoffMenuItem.Click();

var expected = "Home Page - allReady";
var actual = _driver.Title;
Assert.Equal(expected, actual);
}
}
}
24 changes: 24 additions & 0 deletions AllReadyApp/AllReady.BrowserTest/BrowserFixture.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace AllReady.BrowserTest
{
public class BrowserFixture : IDisposable
{
public IWebDriver _driver;

public BrowserFixture()
{
_driver = new ChromeDriver(Environment.CurrentDirectory);
_driver.Manage().Window.Size = new System.Drawing.Size(1024, 768);
}
void IDisposable.Dispose()
{
_driver.Quit();
}
}
}
25 changes: 25 additions & 0 deletions AllReadyApp/AllReady.BrowserTest/ConfigurationFixture.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using Xunit;

namespace AllReady.BrowserTest
{
public class ConfigurationFixture
{
public IConfiguration Config { get; private set; }

public ConfigurationFixture()
{
var builder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json");

Config = new ConfigurationBuilder()
.AddJsonFile("appsettings.json", true, true)
.Build();
}
}
}
27 changes: 27 additions & 0 deletions AllReadyApp/AllReady.BrowserTest/Controls/CheckBox.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using OpenQA.Selenium;
using System;
using System.Collections.Generic;
using System.Text;

namespace AllReady.BrowserTest.Controls
{
class CheckBox
{
IWebDriver _driver;
IWebElement _element;

public CheckBox(IWebDriver driver, string id)
{
_driver = driver;
_element = _driver.FindElement(By.Id(id));
}

public void Checked(bool isChecked)
{
if ((_element.Selected && !isChecked) || (!_element.Selected && isChecked))
{
_element.Click();
}
}
}
}
Loading