entity-prefix.e2e-spec.ts 1.8 KB

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