Skip to content

Commit fcb435f

Browse files
authored
Attributes part 11 (#1730)
1 parent a7f144d commit fcb435f

File tree

5 files changed

+38
-5
lines changed

5 files changed

+38
-5
lines changed

lib/PuppeteerSharp.Tests/TargetTests/CreateCDPSessionTests.cs renamed to lib/PuppeteerSharp.Tests/CDPSessionTests/CreateCDPSessionTests.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
using Newtonsoft.Json.Linq;
55
using PuppeteerSharp.Messaging;
66
using PuppeteerSharp.Tests.Attributes;
7+
using PuppeteerSharp.Xunit;
78
using Xunit;
89
using Xunit.Abstractions;
910

10-
namespace PuppeteerSharp.Tests.TargetTests
11+
namespace PuppeteerSharp.Tests.CDPSessionTests
1112
{
1213
[Collection(TestConstants.TestFixtureCollectionName)]
1314
public class CreateCDPSessionTests : PuppeteerPageBaseTest
@@ -16,6 +17,7 @@ public CreateCDPSessionTests(ITestOutputHelper output) : base(output)
1617
{
1718
}
1819

20+
[PuppeteerTest("CDPSession.spec.ts", "Target.createCDPSession", "should work")]
1921
[SkipBrowserFact(skipFirefox: true)]
2022
public async Task ShouldWork()
2123
{
@@ -29,6 +31,7 @@ await Task.WhenAll(
2931
Assert.Equal("bar", foo);
3032
}
3133

34+
[PuppeteerTest("CDPSession.spec.ts", "Target.createCDPSession", "should send events")]
3235
[SkipBrowserFact(skipFirefox: true)]
3336
public async Task ShouldSendEvents()
3437
{
@@ -48,6 +51,7 @@ public async Task ShouldSendEvents()
4851
Assert.Single(events);
4952
}
5053

54+
[PuppeteerTest("CDPSession.spec.ts", "Target.createCDPSession", "should enable and disable domains independently")]
5155
[SkipBrowserFact(skipFirefox: true)]
5256
public async Task ShouldEnableAndDisableDomainsIndependently()
5357
{
@@ -67,6 +71,7 @@ await Task.WhenAll(
6771
Assert.Equal("foo.js", eventTask.Result["url"].Value<string>());
6872
}
6973

74+
[PuppeteerTest("CDPSession.spec.ts", "Target.createCDPSession", "should be able to detach session")]
7075
[SkipBrowserFact(skipFirefox: true)]
7176
public async Task ShouldBeAbleToDetachSession()
7277
{
@@ -89,6 +94,7 @@ public async Task ShouldBeAbleToDetachSession()
8994
Assert.Contains("Session closed.", exception.Message);
9095
}
9196

97+
[PuppeteerTest("CDPSession.spec.ts", "Target.createCDPSession", "should throw nice errors")]
9298
[SkipBrowserFact(skipFirefox: true)]
9399
public async Task ShouldThrowNiceErrors()
94100
{

lib/PuppeteerSharp.Tests/ClickTests/PageClickTests.cs renamed to lib/PuppeteerSharp.Tests/ClickTests/ClickTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
namespace PuppeteerSharp.Tests.ClickTests
1111
{
1212
[Collection(TestConstants.TestFixtureCollectionName)]
13-
public class PageClickTests : PuppeteerPageBaseTest
13+
public class ClickTests : PuppeteerPageBaseTest
1414
{
15-
public PageClickTests(ITestOutputHelper output) : base(output)
15+
public ClickTests(ITestOutputHelper output) : base(output)
1616
{
1717
}
1818

lib/PuppeteerSharp.Tests/TargetTests/TargetTests.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Microsoft.AspNetCore.Http;
22
using PuppeteerSharp.Tests.Attributes;
3+
using PuppeteerSharp.Xunit;
34
using System;
45
using System.Linq;
56
using System.Threading.Tasks;
@@ -15,6 +16,7 @@ public TargetTests(ITestOutputHelper output) : base(output)
1516
{
1617
}
1718

19+
[PuppeteerTest("target.spec.ts", "Target", "Browser.targets should return all of the targets")]
1820
[Fact(Timeout = TestConstants.DefaultTestTimeout)]
1921
public void BrowserTargetsShouldReturnAllOfTheTargets()
2022
{
@@ -25,6 +27,7 @@ public void BrowserTargetsShouldReturnAllOfTheTargets()
2527
Assert.Contains(targets, target => target.Type == TargetType.Browser);
2628
}
2729

30+
[PuppeteerTest("target.spec.ts", "Target", "Browser.pages should return all of the pages")]
2831
[Fact(Timeout = TestConstants.DefaultTestTimeout)]
2932
public async Task BrowserPagesShouldReturnAllOfThePages()
3033
{
@@ -34,6 +37,7 @@ public async Task BrowserPagesShouldReturnAllOfThePages()
3437
Assert.Contains(Page, allPages);
3538
}
3639

40+
[PuppeteerTest("target.spec.ts", "Target", "should contain browser target")]
3741
[Fact(Timeout = TestConstants.DefaultTestTimeout)]
3842
public void ShouldContainBrowserTarget()
3943
{
@@ -42,6 +46,7 @@ public void ShouldContainBrowserTarget()
4246
Assert.NotNull(browserTarget);
4347
}
4448

49+
[PuppeteerTest("target.spec.ts", "Target", "should be able to use the default page in the browser")]
4550
[Fact(Timeout = TestConstants.DefaultTestTimeout)]
4651
public async Task ShouldBeAbleToUseTheDefaultPageInTheBrowser()
4752
{
@@ -53,6 +58,7 @@ public async Task ShouldBeAbleToUseTheDefaultPageInTheBrowser()
5358
Assert.NotNull(await originalPage.QuerySelectorAsync("body"));
5459
}
5560

61+
[PuppeteerTest("target.spec.ts", "Target", "should report when a new page is created and closed")]
5662
[SkipBrowserFact(skipFirefox: true)]
5763
public async Task ShouldReportWhenANewPageIsCreatedAndClosed()
5864
{
@@ -89,6 +95,7 @@ async void TargetDestroyedEventHandler(object sender, TargetChangedArgs e)
8995
Assert.DoesNotContain(otherPage, allPages);
9096
}
9197

98+
[PuppeteerTest("target.spec.ts", "Target", "should report when a service worker is created and destroyed")]
9299
[SkipBrowserFact(skipFirefox: true)]
93100
public async Task ShouldReportWhenAServiceWorkerIsCreatedAndDestroyed()
94101
{
@@ -117,6 +124,7 @@ void TargetDestroyedEventHandler(object sender, TargetChangedArgs e)
117124
Assert.Equal(createdTarget, await targetDestroyedTaskCompletion.Task);
118125
}
119126

127+
[PuppeteerTest("target.spec.ts", "Target", "should create a worker from a service worker")]
120128
[SkipBrowserFact(skipFirefox: true)]
121129
public async Task ShouldCreateAWorkerFromAServiceWorker()
122130
{
@@ -127,6 +135,7 @@ public async Task ShouldCreateAWorkerFromAServiceWorker()
127135
Assert.Equal("[object ServiceWorkerGlobalScope]", await worker.EvaluateFunctionAsync("() => self.toString()"));
128136
}
129137

138+
[PuppeteerTest("target.spec.ts", "Target", "should create a worker from a shared worker")]
130139
[SkipBrowserFact(skipFirefox: true)]
131140
public async Task ShouldCreateAWorkerFromASharedWorker()
132141
{
@@ -140,6 +149,7 @@ await Page.EvaluateFunctionAsync(@"() =>
140149
Assert.Equal("[object SharedWorkerGlobalScope]", await worker.EvaluateFunctionAsync("() => self.toString()"));
141150
}
142151

152+
[PuppeteerTest("target.spec.ts", "Target", "should report when a target url changes")]
143153
[SkipBrowserFact(skipFirefox: true)]
144154
public async Task ShouldReportWhenATargetUrlChanges()
145155
{
@@ -164,6 +174,7 @@ void ChangedTargetEventHandler(object sender, TargetChangedArgs e)
164174
Assert.Equal(TestConstants.EmptyPage, changedTarget.Url);
165175
}
166176

177+
[PuppeteerTest("target.spec.ts", "Target", "should not report uninitialized pages")]
167178
[SkipBrowserFact(skipFirefox: true)]
168179
public async Task ShouldNotReportUninitializedPages()
169180
{
@@ -193,6 +204,7 @@ void TargetCreatedEventHandler(object sender, TargetChangedArgs e)
193204
Context.TargetChanged -= listener;
194205
}
195206

207+
[PuppeteerTest("target.spec.ts", "Target", "should not crash while redirecting if original request was missed")]
196208
[SkipBrowserFact(skipFirefox: true)]
197209
public async Task ShouldNotCrashWhileRedirectingIfOriginalRequestWasMissed()
198210
{
@@ -216,6 +228,7 @@ await Task.WhenAll(
216228
await newPage.CloseAsync();
217229
}
218230

231+
[PuppeteerTest("target.spec.ts", "Target", "should have an opener")]
219232
[SkipBrowserFact(skipFirefox: true)]
220233
public async Task ShouldHaveAnOpener()
221234
{

lib/PuppeteerSharp.Tests/TracingTests/TracingTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using Newtonsoft.Json;
88
using Newtonsoft.Json.Linq;
99
using PuppeteerSharp.Tests.Attributes;
10+
using PuppeteerSharp.Xunit;
1011
using Xunit;
1112
using Xunit.Abstractions;
1213

@@ -52,6 +53,7 @@ public override async Task DisposeAsync()
5253
}
5354
}
5455

56+
[PuppeteerTest("tracing.spec.ts", "Tracing", "should output a trace")]
5557
[SkipBrowserFact(skipFirefox: true)]
5658
public async Task ShouldOutputATrace()
5759
{
@@ -66,6 +68,7 @@ await Page.Tracing.StartAsync(new TracingOptions
6668
Assert.True(File.Exists(_file));
6769
}
6870

71+
[PuppeteerTest("tracing.spec.ts", "Tracing", "should run with custom categories if provided")]
6972
[SkipBrowserFact(skipFirefox: true)]
7073
public async Task ShouldRunWithCustomCategoriesProvided()
7174
{
@@ -89,6 +92,7 @@ await Page.Tracing.StartAsync(new TracingOptions
8992
}
9093
}
9194

95+
[PuppeteerTest("tracing.spec.ts", "Tracing", "should throw if tracing on two pages")]
9296
[SkipBrowserFact(skipFirefox: true)]
9397
public async Task ShouldThrowIfTracingOnTwoPages()
9498
{
@@ -109,6 +113,7 @@ await Page.Tracing.StartAsync(new TracingOptions
109113
await Page.Tracing.StopAsync();
110114
}
111115

116+
[PuppeteerTest("tracing.spec.ts", "Tracing", "should return a buffer")]
112117
[SkipBrowserFact(skipFirefox: true)]
113118
public async Task ShouldReturnABuffer()
114119
{
@@ -123,6 +128,7 @@ await Page.Tracing.StartAsync(new TracingOptions
123128
Assert.Equal(trace, buf);
124129
}
125130

131+
[PuppeteerTest("tracing.spec.ts", "Tracing", "should work without options")]
126132
[SkipBrowserFact(skipFirefox: true)]
127133
public async Task ShouldWorkWithoutOptions()
128134
{
@@ -132,6 +138,7 @@ public async Task ShouldWorkWithoutOptions()
132138
Assert.NotNull(trace);
133139
}
134140

141+
[PuppeteerTest("tracing.spec.ts", "Tracing", "should support a buffer without a path")]
135142
[SkipBrowserFact(skipFirefox: true)]
136143
public async Task ShouldSupportABufferWithoutAPath()
137144
{

lib/PuppeteerSharp.Tests/WorkerTests/WorkerTests.cs renamed to lib/PuppeteerSharp.Tests/WorkerTests/PageWorkerTests.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,18 @@
33
using Xunit.Abstractions;
44
using PuppeteerSharp.Helpers;
55
using PuppeteerSharp.Tests.Attributes;
6+
using PuppeteerSharp.Xunit;
67

78
namespace PuppeteerSharp.Tests.WorkerTests
89
{
910
[Collection(TestConstants.TestFixtureCollectionName)]
10-
public class WorkerTests : PuppeteerPageBaseTest
11+
public class PageWorkerTests : PuppeteerPageBaseTest
1112
{
12-
public WorkerTests(ITestOutputHelper output) : base(output)
13+
public PageWorkerTests(ITestOutputHelper output) : base(output)
1314
{
1415
}
1516

17+
[PuppeteerTest("worker.spec.ts", "Workers", "Page.workers")]
1618
[SkipBrowserFact(skipFirefox: true)]
1719
public async Task PageWorkers()
1820
{
@@ -35,6 +37,7 @@ await Task.WhenAll(
3537
Assert.Empty(Page.Workers);
3638
}
3739

40+
[PuppeteerTest("worker.spec.ts", "Workers", "should emit created and destroyed events")]
3841
[SkipBrowserFact(skipFirefox: true)]
3942
public async Task ShouldEmitCreatedAndDestroyedEvents()
4043
{
@@ -49,6 +52,7 @@ public async Task ShouldEmitCreatedAndDestroyedEvents()
4952
Assert.Same(worker, await workerDestroyedTcs.Task);
5053
}
5154

55+
[PuppeteerTest("worker.spec.ts", "Workers", "should report console logs")]
5256
[SkipBrowserFact(skipFirefox: true)]
5357
public async Task ShouldReportConsoleLogs()
5458
{
@@ -67,6 +71,7 @@ public async Task ShouldReportConsoleLogs()
6771
}, log.Location);
6872
}
6973

74+
[PuppeteerTest("worker.spec.ts", "Workers", "should have JSHandles for console logs")]
7075
[SkipBrowserFact(skipFirefox: true)]
7176
public async Task ShouldHaveJSHandlesForConsoleLogs()
7277
{
@@ -83,6 +88,7 @@ public async Task ShouldHaveJSHandlesForConsoleLogs()
8388
Assert.Equal("null", json);
8489
}
8590

91+
[PuppeteerTest("worker.spec.ts", "Workers", "should have an execution context")]
8692
[SkipBrowserFact(skipFirefox: true)]
8793
public async Task ShouldHaveAnExecutionContext()
8894
{
@@ -94,6 +100,7 @@ public async Task ShouldHaveAnExecutionContext()
94100
Assert.Equal(2, await worker.EvaluateExpressionAsync<int>("1+1"));
95101
}
96102

103+
[PuppeteerTest("worker.spec.ts", "Workers", "should report errors")]
97104
[SkipBrowserFact(skipFirefox: true)]
98105
public async Task ShouldReportErrors()
99106
{

0 commit comments

Comments
 (0)