|
|
@@ -1,3 +1,4 @@
|
|
|
+import { pick } from '@vendure/common/lib/pick';
|
|
|
import { mergeConfig } from '@vendure/core';
|
|
|
import { createTestEnvironment } from '@vendure/testing';
|
|
|
import gql from 'graphql-tag';
|
|
|
@@ -7,8 +8,14 @@ import { initialData } from '../../../e2e-common/e2e-initial-data';
|
|
|
import { testConfig, TEST_SETUP_TIMEOUT_MS } from '../../../e2e-common/test-config';
|
|
|
|
|
|
import { TestAuthenticationStrategy, VALID_AUTH_TOKEN } from './fixtures/test-authentication-strategies';
|
|
|
-import { Authenticate, GetCustomers, Me } from './graphql/generated-e2e-admin-types';
|
|
|
-import { ME } from './graphql/shared-definitions';
|
|
|
+import {
|
|
|
+ Authenticate,
|
|
|
+ GetCustomerHistory,
|
|
|
+ GetCustomers,
|
|
|
+ HistoryEntryType,
|
|
|
+ Me,
|
|
|
+} from './graphql/generated-e2e-admin-types';
|
|
|
+import { GET_CUSTOMER_HISTORY, ME } from './graphql/shared-definitions';
|
|
|
import { assertThrowsWithMessage } from './utils/assert-throws-with-message';
|
|
|
|
|
|
describe('AuthenticationStrategy', () => {
|
|
|
@@ -39,6 +46,7 @@ describe('AuthenticationStrategy', () => {
|
|
|
firstName: 'Cixin',
|
|
|
lastName: 'Liu',
|
|
|
};
|
|
|
+ let newCustomerId: string;
|
|
|
|
|
|
it(
|
|
|
'fails with a bad token',
|
|
|
@@ -73,6 +81,31 @@ describe('AuthenticationStrategy', () => {
|
|
|
'hayden.zieme12@hotmail.com',
|
|
|
userData.email,
|
|
|
]);
|
|
|
+ newCustomerId = after.items[1].id;
|
|
|
+ });
|
|
|
+
|
|
|
+ it('creates customer history entry', async () => {
|
|
|
+ const { customer } = await adminClient.query<
|
|
|
+ GetCustomerHistory.Query,
|
|
|
+ GetCustomerHistory.Variables
|
|
|
+ >(GET_CUSTOMER_HISTORY, {
|
|
|
+ id: newCustomerId,
|
|
|
+ });
|
|
|
+
|
|
|
+ expect(customer?.history.items.map(pick(['type', 'data']))).toEqual([
|
|
|
+ {
|
|
|
+ type: HistoryEntryType.CUSTOMER_REGISTERED,
|
|
|
+ data: {
|
|
|
+ strategy: 'test_strategy',
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: HistoryEntryType.CUSTOMER_VERIFIED,
|
|
|
+ data: {
|
|
|
+ strategy: 'test_strategy',
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ]);
|
|
|
});
|
|
|
|
|
|
it('creates authenticated session', async () => {
|