fix(trace): remote SaveAsAsync() with fileName only (#2744)

This commit is contained in:
Max Schmitt
2023-11-04 12:09:24 +01:00
committed by GitHub
parent 530809455f
commit 211fb9ec5f
2 changed files with 32 additions and 1 deletions
@@ -421,6 +421,37 @@ public class BrowserTypeConnectTests : PlaywrightTestEx
Assert.AreEqual(1, Directory.GetFiles(Path.Join(tempDirectory.Path, "resources"), "*.txt").Length);
}
[PlaywrightTest("browsertype-connect.spec.ts", "should record trace with no directory name")]
public async Task ShouldRecordContextTraceWithNoDirectoryName()
{
using var tempDirectory = new TempDirectory();
var tracePath = "trace.zip";
var browser = await BrowserType.ConnectAsync(_remoteServer.WSEndpoint);
var context = await browser.NewContextAsync();
var page = await context.NewPageAsync();
await context.Tracing.StartAsync(new() { Sources = true });
await page.GotoAsync(Server.EmptyPage);
await page.SetContentAsync("<button>Click</button>");
await page.ClickAsync("button");
try
{
await context.Tracing.StopAsync(new() { Path = tracePath });
await browser.CloseAsync();
Assert.That(tracePath, Does.Exist);
ZipFile.ExtractToDirectory(tracePath, tempDirectory.Path);
Assert.That(tempDirectory.Path + "/trace.trace", Does.Exist);
Assert.That(tempDirectory.Path + "/trace.network", Does.Exist);
Assert.AreEqual(1, Directory.GetFiles(Path.Join(tempDirectory.Path, "resources"), "*.txt").Length);
}
finally
{
File.Delete(tracePath);
}
}
[PlaywrightTest("browsertype-connect.spec.ts", "should upload large file")]
[Timeout(TestConstants.SlowTestTimeout)]
public async Task ShouldUploadLargeFile()
+1 -1
View File
@@ -67,7 +67,7 @@ internal class Artifact : ChannelOwnerBase, IChannelOwner<Artifact>
await _channel.SaveAsAsync(path).ConfigureAwait(false);
return;
}
System.IO.Directory.CreateDirectory(Path.GetDirectoryName(path));
System.IO.Directory.CreateDirectory(Path.GetDirectoryName(Path.GetFullPath(path)));
var stream = await _channel.SaveAsStreamAsync().ConfigureAwait(false);
await using (stream.ConfigureAwait(false))
{