Skip to content

Commit

Permalink
Adding TagsPage scenario (#1920)
Browse files Browse the repository at this point in the history
* add TagsPage

* add DeviceTags scenario

* Update and rename TagsPage.cs to TagsConfigurationPage.cs

* Update and rename DeviceTags.cs to TagsConfiguration.cs

---------

Co-authored-by: unknown <yamraniala@T-45GV55J.local.isima.fr>
Co-authored-by: Achraf-Git-dev <78796647+Achraf-Git-dev@users.noreply.github.com>
  • Loading branch information
3 people authored Mar 19, 2023
1 parent 336f2ec commit 8823f73
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 0 deletions.
52 changes: 52 additions & 0 deletions src/AzureIoTHub.Portal.Tests.E2E/Pages/TagsConfigurationPage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// 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 TagsConfigurationPage
{
public WebDriverWait wait;

public TagsConfigurationPage()
{
this.wait = new WebDriverWait(WebDriverFactory.Default, TimeSpan.FromSeconds(5));

_ = wait.Until(d => d.FindElement(By.CssSelector(".mud-nav-group:nth-child(5) > .mud-collapse-container .mud-nav-link-text")).Displayed);
WebDriverFactory.Default.FindElement(By.CssSelector(".mud-nav-group:nth-child(5) > .mud-collapse-container .mud-nav-link-text")).Click();
}

public void NavigateToTagsPage()
{
_ = wait.Until(d => d.FindElement(By.CssSelector(".mud-nav-group:nth-child(5) > .mud-collapse-container .mud-nav-link-text")).Displayed);
WebDriverFactory.Default.FindElement(By.CssSelector(".mud-nav-group:nth-child(5) > .mud-collapse-container .mud-nav-link-text")).Click();
}

public void AddTag(string name, string label)
{
_ = wait.Until(d => d.FindElement(By.Id("addTagButton")).Displayed);
WebDriverFactory.Default.FindElement(By.Id("addTagButton")).Click();

WebDriverFactory.Default.FindElement(By.CssSelector(".tag- > .mud-table-cell:nth-child(1) .mud-input-slot:nth-child(1)")).Click();
WebDriverFactory.Default.FindElement(By.CssSelector(".tag- > .mud-table-cell:nth-child(1) .mud-input-slot:nth-child(1)")).SendKeys(name);

_ = wait.Until(d => d.FindElement(By.CssSelector(".tag- > .mud-table-cell:nth-child(2) .mud-input-slot:nth-child(1)")).Displayed);
WebDriverFactory.Default.FindElement(By.CssSelector(".tag- > .mud-table-cell:nth-child(2) .mud-input-slot:nth-child(1)")).SendKeys(label);

WebDriverFactory.Default.FindElement(By.CssSelector(".tag-" + name + " #saveButton .mud-icon-root")).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("Settings have been successfully updated!"));
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 RemoveTag(string name)
{
WebDriverFactory.Default.FindElement(By.CssSelector(".tag-" + name + " #deleteButton .mud-icon-root")).Click();
}
}
}
55 changes: 55 additions & 0 deletions src/AzureIoTHub.Portal.Tests.E2E/TagsConfiguration.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// 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 DeviceTags : 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 UserCanAddAndRemoveTagsConfiguration()
{
var fixture = new Fixture();

var tagName = new string(
fixture.CreateMany<char>(4)
.Where(c => char.IsLetterOrDigit(c))
.ToArray()
);

var tagLabel = new string(
fixture.CreateMany<char>(4)
.Where(c => char.IsLetterOrDigit(c))
.ToArray()
);

var tag = new TagsConfigurationPage();

tag.AddTag(tagName, tagLabel);

tag.RemoveTag(tagName);
}
}
}

0 comments on commit 8823f73

Please sign in to comment.