Skip to content

Commit 7c3777c

Browse files
committed
[red] Keep firmware availability copy selector-driven
Signed-off-by: Viwat Vchirawongkwin <viwat.v@chula.ac.th>
1 parent e9d222a commit 7c3777c

1 file changed

Lines changed: 64 additions & 13 deletions

File tree

‎tools/web/src/test/site-contract.test.tsx‎

Lines changed: 64 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
// Part of PyBLE (https://pyble.dev) — see /LICENSE.
33

44
import { 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";
67
import { join } from "node:path";
78

89
import { render, screen, within } from "@testing-library/react";
@@ -15,7 +16,13 @@ import PrivacyPage, { metadata as privacyMetadata } from "@/app/privacy/page";
1516
import SupportPage, { metadata as supportMetadata } from "@/app/support/page";
1617
import { SiteFooter } from "@/components/site-footer";
1718
import { 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

2027
describe("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
/designed for boards that run MicroPython and support Bluetooth Low Energy/i,
174181
),
175182
).toBeInTheDocument();
176-
expect(screen.getByText(/public v0\.4\.1 firmware/i)).toHaveTextContent(
177-
/unqualified beta for the exact esp32-4mb and esp32-s3-n16r8 profiles/i,
178-
);
179-
expect(screen.getByText(/public v0\.4\.1 firmware/i)).toHaveTextContent(
180-
/full hardware-in-the-loop qualification is pending.*use it at your own risk/i,
181-
);
183+
expect(
184+
screen.getByText(/firmware installer is currently unavailable/i),
185+
).toBeInTheDocument();
186+
expect(
187+
screen.queryByText(/unqualified firmware beta is available/i),
188+
).not.toBeInTheDocument();
182189
expect(
183190
screen.getByText(
184191
/ESP32-C3 and more microcontroller families remain planned/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(/provision once/i).closest("li")).toHaveTextContent(
363-
/v0\.4\.1 unqualified beta.*full HIL is pending.*use it at your own risk/i,
370+
/check firmware status.*installer is currently unavailable/i,
364371
);
365372
expect(
366373
screen.getByRole("link", { name: /open firmware installer/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(/public v0\.4\.2 firmware/i)).toHaveTextContent(
393+
/unqualified beta for the exact esp32-4mb and esp32-s3-n16r8 profiles/i,
394+
);
395+
expect(screen.getByText(/public v0\.4\.2 firmware/i)).toHaveTextContent(
396+
/full hardware-in-the-loop qualification is pending.*use it at your own risk/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(/v0\.4\.2 unqualified beta is available/i),
410+
).toHaveTextContent(/full HIL remains pending.*use it at your own risk/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-
/v0\.4\.1 unqualified beta is available for the exact esp32-4mb and esp32-s3-n16r8 profiles/i,
603+
/v0\.4\.2 unqualified beta is available for the exact esp32-4mb and esp32-s3-n16r8 profiles/i,
553604
),
554605
).toBeInTheDocument();
555606
expect(

0 commit comments

Comments
 (0)