-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Edge model creation and removal E2E test scenarios (#1916)
* Create teste2e.yml test e2e CI * Add E2E tests * Updated dependencies * LoginPage can now read from the settings file * Added the settings file * Adapted to new modifications in the LoginPage * Added environment variables to the CI * Separating actions * Setting up environment variables * path to the settings file isn't found * Another try to set the path * Update LoginPage.cs * Update AzureIoTHub.Portal.Tests.E2E.csproj * fixed * Update appsettings.json * testing to identify the error's source * more tries * Update LoginPage.cs * Update LoginTest.cs * Update LoginPage.cs * Update LoginPage.cs * installing user secrets package * Adding the User Secrets package reference * testing * Update teste2e.yml * Update LoginPage.cs * Update LoginPage.cs * Update LoginPage.cs * Update LoginPage.cs * Update teste2e.yml * Update teste2e.yml * Update LoginTest.cs * Premier Scenario * Update teste2e.yml * adding evn variables * Update teste2e.yml * Update LoginPage.cs * Update teste2e.yml * Update teste2e.yml * Update teste2e.yml * Update teste2e.yml * Update LoginPage.cs * URL variable created * Update LoginPage.cs * Update Scenario1.cs * Add 2E2 tests during CI * Update E2E tests * add EdgeModelPage * add EdgeDevicePage * add EdgeModels scenario * add ConcentratorsPage * a bug in adding concentrator * Update .github/workflows/ci-open-api-documentation.yml --------- Co-authored-by: Achraf-Git-dev <[email protected]> Co-authored-by: YASSIR MRANI ALAOUI <[email protected]> Co-authored-by: unknown <[email protected]>
- Loading branch information
1 parent
26f80d4
commit e9fbb6c
Showing
4 changed files
with
340 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright (c) CGI France. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace AzureIoTHub.Portal.Tests.E2E | ||
{ | ||
using AutoFixture; | ||
using AzureIoTHub.Portal.Tests.E2E.Pages; | ||
using NUnit.Framework; | ||
using NUnit.Framework.Internal; | ||
|
||
public class EdgeModels : E2ETest | ||
{ | ||
private LoginPage loginPage; | ||
|
||
[SetUp] | ||
public void SetUp() | ||
{ | ||
loginPage = new LoginPage(Configuration); | ||
|
||
loginPage.Login(); | ||
} | ||
|
||
[TearDown] | ||
public override void TearDown() | ||
{ | ||
loginPage.Logout(); | ||
|
||
base.TearDown(); | ||
} | ||
|
||
[Test] | ||
public void UserCanAddAndRemoveEdgeModel() | ||
{ | ||
var modelName = Fixture.Create<string>(); | ||
|
||
var model = new EdgeModelPage(); | ||
|
||
model.AddEdgeModel(modelName, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Vel fringilla est ullamcorper eget nulla. Vel turpis nunc eget lorem dolor sed viverra ipsum nunc. Eget dolor morbi non arcu. Urna duis convallis convallis tellus id interdum velit laoreet id. "); | ||
|
||
model.RemoveEdgeModel(modelName); | ||
} | ||
} | ||
} |
91 changes: 91 additions & 0 deletions
91
src/AzureIoTHub.Portal.Tests.E2E/Pages/ConcentratorsPage.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
// Copyright (c) CGI France. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace AzureIoTHub.Portal.Tests.E2E.Pages | ||
{ | ||
using NUnit.Framework; | ||
using OpenQA.Selenium; | ||
using OpenQA.Selenium.Support.UI; | ||
|
||
public class ConcentratorsPage | ||
{ | ||
private readonly WebDriverWait wait; | ||
|
||
public ConcentratorsPage() | ||
{ | ||
this.wait = new WebDriverWait(WebDriverFactory.Default, TimeSpan.FromSeconds(5)); | ||
|
||
_ = wait.Until(d => d.FindElement(By.XPath("/html/body/div[2]/div[3]/aside/div/div/div[4]/div/div/div/div/div")).Displayed); | ||
WebDriverFactory.Default.FindElement(By.XPath("/html/body/div[2]/div[3]/aside/div/div/div[4]/div/div/div/div/div")).Click(); | ||
} | ||
|
||
public void AddConcentrator(string id, string name) | ||
{ | ||
_ = wait.Until(d => d.FindElement(By.Id("add-concentrator")).Displayed); | ||
|
||
WebDriverFactory.Default.FindElement(By.Id("add-concentrator")).Click(); | ||
|
||
_ = wait.Until(d => d.FindElement(By.Id("DeviceId")).Displayed); | ||
|
||
WebDriverFactory.Default.FindElement(By.Id("DeviceId")).Click(); | ||
WebDriverFactory.Default.FindElement(By.Id("DeviceId")).SendKeys(id); | ||
|
||
WebDriverFactory.Default.FindElement(By.Id("DeviceName")).Click(); | ||
WebDriverFactory.Default.FindElement(By.Id("DeviceName")).SendKeys(name); | ||
|
||
WebDriverFactory.Default.FindElement(By.Id("LoraRegion")).Click(); | ||
|
||
_ = wait.Until(d => d.FindElement(By.CssSelector(".mud-list.mud-list-padding li:first-child")).Displayed); | ||
WebDriverFactory.Default.FindElement(By.CssSelector(".mud-list.mud-list-padding li:first-child")).Click(); | ||
|
||
|
||
_ = wait.Until(d => d.FindElement(By.ClassName("mud-snackbar-content-message")).Displayed); | ||
|
||
Assert.That(WebDriverFactory.Default.FindElement(By.ClassName("mud-snackbar-content-message")).Text, Is.EqualTo("Device" + id + " has been successfully created! Please note that changes might take some minutes to be visible in the list...")); | ||
|
||
WebDriverFactory.Default.FindElement(By.CssSelector("button[class='mud-button-root mud-icon-button mud-ripple mud-ripple-icon mud-icon-button-size-small ms-2']")).Click(); | ||
|
||
_ = wait.Until(d => !d.FindElement(By.Id("mud-snackbar-container")).Displayed); | ||
|
||
} | ||
|
||
public void SearchConcentrator(string id) | ||
{ | ||
_ = wait.Until(d => d.FindElement(By.XPath("/html/body/div[2]/div[3]/aside/div/div/div[4]/div/div/div/div/div")).Displayed); | ||
|
||
WebDriverFactory.Default.FindElement(By.XPath("/html/body/div[2]/div[3]/aside/div/div/div[4]/div/div/div/div/div")).Click(); | ||
|
||
_ = wait.Until(d => d.FindElement(By.ClassName("mud-expand-panel")).Displayed); | ||
|
||
WebDriverFactory.Default.FindElement(By.ClassName("mud-expand-panel-header")).Click(); | ||
|
||
_ = wait.Until(d => d.FindElement(By.Id("searchKeyword")).Displayed); | ||
|
||
WebDriverFactory.Default.FindElement(By.Id("searchKeyword")).Click(); | ||
WebDriverFactory.Default.FindElement(By.Id("searchKeyword")).SendKeys(id); | ||
|
||
WebDriverFactory.Default.FindElement(By.Id("searchButton")).Click(); | ||
} | ||
|
||
public void RemoveConcentrator(string id) | ||
{ | ||
SearchConcentrator(id); | ||
|
||
_ = wait.Until(d => d.FindElement(By.ClassName("mud-tooltip-root mud-tooltip-inline")).Displayed); | ||
WebDriverFactory.Default.FindElement(By.ClassName("mud-tooltip-root mud-tooltip-inline")).Click(); | ||
|
||
_ = wait.Until(d => d.FindElement(By.ClassName("outline-none")).Displayed); | ||
|
||
WebDriverFactory.Default.FindElement(By.CssSelector(".mud-button-text-primary > .mud-button-label")).Click(); | ||
|
||
_ = wait.Until(d => d.FindElement(By.ClassName("mud-snackbar-content-message")).Displayed); | ||
|
||
Assert.That(WebDriverFactory.Default.FindElement(By.ClassName("mud-snackbar-content-message")).Text, Is.EqualTo("Device " + id + " A has been successfully deleted!")); | ||
|
||
|
||
WebDriverFactory.Default.FindElement(By.CssSelector("button[class='mud-button-root mud-icon-button mud-ripple mud-ripple-icon mud-icon-button-size-small ms-2']")).Click(); | ||
|
||
_ = wait.Until(d => !d.FindElement(By.Id("mud-snackbar-container")).Displayed); | ||
} | ||
} | ||
} |
112 changes: 112 additions & 0 deletions
112
src/AzureIoTHub.Portal.Tests.E2E/Pages/EdgeDevicePage.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
// Copyright (c) CGI France. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace AzureIoTHub.Portal.Tests.E2E.Pages | ||
{ | ||
using NUnit.Framework; | ||
using OpenQA.Selenium; | ||
using OpenQA.Selenium.Interactions; | ||
using OpenQA.Selenium.Support.UI; | ||
|
||
public class EdgeDevicePage | ||
{ | ||
|
||
private readonly WebDriverWait wait; | ||
|
||
public EdgeDevicePage() | ||
{ | ||
this.wait = new WebDriverWait(WebDriverFactory.Default, TimeSpan.FromSeconds(5)); | ||
|
||
_ = wait.Until(d => d.FindElement(By.XPath("/ html / body / div[2] / div[3] / aside / div / div / div[3] / div / div / div / div / div[1] / a")).Displayed); | ||
|
||
WebDriverFactory.Default.FindElement(By.XPath("/ html / body / div[2] / div[3] / aside / div / div / div[3] / div / div / div / div / div[1] / a")).Click(); | ||
} | ||
|
||
|
||
|
||
|
||
public void AddEdgeDevice(string id, string name, string model) | ||
{ | ||
_ = wait.Until(d => d.FindElement(By.XPath("/html/body/div[2]/div[3]/div/div/div/div[2]/div/div[1]/div[3]/button")).Displayed); | ||
|
||
WebDriverFactory.Default.FindElement(By.XPath("/html/body/div[2]/div[3]/div/div/div/div[2]/div/div[1]/div[3]/button")).Click(); | ||
_ = wait.Until(d => d.FindElement(By.Id("ModelId")).Displayed); | ||
|
||
WebDriverFactory.Default.FindElement(By.Id("ModelId")).Click(); | ||
|
||
System.Threading.Thread.Sleep(2000); | ||
|
||
WebDriverFactory.Default.FindElement(By.Id("ModelId")).SendKeys(model + Keys.Enter); | ||
|
||
System.Threading.Thread.Sleep(2000); | ||
|
||
// driver.FindElement(By.Id("ModelId")).SendKeys(Keys.Enter); | ||
|
||
WebDriverFactory.Default.FindElement(By.Id("DeviceId")).Click(); | ||
WebDriverFactory.Default.FindElement(By.Id("DeviceId")).SendKeys(id); | ||
WebDriverFactory.Default.FindElement(By.Id("DeviceName")).Click(); | ||
WebDriverFactory.Default.FindElement(By.Id("DeviceName")).SendKeys(name); | ||
|
||
|
||
System.Threading.Thread.Sleep(2000); | ||
|
||
|
||
// Find the "Save" button | ||
var saveButton = WebDriverFactory.Default.FindElement(By.XPath("//span[@class='mud-button-label' and text()='Save']")); | ||
|
||
// Scroll to the "Save" button | ||
//((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].scrollIntoView(true);", saveButton); | ||
|
||
// Click the element | ||
saveButton.Click(); | ||
|
||
System.Threading.Thread.Sleep(5000); | ||
|
||
_ = wait.Until(d => d.FindElement(By.ClassName("mud-snackbar-content-message")).Displayed); | ||
|
||
Assert.That(WebDriverFactory.Default.FindElement(By.ClassName("mud-snackbar-content-message")).Text, Is.EqualTo("Device " + id + " has been successfully created!")); | ||
|
||
WebDriverFactory.Default.FindElement(By.CssSelector("button[class='mud-button-root mud-icon-button mud-ripple mud-ripple-icon mud-icon-button-size-small ms-2']")).Click(); | ||
|
||
_ = wait.Until(d => !d.FindElement(By.Id("mud-snackbar-container")).Displayed); | ||
} | ||
|
||
public void SearchEdgeDevice(string name) | ||
{ | ||
_ = wait.Until(d => d.FindElement(By.ClassName("mud-expand-panel-header")).Displayed); | ||
|
||
WebDriverFactory.Default.FindElement(By.ClassName("mud-expand-panel-header")).Click(); | ||
|
||
_ = wait.Until(d => d.FindElement(By.CssSelector(".mud-input-input-control .mud-input-slot:nth-child(1)")).Displayed); | ||
|
||
WebDriverFactory.Default.FindElement(By.CssSelector(".mud-input-input-control .mud-input-slot:nth-child(1)")).Click(); | ||
WebDriverFactory.Default.FindElement(By.CssSelector(".mud-input-input-control .mud-input-slot:nth-child(1)")).SendKeys(name); | ||
|
||
|
||
WebDriverFactory.Default.FindElement(By.Id("searchFilterButton")).Click(); | ||
|
||
} | ||
|
||
public void RemoveEdgeDevice(string id) | ||
{ | ||
SearchEdgeDevice(id); | ||
|
||
_ = wait.Until(d => d.FindElement(By.CssSelector("#delete_789456 path:nth-child(2)")).Displayed); | ||
WebDriverFactory.Default.FindElement(By.CssSelector("#delete_789456 path:nth-child(2)")).Click(); | ||
|
||
_ = wait.Until(d => d.FindElement(By.ClassName("outline-none")).Displayed); | ||
|
||
WebDriverFactory.Default.FindElement(By.CssSelector(".mud-button-text-primary > .mud-button-label")).Click(); | ||
System.Threading.Thread.Sleep(5000); | ||
|
||
|
||
_ = wait.Until(d => d.FindElement(By.ClassName("mud-snackbar-content-message")).Displayed); | ||
|
||
Assert.That(WebDriverFactory.Default.FindElement(By.ClassName("mud-snackbar-content-message")).Text, Is.EqualTo("Device " + id + " has been successfully deleted!")); | ||
|
||
WebDriverFactory.Default.FindElement(By.CssSelector("button[class='mud-button-root mud-icon-button mud-ripple mud-ripple-icon mud-icon-button-size-small ms-2']")).Click(); | ||
|
||
_ = wait.Until(d => !d.FindElement(By.Id("mud-snackbar-container")).Displayed); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
// Copyright (c) CGI France. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace AzureIoTHub.Portal.Tests.E2E.Pages | ||
{ | ||
using NUnit.Framework; | ||
using OpenQA.Selenium; | ||
using OpenQA.Selenium.Support.UI; | ||
|
||
public class EdgeModelPage | ||
{ | ||
private readonly WebDriverWait wait; | ||
|
||
public EdgeModelPage() | ||
{ | ||
this.wait = new WebDriverWait(WebDriverFactory.Default, TimeSpan.FromSeconds(5)); | ||
|
||
_ = wait.Until(d => d.FindElement(By.CssSelector(".mud-navmenu > .mud-nav-item:nth-child(2) .mud-nav-link-text")).Displayed); | ||
|
||
WebDriverFactory.Default.FindElement(By.CssSelector(".mud-navmenu > .mud-nav-item:nth-child(2) .mud-nav-link-text")).Click(); | ||
} | ||
|
||
public void NavigateToEdgeModelPage() | ||
{ | ||
_ = wait.Until(d => d.FindElement(By.CssSelector(".mud-navmenu > .mud-nav-item:nth-child(2) .mud-nav-link-text")).Displayed); | ||
|
||
|
||
WebDriverFactory.Default.FindElement(By.CssSelector(".mud-navmenu > .mud-nav-item:nth-child(2) .mud-nav-link-text")).Click(); | ||
} | ||
|
||
|
||
public void AddEdgeModel(string name, string description) | ||
{ | ||
_ = wait.Until(d => d.FindElement(By.Id("addEdgeModelButton")).Displayed); | ||
|
||
WebDriverFactory.Default.FindElement(By.Id("addEdgeModelButton")).Click(); | ||
|
||
_ = wait.Until(d => d.FindElement(By.Id("Name")).Displayed); | ||
|
||
WebDriverFactory.Default.FindElement(By.Id("Name")).Click(); | ||
WebDriverFactory.Default.FindElement(By.Id("Name")).SendKeys(name); | ||
WebDriverFactory.Default.FindElement(By.Id("Description")).Click(); | ||
WebDriverFactory.Default.FindElement(By.Id("Description")).SendKeys(description); | ||
WebDriverFactory.Default.FindElement(By.Id("SaveButton")).Click(); | ||
|
||
_ = wait.Until(d => d.FindElement(By.ClassName("mud-snackbar-content-message")).Displayed); | ||
|
||
Assert.That(WebDriverFactory.Default.FindElement(By.ClassName("mud-snackbar-content-message")).Text, Is.EqualTo("Device model successfully created.")); | ||
|
||
WebDriverFactory.Default.FindElement(By.CssSelector("button[class='mud-button-root mud-icon-button mud-ripple mud-ripple-icon mud-icon-button-size-small ms-2']")).Click(); | ||
|
||
_ = wait.Until(d => !d.FindElement(By.Id("mud-snackbar-container")).Displayed); | ||
} | ||
|
||
public void SearchEdgeModel(string description) | ||
{ | ||
WebDriverFactory.Default.FindElement(By.ClassName("mud-expand-panel-text")).Click(); | ||
|
||
_ = wait.Until(d => d.FindElement(By.Id("edge-model-search-keyword")).Displayed); | ||
|
||
|
||
WebDriverFactory.Default.FindElement(By.Id("edge-model-search-keyword")).SendKeys(description); | ||
|
||
_ = wait.Until(d => d.FindElement(By.Id("edge-model-search-button")).Displayed); | ||
WebDriverFactory.Default.FindElement(By.Id("edge-model-search-button")).Click(); | ||
} | ||
|
||
|
||
|
||
|
||
public void RemoveEdgeModel(string name) | ||
{ | ||
SearchEdgeModel(name); | ||
|
||
WebDriverFactory.Default.FindElement(By.Id("deleteButton")).Click(); | ||
|
||
_ = wait.Until(d => d.FindElement(By.ClassName("outline-none")).Displayed); | ||
|
||
WebDriverFactory.Default.FindElement(By.CssSelector(".mud-button-text-primary > .mud-button-label")).Click(); | ||
System.Threading.Thread.Sleep(5000); | ||
|
||
|
||
_ = wait.Until(d => d.FindElement(By.ClassName("mud-snackbar-content-message")).Displayed); | ||
|
||
Assert.That(WebDriverFactory.Default.FindElement(By.ClassName("mud-snackbar-content-message")).Text, Is.EqualTo("Device model " + name + " has been successfully deleted!")); | ||
|
||
WebDriverFactory.Default.FindElement(By.CssSelector("button[class='mud-button-root mud-icon-button mud-ripple mud-ripple-icon mud-icon-button-size-small ms-2']")).Click(); | ||
|
||
_ = wait.Until(d => !d.FindElement(By.Id("mud-snackbar-container")).Displayed); | ||
} | ||
|
||
|
||
} | ||
} |