fix: Bug fixed für Rollen
Backend Image / build-and-push (push) Failing after 1m12s
Frontend Image / build-and-push (push) Successful in 1m14s

This commit is contained in:
Nick Szaunig committed 2026-09-01 16:54:42 +02:00
1 parent 8432313fa9
commit 5f4e1a7ba9
9 files changed
+311 -341

No files matched your search

@@ -2,6 +2,7 @@ import { NotFoundException } from '@nestjs/common';
import { LabelTemplatesService } from './label-templates.service';
import { PrismaService } from '../prisma/prisma.service';
import { AuditLogService } from '../audit/audit-log.service';
import { LabelElement } from './label-element.types';
describe('LabelTemplatesService', () => {
let service: LabelTemplatesService;
@@ -23,10 +24,44 @@ describe('LabelTemplatesService', () => {
};
let auditLog: { record: jest.Mock };
const elements: LabelElement[] = [
{
id: 'el-1',
type: 'text',
x: 2,
y: 2,
width: 60,
height: 10,
text: '',
placeholderKey: 'batchNumber',
fontSize: 9,
fontFamily: 'sans',
bold: false,
italic: false,
color: '#000000',
align: 'left',
},
{
id: 'el-2',
type: 'text',
x: 2,
y: 14,
width: 60,
height: 10,
text: 'MHD:',
fontSize: 9,
fontFamily: 'sans',
bold: false,
italic: false,
color: '#000000',
align: 'left',
},
];
const template = {
id: 'template-1',
name: 'Standard',
content: 'Charge {{batchNumber}} - MHD {{bestBeforeDate}}',
elements,
widthMm: 90,
heightMm: 35,
isDefault: false,
@@ -74,7 +109,7 @@ describe('LabelTemplatesService', () => {
});
await service.create(
{ name: 'Standard', content: 'x', isDefault: true },
{ name: 'Standard', elements: [], isDefault: true },
'user-1',
);
@@ -90,7 +125,7 @@ describe('LabelTemplatesService', () => {
it('does not touch other defaults when isDefault is not set', async () => {
tx.labelTemplate.create.mockResolvedValue(template);
await service.create({ name: 'Standard', content: 'x' }, 'user-1');
await service.create({ name: 'Standard', elements: [] }, 'user-1');
expect(tx.labelTemplate.updateMany).not.toHaveBeenCalled();
});
@@ -119,7 +154,7 @@ describe('LabelTemplatesService', () => {
});
describe('renderLabelsPdf', () => {
it('fills placeholders and tiles one label per jar', async () => {
it('resolves placeholder text and tiles one label per jar', async () => {
prisma.labelTemplate.findUnique.mockResolvedValue(template);
prisma.bottlingBatch.findUnique.mockResolvedValue({
id: 'batch-1',
@@ -149,10 +184,17 @@ describe('LabelTemplatesService', () => {
).rejects.toBeInstanceOf(NotFoundException);
});
it('embeds a QR code pointing at the Herkunft page when the template uses {{qrCode}}', async () => {
it('embeds a QR code pointing at the Herkunft page when the template has a qrCode element', async () => {
const qrElement: LabelElement = {
id: 'el-qr',
type: 'qrCode',
x: 60,
y: 2,
size: 20,
};
prisma.labelTemplate.findUnique.mockResolvedValue({
...template,
content: `${template.content} {{qrCode}}`,
elements: [...elements, qrElement],
});
prisma.bottlingBatch.findUnique.mockResolvedValue({
id: 'batch-1',