From: Jérôme Benoit Date: Thu, 12 Feb 2026 19:30:26 +0000 (+0100) Subject: fix(tests): use robust threshold test instead of exact boundary X-Git-Tag: ocpp-server@v2.3.0~1 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=1ea2b774baf108860b389759e12122fb3434528e;p=e-mobility-charging-stations-simulator.git fix(tests): use robust threshold test instead of exact boundary The exact boundary test was flaky on Windows due to JSON serialization size differences. Use a clearly-below-threshold payload instead. --- diff --git a/tests/charging-station/ui-server/UIHttpServer.test.ts b/tests/charging-station/ui-server/UIHttpServer.test.ts index 3c7fabb3..f1f8ee73 100644 --- a/tests/charging-station/ui-server/UIHttpServer.test.ts +++ b/tests/charging-station/ui-server/UIHttpServer.test.ts @@ -208,20 +208,17 @@ await describe('UIHttpServer test suite', async () => { expect(res.headers['Content-Type']).toBe('application/json') }) - await it('Verify no compression at exact threshold boundary', () => { + await it('Verify no compression below threshold', () => { const server = new TestableUIHttpServer(createHttpServerConfig()) const res = new MockServerResponse() - const basePayload = { data: '', status: ResponseStatus.SUCCESS } - const baseSize = Buffer.byteLength(JSON.stringify(basePayload)) - const paddingNeeded = DEFAULT_COMPRESSION_THRESHOLD - baseSize - const boundaryPayload = { - data: 'x'.repeat(Math.max(0, paddingNeeded)), + const smallPayload = { + data: 'x'.repeat(100), status: ResponseStatus.SUCCESS, } server.addResponseHandler(TEST_UUID, res) server.setAcceptsGzip(TEST_UUID, true) - server.sendResponse([TEST_UUID, boundaryPayload]) + server.sendResponse([TEST_UUID, smallPayload]) expect(res.headers['Content-Encoding']).toBeUndefined() })