Skip to content

Commit b2b7b7a

Browse files
committed
wait for text to include the expected result
1 parent 46943b3 commit b2b7b7a

File tree

3 files changed

+46
-20
lines changed

3 files changed

+46
-20
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -684,9 +684,13 @@ describe('Collection aggregations tab', function () {
684684

685685
const errorElement = browser.$(Selectors.AggregationErrorBanner);
686686
await errorElement.waitForDisplayed();
687-
expect(await errorElement.getText()).to.include(
688-
'Document failed validation'
689-
);
687+
688+
await browser.waitUntil(async () => {
689+
return (await errorElement.getText()).includes(
690+
'Document failed validation'
691+
);
692+
});
693+
690694
// enter details
691695
const errorDetailsBtn = browser.$(Selectors.AggregationErrorDetailsBtn);
692696
await errorElement.waitForDisplayed();

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

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -718,9 +718,13 @@ FindIterable<Document> result = collection.find(filter);`);
718718

719719
const errorElement = browser.$(Selectors.InsertDialogErrorMessage);
720720
await errorElement.waitForDisplayed();
721-
expect(await errorElement.getText()).to.include(
722-
'Document failed validation'
723-
);
721+
722+
await browser.waitUntil(async () => {
723+
return (await errorElement.getText()).includes(
724+
'Document failed validation'
725+
);
726+
});
727+
724728
// enter details
725729
const errorDetailsBtn = browser.$(Selectors.InsertDialogErrorDetailsBtn);
726730
await errorElement.waitForDisplayed();
@@ -764,9 +768,12 @@ FindIterable<Document> result = collection.find(filter);`);
764768

765769
const errorMessage = browser.$(Selectors.DocumentFooterMessage);
766770
await errorMessage.waitForDisplayed();
767-
expect(await errorMessage.getText()).to.include(
768-
'Document failed validation'
769-
);
771+
772+
await browser.waitUntil(async () => {
773+
return (await errorMessage.getText()).includes(
774+
'Document failed validation'
775+
);
776+
});
770777

771778
// enter details
772779
const errorDetailsBtn = browser.$(
@@ -810,9 +817,12 @@ FindIterable<Document> result = collection.find(filter);`);
810817

811818
const errorMessage = browser.$(Selectors.DocumentFooterMessage);
812819
await errorMessage.waitForDisplayed();
813-
expect(await errorMessage.getText()).to.include(
814-
'Document failed validation'
815-
);
820+
821+
await browser.waitUntil(async () => {
822+
return (await errorMessage.getText()).includes(
823+
'Document failed validation'
824+
);
825+
});
816826

817827
// enter details
818828
const errorDetailsBtn = browser.$(
@@ -853,9 +863,12 @@ FindIterable<Document> result = collection.find(filter);`);
853863

854864
const errorMessage = browser.$(Selectors.DocumentFooterMessage);
855865
await errorMessage.waitForDisplayed();
856-
expect(await errorMessage.getText()).to.include(
857-
'Document failed validation'
858-
);
866+
867+
await browser.waitUntil(async () => {
868+
return (await errorMessage.getText()).includes(
869+
'Document failed validation'
870+
);
871+
});
859872

860873
// enter details
861874
const errorDetailsBtn = browser.$(

packages/compass-e2e-tests/tests/collection-import.test.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -573,8 +573,12 @@ describe('Collection import', function () {
573573
// Wait for the error toast to appear
574574
const toastElement = browser.$(Selectors.ImportToast);
575575
await toastElement.waitForDisplayed();
576-
const errorText = await toastElement.getText();
577-
expect(errorText).to.include('Document failed validation');
576+
577+
await browser.waitUntil(async () => {
578+
return (await toastElement.getText()).includes(
579+
'Document failed validation'
580+
);
581+
});
578582

579583
// Visit error details
580584
await browser.clickVisible(Selectors.ImportToastErrorDetailsBtn);
@@ -618,9 +622,14 @@ describe('Collection import', function () {
618622
// Wait for the error toast to appear
619623
const toastElement = browser.$(Selectors.ImportToast);
620624
await toastElement.waitForDisplayed();
621-
const errorText = await toastElement.getText();
622-
expect(errorText).to.include('Document failed validation');
623-
expect(errorText).to.include('VIEW LOG');
625+
626+
await browser.waitUntil(async () => {
627+
const text = await toastElement.getText();
628+
return (
629+
text.includes('Document failed validation') &&
630+
text.includes('VIEW LOG')
631+
);
632+
});
624633

625634
// Find the log file
626635
const logFilePath = path.resolve(

0 commit comments

Comments
 (0)