diff --git a/src/PlaywrightSharp.Nunit/TestExpectations/TestExpectations.local.json b/src/PlaywrightSharp.Nunit/TestExpectations/TestExpectations.local.json index 785aa09a4..42a60d767 100644 --- a/src/PlaywrightSharp.Nunit/TestExpectations/TestExpectations.local.json +++ b/src/PlaywrightSharp.Nunit/TestExpectations/TestExpectations.local.json @@ -42,79 +42,13 @@ "expectations": ["FAIL"] }, { - "testIdPattern": "[page-wait-for-request.spec.ts] *", + "testIdPattern": "[page-goto.spec.ts] should work when navigating to 404", "platforms": ["darwin", "linux", "win32"], "parameters": [], "expectations": ["FAIL"] }, { - "testIdPattern": "[page-wait-for-load-state.ts] *", - "platforms": ["darwin", "linux", "win32"], - "parameters": [], - "expectations": ["FAIL"] - }, - { - "testIdPattern": "[page-wait-for-response.spec.ts] *", - "platforms": ["darwin", "linux", "win32"], - "parameters": [], - "expectations": ["FAIL"] - }, - { - "testIdPattern": "[page-goto.spec.ts] *", - "platforms": ["darwin", "linux", "win32"], - "parameters": [], - "expectations": ["FAIL"] - }, - { - "testIdPattern": "[beforeunload.spec.ts] *", - "platforms": ["darwin", "linux", "win32"], - "parameters": [], - "expectations": ["FAIL"] - }, - { - "testIdPattern": "[browsertype-basic.spec.ts] *", - "platforms": ["darwin", "linux", "win32"], - "parameters": [], - "expectations": ["FAIL"] - }, - { - "testIdPattern": "[page-accessibility.spec.ts] *", - "platforms": ["darwin", "linux", "win32"], - "parameters": [], - "expectations": ["FAIL"] - }, - { - "testIdPattern": "[page-basic.spec.ts] *", - "platforms": ["darwin", "linux", "win32"], - "parameters": [], - "expectations": ["FAIL"] - }, - { - "testIdPattern": "[page-event-network.spec.ts] *", - "platforms": ["darwin", "linux", "win32"], - "parameters": [], - "expectations": ["FAIL"] - }, - { - "testIdPattern": "[page-network-request.spec.ts] *", - "platforms": ["darwin", "linux", "win32"], - "parameters": [], - "expectations": ["FAIL"] - }, - { - "testIdPattern": "[page-wait-for-selector-2.spec.ts] *", - "platforms": ["darwin", "linux", "win32"], - "parameters": [], - "expectations": ["FAIL"] - }, - { - "testIdPattern": "[tap.spec.ts] *", - "platforms": ["darwin", "linux", "win32"], - "parameters": [], - "expectations": ["FAIL"] - }, - { - "testIdPattern": "[proxy.spec.ts] should exclude patterns", + "testIdPattern": "[page-event-network.spec.ts] Page.Events.RequestFailed", "platforms": ["darwin", "linux", "win32"], "parameters": [], "expectations": ["FAIL"] @@ -167,6 +101,18 @@ "parameters": ["firefox"], "expectations": ["FAIL"] }, + { + "testIdPattern": "[page-autowaiting-basic.spec.ts] should work with noWaitAfter: true", + "platforms": ["darwin", "linux", "win32"], + "parameters": ["firefox"], + "expectations": ["FAIL"] + }, + { + "testIdPattern": "[beforeunload.spec.ts] *", + "platforms": ["darwin", "linux", "win32"], + "parameters": ["headful"], + "expectations": ["FAIL"] + }, { "testIdPattern": "[browsercontext-credentials.spec.ts] *", "platforms": ["darwin", "linux", "win32"], @@ -305,12 +251,6 @@ "parameters": ["headful"], "expectations": ["FAIL"] }, - { - "testIdPattern": "[page-autowaiting-basic.spec.ts] should work with noWaitAfter: true", - "platforms": ["darwin", "linux", "win32"], - "parameters": ["firefox"], - "expectations": ["FAIL"] - }, { "testIdPattern": "[page-add-init-script.spec.ts] should work after a cross origin navigation", "platforms": ["darwin", "linux", "win32"], diff --git a/src/PlaywrightSharp.Tests/BrowserTypeBasicTests.cs b/src/PlaywrightSharp.Tests/BrowserTypeBasicTests.cs index ddf9a637e..68fbf7160 100644 --- a/src/PlaywrightSharp.Tests/BrowserTypeBasicTests.cs +++ b/src/PlaywrightSharp.Tests/BrowserTypeBasicTests.cs @@ -14,13 +14,6 @@ public class BrowserTypeBasicTests : PlaywrightSharpBaseTest [PlaywrightTest("browsertype-basic.spec.ts", "browserType.name should work")] [Test, Timeout(TestConstants.DefaultTestTimeout)] public void BrowserTypeNameShouldWork() - => Assert.That(BrowserType.Name, Is.EqualTo( - TestConstants.Product switch - { - TestConstants.WebkitProduct => "webkit", - TestConstants.FirefoxProduct => "firefox", - TestConstants.ChromiumProduct => "chromium", - _ => null - })); + => Assert.That(BrowserType.Name, Is.EqualTo(TestConstants.Product.ToLowerInvariant())); } } diff --git a/src/PlaywrightSharp.Tests/PageAutoWaitingBasicTests.cs b/src/PlaywrightSharp.Tests/PageAutoWaitingBasicTests.cs index 97bce3713..b623331fa 100644 --- a/src/PlaywrightSharp.Tests/PageAutoWaitingBasicTests.cs +++ b/src/PlaywrightSharp.Tests/PageAutoWaitingBasicTests.cs @@ -192,10 +192,9 @@ await TaskUtils.WhenAll( [Test, Timeout(TestConstants.DefaultTestTimeout)] public async Task ShouldWorkWithNoWaitAfterTrue() { - var messages = new List(); Server.SetRoute("/empty.html", _ => Task.CompletedTask); - await Page.SetContentAsync($@"empty.html"); + await Page.SetContentAsync($@"empty.html"); await Page.ClickAsync("a", noWaitAfter: true); } diff --git a/src/PlaywrightSharp.Tests/PageBasicTests.cs b/src/PlaywrightSharp.Tests/PageBasicTests.cs index 3f1980afa..e748f8814 100644 --- a/src/PlaywrightSharp.Tests/PageBasicTests.cs +++ b/src/PlaywrightSharp.Tests/PageBasicTests.cs @@ -19,7 +19,7 @@ public async Task ShouldRejectAllPromisesWhenPageIsClosed() newPage.CloseAsync() )); Assert.That(exception, Is.InstanceOf()); - Assert.That(exception.Message, Does.Contain("Protocol error")); + Assert.That(exception.Message, Does.Contain("Target closed")); } [PlaywrightTest("page-basic.spec.ts", "async stacks should work")] diff --git a/src/PlaywrightSharp.Tests/PageNetworkRequestTest.cs b/src/PlaywrightSharp.Tests/PageNetworkRequestTest.cs index 51c2a0d56..2520b25f8 100644 --- a/src/PlaywrightSharp.Tests/PageNetworkRequestTest.cs +++ b/src/PlaywrightSharp.Tests/PageNetworkRequestTest.cs @@ -55,7 +55,7 @@ public async Task ShouldReturnHeaders() { var response = await Page.GoToAsync(TestConstants.EmptyPage); - string expected = TestConstants.Product switch + string expected = TestConstants.Product.ToUpperInvariant() switch { TestConstants.ChromiumProduct => "Chrome", TestConstants.FirefoxProduct => "Firefox", diff --git a/src/PlaywrightSharp.Tests/ProxyTests.cs b/src/PlaywrightSharp.Tests/ProxyTests.cs index d2e410770..41da95cfb 100644 --- a/src/PlaywrightSharp.Tests/ProxyTests.cs +++ b/src/PlaywrightSharp.Tests/ProxyTests.cs @@ -62,24 +62,54 @@ public async Task ShouldAuthenticate() [Test, Timeout(TestConstants.DefaultTestTimeout)] public async Task ShouldExcludePatterns() { + // FYI: using long and weird domain names to avoid ATT DNS hijacking + // that resolves everything to some weird search results page. + // + // @see https://gist.github.com/CollinChaffin/24f6c9652efb3d6d5ef2f5502720ef00 Server.SetRoute("/target.html", ctx => ctx.Response.WriteAsync("Served by the proxy")); var proxy = new Proxy { Server = $"localhost:{TestConstants.Port}", - Bypass = "non-existent1.com, .non-existent2.com, .zone", + Bypass = "1.non.existent.domain.for.the.test, 2.non.existent.domain.for.the.test, .another.test", }; await using var browser = await BrowserType.LaunchAsync(proxy: proxy); - var page = await browser.NewPageAsync(); - await page.GoToAsync("http://non-existent.com/target.html"); + { + var page = await browser.NewPageAsync(); + await page.GoToAsync("http://0.non.existent.domain.for.the.test/target.html"); + Assert.That(await page.TitleAsync(), Is.EqualTo("Served by the proxy")); + await page.CloseAsync(); + } - Assert.That(await page.TitleAsync(), Is.EqualTo("Served by the proxy")); + { + var page = await browser.NewPageAsync(); + var error = Assert.CatchAsync(() => page.GoToAsync("http://1.non.existent.domain.for.the.test/target.html")); + Assert.That(error.Message, Is.Not.Empty); + await page.CloseAsync(); + } - Assert.CatchAsync(() => page.GoToAsync("http://non-existent1.com/target.html")); - Assert.CatchAsync(() => page.GoToAsync("http://sub.non-existent2.com/target.html")); - Assert.CatchAsync(() => page.GoToAsync("http://foo.zone/target.html")); + { + var page = await browser.NewPageAsync(); + var error = Assert.CatchAsync(() => page.GoToAsync("http://2.non.existent.domain.for.the.test/target.html")); + Assert.That(error.Message, Is.Not.Empty); + await page.CloseAsync(); + } + + { + var page = await browser.NewPageAsync(); + var error = Assert.CatchAsync(() => page.GoToAsync("http://foo.is.the.another.test/target.html")); + Assert.That(error.Message, Is.Not.Empty); + await page.CloseAsync(); + } + + { + var page = await browser.NewPageAsync(); + await page.GoToAsync("http://3.non.existent.domain.for.the.test/target.html"); + Assert.That(await page.TitleAsync(), Is.EqualTo("Served by the proxy")); + await page.CloseAsync(); + } } } } diff --git a/src/PlaywrightSharp.Tests/SelectorsRegisterTests.cs b/src/PlaywrightSharp.Tests/SelectorsRegisterTests.cs index 3a8da95d4..c566d4f24 100644 --- a/src/PlaywrightSharp.Tests/SelectorsRegisterTests.cs +++ b/src/PlaywrightSharp.Tests/SelectorsRegisterTests.cs @@ -86,9 +86,6 @@ public async Task ShouldHandleErrors() Assert.That(exception.Message, Does.Contain("Unknown engine \"neverregister\" while parsing selector neverregister=ignored")); const string createDummySelector = @"({ - create(root, target) { - return target.nodeName; - }, query(root, selector) { return root.querySelector('dummy'); }, diff --git a/src/PlaywrightSharp.Tests/TapTests.cs b/src/PlaywrightSharp.Tests/TapTests.cs index 70e3c8f64..007dee8d8 100644 --- a/src/PlaywrightSharp.Tests/TapTests.cs +++ b/src/PlaywrightSharp.Tests/TapTests.cs @@ -33,8 +33,10 @@ namespace PlaywrightSharp.Tests public sealed class TapTests : PlaywrightSharpBrowserContextBaseTest { [SetUp] - public async Task TapSetUp() + public new async Task ContextSetUp() { + Context = await Browser.NewContextAsync(new BrowserContextOptions { HasTouch = true }).ConfigureAwait(false); + Context.DefaultTimeout = TestConstants.DefaultContextTimeout; Page = await Context.NewPageAsync().ConfigureAwait(false); } diff --git a/src/PlaywrightSharp.Tests/TestConstants.cs b/src/PlaywrightSharp.Tests/TestConstants.cs index a94df3561..4804ab2cb 100644 --- a/src/PlaywrightSharp.Tests/TestConstants.cs +++ b/src/PlaywrightSharp.Tests/TestConstants.cs @@ -112,9 +112,9 @@ internal static Task LaunchDefaultHeadful( public static string FileToUpload => TestUtils.GetWebServerFile("file-to-upload.txt"); internal static ILoggerFactory LoggerFactory { get; set; } = LoggerFactory = new LoggerFactory(); - internal static readonly bool IsWebKit = Product.Equals(WebkitProduct); - internal static readonly bool IsFirefox = Product.Equals(FirefoxProduct); - internal static readonly bool IsChromium = Product.Equals(ChromiumProduct); + internal static readonly bool IsWebKit = Product.Equals(WebkitProduct, StringComparison.OrdinalIgnoreCase); + internal static readonly bool IsFirefox = Product.Equals(FirefoxProduct, StringComparison.OrdinalIgnoreCase); + internal static readonly bool IsChromium = Product.Equals(ChromiumProduct, StringComparison.OrdinalIgnoreCase); internal static readonly bool IsMacOSX = RuntimeInformation.IsOSPlatform(OSPlatform.OSX); internal static readonly bool IsWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);