Skip to content

Commit

Permalink
Merge pull request #78 from Lombiq/issue/OSOE-146
Browse files Browse the repository at this point in the history
OSOE-146: Flow 'Additional Styling Part' flyout not activating
  • Loading branch information
sarahelsaig authored Jul 13, 2022
2 parents b439543 + fcd65b0 commit 2332bbc
Show file tree
Hide file tree
Showing 57 changed files with 277 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ wwwroot/
node_modules/
*.user
.pnpm-debug.log
.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Lombiq.HelpfulExtensions.Tests.UI.Constants;

public static class TextInputValues
{
public const string TestClass = "test-class";
}
10 changes: 10 additions & 0 deletions Lombiq.HelpfulExtensions.Tests.UI/Constants/WidgetTypes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Lombiq.HelpfulExtensions.Tests.UI.Constants;

public static class WidgetTypes
{
public const string Container = nameof(Container);
public const string Html = nameof(Html);
public const string Liquid = nameof(Liquid);
public const string Menu = nameof(Menu);
public const string Markdown = nameof(Markdown);
}
18 changes: 18 additions & 0 deletions Lombiq.HelpfulExtensions.Tests.UI/Constants/XPathSelectors.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace Lombiq.HelpfulExtensions.Tests.UI.Constants;

public static class XPathSelectors
{
public const string AddWidgetButtonGroup = "//div[contains(@class, 'btn-widget-add-below-wrapper')]"
+ "//div[contains(@class, 'btn-group')]";
public const string AddWidgetButton = $"{AddWidgetButtonGroup}/button[@title='Add Widget']";
public const string WidgetList = $"{AddWidgetButtonGroup}/div[contains(@class, 'dropdown-menu')]";
public const string WidgetEditorHeader = "//div[contains(@class, 'widget-template')]"
+ "/div[contains(@class, 'widget-editor')]"
+ "/div[contains(@class, 'widget-editor-header')]";
public const string WidgetEditorHeaderText = $"{WidgetEditorHeader}/span[contains(@class, 'widget-editor-header-text')]";
public const string FlowSettingsButtonGroup = $"{WidgetEditorHeader}/div[contains(@class, 'btn-widget-metadata')]"
+ "/div[contains(@class, 'btn-group')]/div[contains(@class, 'btn-group')]";
public const string FlowSettingsButton = $"{FlowSettingsButtonGroup}/button[@title='Settings']";
public const string FlowSettingsDropdown = $"{FlowSettingsButtonGroup}/div[contains(@class, 'dropdown-menu')]";
public const string CustomClassesInput = "id('FlowPart-0_ContentItem_CustomClasses')";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
using Atata;
using Lombiq.HelpfulExtensions.Tests.UI.Constants;
using Lombiq.Tests.UI.Extensions;
using Lombiq.Tests.UI.Services;
using OpenQA.Selenium;
using OpenQA.Selenium.Interactions;
using Shouldly;
using System.Threading.Tasks;
using static Lombiq.HelpfulExtensions.Tests.UI.Constants.TextInputValues;
using static Lombiq.HelpfulExtensions.Tests.UI.Constants.XPathSelectors;

namespace Lombiq.HelpfulExtensions.Tests.UI.Extensions;

public static class TestCaseUITestContextExtensions
{
public static async Task TestFeatureWidgetsAsync(this UITestContext context)
{
await context.SignInDirectlyAsync();
await context.EnableFeatureDirectlyAsync(FeatureIds.ContentTypes);
await context.EnableFeatureDirectlyAsync(FeatureIds.Widgets);

var widgets = new[]
{
WidgetTypes.Container,
WidgetTypes.Html,
WidgetTypes.Liquid,
WidgetTypes.Markdown,
WidgetTypes.Menu,
};

foreach (var widget in widgets)
{
await context.TestWidgetAsync(widget);
}
}

/// <summary>
/// <see href="https://github.com/Lombiq/Helpful-Extensions/issues/76">
/// Flow 'Additional Styling Part' flyout not activating
/// </see>.
/// </summary>
public static async Task TestFlowAdditionalStylingPartAsync(this UITestContext context)
{
await context.SignInDirectlyAsync();
await context.EnableFeatureDirectlyAsync(FeatureIds.Flows);
await context.EnableFeatureDirectlyAsync(FeatureIds.ContentTypes);
await context.EnableFeatureDirectlyAsync(FeatureIds.Widgets);

await context.GoToCreatePageAsync();

// Adding 'Html' to flow.
context.AddWidgetToPageFlow(WidgetTypes.Html);

// To show toolbar.
new Actions(context.Driver)
.MoveToElement(context.Get(By.XPath(WidgetEditorHeader)))
.Build()
.Perform();

var flowSettingsButtonSelector = By.XPath(FlowSettingsButton);

// Check that the settings button exists and is visible.
context.Exists(flowSettingsButtonSelector);

// To show 'AdditionalStylingPart' view.
new Actions(context.Driver)
.Click(context.Get(flowSettingsButtonSelector))
.Build()
.Perform();

// Check that the 'AdditionalStylingPart' view exists and is visible.
context.Exists(By.XPath(FlowSettingsDropdown));

// Check CustomClasses input.
var customClassesInputSelector = By.XPath(CustomClassesInput);
context.Get(customClassesInputSelector)
.SendKeys(TestClass);

context.Get(customClassesInputSelector)
.GetValue()
.ShouldBe(TestClass);
}

private static async Task TestWidgetAsync(this UITestContext context, string widget)
{
await context.GoToCreatePageAsync();
context.AddWidgetToPageFlow(widget);

context.Get(By.XPath(WidgetEditorHeaderText))
.GetAttribute("data-content-type-display-text")
.ShouldBe($"{widget} Widget");
}

private static void AddWidgetToPageFlow(this UITestContext context, string widget) =>
new Actions(context.Driver)
.Click(context.Get(By.XPath(AddWidgetButton)))
.Click(context.Get(By.XPath($"{WidgetList}/a[text()='{widget} Widget']").OfAnyVisibility()))
.Build()
.Perform();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Lombiq.Tests.UI.Extensions;
using Lombiq.Tests.UI.Services;
using System.Threading.Tasks;

namespace Lombiq.HelpfulExtensions.Tests.UI.Extensions;

public static class UITestContextExtensions
{
public static Task GoToCreatePageAsync(this UITestContext context) =>
context.CreateNewContentItemAsync("Page", onlyIfNotAlreadyThere: false);
}
15 changes: 15 additions & 0 deletions Lombiq.HelpfulExtensions.Tests.UI/License.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Copyright © 2013, [Lombiq Technologies Ltd.](https://lombiq.com)

All rights reserved.

For more information and requests about licensing please [contact us through our website](https://lombiq.com/contact-us).

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

* Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
<DefaultItemExcludes>$(DefaultItemExcludes);.git*;node_modules\**</DefaultItemExcludes>
</PropertyGroup>

<PropertyGroup>
<Title>Lombiq Helpful Extensions for Orchard Core - UI Test Extensions</Title>
<Authors>Lombiq Technologies</Authors>
<Copyright>Copyright © 2013, Lombiq Technologies Ltd.</Copyright>
<Description>Lombiq Helpful Extensions for Orchard Core - UI Test Extensions: Extension methods that test various features in Lombiq Helpful Extensions for Orchard Core.</Description>
<PackageIcon>NuGetIcon.png</PackageIcon>
<PackageTags>OrchardCore;Lombiq;AspNetCore;CodeGeneration;ShapeTracing;Widgets</PackageTags>
<RepositoryUrl>https://github.com/Lombiq/Helpful-Extensions</RepositoryUrl>
<PackageProjectUrl>https://github.com/Lombiq/Helpful-Extensions/Lombiq.HelpfulExtensions.Tests.UI/Readme.md</PackageProjectUrl>
<PackageLicenseFile>License.md</PackageLicenseFile>
</PropertyGroup>

<ItemGroup>
<None Include="License.md" Pack="true" PackagePath="" />
<None Include="Readme.md" />
<None Include="NuGetIcon.png" Pack="true" PackagePath="" />
</ItemGroup>

<ItemGroup>
<None Remove="node_modules\**" />
<None Remove="Tests\**" />
</ItemGroup>

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Lombiq.HelpfulExtensions\Lombiq.HelpfulExtensions.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(NuGetBuild)' != 'true'">
<ProjectReference Include="..\..\..\..\test\Lombiq.UITestingToolbox\Lombiq.Tests.UI\Lombiq.Tests.UI.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(NuGetBuild)' == 'true'">
<PackageReference Include="Lombiq.Tests.UI" Version="3.3.1-alpha.osoe-146.0" />
</ItemGroup>

</Project>
File renamed without changes
14 changes: 14 additions & 0 deletions Lombiq.HelpfulExtensions.Tests.UI/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Lombiq Helpful Extensions for Orchard Core - UI Test Extensions

## About

Extension methods that test various features in Lombiq Helpful Extensions for Orchard Core.

Call these from a UI test project to verify the module's basic features; as seen in [Open-Source Orchard Core Extensions](https://github.com/Lombiq/Open-Source-Orchard-Core-Extensions).


## Contributing and support

Bug reports, feature requests, comments, questions, code contributions, and love letters are warmly welcome, please do so via GitHub issues and pull requests. Please adhere to our [open-source guidelines](https://lombiq.com/open-source-guidelines) while doing so.

This project is developed by [Lombiq Technologies](https://lombiq.com/). Commercial-grade support is available through Lombiq.
31 changes: 31 additions & 0 deletions Lombiq.HelpfulExtensions.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.1.32319.34
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lombiq.HelpfulExtensions", "Lombiq.HelpfulExtensions\Lombiq.HelpfulExtensions.csproj", "{207243C1-5934-4D94-AAF2-F46D4DB2F20F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lombiq.HelpfulExtensions.Tests.UI", "Lombiq.HelpfulExtensions.Tests.UI\Lombiq.HelpfulExtensions.Tests.UI.csproj", "{B1077AC7-10D3-451C-B467-DA0B4D7BD5A4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{207243C1-5934-4D94-AAF2-F46D4DB2F20F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{207243C1-5934-4D94-AAF2-F46D4DB2F20F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{207243C1-5934-4D94-AAF2-F46D4DB2F20F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{207243C1-5934-4D94-AAF2-F46D4DB2F20F}.Release|Any CPU.Build.0 = Release|Any CPU
{B1077AC7-10D3-451C-B467-DA0B4D7BD5A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B1077AC7-10D3-451C-B467-DA0B4D7BD5A4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B1077AC7-10D3-451C-B467-DA0B4D7BD5A4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B1077AC7-10D3-451C-B467-DA0B4D7BD5A4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {5F8B26CF-89E9-487E-B4B0-643F1A109459}
EndGlobalSection
EndGlobal
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
15 changes: 15 additions & 0 deletions Lombiq.HelpfulExtensions/License.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Copyright © 2013, [Lombiq Technologies Ltd.](https://lombiq.com)

All rights reserved.

For more information and requests about licensing please [contact us through our website](https://lombiq.com/contact-us).

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

* Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<ItemGroup>
<None Include="License.md" Pack="true" PackagePath="" />
<None Include="Readme.md" />
<None Include="..\Readme.md" />
<None Include="NuGetIcon.png" Pack="true" PackagePath="" />
</ItemGroup>

Expand All @@ -43,7 +43,7 @@
</ItemGroup>

<ItemGroup Condition="'$(NuGetBuild)' != 'true'">
<ProjectReference Include="..\..\Libraries\Lombiq.HelpfulLibraries\Lombiq.HelpfulLibraries.OrchardCore\Lombiq.HelpfulLibraries.OrchardCore.csproj" />
<ProjectReference Include="..\..\..\Libraries\Lombiq.HelpfulLibraries\Lombiq.HelpfulLibraries.OrchardCore\Lombiq.HelpfulLibraries.OrchardCore.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(NuGetBuild)' == 'true'">
Expand Down
3 changes: 1 addition & 2 deletions Manifest.cs → Lombiq.HelpfulExtensions/Manifest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,5 @@
Id = TargetBlank,
Name = "Lombiq Helpful Extensions - Target Blank",
Category = "Content",
Description = "Adds shape-based email template rendering and helpful email sending services."
Description = "Turns all external links into target=\"_blank\"."
)]
Binary file added Lombiq.HelpfulExtensions/NuGetIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@model Lombiq.HelpfulExtensions.Extensions.Flows.Models.AdditionalStylingPart
@model Lombiq.HelpfulExtensions.Extensions.Flows.Models.AdditionalStylingPart

<div class="btn-group">
<button type="button" title="@T["Settings"]" class="btn btn-secondary btn-sm dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<button type="button" title="@T["Settings"]" class="btn btn-secondary btn-sm dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fa fa-cog" aria-hidden="true"></i>
</button>
<div class="dropdown-menu dropdown-menu-right" style="padding:8px 10px;">
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@


[![Lombiq.HelpfulExtensions NuGet](https://img.shields.io/nuget/v/Lombiq.HelpfulExtensions?label=Lombiq.HelpfulExtensions)](https://www.nuget.org/packages/Lombiq.HelpfulExtensions/)
[![Lombiq.HelpfulExtensions UI Test Extensions NuGet](https://img.shields.io/nuget/v/Lombiq.HelpfulExtensions.Tests.UI?label=Lombiq.HelpfulExtensions.Tests.UI)](https://www.nuget.org/packages/Lombiq.HelpfulExtensions.Tests.UI/)


## About
Expand Down Expand Up @@ -100,7 +101,9 @@ To add inline styles include:

Use the `ShellScope.Current.SendEmailDeferred()` for sending emails. It'll send emails after the shell scope has ended without blocking the request.

### Target blank

Gives all external links the `target="_blank"` attribute.

## Contributing and support

Expand Down

0 comments on commit 2332bbc

Please sign in to comment.