From c7e77f3a4d2beb9b3d6a4e9944d2892e4717818e Mon Sep 17 00:00:00 2001 From: Roland Date: Thu, 2 Jul 2026 17:20:16 -0600 Subject: [PATCH] Address Greptile review: fix chip-id map (17=C5, 18=P4) and drop stale mock - ESP_CHIP_ID_NAMES disagreed with the backend ESP_CHIP_IDS: it mapped 18 to ESP32-C5 (18 is ESP32-P4) and omitted 17 entirely, so C5 firmware showed as "chip id 17" and P4 firmware was mislabeled "ESP32-C5". Now matches the backend (17=ESP32-C5, 18=ESP32-P4), with a test guarding it. - Removed the stale filesSearch import/mock/beforeEach from the test; the flasher no longer calls it. Co-Authored-By: Claude Opus 4.8 (1M context) --- app/src/components/Flasher.js | 2 +- app/src/components/Flasher.test.js | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/src/components/Flasher.js b/app/src/components/Flasher.js index a5009029..f23593a4 100644 --- a/app/src/components/Flasher.js +++ b/app/src/components/Flasher.js @@ -35,7 +35,7 @@ export function chipFamily(description) { // ESP image chip_id -> family name (matches esptool-js IMAGE_CHIP_ID values). const ESP_CHIP_ID_NAMES = { 0: 'ESP32', 2: 'ESP32-S2', 5: 'ESP32-C3', 9: 'ESP32-S3', - 12: 'ESP32-C2', 13: 'ESP32-C6', 16: 'ESP32-H2', 18: 'ESP32-C5', + 12: 'ESP32-C2', 13: 'ESP32-C6', 16: 'ESP32-H2', 17: 'ESP32-C5', 18: 'ESP32-P4', }; // Known ESP chip names, sorted so each maps to a stable color — colors survive reboots/refreshes and only shift diff --git a/app/src/components/Flasher.test.js b/app/src/components/Flasher.test.js index cdb468c8..2156a57d 100644 --- a/app/src/components/Flasher.test.js +++ b/app/src/components/Flasher.test.js @@ -27,14 +27,13 @@ jest.mock('esptool-js', () => ({ // Flasher fetches media firmware on mount; mock the API so tests don't hit the network. jest.mock('../api', () => ({ - filesSearch: jest.fn().mockResolvedValue([[], 0]), flasherSearch: jest.fn().mockResolvedValue([[], 0]), getFlasherConfigs: jest.fn().mockResolvedValue([]), saveFlasherConfig: jest.fn().mockResolvedValue(true), deleteFlasherConfig: jest.fn().mockResolvedValue(true), })); -import {filesSearch, flasherSearch, getFlasherConfigs} from '../api'; +import {flasherSearch, getFlasherConfigs} from '../api'; import { chipColor, chipTextColor, @@ -167,6 +166,9 @@ describe('chipIdName', () => { expect(chipIdName(0)).toBe('ESP32'); expect(chipIdName(2)).toBe('ESP32-S2'); expect(chipIdName(9)).toBe('ESP32-S3'); + // Must match the backend ESP_CHIP_IDS map: 17 -> C5, 18 -> P4 (not the reverse). + expect(chipIdName(17)).toBe('ESP32-C5'); + expect(chipIdName(18)).toBe('ESP32-P4'); }); it('falls back to a readable string for unknown ids', () => { @@ -245,8 +247,6 @@ describe('FlasherPage', () => { const original = Object.getOwnPropertyDescriptor(global.navigator, 'serial'); beforeEach(() => { - filesSearch.mockClear(); - filesSearch.mockResolvedValue([[], 0]); flasherSearch.mockClear(); flasherSearch.mockResolvedValue([[], 0]); getFlasherConfigs.mockClear();