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

Adding TagsPage scenario #1920

Merged
merged 4 commits into from
Mar 19, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
55 changes: 55 additions & 0 deletions src/AzureIoTHub.Portal.Tests.E2E/DeviceTags.cs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename this class "TagsConfiguration"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

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 UserCanAddAndRemoveDeviceTag()
kbeaugrand marked this conversation as resolved.
Show resolved Hide resolved
{
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 TagsPage();

tag.AddTag(tagName, tagLabel);

tag.RemoveTag(tagName);
}
}
}
52 changes: 52 additions & 0 deletions src/AzureIoTHub.Portal.Tests.E2E/Pages/TagsPage.cs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename this class "TagsConfigurationPage"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's done

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 TagsPage
{
public WebDriverWait wait;

public TagsPage()
{
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();
}
}
}