Skip to content

Commit b35da51

Browse files
committed
Stabilize editor browser harness (#28)
1 parent 8714650 commit b35da51

2 files changed

Lines changed: 9 additions & 17 deletions

File tree

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,12 @@ public static class Editor
381381
public const int CiMaxTypingLongTaskCount = 10;
382382
public const int LocalMaxTypingLongTaskCount = 2;
383383
public const double MaxVisibleRenderP95LatencyMs = 240;
384-
public const double MaxVisibleRenderSpikeLatencyMs = 300;
384+
public const double LocalMaxVisibleRenderSpikeLatencyMs = 300;
385+
public const double CiMaxVisibleRenderSpikeLatencyMs = 450;
386+
public static double MaxVisibleRenderSpikeLatencyMs =>
387+
TestEnvironment.IsCiEnvironment
388+
? CiMaxVisibleRenderSpikeLatencyMs
389+
: LocalMaxVisibleRenderSpikeLatencyMs;
385390
public static int AllowedTypingLongTaskCount =>
386391
TestEnvironment.IsCiEnvironment
387392
? CiMaxTypingLongTaskCount

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

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -308,26 +308,13 @@ await page.WaitForFunctionAsync(
308308

309309
internal static async Task SetTextAsync(IPage page, string text)
310310
{
311-
_ = await InvokeHarnessAsync<EditorMonacoState>(page, "setText", new { text });
311+
var state = await InvokeHarnessAsync<EditorMonacoState?>(page, "setText", new { text });
312+
await Assert.That(state).IsNotNull();
313+
await Assert.That(state!.Text).IsEqualTo(text);
312314
await Expect(SourceInput(page)).ToHaveValueAsync(text, new()
313315
{
314316
Timeout = BrowserTestConstants.Timing.EditorMutationTimeoutMs
315317
});
316-
317-
await page.WaitForFunctionAsync(
318-
"""
319-
(args) => {
320-
const harness = window[args.harnessGlobalName];
321-
return harness?.getState(args.testId)?.text === args.expectedText;
322-
}
323-
""",
324-
new
325-
{
326-
expectedText = text,
327-
harnessGlobalName = EditorMonacoRuntimeContract.BrowserHarnessGlobalName,
328-
testId = UiTestIds.Editor.SourceStage
329-
},
330-
new() { Timeout = BrowserTestConstants.Timing.EditorMutationTimeoutMs });
331318
}
332319

333320
internal static Task DropFilesAsync(IPage page, params DroppedFileDescriptor[] files) =>

0 commit comments

Comments
 (0)