Skip to content

Commit

Permalink
ShouldEnableOrDisableTheCacheBasedOnTheStatePassed test improvements (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
kblok committed Mar 8, 2019
1 parent bada611 commit 60a0ba6
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions lib/PuppeteerSharp.Tests/PageTests/SetCacheEnabledTests.cs
Expand Up @@ -16,16 +16,23 @@ public SetCacheEnabledTests(ITestOutputHelper output) : base(output)
[Fact]
public async Task ShouldEnableOrDisableTheCacheBasedOnTheStatePassed()
{
var responses = new Dictionary<string, Response>();
Page.Response += (sender, e) => responses[e.Response.Url.Split('/').Last()] = e.Response;

await Page.GoToAsync(TestConstants.ServerUrl + "/cached/one-style.html");
await Page.ReloadAsync();
Assert.True(responses["one-style.css"].FromCache);
var waitForRequestTask = Server.WaitForRequest<string>("/cached/one-style.html", (request) => request.Headers["if-modified-since"]);

await Task.WhenAll(
waitForRequestTask,
Page.ReloadAsync());

Assert.False(string.IsNullOrEmpty(waitForRequestTask.Result));

await Page.SetCacheEnabledAsync(false);
await Page.ReloadAsync(waitUntil: new[] { WaitUntilNavigation.Networkidle2 });
Assert.False(responses["one-style.css"].FromCache);
waitForRequestTask = Server.WaitForRequest<string>("/cached/one-style.html", (request) => request.Headers["if-modified-since"]);

await Task.WhenAll(
waitForRequestTask,
Page.ReloadAsync());

Assert.True(string.IsNullOrEmpty(waitForRequestTask.Result));
}
}
}

0 comments on commit 60a0ba6

Please sign in to comment.