mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 16:28:12 +00:00
fix schule issue and contianer type issue
This commit is contained in:
@@ -5,9 +5,8 @@ import { PriorityConfigsService } from './priority-configs.service';
|
||||
|
||||
/**
|
||||
* Contiguous-range rules for priority configs: per type (per currency for
|
||||
* CURRENCY), ranges run 1..cap with no gaps and no overlaps; the next range
|
||||
* must start at the lowest uncovered wagon count. Caps: WAGON 50,
|
||||
* CURRENCY 35, CUSTOMS 15.
|
||||
* CURRENCY), ranges run from 1 with no gaps and no overlaps; the next range
|
||||
* must start at the lowest uncovered wagon count. There is no upper ceiling.
|
||||
*/
|
||||
describe('PriorityConfigsService range validation', () => {
|
||||
const rule = (
|
||||
@@ -118,41 +117,47 @@ describe('PriorityConfigsService range validation', () => {
|
||||
).rejects.toThrow(/overlaps existing rule/);
|
||||
});
|
||||
|
||||
it('enforces the per-type ceilings (WAGON 50, CURRENCY 35, CUSTOMS 15)', async () => {
|
||||
it('imposes no upper ceiling on any type', async () => {
|
||||
await expect(
|
||||
attempt(serviceWith([]), { minWagonCount: 1, maxWagonCount: 51 }),
|
||||
).rejects.toThrow(/may not exceed 50/);
|
||||
attempt(serviceWith([]), { minWagonCount: 1, maxWagonCount: 5000 }),
|
||||
).resolves.toBeUndefined();
|
||||
await expect(
|
||||
attempt(serviceWith([]), {
|
||||
type: 'CURRENCY',
|
||||
currency: 'USD',
|
||||
minWagonCount: 1,
|
||||
maxWagonCount: 36,
|
||||
maxWagonCount: 5000,
|
||||
}),
|
||||
).rejects.toThrow(/may not exceed 35/);
|
||||
).resolves.toBeUndefined();
|
||||
await expect(
|
||||
attempt(serviceWith([]), {
|
||||
type: 'CUSTOMS',
|
||||
minWagonCount: 1,
|
||||
maxWagonCount: 16,
|
||||
maxWagonCount: 5000,
|
||||
}),
|
||||
).rejects.toThrow(/may not exceed 15/);
|
||||
).resolves.toBeUndefined();
|
||||
});
|
||||
|
||||
it('rejects any new rule once the chain covers the full range', async () => {
|
||||
it('keeps extending the chain past the old caps', async () => {
|
||||
await expect(
|
||||
attempt(serviceWith([rule('WAGON', 1, 50)]), {
|
||||
minWagonCount: 51,
|
||||
maxWagonCount: 51,
|
||||
maxWagonCount: 120,
|
||||
}),
|
||||
).rejects.toThrow(/may not exceed 50/);
|
||||
).resolves.toBeUndefined();
|
||||
await expect(
|
||||
attempt(serviceWith([rule('CUSTOMS', 1, 15)]), {
|
||||
type: 'CUSTOMS',
|
||||
minWagonCount: 1,
|
||||
maxWagonCount: 1,
|
||||
minWagonCount: 16,
|
||||
maxWagonCount: 99,
|
||||
}),
|
||||
).rejects.toThrow(/already cover the full 1–15 range/);
|
||||
).resolves.toBeUndefined();
|
||||
});
|
||||
|
||||
it('still rejects a min greater than the max', async () => {
|
||||
await expect(
|
||||
attempt(serviceWith([]), { minWagonCount: 9, maxWagonCount: 4 }),
|
||||
).rejects.toThrow(BadRequestException);
|
||||
});
|
||||
|
||||
it('tracks CURRENCY chains per currency — USD and ETB are independent', async () => {
|
||||
@@ -214,16 +219,13 @@ describe('PriorityConfigsService range validation', () => {
|
||||
|
||||
it('reports the next-range prefill for the form', async () => {
|
||||
const svc = serviceWith([rule('WAGON', 1, 5), rule('WAGON', 11, 20)]);
|
||||
await expect(svc.nextRange('WAGON')).resolves.toEqual({
|
||||
nextMin: 6,
|
||||
maxCap: 50,
|
||||
});
|
||||
await expect(svc.nextRange('WAGON')).resolves.toEqual({ nextMin: 6 });
|
||||
// Past the old CUSTOMS cap of 15 the chain simply continues.
|
||||
await expect(
|
||||
serviceWith([rule('CUSTOMS', 1, 15)]).nextRange('CUSTOMS'),
|
||||
).resolves.toEqual({ nextMin: null, maxCap: 15 });
|
||||
).resolves.toEqual({ nextMin: 16 });
|
||||
await expect(serviceWith([]).nextRange('CURRENCY', 'USD')).resolves.toEqual({
|
||||
nextMin: 1,
|
||||
maxCap: 35,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user