Skip to content

Commit d96b572

Browse files
committed
Stabilize browser readiness checks
1 parent 240ee12 commit d96b572

3 files changed

Lines changed: 22 additions & 5 deletions

File tree

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,11 @@ private static string BuildStepName(int scenarioIndex, string triggerTestId) =>
5858

5959
private static async Task AssertDropdownPaintAsync(Microsoft.Playwright.IPage page, DropdownPaintScenario scenario)
6060
{
61-
await page.GetByTestId(scenario.TriggerTestId).ClickAsync();
6261
var panel = page.GetByTestId(scenario.PanelTestId);
63-
await Expect(panel)
64-
.ToBeVisibleAsync(new() { Timeout = BrowserTestConstants.Timing.FastVisibleTimeoutMs });
62+
await UiInteractionDriver.ClickAndWaitForVisibleAsync(
63+
page.GetByTestId(scenario.TriggerTestId),
64+
panel,
65+
noWaitAfter: true);
6566

6667
var hitTest = await page.EvaluateAsync<DropdownHitTestResult>(
6768
"""

‎tests/PrompterOne.Web.UITests.Reader/Teleprompter/TeleprompterFullFlowTests.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ private static async Task AssertCurrentActiveWordAlignedAsync(Microsoft.Playwrig
157157
var activeWord = page.Locator(BrowserTestConstants.Teleprompter.ActiveWordSelector);
158158
await Expect(activeWord).ToBeVisibleAsync(new()
159159
{
160-
Timeout = BrowserTestConstants.Teleprompter.AlignmentTimeoutMs
160+
Timeout = BrowserTestConstants.Timing.ReaderPlaybackAdvanceTimeoutMs
161161
});
162162
await AssertGuideAlignmentAsync(
163163
page,

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,27 @@ await page.WaitForFunctionAsync(
4747
"""
4848
(args) => {
4949
const host = document.querySelector(`[data-test="${args.testId}"]`);
50-
return host?.getAttribute(args.readyAttributeName) === args.readyValue;
50+
if (!(host instanceof HTMLElement)) {
51+
return false;
52+
}
53+
54+
if (host.getAttribute(args.readyAttributeName) === args.readyValue) {
55+
return true;
56+
}
57+
58+
const harness = window[args.harnessGlobalName];
59+
const state = harness?.getState?.(args.testId);
60+
return state?.engine === args.editorEngineValue &&
61+
state?.languageId === args.languageId &&
62+
typeof state?.text === "string" &&
63+
state?.lineCount > 0;
5164
}
5265
""",
5366
new
5467
{
68+
editorEngineValue = EditorMonacoRuntimeContract.EditorEngineAttributeValue,
69+
harnessGlobalName = EditorMonacoRuntimeContract.BrowserHarnessGlobalName,
70+
languageId = EditorMonacoRuntimeContract.TpsLanguageId,
5571
readyAttributeName = EditorMonacoRuntimeContract.EditorReadyAttributeName,
5672
readyValue = "true",
5773
testId = UiTestIds.Editor.SourceStage

0 commit comments

Comments
 (0)