Out of the box the wallet sent the user's addresses to Blockscout and each recipient's address to Etherscan. Two settings, "Use Blockscout" and "Check recipients on Etherscan", now gate every request that sends the user's data to those services. Both start off and are offered unticked on Welcome and in Settings. Each request reads its setting from storage before it asks. An answer that lands after the setting went off is dropped. While a setting is off, the screens that rely on it say so. ENS lookups ask only the RPC endpoint, so a name resolved off-chain does not resolve. RULES.md's External Communication item is now out of date. Its new wording will be proposed on #211 once this lands. Model: opus-5-5 (implementation, summary); fable-5-1 (prose)
92 lines
2.9 KiB
JavaScript
92 lines
2.9 KiB
JavaScript
// A timer the popup started and that fires after cleanupPopup() has removed
|
|
// the page throws "document is not defined", and the throw fails whatever test
|
|
// the jest worker is running by then, in this file or another
|
|
// (https://git.eeqj.de/sneak/AutistMask/issues/578). The flash message's
|
|
// timer is the one that did it. A throw from a timer during a test fails that
|
|
// test, so each test here passes only if nothing throws.
|
|
|
|
const {
|
|
bootPopup,
|
|
cleanupPopup,
|
|
unversionedValidProfile,
|
|
ADDRESS,
|
|
} = require("./support/popupBoot");
|
|
|
|
const FLASH_MS = 10;
|
|
|
|
function wait(ms) {
|
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
}
|
|
|
|
afterEach(() => {
|
|
cleanupPopup();
|
|
});
|
|
|
|
test("a flash message clears while the page is up", async () => {
|
|
const page = await bootPopup(unversionedValidProfile());
|
|
const { showFlash } = require("../src/popup/views/helpers");
|
|
showFlash("Copied.", FLASH_MS);
|
|
expect(page.text("flash-msg")).toBe("Copied.");
|
|
|
|
await wait(FLASH_MS * 5);
|
|
|
|
expect(page.text("flash-msg")).toBe("");
|
|
});
|
|
|
|
test("a flash message's timer does not fire after cleanupPopup()", async () => {
|
|
await bootPopup(unversionedValidProfile());
|
|
const { showFlash } = require("../src/popup/views/helpers");
|
|
showFlash("Copied.", FLASH_MS);
|
|
cleanupPopup();
|
|
|
|
await wait(FLASH_MS * 5);
|
|
});
|
|
|
|
// A boot onto a screen that sends a request no mocked module answers: that
|
|
// request reaches the boot's fetch() stub, never the internet
|
|
// (https://git.eeqj.de/sneak/AutistMask/issues/559). TransactionDetail asks
|
|
// Blockscout only while "Use Blockscout" is on. ConfirmTx asks Etherscan only
|
|
// while "Check recipients on Etherscan" is on. So the profile turns both on.
|
|
function restoringOnto(view, viewData) {
|
|
return unversionedValidProfile({
|
|
currentView: view,
|
|
selectedWallet: 0,
|
|
selectedAddress: 0,
|
|
viewStack: ["main"],
|
|
viewData,
|
|
useBlockscout: true,
|
|
checkRecipientsOnEtherscan: true,
|
|
});
|
|
}
|
|
|
|
test("the transaction screen's Blockscout request reaches the stub", async () => {
|
|
const page = await bootPopup(
|
|
restoringOnto("transaction", {
|
|
tx: { hash: "0x1", from: ADDRESS, to: ADDRESS, chainId: "0x1" },
|
|
}),
|
|
);
|
|
|
|
expect(page.visibleViews()).toEqual(["transaction"]);
|
|
expect(globalThis.fetch.mock.calls.map((call) => call[0])).toEqual([
|
|
"https://eth.blockscout.com/api/v2/transactions/0x1",
|
|
]);
|
|
});
|
|
|
|
test("the confirmation screen's Etherscan lookup reaches the stub", async () => {
|
|
const page = await bootPopup(
|
|
restoringOnto("confirm-tx", {
|
|
pendingTx: {
|
|
token: "ETH",
|
|
from: ADDRESS,
|
|
to: ADDRESS,
|
|
amount: "1",
|
|
},
|
|
}),
|
|
);
|
|
|
|
expect(page.visibleViews()).toEqual(["confirm-tx"]);
|
|
expect(globalThis.fetch.mock.calls.map((call) => call[0])).toEqual([
|
|
"https://etherscan.io/address/" + ADDRESS,
|
|
]);
|
|
});
|