Skip to content

Commit fe3f457

Browse files
authored
Implement timeout logic for Monaco diff style q
Add functionality to wait for Monaco diff style in Playwright tests.
1 parent 1f0d14a commit fe3f457

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

pages/playwright/index.html

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,30 @@ <h2>Usefull snippets</h2>
109109
// in docker this might throw Error: locator.check: Clicking the checkbox did not change its state
110110
// use .click() better in that case
111111
await page.locator("#loading-sel-1").uncheck();
112+
113+
const style = await page.evaluate(async () => {
114+
const timeout = 5000;
115+
const start = Date.now();
116+
117+
while (Date.now() - start < timeout) {
118+
const el = document.querySelector("monaco-diff") as any;
119+
120+
if (el?.shadowRoot) {
121+
await el.whenReady();
122+
123+
const target = el.shadowRoot.querySelector(".original-in-monaco-diff-editor");
124+
125+
if (target) {
126+
return window.getComputedStyle(target).backgroundColor;
127+
}
128+
}
129+
130+
await new Promise((r) => setTimeout(r, 200));
131+
}
132+
133+
throw new Error("Timeout waiting for monaco-diff style");
134+
});
135+
112136
</script>
113137

114138
<h2>Custom image ultimate test</h2>

0 commit comments

Comments
 (0)