Test the checkout code; publish images only for releases (#5)
build / test (push) Successful in 7s
build / build (push) Skipped

- src/checkout/ (PayPal order request, pricing, VAT) and src/logging/format.ts
  hold the checkout's pure code, moved out of PayPalApi, the product service
  and config without a behaviour change.
- npm test runs node:test on the TypeScript sources (type stripping), with no
  dependencies: 21 tests, 13 pin today's output, 8 describe the correct
  behaviour for the known defects of libretech/mp#67
  and are marked todo.
- CI: the tests run in the image's base (node:22.14.0-alpine) for every pull
  request, push to main and release tag. The image is built for pull requests
  and built and published only for v* tags; main no longer publishes :main
  and :sha-* images.

Refs libretech/mp#71

Co-authored-by: Michael Czechowski <mail@librete.ch>
This commit was merged in pull request #5.
This commit is contained in:
2026-10-08 22:36:47 +02:00
committed by libretech
parent 901a3b385f
commit 9b0c6af8b7
15 changed files with 542 additions and 96 deletions
+2 -4
View File
@@ -1,4 +1,5 @@
import { Environment } from "@paypal/paypal-server-sdk";
import { vatDecimal } from "../src/checkout/vat";
export const pdfApiUrl = process.env.PDF_API_ADDRESS!;
export const mailApiUrl = process.env.MAIL_API_ADDRESS!;
@@ -18,10 +19,7 @@ export const shopEmail = process.env.SHOP_EMAIL ?? process.env.ADMIN_EMAIL_ADDRE
export const shopLogoUrl = process.env.SHOP_LOGO_URL ?? "";
export const shopSecondaryLogoUrl = process.env.SHOP_SECONDARY_LOGO_URL ?? "";
// TODO: Should be retrieved from DepotApi
export const vatIncludedDecimal = 1.19;
// TODO: Should be retrieved from DepotApi
export const vatDecimal = 0.19;
export { vatIncludedDecimal, vatDecimal } from "../src/checkout/vat";
export const vatDecimalExcluded = 1 - vatDecimal;
export const maxProductsSitemap = 500;
+2 -8
View File
@@ -1,16 +1,10 @@
import { winston } from "@strapi/logger";
import { formatLogLine } from "../src/logging/format";
export default {
transports: [
new winston.transports.Console({
format: winston.format.combine(
winston.format.printf(({ timestamp, level, message, ...rest }) => {
let restString = JSON.stringify(rest, undefined, 2);
restString = restString === "{}" ? "" : restString;
return `${timestamp}Z ${level}: ${message} ${restString}`;
})
)
format: winston.format.combine(winston.format.printf(formatLogLine))
})
]
};