Skip to content

Commit 27cc02e

Browse files
committed
Stabilize CI browser tail failures
1 parent 23a544a commit 27cc02e

6 files changed

Lines changed: 44 additions & 7 deletions

‎tests/PrompterOne.Web.UITests/Editor/EditorDocumentSplitFlowTests.cs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ public Task EditorScreen_SplitBySegmentHeadingCreatesLibraryScriptsWithoutReplac
3737

3838
await page.GetByTestId(UiTestIds.Editor.SplitSegment).ClickAsync();
3939

40-
await Expect(page.GetByTestId(UiTestIds.Editor.SplitStatus)).ToBeVisibleAsync();
40+
await Expect(page.GetByTestId(UiTestIds.Editor.SplitStatus)).ToBeVisibleAsync(new()
41+
{
42+
Timeout = BrowserTestConstants.EditorFlow.SplitFeedbackVisibleTimeoutMs
43+
});
4144
await Expect(page.GetByTestId(UiTestIds.Editor.SplitResultTitle)).ToHaveTextAsync(SplitFeedbackTitle);
4245
await Expect(page.GetByTestId(UiTestIds.Editor.SplitResultSummary)).ToHaveTextAsync(SplitFeedbackSummary);
4346
await Expect(page.GetByTestId(UiTestIds.Editor.SplitResultBadge)).ToHaveTextAsync(SplitFeedbackBadge);

‎tests/PrompterOne.Web.UITests/Editor/EditorFloatingToolbarLayoutTests.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public async Task EditorScreen_FloatingToolbarStaysPinnedAfterFloatingFormatActi
9999
await GotoEditorAndWaitForSourceAsync(page);
100100
await EditorMonacoDriver.SetCaretAtTextStartAsync(page, BrowserTestConstants.Editor.ToolbarPinnedSelectionTarget);
101101
await EditorMonacoDriver.FocusAsync(page);
102-
await EditorMonacoDriver.PressKeyRepeatedlyAsync(
102+
await EditorMonacoDriver.ExpandSelectionWithKeyAsync(
103103
page,
104104
BrowserTestConstants.Keyboard.ShiftArrowRight,
105105
BrowserTestConstants.Editor.ToolbarPinnedSelectionCharacterCount);

‎tests/PrompterOne.Web.UITests/Editor/EditorSelectionRenderRegressionTests.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public async Task EditorScreen_BackwardSelection_KeepsGrowingAcrossRepeatedArrow
4848
await EditorMonacoDriver.SetTextAsync(page, BrowserTestConstants.Editor.TypedScript);
4949
await EditorMonacoDriver.SetCaretAtTextEndAsync(page, BrowserTestConstants.Editor.ReverseSelectionTarget);
5050
await EditorMonacoDriver.FocusAsync(page);
51-
await EditorMonacoDriver.PressKeyRepeatedlyAsync(
51+
await EditorMonacoDriver.ExpandSelectionWithKeyAsync(
5252
page,
5353
BrowserTestConstants.Keyboard.ShiftArrowLeft,
5454
BrowserTestConstants.Editor.ReverseSelectionCharacterCount);
@@ -78,7 +78,7 @@ public async Task EditorScreen_BackwardSelection_CanExtendAcrossLineBreaks()
7878
await EditorMonacoDriver.SetTextAsync(page, BrowserTestConstants.Editor.TypedMultilineScript);
7979
await EditorMonacoDriver.SetCaretAtTextEndAsync(page, BrowserTestConstants.Editor.ReverseMultilineSelectionTarget);
8080
await EditorMonacoDriver.FocusAsync(page);
81-
await EditorMonacoDriver.PressKeyRepeatedlyAsync(
81+
await EditorMonacoDriver.ExpandSelectionWithKeyAsync(
8282
page,
8383
BrowserTestConstants.Keyboard.ShiftArrowLeft,
8484
BrowserTestConstants.Editor.ReverseMultilineSelectionCharacterCount);

‎tests/PrompterOne.Web.UITests/Support/BrowserTestConstants.ScreenFlows.cs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public static class EditorFlow
2020
public const string LineNumbersStep = "01-gutter-visible";
2121
public const string SplitFeedbackScenario = "editor-split-feedback";
2222
public const string SplitFeedbackStep = "01-split-result-card";
23+
public const int SplitFeedbackVisibleTimeoutMs = 30_000;
2324
public const string LocalHistoryScenario = "editor-local-history";
2425
public const string LocalHistorySavedStep = "01-history-populated";
2526
public const string LocalHistoryRestoredStep = "02-history-restored";

‎tests/PrompterOne.Web.UITests/Support/EditorLargeDraftPerformanceTestData.cs‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@ namespace PrompterOne.Web.UITests;
66
internal static class EditorLargeDraftPerformanceTestData
77
{
88
public const int BlockCountPerSegment = 4;
9+
public const int CiMaxHugeFollowupLongTaskMs = 550;
910
public const int CiMaxHugeTypingLatencyMs = 425;
10-
public const int CiMaxPasteLongTaskMs = 360;
11+
public const int CiMaxPasteLongTaskMs = 375;
1112
public const string FollowupTypingText = " x";
1213
public const int HugeDraftMinimumLength = 250_000;
1314
public const int HugeDraftReadyTimeoutMs = 30_000;
1415
public const int LargeDraftMinimumLength = 32_000;
16+
public const int LocalMaxHugeFollowupLongTaskMs = 500;
1517
public const int LocalMaxHugeTypingLatencyMs = 250;
1618
public const int LocalMaxPasteLongTaskMs = 325;
17-
public const int MaxHugeFollowupLongTaskMs = 500;
1819
public const int MaxTypingLatencyMs = 100;
1920
public const int NavigationTargetSegmentIndex = 14;
2021
public const int ObservationDelayMs = 2_200;
@@ -26,6 +27,11 @@ internal static class EditorLargeDraftPerformanceTestData
2627
private const string FrontMatterOpeningDelimiter = "---\n";
2728
private const string FrontMatterClosingDelimiter = "\n---\n\n";
2829

30+
public static int MaxHugeFollowupLongTaskMs =>
31+
PrompterOne.Testing.TestEnvironment.IsCiEnvironment
32+
? CiMaxHugeFollowupLongTaskMs
33+
: LocalMaxHugeFollowupLongTaskMs;
34+
2935
public static int MaxHugeTypingLatencyMs =>
3036
PrompterOne.Testing.TestEnvironment.IsCiEnvironment
3137
? CiMaxHugeTypingLatencyMs

‎tests/PrompterOne.Web.UITests/Support/EditorMonacoDriver.cs‎

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ internal sealed record DroppedFileDescriptor(string FileName, string Text);
1515
PropertyNameCaseInsensitive = true
1616
};
1717

18+
private static int GetSelectionLength(EditorMonacoState state) =>
19+
Math.Abs(state.Selection.End - state.Selection.Start);
20+
1821
internal static ILocator SourceInput(IPage page) =>
1922
page.GetByTestId(UiTestIds.Editor.SourceInput);
2023

@@ -94,11 +97,35 @@ internal static async Task FocusAsync(IPage page)
9497
_ = await InvokeHarnessAsync<EditorMonacoState>(page, "focus");
9598
}
9699

97-
internal static async Task PressKeyRepeatedlyAsync(IPage page, string key, int repeatCount)
100+
internal static async Task ExpandSelectionWithKeyAsync(IPage page, string key, int repeatCount)
98101
{
102+
var currentSelectionLength = GetSelectionLength(await GetStateAsync(page));
103+
99104
for (var index = 0; index < repeatCount; index++)
100105
{
101106
await page.Keyboard.PressAsync(key);
107+
currentSelectionLength += 1;
108+
109+
await page.WaitForFunctionAsync(
110+
"""
111+
(args) => {
112+
const harness = window[args.harnessGlobalName];
113+
const state = harness?.getState(args.testId);
114+
const selection = state?.selection;
115+
if (!selection) {
116+
return false;
117+
}
118+
119+
return Math.abs(selection.end - selection.start) >= args.minimumSelectionLength;
120+
}
121+
""",
122+
new
123+
{
124+
harnessGlobalName = EditorMonacoRuntimeContract.BrowserHarnessGlobalName,
125+
minimumSelectionLength = currentSelectionLength,
126+
testId = UiTestIds.Editor.SourceStage
127+
},
128+
new() { Timeout = BrowserTestConstants.Timing.FastVisibleTimeoutMs });
102129
}
103130
}
104131

0 commit comments

Comments
 (0)