entity-id-strategy.e2e-spec.ts 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { CreateFacet, LanguageCode } from '@vendure/common/lib/generated-types';
  2. import gql from 'graphql-tag';
  3. import path from 'path';
  4. import { CREATE_FACET } from '../../../admin-ui/src/app/data/definitions/facet-definitions';
  5. import { TEST_SETUP_TIMEOUT_MS } from './config/test-config';
  6. import { TestShopClient } from './test-client';
  7. import { TestServer } from './test-server';
  8. describe('EntityIdStrategy', () => {
  9. const shopClient = new TestShopClient();
  10. const server = new TestServer();
  11. beforeAll(async () => {
  12. await server.init({
  13. productsCsvPath: path.join(__dirname, 'fixtures/e2e-products-minimal.csv'),
  14. customerCount: 1,
  15. });
  16. await shopClient.init();
  17. }, TEST_SETUP_TIMEOUT_MS);
  18. afterAll(async () => {
  19. await server.destroy();
  20. });
  21. it('Does not doubly-encode ids from resolved properties', async () => {
  22. const result = await shopClient.query(gql`
  23. query {
  24. product(id: "T_1", languageCode: en) {
  25. id
  26. variants {
  27. id
  28. options {
  29. id
  30. name
  31. }
  32. }
  33. }
  34. }
  35. `);
  36. expect(result.product.id).toBe('T_1');
  37. expect(result.product.variants[0].id).toBe('T_1');
  38. expect(result.product.variants[0].options[0].id).toBe('T_1');
  39. });
  40. });