Browse Source

test: Further attempt to de-flake some postgres tests

Michael Bromley 5 years ago
parent
commit
2b24cbcd94

+ 10 - 2
packages/core/e2e/default-search-plugin.e2e-spec.ts

@@ -937,8 +937,11 @@ describe('Default search plugin', () => {
                     input: { channelId: secondChannel.id, productVariantIds: ['T_10', 'T_15'] },
                 });
                 await awaitRunningJobs(adminClient);
-                // The postgres test is kinda flaky so we stick in a pause for good measure
-                await new Promise(resolve => setTimeout(resolve, 500));
+
+                if (process.env.DB === 'postgres') {
+                    // The postgres test is kinda flaky so we stick in a pause for good measure
+                    await new Promise(resolve => setTimeout(resolve, 1000));
+                }
 
                 adminClient.setChannelToken(SECOND_CHANNEL_TOKEN);
 
@@ -966,6 +969,11 @@ describe('Default search plugin', () => {
                 });
                 await awaitRunningJobs(adminClient);
 
+                if (process.env.DB === 'postgres') {
+                    // The postgres test is kinda flaky so we stick in a pause for good measure
+                    await new Promise(resolve => setTimeout(resolve, 1000));
+                }
+
                 adminClient.setChannelToken(SECOND_CHANNEL_TOKEN);
 
                 const { search: searchGrouped } = await doAdminSearchQuery({ groupByProduct: true });

+ 10 - 4
packages/elasticsearch-plugin/e2e/elasticsearch-plugin.e2e-spec.ts

@@ -807,8 +807,11 @@ describe('Elasticsearch plugin', () => {
                     input: { channelId: secondChannel.id, productVariantIds: ['T_10', 'T_15'] },
                 });
                 await awaitRunningJobs(adminClient);
-                // Updating of index sometimes flaky (postgres), so add a delay
-                await new Promise(resolve => setTimeout(resolve, 500));
+
+                if (process.env.DB === 'postgres') {
+                    // The postgres test is kinda flaky so we stick in a pause for good measure
+                    await new Promise(resolve => setTimeout(resolve, 1000));
+                }
 
                 adminClient.setChannelToken(SECOND_CHANNEL_TOKEN);
 
@@ -839,8 +842,11 @@ describe('Elasticsearch plugin', () => {
                     input: { channelId: secondChannel.id, productVariantIds: ['T_1', 'T_15'] },
                 });
                 await awaitRunningJobs(adminClient);
-                // Updating of index sometimes flaky (postgres), so add a delay
-                await new Promise(resolve => setTimeout(resolve, 500));
+
+                if (process.env.DB === 'postgres') {
+                    // The postgres test is kinda flaky so we stick in a pause for good measure
+                    await new Promise(resolve => setTimeout(resolve, 1000));
+                }
 
                 adminClient.setChannelToken(SECOND_CHANNEL_TOKEN);