@@ -10,7 +10,10 @@ import { promisify } from "node:util";
1010import { describe , expect , it } from "vitest" ;
1111
1212import { firmwareReleaseSelectedAtBuild } from "@/lib/firmware-release-selection" ;
13- import { pendingPublicFirmwareRelease } from "@/test/fixtures/firmware-release" ;
13+ import {
14+ pendingPublicFirmwareRelease ,
15+ publicBetaFirmwareRelease ,
16+ } from "@/test/fixtures/firmware-release" ;
1417
1518const execFile = promisify ( execFileCallback ) ;
1619
@@ -169,6 +172,36 @@ describe("production build contract", () => {
169172 }
170173 } ) ;
171174
175+ it ( "accepts only the exact attested public-beta selector at the build boundary" , async ( ) => {
176+ const selectionRoot = await mkdtemp ( join ( tmpdir ( ) , "pyble-beta-selection-" ) ) ;
177+ const selectionFile = join ( selectionRoot , "selection.json" ) ;
178+ await writeFile (
179+ selectionFile ,
180+ JSON . stringify ( publicBetaFirmwareRelease ) ,
181+ "utf8" ,
182+ ) ;
183+
184+ const previousSelection = process . env . PYBLE_FLASH_SELECTION_FILE ;
185+ process . env . PYBLE_FLASH_SELECTION_FILE = selectionFile ;
186+ try {
187+ expect ( firmwareReleaseSelectedAtBuild ( ) ) . toEqual (
188+ publicBetaFirmwareRelease ,
189+ ) ;
190+
191+ const altered = structuredClone ( publicBetaFirmwareRelease ) ;
192+ altered . releaseJson . sha256 = "0" . repeat ( 64 ) ;
193+ await writeFile ( selectionFile , JSON . stringify ( altered ) , "utf8" ) ;
194+ expect ( ( ) => firmwareReleaseSelectedAtBuild ( ) ) . toThrow ( / p u b l i c b e t a / i) ;
195+ } finally {
196+ if ( previousSelection === undefined ) {
197+ delete process . env . PYBLE_FLASH_SELECTION_FILE ;
198+ } else {
199+ process . env . PYBLE_FLASH_SELECTION_FILE = previousSelection ;
200+ }
201+ await rm ( selectionRoot , { recursive : true , force : true } ) ;
202+ }
203+ } ) ;
204+
172205 it ( "requires explicit server-side build inputs for protected candidate staging" , async ( ) => {
173206 const [ packageJson , stagingSource ] = await Promise . all ( [
174207 readFile ( join ( process . cwd ( ) , "package.json" ) , "utf8" ) . then (
0 commit comments