Skip to content

Commit

Permalink
Fix wrong test names and tooling (#1731)
Browse files Browse the repository at this point in the history
  • Loading branch information
kblok committed Jul 3, 2021
1 parent fcb435f commit 713b34d
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 52 deletions.
4 changes: 2 additions & 2 deletions lib/PuppeteerSharp.Tests/NavigationTests/PageGoBackTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public PageGoBackTests(ITestOutputHelper output) : base(output)
}

//TODO: This is working in puppeteer. I don't know why is hanging here.
[PuppeteerTest("page.spec.ts", "Page.goBack", "should work")]
[PuppeteerTest("navigation.spec.ts", "Page.goBack", "should work")]
[SkipBrowserFact(skipFirefox: true)]
public async Task ShouldWork()
{
Expand All @@ -33,7 +33,7 @@ public async Task ShouldWork()
Assert.Null(response);
}

[PuppeteerTest("page.spec.ts", "Page.goBack", "should work with HistoryAPI")]
[PuppeteerTest("navigation.spec.ts", "Page.goBack", "should work with HistoryAPI")]
[SkipBrowserFact(skipFirefox: true)]
public async Task ShouldWorkWithHistoryAPI()
{
Expand Down
60 changes: 30 additions & 30 deletions lib/PuppeteerSharp.Tests/NavigationTests/PageGotoTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ public PageGotoTests(ITestOutputHelper output) : base(output)
{
}

[PuppeteerTest("page.spec.ts", "Page.goto", "should work")]
[PuppeteerTest("navigation.spec.ts", "Page.goto", "should work")]
[Fact(Timeout = TestConstants.DefaultTestTimeout)]
public async Task ShouldWork()
{
await Page.GoToAsync(TestConstants.EmptyPage);
Assert.Equal(TestConstants.EmptyPage, Page.Url);
}

[PuppeteerTest("page.spec.ts", "Page.goto", "should work with anchor navigation")]
[PuppeteerTest("navigation.spec.ts", "Page.goto", "should work with anchor navigation")]
[SkipBrowserFact(skipFirefox: true)]
public async Task ShouldWorkWithAnchorNavigation()
{
Expand All @@ -39,7 +39,7 @@ public async Task ShouldWorkWithAnchorNavigation()
Assert.Equal($"{TestConstants.EmptyPage}#bar", Page.Url);
}

[PuppeteerTest("page.spec.ts", "Page.goto", "should work with redirects")]
[PuppeteerTest("navigation.spec.ts", "Page.goto", "should work with redirects")]
[Fact(Timeout = TestConstants.DefaultTestTimeout)]
public async Task ShouldWorkWithRedirects()
{
Expand All @@ -50,23 +50,23 @@ public async Task ShouldWorkWithRedirects()
await Page.GoToAsync(TestConstants.EmptyPage);
}

[PuppeteerTest("page.spec.ts", "Page.goto", "should navigate to about:blank")]
[PuppeteerTest("navigation.spec.ts", "Page.goto", "should navigate to about:blank")]
[Fact(Timeout = TestConstants.DefaultTestTimeout)]
public async Task ShouldNavigateToAboutBlank()
{
var response = await Page.GoToAsync(TestConstants.AboutBlank);
Assert.Null(response);
}

[PuppeteerTest("page.spec.ts", "Page.goto", "should return response when page changes its URL after load")]
[PuppeteerTest("navigation.spec.ts", "Page.goto", "should return response when page changes its URL after load")]
[Fact(Timeout = TestConstants.DefaultTestTimeout)]
public async Task ShouldReturnResponseWhenPageChangesItsURLAfterLoad()
{
var response = await Page.GoToAsync(TestConstants.ServerUrl + "/historyapi.html");
Assert.Equal(HttpStatusCode.OK, response.Status);
}

[PuppeteerTest("page.spec.ts", "Page.goto", "should work with subframes return 204")]
[PuppeteerTest("navigation.spec.ts", "Page.goto", "should work with subframes return 204")]
[SkipBrowserFact(skipFirefox: true)]
public async Task ShouldWorkWithSubframesReturn204()
{
Expand All @@ -78,7 +78,7 @@ public async Task ShouldWorkWithSubframesReturn204()
await Page.GoToAsync(TestConstants.ServerUrl + "/frames/one-frame.html");
}

[PuppeteerTest("page.spec.ts", "Page.goto", "should fail when server returns 204")]
[PuppeteerTest("navigation.spec.ts", "Page.goto", "should fail when server returns 204")]
[SkipBrowserFact(skipFirefox: true)]
public async Task ShouldFailWhenServerReturns204()
{
Expand All @@ -100,7 +100,7 @@ public async Task ShouldFailWhenServerReturns204()
}
}

[PuppeteerTest("page.spec.ts", "Page.goto", "should navigate to empty page with domcontentloaded")]
[PuppeteerTest("navigation.spec.ts", "Page.goto", "should navigate to empty page with domcontentloaded")]
[Fact(Timeout = TestConstants.DefaultTestTimeout)]
public async Task ShouldNavigateToEmptyPageWithDOMContentLoaded()
{
Expand All @@ -112,7 +112,7 @@ public async Task ShouldNavigateToEmptyPageWithDOMContentLoaded()
Assert.Null(response.SecurityDetails);
}

[PuppeteerTest("page.spec.ts", "Page.goto", "should work when page calls history API in beforeunload")]
[PuppeteerTest("navigation.spec.ts", "Page.goto", "should work when page calls history API in beforeunload")]
[Fact(Timeout = TestConstants.DefaultTestTimeout)]
public async Task ShouldWorkWhenPageCallsHistoryAPIInBeforeunload()
{
Expand All @@ -125,23 +125,23 @@ public async Task ShouldWorkWhenPageCallsHistoryAPIInBeforeunload()
Assert.Equal(HttpStatusCode.OK, response.Status);
}

[PuppeteerTest("page.spec.ts", "Page.goto", "should navigate to empty page with networkidle0")]
[PuppeteerTest("navigation.spec.ts", "Page.goto", "should navigate to empty page with networkidle0")]
[SkipBrowserFact(skipFirefox: true)]
public async Task ShouldNavigateToEmptyPageWithNetworkidle0()
{
var response = await Page.GoToAsync(TestConstants.EmptyPage, new NavigationOptions { WaitUntil = new[] { WaitUntilNavigation.Networkidle0 } });
Assert.Equal(HttpStatusCode.OK, response.Status);
}

[PuppeteerTest("page.spec.ts", "Page.goto", "should navigate to empty page with networkidle2")]
[PuppeteerTest("navigation.spec.ts", "Page.goto", "should navigate to empty page with networkidle2")]
[SkipBrowserFact(skipFirefox: true)]
public async Task ShouldNavigateToEmptyPageWithNetworkidle2()
{
var response = await Page.GoToAsync(TestConstants.EmptyPage, new NavigationOptions { WaitUntil = new[] { WaitUntilNavigation.Networkidle2 } });
Assert.Equal(HttpStatusCode.OK, response.Status);
}

[PuppeteerTest("page.spec.ts", "Page.goto", "should fail when navigating to bad url")]
[PuppeteerTest("navigation.spec.ts", "Page.goto", "should fail when navigating to bad url")]
[SkipBrowserFact(skipFirefox: true)]
public async Task ShouldFailWhenNavigatingToBadUrl()
{
Expand All @@ -157,7 +157,7 @@ public async Task ShouldFailWhenNavigatingToBadUrl()
}
}

[PuppeteerTest("page.spec.ts", "Page.goto", "should fail when navigating to bad SSL")]
[PuppeteerTest("navigation.spec.ts", "Page.goto", "should fail when navigating to bad SSL")]
[SkipBrowserFact(skipFirefox: true)]
public async Task ShouldFailWhenNavigatingToBadSSL()
{
Expand All @@ -177,7 +177,7 @@ public async Task ShouldFailWhenNavigatingToBadSSL()
}
}

[PuppeteerTest("page.spec.ts", "Page.goto", "should fail when navigating to bad SSL after redirects")]
[PuppeteerTest("navigation.spec.ts", "Page.goto", "should fail when navigating to bad SSL after redirects")]
[Fact(Timeout = TestConstants.DefaultTestTimeout)]
public async Task ShouldFailWhenNavigatingToBadSSLAfterRedirects()
{
Expand All @@ -193,7 +193,7 @@ public async Task ShouldFailWhenNavigatingToBadSSLAfterRedirects()
}
}

[PuppeteerTest("page.spec.ts", "Page.goto", "should fail when main resources failed to load")]
[PuppeteerTest("navigation.spec.ts", "Page.goto", "should fail when main resources failed to load")]
[Fact(Timeout = TestConstants.DefaultTestTimeout)]
public async Task ShouldFailWhenMainResourcesFailedToLoad()
{
Expand All @@ -209,7 +209,7 @@ public async Task ShouldFailWhenMainResourcesFailedToLoad()
}
}

[PuppeteerTest("page.spec.ts", "Page.goto", "should fail when exceeding maximum navigation timeout")]
[PuppeteerTest("navigation.spec.ts", "Page.goto", "should fail when exceeding maximum navigation timeout")]
[Fact(Timeout = TestConstants.DefaultTestTimeout)]
public async Task ShouldFailWhenExceedingMaximumNavigationTimeout()
{
Expand All @@ -220,7 +220,7 @@ public async Task ShouldFailWhenExceedingMaximumNavigationTimeout()
Assert.Contains("Timeout of 1 ms exceeded", exception.Message);
}

[PuppeteerTest("page.spec.ts", "Page.goto", "should fail when exceeding default maximum navigation timeout")]
[PuppeteerTest("navigation.spec.ts", "Page.goto", "should fail when exceeding default maximum navigation timeout")]
[Fact(Timeout = TestConstants.DefaultTestTimeout)]
public async Task ShouldFailWhenExceedingDefaultMaximumNavigationTimeout()
{
Expand All @@ -231,7 +231,7 @@ public async Task ShouldFailWhenExceedingDefaultMaximumNavigationTimeout()
Assert.Contains("Timeout of 1 ms exceeded", exception.Message);
}

[PuppeteerTest("page.spec.ts", "Page.goto", "should fail when exceeding default maximum timeout")]
[PuppeteerTest("navigation.spec.ts", "Page.goto", "should fail when exceeding default maximum timeout")]
[Fact(Timeout = TestConstants.DefaultTestTimeout)]
public async Task ShouldFailWhenExceedingDefaultMaximumTimeout()
{
Expand All @@ -242,7 +242,7 @@ public async Task ShouldFailWhenExceedingDefaultMaximumTimeout()
Assert.Contains("Timeout of 1 ms exceeded", exception.Message);
}

[PuppeteerTest("page.spec.ts", "Page.goto", "should prioritize default navigation timeout over default timeout")]
[PuppeteerTest("navigation.spec.ts", "Page.goto", "should prioritize default navigation timeout over default timeout")]
[Fact(Timeout = TestConstants.DefaultTestTimeout)]
public async Task ShouldPrioritizeDefaultNavigationTimeoutOverDefaultTimeout()
{
Expand All @@ -254,7 +254,7 @@ public async Task ShouldPrioritizeDefaultNavigationTimeoutOverDefaultTimeout()
Assert.Contains("Timeout of 1 ms exceeded", exception.Message);
}

[PuppeteerTest("page.spec.ts", "Page.goto", "should disable timeout when its set to 0")]
[PuppeteerTest("navigation.spec.ts", "Page.goto", "should disable timeout when its set to 0")]
[Fact(Timeout = TestConstants.DefaultTestTimeout)]
public async Task ShouldDisableTimeoutWhenItsSetTo0()
{
Expand All @@ -270,31 +270,31 @@ void OnLoad(object sender, EventArgs e)
Assert.True(loaded);
}

[PuppeteerTest("page.spec.ts", "Page.goto", "should work when navigating to valid url")]
[PuppeteerTest("navigation.spec.ts", "Page.goto", "should work when navigating to valid url")]
[Fact(Timeout = TestConstants.DefaultTestTimeout)]
public async Task ShouldWorkWhenNavigatingToValidUrl()
{
var response = await Page.GoToAsync(TestConstants.EmptyPage);
Assert.Equal(HttpStatusCode.OK, response.Status);
}

[PuppeteerTest("page.spec.ts", "Page.goto", "should work when navigating to data url")]
[PuppeteerTest("navigation.spec.ts", "Page.goto", "should work when navigating to data url")]
[SkipBrowserFact(skipFirefox: true)]
public async Task ShouldWorkWhenNavigatingToDataUrl()
{
var response = await Page.GoToAsync("data:text/html,hello");
Assert.Equal(HttpStatusCode.OK, response.Status);
}

[PuppeteerTest("page.spec.ts", "Page.goto", "should work when navigating to 404")]
[PuppeteerTest("navigation.spec.ts", "Page.goto", "should work when navigating to 404")]
[Fact(Timeout = TestConstants.DefaultTestTimeout)]
public async Task ShouldWorkWhenNavigatingTo404()
{
var response = await Page.GoToAsync(TestConstants.ServerUrl + "/not-found");
Assert.Equal(HttpStatusCode.NotFound, response.Status);
}

[PuppeteerTest("page.spec.ts", "Page.goto", "should return last response in redirect chain")]
[PuppeteerTest("navigation.spec.ts", "Page.goto", "should return last response in redirect chain")]
[Fact(Timeout = TestConstants.DefaultTestTimeout)]
public async Task ShouldReturnLastResponseInRedirectChain()
{
Expand All @@ -307,7 +307,7 @@ public async Task ShouldReturnLastResponseInRedirectChain()
Assert.Equal(TestConstants.EmptyPage, response.Url);
}

[PuppeteerTest("page.spec.ts", "Page.goto", "should wait for network idle to succeed navigation")]
[PuppeteerTest("navigation.spec.ts", "Page.goto", "should wait for network idle to succeed navigation")]
[SkipBrowserFact(skipFirefox: true)]
public async Task ShouldWaitForNetworkIdleToSucceedNavigation()
{
Expand Down Expand Up @@ -397,7 +397,7 @@ void WaitPageLoad(object sender, EventArgs e)
Assert.Equal(HttpStatusCode.OK, navigationResponse.Status);
}

[PuppeteerTest("page.spec.ts", "Page.goto", "should navigate to dataURL and fire dataURL requests")]
[PuppeteerTest("navigation.spec.ts", "Page.goto", "should navigate to dataURL and fire dataURL requests")]
[SkipBrowserFact(skipFirefox: true)]
public async Task ShouldNavigateToDataURLAndFireDataURLRequests()
{
Expand All @@ -416,7 +416,7 @@ public async Task ShouldNavigateToDataURLAndFireDataURLRequests()
Assert.Equal(dataUrl, requests[0].Url);
}

[PuppeteerTest("page.spec.ts", "Page.goto", "should navigate to URL with hash and fire requests without hash")]
[PuppeteerTest("navigation.spec.ts", "Page.goto", "should navigate to URL with hash and fire requests without hash")]
[SkipBrowserFact(skipFirefox: true)]
public async Task ShouldNavigateToURLWithHashAndFireRequestsWithoutHash()
{
Expand All @@ -435,7 +435,7 @@ public async Task ShouldNavigateToURLWithHashAndFireRequestsWithoutHash()
Assert.Equal(TestConstants.EmptyPage, requests[0].Url);
}

[PuppeteerTest("page.spec.ts", "Page.goto", "should work with self requesting page")]
[PuppeteerTest("navigation.spec.ts", "Page.goto", "should work with self requesting page")]
[Fact(Timeout = TestConstants.DefaultTestTimeout)]
public async Task ShouldWorkWithSelfRequestingPage()
{
Expand All @@ -444,7 +444,7 @@ public async Task ShouldWorkWithSelfRequestingPage()
Assert.Contains("self-request.html", response.Url);
}

[PuppeteerTest("page.spec.ts", "Page.goto", "should fail when navigating and show the url at the error message")]
[PuppeteerTest("navigation.spec.ts", "Page.goto", "should fail when navigating and show the url at the error message")]
[Fact(Timeout = TestConstants.DefaultTestTimeout)]
public async Task ShouldFailWhenNavigatingAndShowTheUrlAtTheErrorMessage()
{
Expand All @@ -454,7 +454,7 @@ public async Task ShouldFailWhenNavigatingAndShowTheUrlAtTheErrorMessage()
Assert.Contains(url, exception.Url);
}

[PuppeteerTest("page.spec.ts", "Page.goto", "should send referer")]
[PuppeteerTest("navigation.spec.ts", "Page.goto", "should send referer")]
[SkipBrowserFact(skipFirefox: true)]
public async Task ShouldSendReferer()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using Xunit;
using Xunit.Abstractions;

namespace PuppeteerSharp.Tests.NetworkTests
namespace PuppeteerSharp.Tests.RequestInterceptionTests
{
[Collection(TestConstants.TestFixtureCollectionName)]
public class RequestRespondTests : PuppeteerPageBaseTest
Expand All @@ -16,7 +16,7 @@ public RequestRespondTests(ITestOutputHelper output) : base(output)
{
}

[PuppeteerTest("network.spec.ts", "Request.respond", "should work")]
[PuppeteerTest("requestinterception.spec.ts", "Request.respond", "should work")]
[SkipBrowserFact(skipFirefox: true)]
public async Task ShouldWork()
{
Expand Down Expand Up @@ -45,14 +45,14 @@ public async Task ShouldWork()
/// I found that status 422 is not available in all .NET runtimes (see https://github.com/dotnet/core/blob/4c4642d548074b3fbfd425541a968aadd75fea99/release-notes/2.1/Preview/api-diff/preview2/2.1-preview2_System.Net.md)
/// As the goal here is testing HTTP codes that are not in Chromium (see https://cs.chromium.org/chromium/src/net/http/http_status_code_list.h?sq=package:chromium&g=0) we will use code 426: Upgrade Required
/// </summary>
[PuppeteerTest("network.spec.ts", "Request.respond", "should work with status code 422")]
[PuppeteerTest("requestinterception.spec.ts", "Request.respond", "should work with status code 422")]
[SkipBrowserFact(skipFirefox: true)]
public async Task ShouldWorkReturnStatusPhrases()
{
await Page.SetRequestInterceptionAsync(true);
Page.Request += async (_, e) =>
{
await e.Request.RespondAsync(new ResponseData
await e. Request.RespondAsync(new ResponseData
{
Status = HttpStatusCode.UpgradeRequired,
Body = "Yo, page!"
Expand All @@ -65,7 +65,7 @@ public async Task ShouldWorkReturnStatusPhrases()
Assert.Equal("Yo, page!", await Page.EvaluateExpressionAsync<string>("document.body.textContent"));
}

[PuppeteerTest("network.spec.ts", "Request.respond", "should redirect")]
[PuppeteerTest("requestinterception.spec.ts", "Request.respond", "should redirect")]
[SkipBrowserFact(skipFirefox: true)]
public async Task ShouldRedirect()
{
Expand Down Expand Up @@ -96,7 +96,7 @@ public async Task ShouldRedirect()
Assert.Equal(TestConstants.EmptyPage, response.Url);
}

[PuppeteerTest("network.spec.ts", "Request.respond", "should allow mocking binary responses")]
[PuppeteerTest("requestinterception.spec.ts", "Request.respond", "should allow mocking binary responses")]
[SkipBrowserFact(skipFirefox: true)]
public async Task ShouldAllowMockingBinaryResponses()
{
Expand All @@ -122,7 +122,7 @@ public async Task ShouldAllowMockingBinaryResponses()
Assert.True(ScreenshotHelper.PixelMatch("mock-binary-response.png", await img.ScreenshotDataAsync()));
}

[PuppeteerTest("network.spec.ts", "Request.respond", "should stringify intercepted request response headers")]
[PuppeteerTest("requestinterception.spec.ts", "Request.respond", "should stringify intercepted request response headers")]
[SkipBrowserFact(skipFirefox: true)]
public async Task ShouldStringifyInterceptedRequestResponseHeaders()
{
Expand Down
4 changes: 2 additions & 2 deletions lib/PuppeteerSharp.Tests/TouchScreenTests/TouchScreenTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public TouchScreenTests(ITestOutputHelper output) : base(output)
{
}

[PuppeteerTest("touchescreen.spec.ts", "Touchscreen", "tap the button")]
[PuppeteerTest("touchscreen.spec.ts", "Touchscreen", "tap the button")]
[SkipBrowserFact(skipFirefox: true)]
public async Task ShouldTapTheButton()
{
Expand All @@ -26,7 +26,7 @@ public async Task ShouldTapTheButton()
Assert.Equal("Clicked", await Page.EvaluateExpressionAsync<string>("result"));
}

[PuppeteerTest("touchescreen.spec.ts", "Touchscreen", "should report touches")]
[PuppeteerTest("touchscreen.spec.ts", "Touchscreen", "should report touches")]
[SkipBrowserFact(skipFirefox: true)]
public async Task ShouldReportTouches()
{
Expand Down

0 comments on commit 713b34d

Please sign in to comment.