Skip to content

Commit 64e7866

Browse files
committed
fix observer for interest removal
1 parent 0db4f12 commit 64e7866

File tree

5 files changed

+52
-21
lines changed

5 files changed

+52
-21
lines changed

src/Frontend/NetzkollektivEasyCredit/Subscriber/Frontend.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ public function onOrderSave(\Enlight_Event_EventArgs $args)
121121

122122
$orderVariables = $args->get('variables');
123123
if (
124-
!isset($orderVariables['additional']['payment']['name'])
125-
|| $orderVariables['additional']['payment']['name'] != 'easycredit'
124+
!isset($orderVariables['additional']['payment']['class'])
125+
|| $orderVariables['additional']['payment']['class'] != 'easycredit'
126126
) {
127127
return;
128128
}

tests/api.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { request } from "@playwright/test";
2+
import config from './playwright.config';
3+
4+
const username = "demo";
5+
const apiKey = "dVHnNzuVi4wvTcwV36K12D0OFgqvVzTxsRvTmRqC";
6+
7+
const headers = {
8+
"Content-Type": "application/json",
9+
Accept: "application/json",
10+
Authorization: "Basic " + btoa(username + ":" + apiKey),
11+
};
12+
13+
14+
async function createApiClient() {
15+
console.log(config.use.baseURL);
16+
const req = await request.newContext({
17+
baseURL: config.use.baseURL,
18+
});
19+
return req;
20+
}
21+
22+
export { createApiClient, headers as apiDefaultHeaders };

tests/common.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { test, expect } from "@playwright/test";
22
import { delay, randomize, clickWithRetry } from "./utils";
33
import { PaymentTypes } from "./types";
4+
import { createApiClient, apiDefaultHeaders } from "./api"
45

56
export const goToProduct = async (page, sku = "regular") => {
67
await test.step(`Go to product (sku: ${sku}}`, async () => {
@@ -184,6 +185,25 @@ export const confirmOrder = async ({
184185
await expect(
185186
page.getByText("Vielen Dank für Ihre Bestellung")
186187
).toBeVisible();
188+
189+
if (paymentType === PaymentTypes.INSTALLMENT) {
190+
const textContent = await page.locator('.finish--details').textContent();
191+
const orderNumber = textContent.match(/Bestellnummer: (\d+)/)[1];
192+
193+
const apiClient = await createApiClient();
194+
const orderResponse = await apiClient
195+
.get(`/api/orders/${orderNumber}?useNumberAsId=true`, {
196+
headers: apiDefaultHeaders,
197+
});
198+
const order = await orderResponse.json()
199+
console.log(order)
200+
await expect(
201+
order.data.details.filter(
202+
(pos) => pos.articleNumber === "sw-payment-ec-interest"
203+
),
204+
"Interest should be removed after order (default setting)"
205+
).toHaveLength(0);
206+
}
187207
});
188208
};
189209

tests/global.setup.ts

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,12 @@
1-
import { chromium, request, type FullConfig } from "@playwright/test";
1+
import { createApiClient, apiDefaultHeaders } from "./api"
22

3-
async function globalSetup(config: FullConfig) {
3+
async function globalSetup() {
44
console.log("[prepareData] preparing test data in store");
55

6-
const username = "demo";
7-
const apiKey = "dVHnNzuVi4wvTcwV36K12D0OFgqvVzTxsRvTmRqC";
6+
const apiClient = await createApiClient();
87

9-
var headers = {
10-
"Content-Type": "application/json",
11-
Accept: "application/json",
12-
Authorization: "Basic " + btoa(username + ":" + apiKey),
13-
};
14-
15-
const req = await request.newContext({
16-
baseURL: config.projects[0].use.baseURL,
17-
});
18-
19-
let response = await req.post("/api/categories", {
20-
headers: headers,
8+
let response = await apiClient.post("/api/categories", {
9+
headers: apiDefaultHeaders,
2110
data: {
2211
name: "Default",
2312
active: true,
@@ -90,8 +79,8 @@ async function globalSetup(config: FullConfig) {
9079
];
9180

9281
for (const productData of productsData) {
93-
const response = await req.post("/api/articles", {
94-
headers: headers,
82+
const response = await apiClient.post("/api/articles", {
83+
headers: apiDefaultHeaders,
9584
data: {
9685
...baseProductData,
9786
...productData,

tests/playwright.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ if (!process.env.BASE_URL) {
4343
...{
4444
webServer: {
4545
command:
46-
"cd /opt/shopware; PHP_CLI_SERVER_WORKERS=8 sudo php -S 0.0.0.0:80 -t . router.php",
46+
"cd /opt/shopware; PHP_CLI_SERVER_WORKERS=8 sudo php -q -S 0.0.0.0:80 -t . router.php",
4747
url: "http://localhost/",
4848
reuseExistingServer: !process.env.CI,
4949
stdout: "ignore",

0 commit comments

Comments
 (0)