velxio/frontend/src/__tests__/component-metadata-bmp280.t...

22 lines
751 B
TypeScript
Raw Normal View History

test(esp32): integration tests for QEMU examples Closes the loop on the four ESP32 fixes that landed earlier in this series. Each previously-broken or noisy example now has a regression test that compiles the sketch through the production ESP-IDF compiler and runs it in QEMU via esp32_worker.py — the same code path the WebSocket /ws/{client_id} endpoint drives in production. Testing the worker directly skips the WS transport but exercises the same compile → flash → boot → serial cascade. Coverage: - TestEsp32SerialCleanliness — DHT22, Servo+Pot, Joystick, Dual ADC Asserts the user's Serial.print substring shows up AND no `I (xxx) gpio:|wifi:|phy:` info-level ESP-IDF logs leak through. This validates the sdkconfig CONFIG_LOG_DEFAULT_LEVEL_WARN change from commit b373c97. - TestEsp32CompileSuccess — BLE Advertise, LEDC RGB BLE Advertise validates the sdkconfig switch to Bluedroid (was NimBLE-only, which broke arduino-esp32's BLEDevice.h). LEDC RGB validates velxio_compat.h's ledcAttach() shim from commit f6f6f43; the sketch uses the arduino-esp32 3.x one-shot API on a 2.0.17 toolchain. - TestEsp32WiFiSketches — WiFi Connect, WiFi WebServer Regression coverage to make sure the sdkconfig changes didn't break WiFi association. Connect must reach an "IP Address:" line; Server must report "Server started". - frontend/src/__tests__/component-metadata-bmp280.test.ts Sanity check that the BMP280 entry from commit 1f3f2e0 survives metadata regeneration. All ESP-IDF/QEMU tests use unittest.skipUnless on _toolchain_available() so they no-op cleanly on dev boxes without libqemu-xtensa, and only do real work in the Docker CI image. Sketches are inlined verbatim from the public Velxio examples. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-09 04:39:22 +07:00
import { describe, it, expect } from 'vitest';
import metadata from '../../public/components-metadata.json';
interface ComponentMetadataEntry {
id: string;
tagName: string;
category: string;
pinCount: number;
[key: string]: unknown;
}
test(esp32): integration tests for QEMU examples Closes the loop on the four ESP32 fixes that landed earlier in this series. Each previously-broken or noisy example now has a regression test that compiles the sketch through the production ESP-IDF compiler and runs it in QEMU via esp32_worker.py — the same code path the WebSocket /ws/{client_id} endpoint drives in production. Testing the worker directly skips the WS transport but exercises the same compile → flash → boot → serial cascade. Coverage: - TestEsp32SerialCleanliness — DHT22, Servo+Pot, Joystick, Dual ADC Asserts the user's Serial.print substring shows up AND no `I (xxx) gpio:|wifi:|phy:` info-level ESP-IDF logs leak through. This validates the sdkconfig CONFIG_LOG_DEFAULT_LEVEL_WARN change from commit b373c97. - TestEsp32CompileSuccess — BLE Advertise, LEDC RGB BLE Advertise validates the sdkconfig switch to Bluedroid (was NimBLE-only, which broke arduino-esp32's BLEDevice.h). LEDC RGB validates velxio_compat.h's ledcAttach() shim from commit f6f6f43; the sketch uses the arduino-esp32 3.x one-shot API on a 2.0.17 toolchain. - TestEsp32WiFiSketches — WiFi Connect, WiFi WebServer Regression coverage to make sure the sdkconfig changes didn't break WiFi association. Connect must reach an "IP Address:" line; Server must report "Server started". - frontend/src/__tests__/component-metadata-bmp280.test.ts Sanity check that the BMP280 entry from commit 1f3f2e0 survives metadata regeneration. All ESP-IDF/QEMU tests use unittest.skipUnless on _toolchain_available() so they no-op cleanly on dev boxes without libqemu-xtensa, and only do real work in the Docker CI image. Sketches are inlined verbatim from the public Velxio examples. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-09 04:39:22 +07:00
describe('component metadata — BMP280 entry', () => {
it('is registered with id "bmp280" and tagName "velxio-bmp280"', () => {
const components = (metadata as { components: ComponentMetadataEntry[] }).components;
const entry = components.find((c) => c.id === 'bmp280');
test(esp32): integration tests for QEMU examples Closes the loop on the four ESP32 fixes that landed earlier in this series. Each previously-broken or noisy example now has a regression test that compiles the sketch through the production ESP-IDF compiler and runs it in QEMU via esp32_worker.py — the same code path the WebSocket /ws/{client_id} endpoint drives in production. Testing the worker directly skips the WS transport but exercises the same compile → flash → boot → serial cascade. Coverage: - TestEsp32SerialCleanliness — DHT22, Servo+Pot, Joystick, Dual ADC Asserts the user's Serial.print substring shows up AND no `I (xxx) gpio:|wifi:|phy:` info-level ESP-IDF logs leak through. This validates the sdkconfig CONFIG_LOG_DEFAULT_LEVEL_WARN change from commit b373c97. - TestEsp32CompileSuccess — BLE Advertise, LEDC RGB BLE Advertise validates the sdkconfig switch to Bluedroid (was NimBLE-only, which broke arduino-esp32's BLEDevice.h). LEDC RGB validates velxio_compat.h's ledcAttach() shim from commit f6f6f43; the sketch uses the arduino-esp32 3.x one-shot API on a 2.0.17 toolchain. - TestEsp32WiFiSketches — WiFi Connect, WiFi WebServer Regression coverage to make sure the sdkconfig changes didn't break WiFi association. Connect must reach an "IP Address:" line; Server must report "Server started". - frontend/src/__tests__/component-metadata-bmp280.test.ts Sanity check that the BMP280 entry from commit 1f3f2e0 survives metadata regeneration. All ESP-IDF/QEMU tests use unittest.skipUnless on _toolchain_available() so they no-op cleanly on dev boxes without libqemu-xtensa, and only do real work in the Docker CI image. Sketches are inlined verbatim from the public Velxio examples. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-09 04:39:22 +07:00
expect(entry, 'BMP280 missing from components-metadata.json').toBeDefined();
expect(entry!.tagName).toBe('velxio-bmp280');
expect(entry!.category).toBe('sensor');
expect(entry!.pinCount).toBe(4);
});
});