Skip to content

Commit cf1a6a0

Browse files
committed
(tests) fix import flaky tests (dropdown menus)
some tests break because we want to click too early on elements not there yet, because they appear in dropdown menus right after clicking on buttons showing them. just wait a bit
1 parent 7dd0fb5 commit cf1a6a0

File tree

3 files changed

+45
-34
lines changed

3 files changed

+45
-34
lines changed

test/nbrowser/ImportReferences.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ describe('ImportReferences', function() {
124124
// PName (a reference column) does.
125125
await openSourceMenu('Label');
126126
assert.equal(await findColumnMenuItem('PIndex').isPresent(), true);
127-
assert.equal(await findColumnMenuItem(/as row ID/).isPresent(), false);
127+
assert.equal(await driver.findContent('.test-importer-column-match-menu-item', /as row ID/).isPresent(), false);
128128
await driver.sendKeys(Key.ESCAPE);
129129

130130
await openSourceMenu('PName');
@@ -208,5 +208,5 @@ async function mapper(el: WebElement) {
208208
}
209209

210210
function findColumnMenuItem(label: RegExp|string) {
211-
return driver.findContent('.test-importer-column-match-menu-item', label);
211+
return driver.findContentWait('.test-importer-column-match-menu-item', label, 100);
212212
}

test/nbrowser/Importer.ts

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -461,9 +461,10 @@ describe('Importer', function() {
461461

462462
// Select a merge field, and check that the red outline is gone.
463463
await driver.find('.test-importer-merge-fields-select').click();
464-
await driver.findContent(
464+
await driver.findContentWait(
465465
'.test-multi-select-menu .test-multi-select-menu-option',
466-
/Name/
466+
/Name/,
467+
100
467468
).click();
468469
assert.match(
469470
await driver.find('.test-importer-merge-fields-select').getCssValue('border'),
@@ -518,9 +519,10 @@ describe('Importer', function() {
518519
await waitForColumnMapping();
519520
await driver.find('.test-importer-update-existing-records').click();
520521
await driver.find('.test-importer-merge-fields-select').click();
521-
await driver.findContent(
522+
await driver.findContentWait(
522523
'.test-multi-select-menu .test-multi-select-menu-option',
523-
/Name/
524+
/Name/,
525+
100
524526
).click();
525527
await driver.findContent(
526528
'.test-multi-select-menu .test-multi-select-menu-option',
@@ -599,13 +601,15 @@ describe('Importer', function() {
599601

600602
// Now pick the merge fields, and check that the preview diff looks correct.
601603
await driver.find('.test-importer-merge-fields-select').click();
602-
await driver.findContent(
604+
await driver.findContentWait(
603605
'.test-multi-select-menu .test-multi-select-menu-option',
604-
/Name/
606+
/Name/,
607+
100
605608
).click();
606-
await driver.findContent(
609+
await driver.findContentWait(
607610
'.test-multi-select-menu .test-multi-select-menu-option',
608-
/Phone/
611+
/Phone/,
612+
100
609613
).click();
610614
await gu.sendKeys(Key.ESCAPE);
611615

@@ -634,9 +638,10 @@ describe('Importer', function() {
634638
await waitForColumnMapping();
635639
await driver.find('.test-importer-update-existing-records').click();
636640
await driver.find('.test-importer-merge-fields-select').click();
637-
await driver.findContent(
641+
await driver.findContentWait(
638642
'.test-multi-select-menu .test-multi-select-menu-option',
639-
/CourseId/
643+
/CourseId/,
644+
100
640645
).click();
641646

642647
// Close the merge fields menu.
@@ -724,9 +729,10 @@ describe('Importer', function() {
724729
await waitForColumnMapping();
725730
await driver.find('.test-importer-update-existing-records').click();
726731
await driver.find('.test-importer-merge-fields-select').click();
727-
await driver.findContent(
732+
await driver.findContentWait(
728733
'.test-multi-select-menu .test-multi-select-menu-option',
729-
/Name/
734+
/Name/,
735+
100
730736
).click();
731737
await driver.findContent(
732738
'.test-multi-select-menu .test-multi-select-menu-option',
@@ -758,9 +764,10 @@ describe('Importer', function() {
758764
await waitForColumnMapping();
759765
await driver.find('.test-importer-update-existing-records').click();
760766
await driver.find('.test-importer-merge-fields-select').click();
761-
await driver.findContent(
767+
await driver.findContentWait(
762768
'.test-multi-select-menu .test-multi-select-menu-option',
763-
/Code/
769+
/Code/,
770+
100
764771
).click();
765772
await gu.sendKeys(Key.ESCAPE);
766773

@@ -788,9 +795,10 @@ describe('Importer', function() {
788795
await waitForColumnMapping();
789796
await driver.find('.test-importer-update-existing-records').click();
790797
await driver.find('.test-importer-merge-fields-select').click();
791-
await driver.findContent(
798+
await driver.findContentWait(
792799
'.test-multi-select-menu .test-multi-select-menu-option',
793-
/Country/
800+
/Country/,
801+
100
794802
).click();
795803
await driver.findContent(
796804
'.test-multi-select-menu .test-multi-select-menu-option',
@@ -908,9 +916,10 @@ describe('Importer', function() {
908916

909917
// Select 'CourseId' as the merge column, and check that the preview now contains a diff of old/new values.
910918
await driver.find('.test-importer-merge-fields-select').click();
911-
await driver.findContent(
919+
await driver.findContentWait(
912920
'.test-multi-select-menu .test-multi-select-menu-option',
913-
/CourseId/
921+
/CourseId/,
922+
100
914923
).click();
915924
await gu.sendKeys(Key.ESCAPE);
916925
await gu.waitForServer();
@@ -950,7 +959,7 @@ describe('Importer', function() {
950959
await waitForDiffPreviewToLoad();
951960
await driver.findContent('.test-importer-column-match-source-destination', /CourseId/)
952961
.find('.test-importer-column-match-formula').click();
953-
await driver.find('.test-importer-apply-formula').click();
962+
await driver.findWait('.test-importer-apply-formula', 100).click();
954963
await gu.sendKeys(' + "-NEW"');
955964

956965
// Before saving the formula, check that the preview isn't showing the hidden helper column ids.

test/nbrowser/Importer2.ts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,10 @@ describe('Importer2', function() {
223223
await waitForColumnMapping();
224224
await driver.find('.test-importer-update-existing-records').click();
225225
await driver.find('.test-importer-merge-fields-select').click();
226-
await driver.findContent(
226+
await driver.findContentWait(
227227
'.test-multi-select-menu .test-multi-select-menu-option',
228-
/CourseId/
228+
/CourseId/,
229+
100
229230
).click();
230231
await gu.sendKeys(Key.ESCAPE);
231232
await gu.waitForServer();
@@ -458,7 +459,7 @@ describe('Importer2', function() {
458459
);
459460

460461
// Click 'Skip', and check that the column mapping section and preview both updated.
461-
await menu.findContent('.test-importer-column-match-menu-item', /Skip/).click();
462+
await menu.findContentWait('.test-importer-column-match-menu-item', /Skip/, 100).click();
462463
await gu.waitForServer();
463464
assert.deepEqual(await getColumnMatchingRows(), [
464465
{ destination: 'Name', source: 'Name' },
@@ -484,7 +485,7 @@ describe('Importer2', function() {
484485

485486
// Click Country in the column mapping section, and clear the formula.
486487
await driver.findContent('.test-importer-column-match-source', /Country/).click();
487-
await driver.find('.test-importer-apply-formula').click();
488+
await driver.findWait('.test-importer-apply-formula', 100).click();
488489
await gu.sendKeys(await gu.selectAllKey(), Key.DELETE, Key.ENTER);
489490
await gu.waitForServer();
490491

@@ -516,7 +517,7 @@ describe('Importer2', function() {
516517

517518
// We want to map the same column twice, which is not possible through the menu, so we will
518519
// use the formula.
519-
await driver.find('.test-importer-apply-formula').click();
520+
await driver.findWait('.test-importer-apply-formula', 100).click();
520521
await gu.sendKeys(await gu.selectAllKey(), Key.DELETE, '$Population', Key.ENTER);
521522
await gu.waitForServer();
522523
assert.deepEqual(await getColumnMatchingRows(), [
@@ -541,7 +542,7 @@ describe('Importer2', function() {
541542

542543
// Click Country (with formula 'Skip') in the column mapping section, and start typing a formula.
543544
await openSourceFor(/Country/);
544-
await driver.find('.test-importer-apply-formula').click();
545+
await driver.findWait('.test-importer-apply-formula', 100).click();
545546
await gu.sendKeys('$');
546547
await gu.waitForServer();
547548

@@ -593,7 +594,7 @@ describe('Importer2', function() {
593594
it('should reflect mappings when import to new table is finished', async function() {
594595
// Skip 'Population', so that we can test imports with skipped columns.
595596
await openSourceFor(/Population/);
596-
await driver.findContent('.test-importer-column-match-menu-item', 'Skip').click();
597+
await driver.findContentWait('.test-importer-column-match-menu-item', 'Skip', 100).click();
597598
await gu.waitForServer();
598599

599600
// Finish importing, and check that the destination tables have the correct data.
@@ -681,14 +682,14 @@ describe('Importer2', function() {
681682

682683
// Set formula for 'Name' to 'city_name' by typing in the formula.
683684
await openSourceFor(/Name/);
684-
await driver.find('.test-importer-apply-formula').click();
685+
await driver.findWait('.test-importer-apply-formula', 100).click();
685686
await gu.sendKeys('$city_name', Key.ENTER);
686687
await gu.waitForServer();
687688

688689
// Map 'District' to 'city_district' via the column mapping menu.
689690
await openSourceFor('District');
690691
const menu = gu.findOpenMenu();
691-
await menu.findContent('.test-importer-column-match-menu-item', /city_district/).click();
692+
await menu.findContentWait('.test-importer-column-match-menu-item', /city_district/, 100).click();
692693
await gu.waitForServer();
693694

694695
// Check the column mapping section and preview both updated correctly.
@@ -715,9 +716,10 @@ describe('Importer2', function() {
715716
// Now toggle 'Update existing records', and merge on 'Name' and 'District'.
716717
await driver.find('.test-importer-update-existing-records').click();
717718
await driver.find('.test-importer-merge-fields-select').click();
718-
await driver.findContent(
719+
await driver.findContentWait(
719720
'.test-multi-select-menu .test-multi-select-menu-option',
720-
/Name/
721+
/Name/,
722+
100
721723
).click();
722724
await driver.findContent(
723725
'.test-multi-select-menu .test-multi-select-menu-option',
@@ -764,13 +766,13 @@ describe('Importer2', function() {
764766
// we don't overwrite any values in the destination table. (A previous bug caused non-text
765767
// skipped columns to overwrite data with default values, like 0.)
766768
await openSourceFor(/Population/);
767-
await driver.find('.test-importer-apply-formula').click();
769+
await driver.findWait('.test-importer-apply-formula', 100).click();
768770
await gu.sendKeys('$city_pop', Key.ENTER);
769771
await gu.waitForServer();
770772

771773
// For "Pop. '000", deliberately map a duplicate column (so we can later check if import succeeded).
772774
await openSourceFor(/Pop\. '000/);
773-
await driver.find('.test-importer-apply-formula').click();
775+
await driver.findWait('.test-importer-apply-formula', 100).click();
774776
await gu.sendKeys('$city_pop', Key.ENTER);
775777
await gu.waitForServer();
776778

0 commit comments

Comments
 (0)