Skip to content

Commit 3baefc1

Browse files
authored
chore(tests): relocate tests to match upstream (microsoft#1144)
* Some progress * some progress * More progress * More progress * More progress * feature complete * dotnet format * Fix tests * dotnet format
1 parent aa11d01 commit 3baefc1

File tree

198 files changed

+3374
-4533
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

198 files changed

+3374
-4533
lines changed

src/PlaywrightSharp.Tests/Accessibility/RootOptionTests.cs

-130
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
using System.Threading.Tasks;
2+
using PlaywrightSharp.Tests.BaseTests;
3+
using PlaywrightSharp.Xunit;
4+
using Xunit;
5+
using Xunit.Abstractions;
6+
7+
namespace PlaywrightSharp.Tests
8+
{
9+
[Collection(TestConstants.TestFixtureBrowserCollectionName)]
10+
public class BeforeUnloadTests : PlaywrightSharpPageBaseTest
11+
{
12+
/// <inheritdoc/>
13+
public BeforeUnloadTests(ITestOutputHelper output) : base(output)
14+
{
15+
}
16+
17+
18+
[PlaywrightTest("beforeunload.spec.ts", "should run beforeunload if asked for")]
19+
[Fact(Timeout = TestConstants.DefaultTestTimeout)]
20+
public async Task ShouldRunBeforeunloadIfAskedFor()
21+
{
22+
var newPage = await Context.NewPageAsync();
23+
await newPage.GoToAsync(TestConstants.ServerUrl + "/beforeunload.html");
24+
// We have to interact with a page so that 'beforeunload' handlers
25+
// fire.
26+
await newPage.ClickAsync("body");
27+
var pageClosingTask = newPage.CloseAsync(true);
28+
var dialog = await newPage.WaitForEventAsync(PageEvent.Dialog).ContinueWith(task => task.Result.Dialog);
29+
Assert.Equal(DialogType.BeforeUnload, dialog.Type);
30+
Assert.Empty(dialog.DefaultValue);
31+
if (TestConstants.IsChromium)
32+
{
33+
Assert.Empty(dialog.Message);
34+
}
35+
else if (TestConstants.IsWebKit)
36+
{
37+
Assert.Equal("Leave?", dialog.Message);
38+
}
39+
else
40+
{
41+
Assert.Equal("This page is asking you to confirm that you want to leave - data you have entered may not be saved.", dialog.Message);
42+
}
43+
44+
await dialog.AcceptAsync();
45+
await pageClosingTask;
46+
}
47+
48+
[PlaywrightTest("beforeunload.spec.ts", "should *not* run beforeunload by default")]
49+
[Fact(Timeout = TestConstants.DefaultTestTimeout)]
50+
public async Task ShouldNotRunBeforeunloadByDefault()
51+
{
52+
var newPage = await Context.NewPageAsync();
53+
await newPage.GoToAsync(TestConstants.ServerUrl + "/beforeunload.html");
54+
// We have to interact with a page so that 'beforeunload' handlers
55+
// fire.
56+
await newPage.ClickAsync("body");
57+
await newPage.CloseAsync();
58+
}
59+
60+
}
61+
}

src/PlaywrightSharp.Tests/BrowserContext/EventsBrowserContextPageTests.cs renamed to src/PlaywrightSharp.Tests/BrowserContectPageEventTests.cs

+14-16
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,17 @@
88
using Xunit;
99
using Xunit.Abstractions;
1010

11-
namespace PlaywrightSharp.Tests.BrowserContext
11+
namespace PlaywrightSharp.Tests
1212
{
13-
///<playwright-file>browsercontext.spec.js</playwright-file>
14-
///<playwright-describe>Events.BrowserContext.Page</playwright-describe>
1513
[Collection(TestConstants.TestFixtureBrowserCollectionName)]
16-
public class EventsBrowserContextPageTests : PlaywrightSharpBrowserBaseTest
14+
public class BrowserContectPageEventTests : PlaywrightSharpBrowserBaseTest
1715
{
1816
/// <inheritdoc/>
19-
public EventsBrowserContextPageTests(ITestOutputHelper output) : base(output)
17+
public BrowserContectPageEventTests(ITestOutputHelper output) : base(output)
2018
{
2119
}
2220

23-
[PlaywrightTest("browsercontext.spec.js", "Events.BrowserContext.Page", "should have url")]
21+
[PlaywrightTest("browsercontext-page-event.spec.ts", "should have url")]
2422
[Fact(Timeout = TestConstants.DefaultTestTimeout)]
2523
public async Task ShouldHaveUrl()
2624
{
@@ -34,7 +32,7 @@ public async Task ShouldHaveUrl()
3432
Assert.Equal(TestConstants.EmptyPage, otherPage.Page.Url);
3533
}
3634

37-
[PlaywrightTest("browsercontext.spec.js", "Events.BrowserContext.Page", "should have url after domcontentloaded")]
35+
[PlaywrightTest("browsercontext-page-event.spec.ts", "should have url after domcontentloaded")]
3836
[Fact(Timeout = TestConstants.DefaultTestTimeout)]
3937
public async Task ShouldHaveUrlAfterDomcontentloaded()
4038
{
@@ -49,7 +47,7 @@ public async Task ShouldHaveUrlAfterDomcontentloaded()
4947
Assert.Equal(TestConstants.EmptyPage, otherPage.Page.Url);
5048
}
5149

52-
[PlaywrightTest("browsercontext.spec.js", "Events.BrowserContext.Page", "should have about:blank url with domcontentloaded")]
50+
[PlaywrightTest("browsercontext-page-event.spec.ts", "should have about:blank url with domcontentloaded")]
5351
[Fact(Timeout = TestConstants.DefaultTestTimeout)]
5452
public async Task ShouldHaveAboutBlankUrlWithDomcontentloaded()
5553
{
@@ -64,7 +62,7 @@ public async Task ShouldHaveAboutBlankUrlWithDomcontentloaded()
6462
Assert.Equal("about:blank", otherPage.Page.Url);
6563
}
6664

67-
[PlaywrightTest("browsercontext.spec.js", "Events.BrowserContext.Page", "should have about:blank for empty url with domcontentloaded")]
65+
[PlaywrightTest("browsercontext-page-event.spec.ts", "should have about:blank for empty url with domcontentloaded")]
6866
[Fact(Timeout = TestConstants.DefaultTestTimeout)]
6967
public async Task ShouldHaveAboutBlankUrlForEmptyUrlWithDomcontentloaded()
7068
{
@@ -79,7 +77,7 @@ public async Task ShouldHaveAboutBlankUrlForEmptyUrlWithDomcontentloaded()
7977
Assert.Equal("about:blank", otherPage.Page.Url);
8078
}
8179

82-
[PlaywrightTest("browsercontext.spec.js", "Events.BrowserContext.Page", "should report when a new page is created and closed")]
80+
[PlaywrightTest("browsercontext-page-event.spec.ts", "should report when a new page is created and closed")]
8381
[Fact(Timeout = TestConstants.DefaultTestTimeout)]
8482
public async Task ShouldReportWhenANewPageIsCreatedAndClosed()
8583
{
@@ -111,7 +109,7 @@ public async Task ShouldReportWhenANewPageIsCreatedAndClosed()
111109
Assert.DoesNotContain(otherPage, allPages);
112110
}
113111

114-
[PlaywrightTest("browsercontext.spec.js", "Events.BrowserContext.Page", "should report initialized pages")]
112+
[PlaywrightTest("browsercontext-page-event.spec.ts", "should report initialized pages")]
115113
[Fact(Timeout = TestConstants.DefaultTestTimeout)]
116114
public async Task ShouldReportInitializedPages()
117115
{
@@ -128,7 +126,7 @@ public async Task ShouldReportInitializedPages()
128126
await evaluateTask;
129127
}
130128

131-
[PlaywrightTest("browsercontext.spec.js", "Events.BrowserContext.Page", "should not crash while redirecting of original request was missed")]
129+
[PlaywrightTest("browsercontext-page-event.spec.ts", "should not crash while redirecting of original request was missed")]
132130
[Fact(Timeout = TestConstants.DefaultTestTimeout)]
133131
public async Task ShouldNotCrashWhileRedirectingOfOriginalRequestWasMissed()
134132
{
@@ -154,7 +152,7 @@ await TaskUtils.WhenAll(
154152
Assert.Equal(TestConstants.ServerUrl + "/one-style.html", newPage.Url);
155153
}
156154

157-
[PlaywrightTest("browsercontext.spec.js", "Events.BrowserContext.Page", "should have an opener")]
155+
[PlaywrightTest("browsercontext-page-event.spec.ts", "should have an opener")]
158156
[Fact(Timeout = TestConstants.DefaultTestTimeout)]
159157
public async Task ShouldHaveAnOpener()
160158
{
@@ -172,7 +170,7 @@ public async Task ShouldHaveAnOpener()
172170
Assert.Null(await page.GetOpenerAsync());
173171
}
174172

175-
[PlaywrightTest("browsercontext.spec.js", "Events.BrowserContext.Page", "should fire page lifecycle events")]
173+
[PlaywrightTest("browsercontext-page-event.spec.ts", "should fire page lifecycle events")]
176174
[Fact(Timeout = TestConstants.DefaultTestTimeout)]
177175
public async Task ShouldFirePageLifecycleEvents()
178176
{
@@ -197,7 +195,7 @@ public async Task ShouldFirePageLifecycleEvents()
197195
events);
198196
}
199197

200-
[PlaywrightTest("browsercontext.spec.js", "Events.BrowserContext.Page", "should work with Shift-clicking")]
198+
[PlaywrightTest("browsercontext-page-event.spec.ts", "should work with Shift-clicking")]
201199
[SkipBrowserAndPlatformFact(skipWebkit: true)]
202200
public async Task ShouldWorkWithShiftClicking()
203201
{
@@ -215,7 +213,7 @@ await TaskUtils.WhenAll(
215213
Assert.Null(await popupEventTask.Result.Page.GetOpenerAsync());
216214
}
217215

218-
[PlaywrightTest("browsercontext.spec.js", "Events.BrowserContext.Page", "should report when a new page is created and closed")]
216+
[PlaywrightTest("browsercontext-page-event.spec.ts", "should report when a new page is created and closed")]
219217
[SkipBrowserAndPlatformFact(skipWebkit: true, skipFirefox: true)]
220218
public async Task ShouldWorkWithCtrlClicking()
221219
{

0 commit comments

Comments
 (0)