|
|
@@ -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']));
|
|
|
});
|