Skip to content

Commit

Permalink
Merge remote-tracking branch 'lombiq/dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
DemeSzabolcs committed Mar 9, 2022
2 parents 9edfdef + 725fedb commit b2971d0
Show file tree
Hide file tree
Showing 130 changed files with 3,616 additions and 839 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: publish

on:
push:
tags:
- v*

jobs:
call-publish-workflow:
uses: Lombiq/GitHub-Actions/.github/workflows/publish.yml@dev
secrets:
API_KEY: ${{ secrets.DEFAULT_NUGET_PUBLISH_API_KEY }}
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,11 @@
obj/
bin/
*.user
Localization/
artifacts/
.vs/
wwwroot
node_modules/
.pnpm-debug.log
package-lock.json
Localization/
/.editorconfig
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ namespace Microsoft.Extensions.Configuration
public static class ConfigurationExtensions
{
public static bool IsUITesting(this IConfiguration configuration) =>
configuration.GetValue("Lombiq_Tests_UI:IsUITesting", false);
configuration.GetValue("Lombiq_Tests_UI:IsUITesting", defaultValue: false);
}
}
15 changes: 15 additions & 0 deletions Lombiq.Tests.UI.AppExtensions/License.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Copyright © 2020, [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.
24 changes: 21 additions & 3 deletions Lombiq.Tests.UI.AppExtensions/Lombiq.Tests.UI.AppExtensions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,28 @@

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<IsPublishable>false</IsPublishable>
<DefaultItemExcludes>$(DefaultItemExcludes);.git*;node_modules\**</DefaultItemExcludes>
</PropertyGroup>

<PropertyGroup>
<Title>App Extensions - Lombiq UI Testing Toolbox</Title>
<Authors>Lombiq Technologies</Authors>
<Copyright>Copyright © 2020, Lombiq Technologies Ltd.</Copyright>
<Description>App Extensions - Lombiq UI Testing Toolbox: UI testing-related configuration extensions for the web app under test. See the project website for detailed documentation.</Description>
<PackageIcon>NuGetIcon.png</PackageIcon>
<PackageTags>OrchardCore;Lombiq;AspNetCore;Selenium;Atata;Shouldly;xUnit;Axe;AccessibilityTesting;UITesting;Testing;Automation</PackageTags>
<RepositoryUrl>https://github.com/Lombiq/UI-Testing-Toolbox</RepositoryUrl>
<PackageProjectUrl></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\**" />
</ItemGroup>
Expand All @@ -14,9 +33,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="OrchardCore" Version="1.0.0" />
<PackageReference Include="OrchardCore.Email.Abstractions" Version="1.0.0" />
<PackageReference Include="OrchardCore.Media.Azure" Version="1.0.0" />
<PackageReference Include="OrchardCore" Version="1.2.2" />
<PackageReference Include="OrchardCore.Email.Abstractions" Version="1.2.2" />
</ItemGroup>

</Project>
Binary file added Lombiq.Tests.UI.AppExtensions/NuGetIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion Lombiq.Tests.UI.AppExtensions/Readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Lombiq UI Testing Toolbox - App Extensions
# App Extensions - Lombiq UI Testing Toolbox



Expand Down
1 change: 1 addition & 0 deletions Lombiq.Tests.UI.Samples/.htmlvalidate.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

"rules": {
"attribute-boolean-style": "off",
"long-title": "off",
"no-trailing-whitespace": "off",
"no-inline-style": "off",
"no-dup-class": "off",
Expand Down

This file was deleted.

49 changes: 20 additions & 29 deletions Lombiq.Tests.UI.Samples/Helpers/SetupHelpers.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using Lombiq.Tests.UI.Constants;
using Lombiq.Tests.UI.Extensions;
using Lombiq.Tests.UI.Pages;
using Lombiq.Tests.UI.Samples.Extensions;
using Lombiq.Tests.UI.Services;
using OpenQA.Selenium;
using System;
using System.Threading.Tasks;

namespace Lombiq.Tests.UI.Samples.Helpers
{
Expand All @@ -18,30 +18,21 @@ public static class SetupHelpers
// If you use a setup recipe for local development then you can execute that from this test recipe.
public const string RecipeId = "Lombiq.OSOCE.Tests";

public static Uri RunSetup(UITestContext context)
public static async Task<Uri> RunSetupAsync(UITestContext context)
{
// You should always explicitly set the window size of the browser, otherwise the size will be random based
// on the settings of the given machine. This is especially true when running tests in headless mode. So, we
// set it to full HD here.
context.SetStandardBrowserSize();

// Running the setup.
var uri = context
.GoToSetupPage()
// OrchardCoreSetupParameters will initialize some basic settings from the context.
.SetupOrchardCore(
new OrchardCoreSetupParameters(context)
{
SiteName = "Lombiq's Open-Source Orchard Core Extensions - UI Testing",
RecipeId = RecipeId,
// A table prefix is not really needed but this way we also check whether we've written any SQL
// that doesn't support prefixes.
TablePrefix = "OSOCE",
// Where else would we be?!
SiteTimeZoneValue = "Europe/Budapest",
})
.PageUri
.Value;
// OrchardCoreSetupParameters will initialize some basic settings from the context.
var homepageUri = await context.GoToSetupPageAndSetupOrchardCoreAsync(
new OrchardCoreSetupParameters(context)
{
SiteName = "Lombiq's OSOCE - UI Testing",
RecipeId = RecipeId,
// A table prefix is not really needed but this way we also check whether we've written any SQL
// that doesn't support prefixes.
TablePrefix = "OSOCE",
// Where else would we be?!
SiteTimeZoneValue = "Europe/Budapest",
});

// Here we make sure that the setup actually finished and we're on the homepage where the menu is visible.
// Without this, a failing setup may only surface much later when an assertion in a test fails. Failing
Expand All @@ -50,14 +41,14 @@ public static Uri RunSetup(UITestContext context)
// interested how that works.
AssertSetupSuccessful(context);

return uri;
return homepageUri;
}

// Just a convenience method.
public static void RunSetupAndSignInDirectly(UITestContext context, string userName = DefaultUser.UserName)
public static async Task RunSetupAndSignInDirectlyAsync(UITestContext context, string userName = DefaultUser.UserName)
{
RunSetup(context);
context.SignInDirectly(userName);
await RunSetupAsync(context);
await context.SignInDirectlyAsync(userName);
}

// When using the Auto Setup feature (https://docs.orchardcore.net/en/dev/docs/reference/modules/AutoSetup/) you
Expand All @@ -67,9 +58,9 @@ public static void RunSetupAndSignInDirectly(UITestContext context, string userN
// recipe, contain testing-specific content and configuration). So it's still better to not use Auto Setup for
// test execution even if you use it for development: To achieve this, in your web app's Startup class you can
// only conditionally run AddSetupFeatures("OrchardCore.AutoSetup"), based on IConfiguration.IsUITesting().
public static Uri RunAutoSetup(UITestContext context)
public static async Task<Uri> RunAutoSetupAsync(UITestContext context)
{
context.GoToHomePage();
await context.GoToHomePageAsync();
AssertSetupSuccessful(context);
return context.GetCurrentUri();
}
Expand Down
3 changes: 3 additions & 0 deletions Lombiq.Tests.UI.Samples/Lombiq.Tests.UI.Samples.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<IsPackable>false</IsPackable>
<!-- Eliminates problem with dotnet publish caused by duplicate .htmlvalidate.json file. See
https://docs.microsoft.com/en-us/dotnet/core/compatibility/sdk/6.0/duplicate-files-in-output. -->
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
</PropertyGroup>

<ItemGroup>
Expand Down
18 changes: 16 additions & 2 deletions Lombiq.Tests.UI.Samples/Readme.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Lombiq UI Testing Toolbox - Samples
# Samples - Lombiq UI Testing Toolbox



Example UI testing project. The whole project is heavily documented to teach you how to write UI tests with the UI Testing Toolbox. It guides you through this process just like the [Lombiq Training Demo](https://github.com/Lombiq/Orchard-Training-Demo-Module) teaches Orchard Core and Orchard 1 development.
Example UI testing project. The whole project is heavily documented to teach you how to write UI tests with the UI Testing Toolbox. It guides you through this process just like the [Lombiq Training Demo for Orchard Core](https://github.com/Lombiq/Orchard-Training-Demo-Module) teaches Orchard Core and Orchard 1 development.

For general details about and on using the Toolbox see the [root Readme](../Readme.md).

Expand All @@ -15,4 +15,18 @@ For general details about and on using the Toolbox see the [root Readme](../Read
4. Now that we have the basics out of the way start the tutorial in the [*GlobalSuppressions.cs*](GlobalSuppressions.cs) file.


## Training sections

- [UI Testing Toolbox basics](GlobalSuppressions.cs)
- [Basic Orchard features tests](Tests/BasicOrchardFeaturesTests.cs)
- [E-mail tests](Tests/EmailTests.cs)
- [Accessibility tests](Tests/AccessibilityTest.cs)
- [Using SQL Server](Tests/SqlServerTests.cs)
- [Using Azure Blob Storage](Tests/AzureBlobStorageTests.cs)
- [Error handling](Tests/ErrorHandlingtests.cs)
- [Monkey tests](Tests/MonkeyTests.cs)


## Adding new tutorials

Follow the practices of the [Lombiq Training Demo for Orchard Core](https://github.com/Lombiq/Orchard-Training-Demo-Module#contributing-and-support).
4 changes: 2 additions & 2 deletions Lombiq.Tests.UI.Samples/Tests/AccessibilityTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public Task FrontendPagesShoudlBeAccessbile(Browser browser) =>
context =>
// This is just a simple test that visits two pages: The homepage, where the test will start by
// default, and another one.
context.GoToRelativeUrl("/categories/travel"),
context.GoToRelativeUrlAsync("/categories/travel"),
browser,
configuration =>
{
Expand All @@ -43,5 +43,5 @@ public Task FrontendPagesShoudlBeAccessbile(Browser browser) =>
}
}

// END OF TRAINING SECTION: UI Testing Toolbox basics.
// END OF TRAINING SECTION: Accessibility tests.
// NEXT STATION: Head over to Tests/SqlServerTests.cs.
7 changes: 4 additions & 3 deletions Lombiq.Tests.UI.Samples/Tests/AzureBlobStorageTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public Task AnonymousHomePageShouldExistWithAzureBlobStorage(Browser browser) =>
context => context
.Get(By.ClassName("navbar-brand"))
.Text
.ShouldBe("Lombiq's Open-Source Orchard Core Extensions - UI Testing"),
.ShouldBe("Lombiq's OSOCE - UI Testing"),
browser,
// Note the configuration! We could also set this globally in UITestBase.
// You'll need an accessible Azure Blob Storage account. For testing we recommend the Azurite emulator
Expand All @@ -37,9 +37,9 @@ public Task AnonymousHomePageShouldExistWithAzureBlobStorage(Browser browser) =>
configuration => configuration.UseAzureBlobStorage = true);

[Theory, Chrome]
public Task TogglingFeaturesShouldWorkWithSqlServer(Browser browser) =>
public Task TogglingFeaturesShouldWorkWithAzureBlobStorage(Browser browser) =>
ExecuteTestAfterSetupAsync(
context => context.ExecuteAndAssertTestFeatureToggle(),
context => context.ExecuteAndAssertTestFeatureToggleAsync(),
browser,
configuration =>
{
Expand All @@ -57,3 +57,4 @@ public Task TogglingFeaturesShouldWorkWithSqlServer(Browser browser) =>
}

// END OF TRAINING SECTION: Using Azure Blob Storage.
// NEXT STATION: Head over to Tests/ErrorHandlingtests.cs.
11 changes: 3 additions & 8 deletions Lombiq.Tests.UI.Samples/Tests/BasicOrchardFeaturesTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Lombiq.Tests.UI.Attributes;
using Lombiq.Tests.UI.Extensions;
using Lombiq.Tests.UI.Pages;
using Lombiq.Tests.UI.Services;
using System.Threading.Tasks;
using Xunit;
Expand All @@ -19,16 +18,12 @@ public BasicOrchardFeaturesTests(ITestOutputHelper testOutputHelper)
{
}

// We could reuse the previously specified SetupHelpers.RecipeId const here but it's actually a different
// recipe for this tests.
[Theory, Chrome]
public Task BasicOrchardFeaturesShouldWork(Browser browser) =>
ExecuteTestAsync(
context => context.TestBasicOrchardFeatures(
new OrchardCoreSetupParameters
{
// We could reuse the previously specified SetupHelpers.RecipeId const here but it's actually a
// different recipe for this tests.
RecipeId = "Lombiq.OSOCE.BasicOrchardFeaturesTests",
}),
context => context.TestBasicOrchardFeaturesAsync("Lombiq.OSOCE.BasicOrchardFeaturesTests"),
browser);
}
}
Expand Down
Loading

0 comments on commit b2971d0

Please sign in to comment.