浏览代码

test(core): Fix broken e2e tests

Michael Bromley 5 年之前
父节点
当前提交
2b36de2913

+ 4 - 4
packages/core/e2e/customer-group.e2e-spec.ts

@@ -12,7 +12,7 @@ import cu from 'i18next-icu/locale-data/cu';
 import path from 'path';
 
 import { initialData } from '../../../e2e-common/e2e-initial-data';
-import { TEST_SETUP_TIMEOUT_MS, testConfig } from '../../../e2e-common/test-config';
+import { testConfig, TEST_SETUP_TIMEOUT_MS } from '../../../e2e-common/test-config';
 
 import {
     AddCustomersToGroup,
@@ -76,7 +76,7 @@ describe('CustomerGroup resolver', () => {
             {
                 id: customers[0].id,
                 options: {
-                    skip: 1,
+                    skip: 3,
                 },
             },
         );
@@ -194,7 +194,7 @@ describe('CustomerGroup resolver', () => {
             {
                 id: customers[2].id,
                 options: {
-                    skip: 1,
+                    skip: 3,
                 },
             },
         );
@@ -254,7 +254,7 @@ describe('CustomerGroup resolver', () => {
             {
                 id: customers[1].id,
                 options: {
-                    skip: 2,
+                    skip: 4,
                 },
             },
         );

+ 18 - 16
packages/core/e2e/shop-auth.e2e-spec.ts

@@ -18,7 +18,7 @@ import gql from 'graphql-tag';
 import path from 'path';
 
 import { initialData } from '../../../e2e-common/e2e-initial-data';
-import { TEST_SETUP_TIMEOUT_MS, testConfig } from '../../../e2e-common/test-config';
+import { testConfig, TEST_SETUP_TIMEOUT_MS } from '../../../e2e-common/test-config';
 
 import {
     CreateAdministrator,
@@ -68,16 +68,16 @@ let sendEmailFn: jest.Mock;
 class TestEmailPlugin implements OnModuleInit {
     constructor(private eventBus: EventBus) {}
     onModuleInit() {
-        this.eventBus.ofType(AccountRegistrationEvent).subscribe((event) => {
+        this.eventBus.ofType(AccountRegistrationEvent).subscribe(event => {
             sendEmailFn(event);
         });
-        this.eventBus.ofType(PasswordResetEvent).subscribe((event) => {
+        this.eventBus.ofType(PasswordResetEvent).subscribe(event => {
             sendEmailFn(event);
         });
-        this.eventBus.ofType(IdentifierChangeRequestEvent).subscribe((event) => {
+        this.eventBus.ofType(IdentifierChangeRequestEvent).subscribe(event => {
             sendEmailFn(event);
         });
-        this.eventBus.ofType(IdentifierChangeEvent).subscribe((event) => {
+        this.eventBus.ofType(IdentifierChangeEvent).subscribe(event => {
             sendEmailFn(event);
         });
     }
@@ -148,7 +148,7 @@ describe('Shop auth & accounts', () => {
         });
 
         it('issues a new token if attempting to register a second time', async () => {
-            const sendEmail = new Promise<string>((resolve) => {
+            const sendEmail = new Promise<string>(resolve => {
                 sendEmailFn.mockImplementation((event: AccountRegistrationEvent) => {
                     resolve(event.user.verificationToken!);
                 });
@@ -172,7 +172,7 @@ describe('Shop auth & accounts', () => {
         });
 
         it('refreshCustomerVerification issues a new token', async () => {
-            const sendEmail = new Promise<string>((resolve) => {
+            const sendEmail = new Promise<string>(resolve => {
                 sendEmailFn.mockImplementation((event: AccountRegistrationEvent) => {
                     resolve(event.user.verificationToken!);
                 });
@@ -364,7 +364,7 @@ describe('Shop auth & accounts', () => {
                     id: customer.id,
                     options: {
                         // skip CUSTOMER_ADDRESS_CREATED entry
-                        skip: 1,
+                        skip: 3,
                     },
                 },
             );
@@ -522,7 +522,7 @@ describe('Shop auth & accounts', () => {
                 {
                     id: customer.id,
                     options: {
-                        skip: 3,
+                        skip: 5,
                     },
                 },
             );
@@ -587,7 +587,9 @@ describe('Shop auth & accounts', () => {
 
         const role = roleResult.createRole;
 
-        const identifier = `${code}@${Math.random().toString(16).substr(2, 8)}`;
+        const identifier = `${code}@${Math.random()
+            .toString(16)
+            .substr(2, 8)}`;
         const password = `test`;
 
         const adminResult = await shopClient.query<
@@ -614,7 +616,7 @@ describe('Shop auth & accounts', () => {
      * A "sleep" function which allows the sendEmailFn time to get called.
      */
     function waitForSendEmailFn() {
-        return new Promise((resolve) => setTimeout(resolve, 10));
+        return new Promise(resolve => setTimeout(resolve, 10));
     }
 });
 
@@ -664,7 +666,7 @@ describe('Expiring tokens', () => {
             expect(sendEmailFn).toHaveBeenCalledTimes(1);
             expect(verificationToken).toBeDefined();
 
-            await new Promise((resolve) => setTimeout(resolve, 3));
+            await new Promise(resolve => setTimeout(resolve, 3));
 
             return shopClient.query(VERIFY_EMAIL, {
                 password: 'test',
@@ -695,7 +697,7 @@ describe('Expiring tokens', () => {
             expect(sendEmailFn).toHaveBeenCalledTimes(1);
             expect(passwordResetToken).toBeDefined();
 
-            await new Promise((resolve) => setTimeout(resolve, 3));
+            await new Promise(resolve => setTimeout(resolve, 3));
 
             return shopClient.query<ResetPassword.Mutation, ResetPassword.Variables>(RESET_PASSWORD, {
                 password: 'test',
@@ -830,7 +832,7 @@ describe('Updating email address without email verification', () => {
 });
 
 function getVerificationTokenPromise(): Promise<string> {
-    return new Promise<any>((resolve) => {
+    return new Promise<any>(resolve => {
         sendEmailFn.mockImplementation((event: AccountRegistrationEvent) => {
             resolve(event.user.verificationToken);
         });
@@ -838,7 +840,7 @@ function getVerificationTokenPromise(): Promise<string> {
 }
 
 function getPasswordResetTokenPromise(): Promise<string> {
-    return new Promise<any>((resolve) => {
+    return new Promise<any>(resolve => {
         sendEmailFn.mockImplementation((event: PasswordResetEvent) => {
             resolve(event.user.passwordResetToken);
         });
@@ -849,7 +851,7 @@ function getEmailUpdateTokenPromise(): Promise<{
     identifierChangeToken: string | null;
     pendingIdentifier: string | null;
 }> {
-    return new Promise((resolve) => {
+    return new Promise(resolve => {
         sendEmailFn.mockImplementation((event: IdentifierChangeRequestEvent) => {
             resolve(pick(event.user, ['identifierChangeToken', 'pendingIdentifier']));
         });

+ 1 - 1
packages/core/e2e/shop-catalog.e2e-spec.ts

@@ -132,7 +132,7 @@ describe('Shop catalog', () => {
                     GET_PRODUCT_SIMPLE,
                     {},
                 );
-            }, 'Either the product id or slug must be provided'),
+            }, 'Either the Product id or slug must be provided'),
         );
 
         it('product returns null for disabled product', async () => {

+ 6 - 6
packages/core/e2e/shop-customer.e2e-spec.ts

@@ -6,7 +6,7 @@ import path from 'path';
 import { skip } from 'rxjs/operators';
 
 import { initialData } from '../../../e2e-common/e2e-initial-data';
-import { TEST_SETUP_TIMEOUT_MS, testConfig } from '../../../e2e-common/test-config';
+import { testConfig, TEST_SETUP_TIMEOUT_MS } from '../../../e2e-common/test-config';
 
 import {
     AttemptLogin,
@@ -144,7 +144,7 @@ describe('Shop customers', () => {
                     id: customer.id,
                     options: {
                         // skip populated CUSTOMER_ADDRESS_CREATED entry
-                        skip: 1,
+                        skip: 3,
                     },
                 },
             );
@@ -186,7 +186,7 @@ describe('Shop customers', () => {
                     id: customer.id,
                     options: {
                         // skip populated CUSTOMER_ADDRESS_CREATED, CUSTOMER_DETAIL_UPDATED entries
-                        skip: 2,
+                        skip: 4,
                     },
                 },
             );
@@ -219,7 +219,7 @@ describe('Shop customers', () => {
         it('customer history for CUSTOMER_ADDRESS_UPDATED', async () => {
             const result = await adminClient.query<GetCustomerHistory.Query, GetCustomerHistory.Variables>(
                 GET_CUSTOMER_HISTORY,
-                { id: customer.id, options: { skip: 3 } },
+                { id: customer.id, options: { skip: 5 } },
             );
 
             expect(result.customer?.history.items.map(pick(['type', 'data']))).toEqual([
@@ -263,7 +263,7 @@ describe('Shop customers', () => {
         it('customer history for CUSTOMER_ADDRESS_DELETED', async () => {
             const result = await adminClient.query<GetCustomerHistory.Query, GetCustomerHistory.Variables>(
                 GET_CUSTOMER_HISTORY,
-                { id: customer.id, options: { skip: 4 } },
+                { id: customer.id, options: { skip: 6 } },
             );
 
             expect(result.customer?.history.items.map(pick(['type', 'data']))).toEqual([
@@ -312,7 +312,7 @@ describe('Shop customers', () => {
         it('customer history for CUSTOMER_PASSWORD_UPDATED', async () => {
             const result = await adminClient.query<GetCustomerHistory.Query, GetCustomerHistory.Variables>(
                 GET_CUSTOMER_HISTORY,
-                { id: customer.id, options: { skip: 5 } },
+                { id: customer.id, options: { skip: 7 } },
             );
 
             expect(result.customer?.history.items.map(pick(['type', 'data']))).toEqual([