test-client.ts 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. import { getDefaultChannelToken } from '../mock-data/get-default-channel-token';
  2. import { SimpleGraphQLClient } from '../mock-data/simple-graphql-client';
  3. import { testConfig } from './config/test-config';
  4. // tslint:disable:no-console
  5. /**
  6. * A GraphQL client for use in e2e tests configured to use the test admin server endpoint.
  7. */
  8. export class TestAdminClient extends SimpleGraphQLClient {
  9. constructor() {
  10. super(`http://localhost:${testConfig.port}/${testConfig.adminApiPath}`);
  11. }
  12. async init() {
  13. const token = await getDefaultChannelToken(false);
  14. this.setChannelToken(token);
  15. await this.asSuperAdmin();
  16. }
  17. }
  18. /**
  19. * A GraphQL client for use in e2e tests configured to use the test shop server endpoint.
  20. */
  21. export class TestShopClient extends SimpleGraphQLClient {
  22. constructor() {
  23. super(`http://localhost:${testConfig.port}/${testConfig.shopApiPath}`);
  24. }
  25. async init() {
  26. const token = await getDefaultChannelToken(false);
  27. this.setChannelToken(token);
  28. }
  29. }