Skip to content

Commit

Permalink
fixing page testing
Browse files Browse the repository at this point in the history
  • Loading branch information
joaofx committed Aug 24, 2023
1 parent 6ce11f3 commit a69bea6
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/Miru.PageTesting/PageTestFixture.cs
Expand Up @@ -18,15 +18,15 @@ public class PageTestFixture : PageBody, ITestFixture
private readonly UrlLookup _urlLookup;
private readonly PageTestingConfig _config;
private readonly WebDriver _driver;
private readonly IStorage _storage;
private readonly ITempStorage _storage;
private readonly PageBody _browser;

public PageTestFixture(
IMiruApp app,
UrlLookup urlLookup,
PageTestingConfig config,
WebDriver driver,
IStorage storage,
ITempStorage storage,
PageBody browser,
MiruNavigator navigator) : base(navigator)
{
Expand Down Expand Up @@ -120,7 +120,7 @@ public string FailureScreenshot()

public string Screenshot(string suffix)
{
var file = _storage.Path / "temp" / "screenshots" / $"{TestContext.CurrentContext.Test.MethodName}-{suffix}.png";
var file = _storage.Path / "screenshots" / $"{TestContext.CurrentContext.Test.MethodName}-{suffix}.png";

file.Dir().EnsureDirExist();

Expand All @@ -131,7 +131,7 @@ public string Screenshot(string suffix)

private string SaveHtml()
{
var file = _storage.Path / "temp" / "htmls" / $"{TestContext.CurrentContext.Test.MethodName}-Failure.html";
var file = _storage.Path / "htmls" / $"{TestContext.CurrentContext.Test.MethodName}-Failure.html";

file.Dir().EnsureDirExist();

Expand Down
3 changes: 2 additions & 1 deletion src/Miru/StorageRegistry.cs
Expand Up @@ -10,7 +10,8 @@ public static IServiceCollection AddStorages(this IServiceCollection services)
{
return services
.AddAppStorage<DefaultAppStorage>()
.AddAssetsStorage<AssetsStorage>();
.AddAssetsStorage<AssetsStorage>()
.AddSingleton<ITempStorage, DefaultTempStorage>();
}

public static IServiceCollection AddAssetsStorage<TStorage>(this IServiceCollection services)
Expand Down
9 changes: 9 additions & 0 deletions src/Miru/Storages/DefaultTempStorage.cs
@@ -0,0 +1,9 @@
namespace Miru.Storages;

public class DefaultTempStorage : LocalDiskStorage, ITempStorage
{
public DefaultTempStorage(MiruSolution solution) : base(solution)
{
Root = StorageDir / "temp";
}
}
1 change: 0 additions & 1 deletion src/Miru/Storages/IStorage.cs
Expand Up @@ -2,7 +2,6 @@
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Miru.Core;

namespace Miru.Storages;

Expand Down
5 changes: 5 additions & 0 deletions src/Miru/Storages/ITempStorage.cs
@@ -0,0 +1,5 @@
namespace Miru.Storages;

public interface ITempStorage : IStorage
{
}

0 comments on commit a69bea6

Please sign in to comment.