ソースを参照

test(core): Fix flaky e2e test on mysql

Michael Bromley 3 年 前
コミット
929ccd1b0a
1 ファイル変更12 行追加2 行削除
  1. 12 2
      packages/core/e2e/list-query-builder.e2e-spec.ts

+ 12 - 2
packages/core/e2e/list-query-builder.e2e-spec.ts

@@ -975,6 +975,14 @@ describe('ListQueryBuilder', () => {
                 { languageCode: LanguageCode.de, name: 'fahrrad' },
                 { languageCode: LanguageCode.de, name: 'fahrrad' },
             ],
             ],
         ];
         ];
+        function getTestEntityTranslations(testEntities: { items: any[] }) {
+            // Explicitly sort the order of the translations as it was being non-deterministic on
+            // the mysql CI tests.
+            return testEntities.items.map((e: any) =>
+                e.translations.sort((a: any, b: any) => (a.languageCode < b.languageCode ? 1 : -1)),
+            );
+        }
+
         it('returns all translations with default languageCode', async () => {
         it('returns all translations with default languageCode', async () => {
             const { testEntities } = await shopClient.query(GET_LIST_WITH_TRANSLATIONS, {
             const { testEntities } = await shopClient.query(GET_LIST_WITH_TRANSLATIONS, {
                 options: {
                 options: {
@@ -985,8 +993,9 @@ describe('ListQueryBuilder', () => {
                 },
                 },
             });
             });
 
 
+            const testEntityTranslations = getTestEntityTranslations(testEntities);
             expect(testEntities.items.map((e: any) => e.name)).toEqual(['apple', 'bike']);
             expect(testEntities.items.map((e: any) => e.name)).toEqual(['apple', 'bike']);
-            expect(testEntities.items.map((e: any) => e.translations)).toEqual(allTranslations);
+            expect(testEntityTranslations).toEqual(allTranslations);
         });
         });
         it('returns all translations with non-default languageCode', async () => {
         it('returns all translations with non-default languageCode', async () => {
             const { testEntities } = await shopClient.query(
             const { testEntities } = await shopClient.query(
@@ -1002,8 +1011,9 @@ describe('ListQueryBuilder', () => {
                 { languageCode: LanguageCode.de },
                 { languageCode: LanguageCode.de },
             );
             );
 
 
+            const testEntityTranslations = getTestEntityTranslations(testEntities);
             expect(testEntities.items.map((e: any) => e.name)).toEqual(['apfel', 'fahrrad']);
             expect(testEntities.items.map((e: any) => e.name)).toEqual(['apfel', 'fahrrad']);
-            expect(testEntities.items.map((e: any) => e.translations)).toEqual(allTranslations);
+            expect(testEntityTranslations).toEqual(allTranslations);
         });
         });
     });
     });
 });
 });