22// Part of PyBLE (https://pyble.dev) — see /LICENSE.
33
44import { createHash } from "node:crypto" ;
5- import { readFile } from "node:fs/promises" ;
5+ import { mkdtemp , readFile , rm , writeFile } from "node:fs/promises" ;
6+ import { tmpdir } from "node:os" ;
67import { join } from "node:path" ;
78
89import { render , screen , within } from "@testing-library/react" ;
@@ -15,7 +16,13 @@ import PrivacyPage, { metadata as privacyMetadata } from "@/app/privacy/page";
1516import SupportPage , { metadata as supportMetadata } from "@/app/support/page" ;
1617import { SiteFooter } from "@/components/site-footer" ;
1718import { SiteHeader } from "@/components/site-header" ;
18- import { initialFirmwareTargets , navigation , siteConfig } from "@/lib/site" ;
19+ import {
20+ firmwareTargetsForRelease ,
21+ initialFirmwareTargets ,
22+ navigation ,
23+ siteConfig ,
24+ } from "@/lib/site" ;
25+ import { publicBetaFirmwareRelease } from "@/test/fixtures/firmware-release" ;
1926
2027describe ( "public-site contract" , ( ) => {
2128 it ( "keeps pyble.dev canonical and presents the four launch routes" , ( ) => {
@@ -159,7 +166,7 @@ describe("public-site contract", () => {
159166 ) ;
160167 } ) ;
161168
162- it ( "states the vendor-neutral vision and the truthful public-beta firmware state " , ( ) => {
169+ it ( "states the vendor-neutral vision without claiming unavailable firmware is active " , ( ) => {
163170 render ( < HomePage /> ) ;
164171
165172 expect (
@@ -173,12 +180,12 @@ describe("public-site contract", () => {
173180 / d e s i g n e d f o r b o a r d s t h a t r u n M i c r o P y t h o n a n d s u p p o r t B l u e t o o t h L o w E n e r g y / i,
174181 ) ,
175182 ) . toBeInTheDocument ( ) ;
176- expect ( screen . getByText ( / p u b l i c v 0 \. 4 \. 1 f i r m w a r e / i ) ) . toHaveTextContent (
177- / u n q u a l i f i e d b e t a f o r t h e e x a c t e s p 3 2 - 4 m b a n d e s p 3 2 - s 3 - n 1 6 r 8 p r o f i l e s / i ,
178- ) ;
179- expect ( screen . getByText ( / p u b l i c v 0 \. 4 \. 1 f i r m w a r e / i ) ) . toHaveTextContent (
180- / f u l l h a r d w a r e - i n - t h e - l o o p q u a l i f i c a t i o n i s p e n d i n g . * u s e i t a t y o u r o w n r i s k / i ,
181- ) ;
183+ expect (
184+ screen . getByText ( / f i r m w a r e i n s t a l l e r i s c u r r e n t l y u n a v a i l a b l e / i ) ,
185+ ) . toBeInTheDocument ( ) ;
186+ expect (
187+ screen . queryByText ( / u n q u a l i f i e d f i r m w a r e b e t a i s a v a i l a b l e / i ) ,
188+ ) . not . toBeInTheDocument ( ) ;
182189 expect (
183190 screen . getByText (
184191 / E S P 3 2 - C 3 a n d m o r e m i c r o c o n t r o l l e r f a m i l i e s r e m a i n p l a n n e d / i,
@@ -332,14 +339,14 @@ describe("public-site contract", () => {
332339 id : "esp32-4mb" ,
333340 target : "Classic ESP32" ,
334341 constraint : "4 MiB external SPI flash · no PSRAM assumed" ,
335- status : "v0.4.1 unqualified beta · HIL pending " ,
342+ status : "Installer unavailable " ,
336343 planned : false ,
337344 } ,
338345 {
339346 id : "esp32-s3-n16r8" ,
340347 target : "ESP32-S3 N16R8" ,
341348 constraint : "16 MiB flash · 8 MiB Octal PSRAM" ,
342- status : "v0.4.1 unqualified beta · HIL pending " ,
349+ status : "Installer unavailable " ,
343350 planned : false ,
344351 } ,
345352 {
@@ -360,13 +367,57 @@ describe("public-site contract", () => {
360367 expect ( targetCard ) . toHaveTextContent ( target . status ) ;
361368 }
362369 expect ( screen . getByText ( / p r o v i s i o n o n c e / i) . closest ( "li" ) ) . toHaveTextContent (
363- / v 0 \. 4 \. 1 u n q u a l i f i e d b e t a . * f u l l H I L i s p e n d i n g . * u s e i t a t y o u r o w n r i s k / i,
370+ / c h e c k f i r m w a r e s t a t u s . * i n s t a l l e r i s c u r r e n t l y u n a v a i l a b l e / i,
364371 ) ;
365372 expect (
366373 screen . getByRole ( "link" , { name : / o p e n f i r m w a r e i n s t a l l e r / i } ) ,
367374 ) . toHaveAttribute ( "href" , "/flash" ) ;
368375 } ) ;
369376
377+ it ( "shows the exact beta claims only when its build selector is active" , async ( ) => {
378+ const selectionRoot = await mkdtemp (
379+ join ( tmpdir ( ) , "pyble-site-beta-selection-" ) ,
380+ ) ;
381+ const selectionFile = join ( selectionRoot , "selection.json" ) ;
382+ await writeFile (
383+ selectionFile ,
384+ JSON . stringify ( publicBetaFirmwareRelease ) ,
385+ "utf8" ,
386+ ) ;
387+ const previousSelection = process . env . PYBLE_FLASH_SELECTION_FILE ;
388+ process . env . PYBLE_FLASH_SELECTION_FILE = selectionFile ;
389+
390+ try {
391+ const home = render ( < HomePage /> ) ;
392+ expect ( screen . getByText ( / p u b l i c v 0 \. 4 \. 2 f i r m w a r e / i) ) . toHaveTextContent (
393+ / u n q u a l i f i e d b e t a f o r t h e e x a c t e s p 3 2 - 4 m b a n d e s p 3 2 - s 3 - n 1 6 r 8 p r o f i l e s / i,
394+ ) ;
395+ expect ( screen . getByText ( / p u b l i c v 0 \. 4 \. 2 f i r m w a r e / i) ) . toHaveTextContent (
396+ / f u l l h a r d w a r e - i n - t h e - l o o p q u a l i f i c a t i o n i s p e n d i n g .* u s e i t a t y o u r o w n r i s k / i,
397+ ) ;
398+ for ( const target of firmwareTargetsForRelease (
399+ publicBetaFirmwareRelease ,
400+ ) . filter ( ( { planned } ) => ! planned ) ) {
401+ expect ( screen . getByText ( target . id ) . closest ( "div" ) ) . toHaveTextContent (
402+ "v0.4.2 unqualified beta · HIL pending" ,
403+ ) ;
404+ }
405+ home . unmount ( ) ;
406+
407+ render ( < SupportPage /> ) ;
408+ expect (
409+ screen . getByText ( / v 0 \. 4 \. 2 u n q u a l i f i e d b e t a i s a v a i l a b l e / i) ,
410+ ) . toHaveTextContent ( / f u l l H I L r e m a i n s p e n d i n g .* u s e i t a t y o u r o w n r i s k / i) ;
411+ } finally {
412+ if ( previousSelection === undefined ) {
413+ delete process . env . PYBLE_FLASH_SELECTION_FILE ;
414+ } else {
415+ process . env . PYBLE_FLASH_SELECTION_FILE = previousSelection ;
416+ }
417+ await rm ( selectionRoot , { recursive : true , force : true } ) ;
418+ }
419+ } ) ;
420+
370421 it ( "keeps the public installer unavailable while explaining exact profiles, BLE use, and recovery" , ( ) => {
371422 render ( < FlashPage /> ) ;
372423
@@ -549,7 +600,7 @@ describe("public-site contract", () => {
549600 ) . toBeInTheDocument ( ) ;
550601 expect (
551602 screen . getByText (
552- / v 0 \. 4 \. 1 u n q u a l i f i e d b e t a i s a v a i l a b l e f o r t h e e x a c t e s p 3 2 - 4 m b a n d e s p 3 2 - s 3 - n 1 6 r 8 p r o f i l e s / i,
603+ / v 0 \. 4 \. 2 u n q u a l i f i e d b e t a i s a v a i l a b l e f o r t h e e x a c t e s p 3 2 - 4 m b a n d e s p 3 2 - s 3 - n 1 6 r 8 p r o f i l e s / i,
553604 ) ,
554605 ) . toBeInTheDocument ( ) ;
555606 expect (
0 commit comments