]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commitdiff
fix(tests): use robust threshold test instead of exact boundary
authorJérôme Benoit <jerome.benoit@sap.com>
Thu, 12 Feb 2026 19:30:26 +0000 (20:30 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Thu, 12 Feb 2026 19:30:26 +0000 (20:30 +0100)
The exact boundary test was flaky on Windows due to JSON serialization
size differences. Use a clearly-below-threshold payload instead.

tests/charging-station/ui-server/UIHttpServer.test.ts

index 3c7fabb3c2fcbf15088f04ffa6fa9527a93bea2d..f1f8ee7321294377b8f364603bcf4bc53e580c01 100644 (file)
@@ -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()
     })