Skip to content

Commit 5f4be17

Browse files
authored
Fix and identify flaky components E2E Tests (#8690)
1 parent 69732c9 commit 5f4be17

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

src/Components/test/E2ETest/ServerExecutionTests/ServerSideAppTest.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

4+
using System;
5+
using System.Linq;
46
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure;
57
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures;
68
using Microsoft.AspNetCore.E2ETesting;
79
using OpenQA.Selenium;
810
using OpenQA.Selenium.Support.UI;
9-
using System;
10-
using System.Linq;
11-
using System.Threading.Tasks;
1211
using Xunit;
1312
using Xunit.Abstractions;
1413

@@ -41,7 +40,7 @@ public void HasTitle()
4140
[Fact]
4241
public void HasHeading()
4342
{
44-
Assert.Equal("Hello, world!", Browser.FindElement(By.TagName("h1")).Text);
43+
Browser.Equal("Hello, world!", () => Browser.FindElement(By.CssSelector("h1#index")).Text);
4544
}
4645

4746
[Fact]
@@ -96,7 +95,7 @@ public void HasFetchDataPage()
9695
{
9796
// Navigate to "Fetch Data"
9897
Browser.FindElement(By.LinkText("Fetch data")).Click();
99-
Browser.Equal("Weather forecast", () => Browser.FindElement(By.TagName("h1")).Text);
98+
Browser.Equal("Weather forecast", () => Browser.FindElement(By.CssSelector("h1#fetch-data")).Text);
10099

101100
// Wait until loaded
102101
var tableSelector = By.CssSelector("table.table");

src/Components/test/E2ETest/Tests/EventTest.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure;
77
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures;
88
using Microsoft.AspNetCore.E2ETesting;
9+
using Microsoft.AspNetCore.Testing.xunit;
910
using OpenQA.Selenium;
1011
using OpenQA.Selenium.Interactions;
1112
using Xunit;
@@ -133,6 +134,7 @@ public void PreventDefault_DotNotApplyByDefault()
133134
}
134135

135136
[Fact]
137+
[Flaky("https://github.com/aspnet/AspNetCore-Internal/issues/1987")]
136138
public void InputEvent_RespondsOnKeystrokes()
137139
{
138140
MountTestComponent<InputEventComponent>();

src/Components/test/testassets/ComponentsApp.App/Pages/FetchData.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
@page "/fetchdata/{StartDate:datetime}"
33
@inject WeatherForecastService ForecastService
44

5-
<h1>Weather forecast</h1>
5+
<h1 id="fetch-data">Weather forecast</h1>
66

77
<p>This component demonstrates fetching data from the server.</p>
88

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
@page "/"
1+
@page "/"
22

3-
<h1>Hello, world!</h1>
3+
<h1 id="index">Hello, world!</h1>
44

55
Welcome to your new app.

0 commit comments

Comments
 (0)