Skip to content

Commit

Permalink
test(payments-plugin): Fix broken e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbromley committed Nov 10, 2021
1 parent 1c2e01b commit 2cb9765
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions packages/payment-plugin/e2e/mollie-payment.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import {
SqljsInitializer,
TestServer,
} from '@vendure/testing';
import { TEST_SETUP_TIMEOUT_MS, testConfig } from '../../../e2e-common/test-config';
import nock from 'nock';
import fetch from 'node-fetch';
import path from 'path';

import { initialData } from '../../../e2e-common/e2e-initial-data';
import { testConfig, TEST_SETUP_TIMEOUT_MS } from '../../../e2e-common/test-config';
import { MolliePlugin } from '../src/mollie';
import { molliePaymentHandler } from '../src/mollie/mollie.handler';

Expand Down Expand Up @@ -49,11 +49,13 @@ describe('Mollie payments', () => {
let started = false;
let customers: GetCustomerListQuery['customers']['items'];
let order: TestOrderFragmentFragment;
let serverPort: number;
beforeAll(async () => {
const devConfig = mergeConfig(testConfig, {
const devConfig = mergeConfig(testConfig(), {
plugins: [MolliePlugin.init({ vendureHost: mockData.host })],
});
const env = createTestEnvironment(devConfig);
serverPort = devConfig.apiOptions.port;
shopClient = env.shopClient;
adminClient = env.adminClient;
server = env.server;
Expand Down Expand Up @@ -83,8 +85,10 @@ describe('Mollie payments', () => {
});

it('Should add a Mollie paymentMethod', async () => {
const { createPaymentMethod } = await adminClient.query<CreatePaymentMethod.Mutation,
CreatePaymentMethod.Variables>(CREATE_PAYMENT_METHOD, {
const { createPaymentMethod } = await adminClient.query<
CreatePaymentMethod.Mutation,
CreatePaymentMethod.Variables
>(CREATE_PAYMENT_METHOD, {
input: {
code: mockData.methodCode,
name: 'Mollie payment test',
Expand Down Expand Up @@ -116,8 +120,10 @@ describe('Mollie payments', () => {
quantity: 2,
});
await proceedToArrangingPayment(shopClient);
const { addPaymentToOrder } = await shopClient.query<AddPaymentToOrder.Mutation,
AddPaymentToOrder.Variables>(ADD_PAYMENT, {
const { addPaymentToOrder } = await shopClient.query<
AddPaymentToOrder.Mutation,
AddPaymentToOrder.Variables
>(ADD_PAYMENT, {
input: {
method: mockData.methodCode,
metadata: {},
Expand Down Expand Up @@ -146,7 +152,7 @@ describe('Mollie payments', () => {
status: PaymentStatus.paid,
metadata: { orderCode: order.code },
});
await fetch(`http://localhost:3050/payments/mollie/${E2E_DEFAULT_CHANNEL_TOKEN}/1`, {
await fetch(`http://localhost:${serverPort}/payments/mollie/${E2E_DEFAULT_CHANNEL_TOKEN}/1`, {
method: 'post',
body: JSON.stringify({ id: mockData.mollieResponse.id }),
headers: { 'Content-Type': 'application/json' },
Expand Down

0 comments on commit 2cb9765

Please sign in to comment.