Skip to content

Commit 6c1b8bf

Browse files
authored
attempt at fixing the line numbers flake (#2913)
1 parent 68e6199 commit 6c1b8bf

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

packages/compass-e2e-tests/tests/collection-documents-tab.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,19 @@ async function navigateToTab(browser: CompassBrowser, tabName: string) {
6060
await tabSelectedSelectorElement.waitForDisplayed();
6161
}
6262

63+
async function waitForJSON(browser: CompassBrowser, element: Element<'async'>) {
64+
// Sometimes the line numbers end up in the text for some reason. Probably
65+
// because we get the text before the component is properly initialised.
66+
await browser.waitUntil(async () => {
67+
const text = await element.getText();
68+
const isJSON = text.replace(/\s+/g, ' ').startsWith('{');
69+
if (!isJSON) {
70+
console.log({ text });
71+
}
72+
return isJSON;
73+
});
74+
}
75+
6376
describe('Collection documents tab', function () {
6477
let compass: Compass;
6578
let browser: CompassBrowser;
@@ -338,6 +351,9 @@ FindIterable<Document> result = collection.find(filter);`);
338351

339352
const document = await browser.$(Selectors.DocumentJSONEntry);
340353
await document.waitForDisplayed();
354+
355+
await waitForJSON(browser, document);
356+
341357
const json = await document.getText();
342358
expect(json.replace(/\s+/g, ' ')).to.match(
343359
/^\{ "_id": \{ "\$oid": "[a-f0-9]{24}" \}, "i": 32, "j": 0 \}$/
@@ -365,6 +381,9 @@ FindIterable<Document> result = collection.find(filter);`);
365381

366382
const modifiedDocument = await browser.$(Selectors.DocumentJSONEntry);
367383
await modifiedDocument.waitForDisplayed();
384+
385+
await waitForJSON(browser, modifiedDocument);
386+
368387
expect((await modifiedDocument.getText()).replace(/\s+/g, ' ')).to.match(
369388
/^\{ "_id": \{ "\$oid": "[a-f0-9]{24}" \}, "i": 32, "j": 1234 \}$/
370389
);

0 commit comments

Comments
 (0)