Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
10 changes: 8 additions & 2 deletions Lombiq.Tests.UI.Samples/Tests/JavaScriptTests.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
using Lombiq.Tests.UI.Extensions;
using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Threading.Tasks;
using Xunit;

// Warning: This feature relies on PNPM and Node.js, and it was designed for projects that use Lombiq.NodeJs.Targets.
// Since the latter is deprecated and PNPM won't be shipped with future versions of Node.js either, this
// feature is no longer supported.

namespace Lombiq.Tests.UI.Samples.Tests;

// Let's suppose you want to write UI tests in JavaScript. Why would you want to do that? Unlikely if you are an Orchard
// Core developer, but what if the person responsible for writing the tests is not? In the previous training section we
// discussed using a separate frontend server, with mention of technologies using Node.js. In that case the frontend
// developers may be more familiar with JavaScript so it makes sense to write and debug the tests in Node.js so they
// don't have to learn different tools and tech stacks just to create some UI tests.
[SuppressMessage("Usage", "xUnit1004:Test methods should not be skipped", Justification = "See note at the top of the file.")]
[Obsolete("See note at the top of the file.")]
public class JavaScriptTests : UITestBase
{
public JavaScriptTests(ITestOutputHelper testOutputHelper)
Expand All @@ -19,7 +26,7 @@ public JavaScriptTests(ITestOutputHelper testOutputHelper)
}

// Using this approach you only have to write minimal C# boilerplate, which you can see below.
[Fact]
[Fact(Skip = "See note at the top of the file.")]
public Task ExampleJavaScriptTestShouldWork() =>
ExecuteTestAfterSetupAsync(context =>
{
Expand All @@ -39,7 +46,6 @@ public Task ExampleJavaScriptTestShouldWork() =>
// information on how to start up test scripts from your GUI. It's an example of some tooling that can improve the
// test developer's workflow.
// If you want to try it out yourself, just remove the "Skip" parameter and run this test.
[SuppressMessage("Usage", "xUnit1004:Test methods should not be skipped", Justification = "Only a demo.")]
[Fact(Skip = "Use this to test to try out the interactive mode. This is not a real test you can run in CI.")]
public Task Sandbox() =>
OpenSandboxAfterSetupAsync(async context =>
Expand Down
11 changes: 10 additions & 1 deletion Lombiq.Tests.UI/Extensions/FrontendUITestContextExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ public static string GetDriverPath(this UITestContext context)
return Path.Join(service.DriverServicePath, service.DriverServiceExecutableName);
}

#region Methods related to executing UI tests written in JavaScript. All of this is obsolete.

private static (string WorkingDirectory, string[] Arguments) GetExecuteJavaScriptTestPaths(
this UITestContext context,
string scriptPath,
Expand Down Expand Up @@ -101,7 +103,7 @@ static string GetShorterPath(string basePath, string path)
}

// This uses a different casing of "JavaScript" to avoid breaking backwards compatibility.
[Obsolete($"Use {nameof(ExecuteJavaScriptTestAsync)} instead.")]
[Obsolete("Tests written in JavaScript are no longer supported.")]
public static Task ExecuteJavascriptTestAsync(
this UITestContext context,
string scriptPath,
Expand All @@ -115,6 +117,7 @@ public static Task ExecuteJavascriptTestAsync(
/// <param name="testOutputHelper">Needed to redirect the <c>node</c> output into the test logs.</param>
/// <param name="scriptPath">The JavaScript source file to execute using <c>node</c>.</param>
/// <param name="workingDirectory">The working directory where <c>node</c> is executed from.</param>
[Obsolete("Tests written in JavaScript are no longer supported.")]
public static async Task ExecuteJavaScriptTestAsync(
this UITestContext context,
ITestOutputHelper testOutputHelper,
Expand Down Expand Up @@ -155,6 +158,7 @@ await Cli.Wrap(command)
/// </summary>
/// <param name="scriptPath">The relative or absolute path pointing to the test script file.</param>
/// <param name="workingDirectory">The path where the test script should be executed, will be converted to absolute.</param>
[Obsolete("Tests written in JavaScript are no longer supported.")]
public static Task SwitchToInteractiveWithJavaScriptTestInfoAsync(
this UITestContext context,
string scriptPath,
Expand All @@ -178,6 +182,7 @@ public static Task SwitchToInteractiveWithJavaScriptTestInfoAsync(
/// relative path based on the temp directory to conserve path length because long paths can be a problem in some
/// operating systems.
/// </param>
[Obsolete("Tests written in JavaScript are no longer supported.")]
public static async Task SetupSeleniumAndExecuteJavaScriptTestAsync(
this UITestContext context,
ITestOutputHelper testOutputHelper,
Expand All @@ -193,6 +198,7 @@ public static async Task SetupSeleniumAndExecuteJavaScriptTestAsync(
/// Creates a blank Node.js project in the current test session's <see cref="DirectoryPaths.Temp"/> directory and
/// installs the provided NPM <paramref name="dependencies"/> using <c>pnpm</c>.
/// </summary>
[Obsolete("Tests written in JavaScript are no longer supported.")]
public static async Task SetupNodeDependenciesAsync(
this UITestContext context,
ITestOutputHelper helper,
Expand Down Expand Up @@ -220,6 +226,7 @@ await Cli.Wrap("pnpm")
/// Creates a blank Node.js project in the current test session's <see cref="DirectoryPaths.Temp"/> directory, then
/// installs <c>selenium-webdriver</c> and any additional NPM dependencies using <c>pnpm</c>.
/// </summary>
[Obsolete("Tests written in JavaScript are no longer supported.")]
public static Task SetupNodeSeleniumAsync(
this UITestContext context,
ITestOutputHelper helper,
Expand All @@ -246,4 +253,6 @@ public static Task SetupNodeSeleniumAsync(
workingDirectory,
[$"selenium-webdriver@{seleniumWebDriverVersion}", .. otherDependencies]);
}

#endregion
}
7 changes: 1 addition & 6 deletions Lombiq.Tests.UI/Lombiq.Tests.UI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
<PackageReference Include="Deque.AxeCore.Selenium" Version="4.11.0" />
<PackageReference Include="MailKit" Version="4.14.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0" />
<PackageReference Include="Microsoft.Web.LibraryManager.Build" Version="3.0.71" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.Testing" Version="8.10.0" />
<PackageReference Include="Microsoft.SqlServer.DACFx" Version="170.2.70" />
Expand Down Expand Up @@ -102,18 +103,13 @@
<ProjectReference Include="..\..\..\src\Libraries\Lombiq.HelpfulLibraries\Lombiq.HelpfulLibraries.Cli\Lombiq.HelpfulLibraries.Cli.csproj" />
<ProjectReference Include="..\..\..\src\Libraries\Lombiq.HelpfulLibraries\Lombiq.HelpfulLibraries.OrchardCore\Lombiq.HelpfulLibraries.OrchardCore.csproj" />
<ProjectReference Include="..\..\..\src\Libraries\Lombiq.HelpfulLibraries\Lombiq.HelpfulLibraries.Refit\Lombiq.HelpfulLibraries.Refit.csproj" />
<ProjectReference Include="..\..\..\src\Utilities\Lombiq.Npm.Targets\Lombiq.Npm.Targets.csproj" />
</ItemGroup>

<Import Condition="'$(NuGetBuild)' != 'true'" Project="..\..\..\src\Utilities\Lombiq.Npm.Targets\Lombiq.Npm.Targets.props" />
<Import Condition="'$(NuGetBuild)' != 'true'" Project="..\..\..\src\Utilities\Lombiq.Npm.Targets\Lombiq.Npm.Targets.targets" />

<ItemGroup Condition="'$(NuGetBuild)' == 'true'">
<PackageReference Include="Lombiq.Tests" Version="5.0.0" />
<PackageReference Include="Lombiq.HelpfulLibraries.Cli" Version="12.3.0" />
<PackageReference Include="Lombiq.HelpfulLibraries.OrchardCore" Version="12.3.0" />
<PackageReference Include="Lombiq.HelpfulLibraries.Refit" Version="12.3.0" />
<PackageReference Include="Lombiq.Npm.Targets" Version="1.5.0" />
</ItemGroup>

<!-- These are necessary for symbols NuGet packaging, otherwise Shouldly would prevent PDBs to be packaged, see:
Expand All @@ -128,7 +124,6 @@
<EmbeddedResource Include="node_modules\gremlins.js\dist\gremlins.min.js">
<Link>Resources\gremlins.min.js</Link>
</EmbeddedResource>
<None Remove="node_modules\**" />
<EmbeddedResource Include="Resources\gremlins-summoning-circle.js" />
</ItemGroup>
<ItemGroup>
Expand Down
11 changes: 11 additions & 0 deletions Lombiq.Tests.UI/libman.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"version": "3.0",
"defaultProvider": "jsdelivr",
"defaultDestination": "node_modules/[Name]",
"libraries": [
{
"library": "[email protected]",
"files": [ "dist/gremlins.min.js" ]
}
]
}
7 changes: 0 additions & 7 deletions Lombiq.Tests.UI/package.json

This file was deleted.

35 changes: 0 additions & 35 deletions Lombiq.Tests.UI/pnpm-lock.yaml

This file was deleted.

Loading