Skip to content
Merged
Show file tree
Hide file tree
Changes from 15 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
1 change: 1 addition & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
<PackageVersion Include="Microsoft.Azure.Cosmos" Version="3.32.1"/>
<PackageVersion Include="Microsoft.Azure.Kusto.Data" Version="12.2.8"/>
<PackageVersion Include="Microsoft.Data.SqlClient" Version="5.2.2"/>
<PackageVersion Include="Microsoft.Playwright" Version="1.55.0"/>
<PackageVersion Include="Milvus.Client" Version="2.2.2-preview.6"/>
<PackageVersion Include="MongoDB.Driver" Version="3.2.0"/>
<PackageVersion Include="MyCouch" Version="7.6.0"/>
Expand Down
14 changes: 14 additions & 0 deletions Testcontainers.sln
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.Oracle", "sr
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.Papercut", "src\Testcontainers.Papercut\Testcontainers.Papercut.csproj", "{B2608563-8EE4-49AA-A9A0-B1614486AEEF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.Playwright", "src\Testcontainers.Playwright\Testcontainers.Playwright.csproj", "{7F91A202-4F07-470D-881C-9A46A700DCA5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.PostgreSql", "src\Testcontainers.PostgreSql\Testcontainers.PostgreSql.csproj", "{8AB91636-9055-4900-A72A-7CFFACDFDBF0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.PubSub", "src\Testcontainers.PubSub\Testcontainers.PubSub.csproj", "{E6642255-667D-476B-B584-089AA5E6C0B1}"
Expand Down Expand Up @@ -230,6 +232,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.Platform.Lin
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.Platform.Windows.Tests", "tests\Testcontainers.Platform.Windows.Tests\Testcontainers.Platform.Windows.Tests.csproj", "{3E55CBE8-AFE8-426D-9470-49D63CD1051C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.Playwright.Tests", "tests\Testcontainers.Playwright.Tests\Testcontainers.Playwright.Tests.csproj", "{DE065875-1B7B-4E20-9332-C88C8437333D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.PostgreSql.Tests", "tests\Testcontainers.PostgreSql.Tests\Testcontainers.PostgreSql.Tests.csproj", "{56D0DCA5-567F-4B3B-8B79-CB108F8EB8A6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.PubSub.Tests", "tests\Testcontainers.PubSub.Tests\Testcontainers.PubSub.Tests.csproj", "{0F86BCE8-62E1-4BFC-AA84-63C7514C90AC}"
Expand Down Expand Up @@ -434,6 +438,10 @@ Global
{B2608563-8EE4-49AA-A9A0-B1614486AEEF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B2608563-8EE4-49AA-A9A0-B1614486AEEF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B2608563-8EE4-49AA-A9A0-B1614486AEEF}.Release|Any CPU.Build.0 = Release|Any CPU
{7F91A202-4F07-470D-881C-9A46A700DCA5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7F91A202-4F07-470D-881C-9A46A700DCA5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7F91A202-4F07-470D-881C-9A46A700DCA5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7F91A202-4F07-470D-881C-9A46A700DCA5}.Release|Any CPU.Build.0 = Release|Any CPU
{8AB91636-9055-4900-A72A-7CFFACDFDBF0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8AB91636-9055-4900-A72A-7CFFACDFDBF0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8AB91636-9055-4900-A72A-7CFFACDFDBF0}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -690,6 +698,10 @@ Global
{3E55CBE8-AFE8-426D-9470-49D63CD1051C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3E55CBE8-AFE8-426D-9470-49D63CD1051C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3E55CBE8-AFE8-426D-9470-49D63CD1051C}.Release|Any CPU.Build.0 = Release|Any CPU
{DE065875-1B7B-4E20-9332-C88C8437333D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DE065875-1B7B-4E20-9332-C88C8437333D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DE065875-1B7B-4E20-9332-C88C8437333D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DE065875-1B7B-4E20-9332-C88C8437333D}.Release|Any CPU.Build.0 = Release|Any CPU
{56D0DCA5-567F-4B3B-8B79-CB108F8EB8A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{56D0DCA5-567F-4B3B-8B79-CB108F8EB8A6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{56D0DCA5-567F-4B3B-8B79-CB108F8EB8A6}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -805,6 +817,7 @@ Global
{49051DBC-6B80-4412-8505-BC2764A877BD} = {673F23AE-7694-4BB9-ABD4-136D6C13634E}
{596EAFC1-0496-495C-B382-D57415FA456A} = {673F23AE-7694-4BB9-ABD4-136D6C13634E}
{B2608563-8EE4-49AA-A9A0-B1614486AEEF} = {673F23AE-7694-4BB9-ABD4-136D6C13634E}
{7F91A202-4F07-470D-881C-9A46A700DCA5} = {673F23AE-7694-4BB9-ABD4-136D6C13634E}
{8AB91636-9055-4900-A72A-7CFFACDFDBF0} = {673F23AE-7694-4BB9-ABD4-136D6C13634E}
{E6642255-667D-476B-B584-089AA5E6C0B1} = {673F23AE-7694-4BB9-ABD4-136D6C13634E}
{27D46863-65B9-4934-B3C8-2383B217A477} = {673F23AE-7694-4BB9-ABD4-136D6C13634E}
Expand Down Expand Up @@ -869,6 +882,7 @@ Global
{F03FA970-BE2B-4AE2-96FE-7E1F805CEA20} = {7164F1FB-7F24-444A-ACD2-2C329C2B3CCF}
{DA1D7ADE-452C-4369-83CC-56289176EACD} = {7164F1FB-7F24-444A-ACD2-2C329C2B3CCF}
{3E55CBE8-AFE8-426D-9470-49D63CD1051C} = {7164F1FB-7F24-444A-ACD2-2C329C2B3CCF}
{DE065875-1B7B-4E20-9332-C88C8437333D} = {7164F1FB-7F24-444A-ACD2-2C329C2B3CCF}
{56D0DCA5-567F-4B3B-8B79-CB108F8EB8A6} = {7164F1FB-7F24-444A-ACD2-2C329C2B3CCF}
{0F86BCE8-62E1-4BFC-AA84-63C7514C90AC} = {7164F1FB-7F24-444A-ACD2-2C329C2B3CCF}
{D05FCB31-793E-43E0-BD6C-077013AE9113} = {7164F1FB-7F24-444A-ACD2-2C329C2B3CCF}
Expand Down
1 change: 1 addition & 0 deletions src/Testcontainers.Playwright/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
root = true
56 changes: 56 additions & 0 deletions src/Testcontainers.Playwright/PlaywrightBrowser.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
namespace Testcontainers.Playwright;

/// <summary>
/// Playwright browser configuration.
/// </summary>
/// <remarks>
/// The browsers are standalone, pre-built Playwright versions from the
/// https://github.com/JacobLinCool/playwright-docker repository.
/// </remarks>
[PublicAPI]
public readonly struct PlaywrightBrowser
{
/// <summary>
/// Gets the Playwright standalone Chrome configuration.
/// </summary>
public static readonly PlaywrightBrowser Chrome = new PlaywrightBrowser("jacoblincool/playwright:chrome-server-1.55.1");

/// <summary>
/// Gets the Playwright standalone Chromium configuration.
/// </summary>
public static readonly PlaywrightBrowser Chromium = new PlaywrightBrowser("jacoblincool/playwright:chromium-server-1.55.1");

/// <summary>
/// Gets the Playwright standalone Firefox configuration.
/// </summary>
public static readonly PlaywrightBrowser Firefox = new PlaywrightBrowser("jacoblincool/playwright:firefox-server-1.55.1");

/// <summary>
/// Gets the Playwright standalone Edge configuration.
/// </summary>
public static readonly PlaywrightBrowser Edge = new PlaywrightBrowser("jacoblincool/playwright:msedge-server-1.55.1");

/// <summary>
/// Initializes a new instance of the <see cref="PlaywrightBrowser" /> struct.
/// </summary>
/// <param name="image">The Playwright standalone Docker image.</param>
public PlaywrightBrowser(string image)
: this(new DockerImage(image))
{
}

/// <summary>
/// Initializes a new instance of the <see cref="PlaywrightBrowser" /> struct.
/// </summary>
/// <param name="image">The Playwright standalone Docker image.</param>
public PlaywrightBrowser(IImage image)
{
Image = image;
}

/// <summary>
/// Gets the Playwright standalone Docker image.
/// </summary>
[NotNull]
public IImage Image { get; }
}
81 changes: 81 additions & 0 deletions src/Testcontainers.Playwright/PlaywrightBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
namespace Testcontainers.Playwright;

/// <inheritdoc cref="ContainerBuilder{TBuilderEntity, TContainerEntity, TConfigurationEntity}" />
[PublicAPI]
public sealed class PlaywrightBuilder : ContainerBuilder<PlaywrightBuilder, PlaywrightContainer, PlaywrightConfiguration>
{
public const string PlaywrightNetworkAlias = "standalone-container";

public const ushort PlaywrightPort = 53333;

/// <summary>
/// Initializes a new instance of the <see cref="PlaywrightBuilder" /> class.
/// </summary>
public PlaywrightBuilder()
: this(new PlaywrightConfiguration())
{
DockerResourceConfiguration = Init().DockerResourceConfiguration;
}

/// <summary>
/// Initializes a new instance of the <see cref="PlaywrightBuilder" /> class.
/// </summary>
/// <param name="resourceConfiguration">The Docker resource configuration.</param>
private PlaywrightBuilder(PlaywrightConfiguration resourceConfiguration)
: base(resourceConfiguration)
{
DockerResourceConfiguration = resourceConfiguration;
}

/// <inheritdoc />
protected override PlaywrightConfiguration DockerResourceConfiguration { get; }

/// <summary>
/// Sets the Playwright browser configuration.
/// </summary>
/// <remarks>
/// https://github.com/JacobLinCool/playwright-docker.
/// </remarks>
/// <param name="playwrightBrowser">The Playwright browser configuration.</param>
/// <returns>A configured instance of <see cref="PlaywrightBuilder" />.</returns>
public PlaywrightBuilder WithBrowser(PlaywrightBrowser playwrightBrowser)
{
return WithImage(playwrightBrowser.Image);
}

/// <inheritdoc />
public override PlaywrightContainer Build()
{
Validate();
return new PlaywrightContainer(DockerResourceConfiguration);
}

/// <inheritdoc />
protected override PlaywrightBuilder Init()
{
return base.Init()
.WithBrowser(PlaywrightBrowser.Chrome)
.WithNetwork(new NetworkBuilder().Build())
.WithNetworkAliases(PlaywrightNetworkAlias)
.WithPortBinding(PlaywrightPort, true)
.WithWaitStrategy(Wait.ForUnixContainer().UntilMessageIsLogged("ws://localhost:" + PlaywrightPort + "/playwright"));
}

/// <inheritdoc />
protected override PlaywrightBuilder Clone(IResourceConfiguration<CreateContainerParameters> resourceConfiguration)
{
return Merge(DockerResourceConfiguration, new PlaywrightConfiguration(resourceConfiguration));
}

/// <inheritdoc />
protected override PlaywrightBuilder Clone(IContainerConfiguration resourceConfiguration)
{
return Merge(DockerResourceConfiguration, new PlaywrightConfiguration(resourceConfiguration));
}

/// <inheritdoc />
protected override PlaywrightBuilder Merge(PlaywrightConfiguration oldValue, PlaywrightConfiguration newValue)
{
return new PlaywrightBuilder(new PlaywrightConfiguration(oldValue, newValue));
}
}
53 changes: 53 additions & 0 deletions src/Testcontainers.Playwright/PlaywrightConfiguration.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
namespace Testcontainers.Playwright;

/// <inheritdoc cref="ContainerConfiguration" />
[PublicAPI]
public sealed class PlaywrightConfiguration : ContainerConfiguration
{
/// <summary>
/// Initializes a new instance of the <see cref="PlaywrightConfiguration" /> class.
/// </summary>
public PlaywrightConfiguration()
{
}

/// <summary>
/// Initializes a new instance of the <see cref="PlaywrightConfiguration" /> class.
/// </summary>
/// <param name="resourceConfiguration">The Docker resource configuration.</param>
public PlaywrightConfiguration(IResourceConfiguration<CreateContainerParameters> resourceConfiguration)
: base(resourceConfiguration)
{
// Passes the configuration upwards to the base implementations to create an updated immutable copy.
}

/// <summary>
/// Initializes a new instance of the <see cref="PlaywrightConfiguration" /> class.
/// </summary>
/// <param name="resourceConfiguration">The Docker resource configuration.</param>
public PlaywrightConfiguration(IContainerConfiguration resourceConfiguration)
: base(resourceConfiguration)
{
// Passes the configuration upwards to the base implementations to create an updated immutable copy.
}

/// <summary>
/// Initializes a new instance of the <see cref="PlaywrightConfiguration" /> class.
/// </summary>
/// <param name="resourceConfiguration">The Docker resource configuration.</param>
public PlaywrightConfiguration(PlaywrightConfiguration resourceConfiguration)
: this(new PlaywrightConfiguration(), resourceConfiguration)
{
// Passes the configuration upwards to the base implementations to create an updated immutable copy.
}

/// <summary>
/// Initializes a new instance of the <see cref="PlaywrightConfiguration" /> class.
/// </summary>
/// <param name="oldValue">The old Docker resource configuration.</param>
/// <param name="newValue">The new Docker resource configuration.</param>
public PlaywrightConfiguration(PlaywrightConfiguration oldValue, PlaywrightConfiguration newValue)
: base(oldValue, newValue)
{
}
}
36 changes: 36 additions & 0 deletions src/Testcontainers.Playwright/PlaywrightContainer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
namespace Testcontainers.Playwright;

/// <inheritdoc cref="DockerContainer" />
[PublicAPI]
public sealed class PlaywrightContainer : DockerContainer
{
private readonly PlaywrightConfiguration _configuration;

/// <summary>
/// Initializes a new instance of the <see cref="PlaywrightContainer" /> class.
/// </summary>
/// <param name="configuration">The container configuration.</param>
public PlaywrightContainer(PlaywrightConfiguration configuration)
: base(configuration)
{
_configuration = configuration;
}

/// <summary>
/// Gets the Playwright connection string.
/// </summary>
/// <returns>The Playwright connection string.</returns>
public string GetConnectionString()
{
return new UriBuilder("ws", Hostname, GetMappedPublicPort(PlaywrightBuilder.PlaywrightPort), "/playwright").ToString();
}

/// <summary>
/// Gets the Playwright network.
/// </summary>
/// <returns>The Playwright network.</returns>
public INetwork GetNetwork()
{
return _configuration.Networks.Single();
}
}
12 changes: 12 additions & 0 deletions src/Testcontainers.Playwright/Testcontainers.Playwright.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0;net9.0;netstandard2.0;netstandard2.1</TargetFrameworks>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="JetBrains.Annotations" VersionOverride="2023.3.0" PrivateAssets="All"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="../Testcontainers/Testcontainers.csproj"/>
</ItemGroup>
</Project>
9 changes: 9 additions & 0 deletions src/Testcontainers.Playwright/Usings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
global using System;
global using System.Linq;
global using Docker.DotNet.Models;
global using DotNet.Testcontainers.Builders;
global using DotNet.Testcontainers.Configurations;
global using DotNet.Testcontainers.Containers;
global using DotNet.Testcontainers.Images;
global using DotNet.Testcontainers.Networks;
global using JetBrains.Annotations;
1 change: 1 addition & 0 deletions tests/Testcontainers.Playwright.Tests/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
root = true
1 change: 1 addition & 0 deletions tests/Testcontainers.Playwright.Tests/.runs-on
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ubuntu-24.04
Loading