entity-prefix.e2e-spec.ts 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import { mergeConfig } from '@vendure/core';
  2. import { createTestEnvironment } from '@vendure/testing';
  3. import path from 'path';
  4. import { afterAll, beforeAll, describe, expect, it } from 'vitest';
  5. import { initialData } from '../../../e2e-common/e2e-initial-data';
  6. import { TEST_SETUP_TIMEOUT_MS, testConfig } from '../../../e2e-common/test-config';
  7. import { ListQueryPlugin } from './fixtures/test-plugins/list-query-plugin';
  8. import { GetCustomerListQuery, GetCustomerListQueryVariables } from './graphql/generated-e2e-admin-types';
  9. import { GET_CUSTOMER_LIST } from './graphql/shared-definitions';
  10. /**
  11. * Tests edge-cases related to configurations with an `entityPrefix` defined in the
  12. * dbConnectionOptions.
  13. */
  14. describe('Entity prefix edge-cases', () => {
  15. const { server, adminClient, shopClient } = createTestEnvironment(
  16. mergeConfig(testConfig(), {
  17. dbConnectionOptions: {
  18. entityPrefix: 'prefix_',
  19. },
  20. plugins: [ListQueryPlugin],
  21. }),
  22. );
  23. beforeAll(async () => {
  24. await server.init({
  25. initialData,
  26. productsCsvPath: path.join(__dirname, 'fixtures/e2e-products-minimal.csv'),
  27. customerCount: 5,
  28. });
  29. await adminClient.asSuperAdmin();
  30. }, TEST_SETUP_TIMEOUT_MS);
  31. afterAll(async () => {
  32. await server.destroy();
  33. });
  34. // https://github.com/vendurehq/vendure/issues/1569
  35. it('customers list filter by postalCode', async () => {
  36. const result = await adminClient.query<GetCustomerListQuery, GetCustomerListQueryVariables>(
  37. GET_CUSTOMER_LIST,
  38. {
  39. options: {
  40. filter: {
  41. postalCode: {
  42. eq: 'NU9 0PW',
  43. },
  44. },
  45. },
  46. },
  47. );
  48. expect(result.customers.items.length).toBe(1);
  49. expect(result.customers.items[0].emailAddress).toBe('eliezer56@yahoo.com');
  50. });
  51. });