fix: restore backend ntfy and refill CI baseline

Closes #605
This commit is contained in:
Daniel Volz
2026-05-10 22:09:06 +02:00
committed by GitHub
parent 72ba4d1272
commit c38964cd70
11 changed files with 760 additions and 111 deletions
+11 -11
View File
@@ -3368,12 +3368,12 @@ describe("E2E Tests with Real Routes", () => {
looseTablets: 10,
},
refillPayload: { packsAdded: 0, loosePillsAdded: 100 },
expectedVisibleStockBeforeRefill: 4,
expectedVisibleStockBeforeRefill: 10,
expectedQuantityAdded: 100,
expectedResponsePacksAdded: 0,
expectedPackCount: 0,
expectedLooseTablets: 104,
expectedTotalPills: 104,
expectedLooseTablets: 110,
expectedTotalPills: 110,
expectedPersistedTotalPills: 100,
expectedStockAdjustment: 0,
},
@@ -3387,14 +3387,14 @@ describe("E2E Tests with Real Routes", () => {
looseTablets: 0,
},
refillPayload: { packsAdded: 1, loosePillsAdded: 0 },
expectedVisibleStockBeforeRefill: 4,
expectedVisibleStockBeforeRefill: 10,
expectedQuantityAdded: 10,
expectedResponsePacksAdded: 1,
expectedPackCount: 2,
expectedLooseTablets: 0,
expectedTotalPills: 14,
expectedTotalPills: 20,
expectedPersistedTotalPills: null,
expectedStockAdjustment: -6,
expectedStockAdjustment: 0,
},
{
name: "liquid_container",
@@ -3408,17 +3408,17 @@ describe("E2E Tests with Real Routes", () => {
blisters: [{ usage: 1, every: 1, start: "2025-01-01T08:00:00.000Z" }],
},
refillPayload: { packsAdded: 1, loosePillsAdded: 0 },
expectedVisibleStockBeforeRefill: 4,
expectedVisibleStockBeforeRefill: 10,
expectedQuantityAdded: 100,
expectedResponsePacksAdded: 1,
expectedAmountPerPackage: 100,
expectedPackCount: 2,
expectedLooseTablets: 104,
expectedTotalPills: 104,
expectedPersistedTotalPills: 104,
expectedLooseTablets: 110,
expectedTotalPills: 110,
expectedPersistedTotalPills: 110,
expectedStockAdjustment: 0,
},
])("should refill from current visible stock after prior consumption for $name", async ({
])("should refill from the persisted stock baseline after prior consumption for $name", async ({
payload,
refillPayload,
expectedVisibleStockBeforeRefill,
+25 -14
View File
@@ -10,33 +10,34 @@ const EnvSchema = z.object({
NODE_ENV: z.enum(["development", "production", "test"]).default("production"),
PORT: z
.string()
.transform((v) => parseInt(v, 10))
.default(3000),
.default("3000")
.transform((v) => parseInt(v, 10)),
CORS_ORIGINS: z.string().default("http://localhost:5173,http://localhost:4173"),
LOG_LEVEL: z.string().default("info"),
PUBLIC_APP_URL: z.string().url().optional(),
AUTH_ENABLED: z
.string()
.transform((v) => v === "true")
.default(false),
.default("false")
.transform((v) => v === "true"),
REGISTRATION_ENABLED: z
.string()
.transform((v) => v === "true")
.default(false),
.default("false")
.transform((v) => v === "true"),
JWT_SECRET: z.string().min(10).optional(),
REFRESH_SECRET: z.string().min(10).optional(),
COOKIE_SECRET: z.string().min(10).optional(),
ACCESS_TOKEN_TTL_MINUTES: z
.string()
.transform((v) => parseInt(v, 10))
.default(15),
.default("15")
.transform((v) => parseInt(v, 10)),
REFRESH_TOKEN_TTL_DAYS: z
.string()
.transform((v) => parseInt(v, 10))
.default(7),
.default("7")
.transform((v) => parseInt(v, 10)),
OIDC_ENABLED: z
.string()
.transform((v) => v === "true")
.default(false),
.default("false")
.transform((v) => v === "true"),
OIDC_ISSUER_URL: z.string().url().optional(),
OIDC_CLIENT_ID: z.string().optional(),
OIDC_CLIENT_SECRET: z.string().optional(),
@@ -44,8 +45,8 @@ const EnvSchema = z.object({
OIDC_SCOPES: z.string().default("openid profile email"),
OIDC_AUTO_CREATE_USERS: z
.string()
.transform((v) => v === "true")
.default(true),
.default("true")
.transform((v) => v === "true"),
OIDC_USERNAME_CLAIM: z.string().default("preferred_username"),
OIDC_PROVIDER_NAME: z.string().default("SSO"),
});
@@ -81,6 +82,7 @@ describe("EnvSchema", () => {
expect(result.PORT).toBe(3000);
expect(result.CORS_ORIGINS).toBe("http://localhost:5173,http://localhost:4173");
expect(result.LOG_LEVEL).toBe("info");
expect(result.PUBLIC_APP_URL).toBeUndefined();
expect(result.AUTH_ENABLED).toBe(false);
expect(result.REGISTRATION_ENABLED).toBe(false);
expect(result.ACCESS_TOKEN_TTL_MINUTES).toBe(15);
@@ -188,6 +190,15 @@ describe("EnvSchema", () => {
});
describe("OIDC URL validation", () => {
it("should accept valid PUBLIC_APP_URL", () => {
const result = EnvSchema.parse({ PUBLIC_APP_URL: "https://medassist.example.com" });
expect(result.PUBLIC_APP_URL).toBe("https://medassist.example.com");
});
it("should reject invalid PUBLIC_APP_URL", () => {
expect(() => EnvSchema.parse({ PUBLIC_APP_URL: "not-a-url" })).toThrow();
});
it("should accept valid OIDC_ISSUER_URL", () => {
const result = EnvSchema.parse({ OIDC_ISSUER_URL: "https://auth.example.com" });
expect(result.OIDC_ISSUER_URL).toBe("https://auth.example.com");
+7 -3
View File
@@ -374,14 +374,14 @@ describe("Real route coverage: settings/export/report", () => {
label: "Take",
url: expect.stringMatching(/^https:\/\/app\.example\.com\/api\/notification-actions\//),
method: "POST",
clear: false,
clear: true,
},
{
action: "http",
label: "Skip",
url: expect.stringMatching(/^https:\/\/app\.example\.com\/api\/notification-actions\//),
method: "POST",
clear: false,
clear: true,
},
{
action: "view",
@@ -632,7 +632,11 @@ describe("Real route coverage: settings/export/report", () => {
expect(body[medId].dosesTaken).toBe(1);
expect(body[medId].dosesSkipped).toBe(1);
expect(body[medId].refills).toHaveLength(1);
expect(body[medId].refills[0].quantityAdded).toBe(22);
expect(body[medId].refills[0]).toMatchObject({
packsAdded: 1,
loosePillsAdded: 2,
usedPrescription: true,
});
});
it("POST /medications/report-data filters dose counts by takenBy suffix when requested", async () => {