The debug/testnet banner appended the active view's internal id, so the user saw text like "[TESTNET] (approve-tx)" — developer vocabulary, and on the approval screen it sat directly above the carefully worded line stating what is being authorized. The view id is now gated on the compile-time DEBUG constant instead of isDebug(), so it survives only in a debug build. A testnet or the runtime debug toggle still raises the banner, but without the view id, which is what a release build shows. Model: opus-4-8
60 lines
1.7 KiB
JavaScript
60 lines
1.7 KiB
JavaScript
// Tests for the debug/testnet banner (issue #375).
|
|
//
|
|
// On a testnet the banner is raised even in a release build, but it must not
|
|
// append the active view's internal id: the user should see "[TESTNET]", never
|
|
// "[TESTNET] (approve-tx)". The suffix is gated on the compile-time DEBUG
|
|
// constant, which is false in a plain test load, so this drives exactly the
|
|
// text a shipped build renders. Revert the gate to the old unconditional
|
|
// suffix and this fails.
|
|
//
|
|
// The banner is created on demand by updateDebugBanner(); the document stub
|
|
// records what it prepends so the assertion can read the resulting text.
|
|
|
|
function makeBanner() {
|
|
return {
|
|
id: "",
|
|
textContent: "",
|
|
style: { cssText: "" },
|
|
remove() {},
|
|
};
|
|
}
|
|
|
|
function makeDocument() {
|
|
let banner = null;
|
|
return {
|
|
getElementById(id) {
|
|
return id === "debug-banner" ? banner : null;
|
|
},
|
|
createElement: () => makeBanner(),
|
|
body: {
|
|
prepend(node) {
|
|
banner = node;
|
|
},
|
|
},
|
|
};
|
|
}
|
|
|
|
function load() {
|
|
jest.resetModules();
|
|
globalThis.chrome = {
|
|
storage: { local: { get: async () => ({}), set: async () => {} } },
|
|
};
|
|
globalThis.document = makeDocument();
|
|
const helpers = require("../src/popup/views/helpers");
|
|
const { state } = require("../src/shared/state");
|
|
return { helpers, state };
|
|
}
|
|
|
|
describe("the release banner on a testnet", () => {
|
|
test("carries no internal view id", () => {
|
|
const { helpers, state } = load();
|
|
state.networkId = "sepolia";
|
|
|
|
helpers.updateDebugBanner("approve-tx");
|
|
|
|
expect(
|
|
globalThis.document.getElementById("debug-banner").textContent,
|
|
).toBe("[TESTNET]");
|
|
});
|
|
});
|