fix: a popup reload no longer logs the requests it cancels, except on the transaction detail and confirmation screens (closes #475)
The transaction lists and ENS name lookups on the address and token screens, the address scan after a wallet is created, the endpoint checks in Settings, the wait screen's receipt check, the Send screen's Max fee estimate and the token lookup on both add-token screens now check the signal the popup aborts on pagehide before reporting a failed request. scanForAddresses(), resolveEnsNames() and lookupTokenInfo() take the signal. End-to-end tests reload the popup on the address screen and during the address scan with their requests held. Jest tests show each of these reports a real failure and stays silent once the popup has closed. The transaction detail and confirmation screens are left out: they discard the popup context that carries the signal. Model: opus-5-5
This commit is contained in:
+35
-2
@@ -21,7 +21,7 @@ jest.mock("../src/shared/log", () => ({
|
||||
debugf: () => {},
|
||||
infof: () => {},
|
||||
warnf: () => {},
|
||||
errorf: () => {},
|
||||
errorf: jest.fn(),
|
||||
},
|
||||
debugFetch: jest.fn(),
|
||||
setRuntimeDebug: () => {},
|
||||
@@ -108,6 +108,7 @@ global.chrome = { storage };
|
||||
const txStatus = require("../src/popup/views/txStatus");
|
||||
const { state } = require("../src/shared/state");
|
||||
const { RESTORABLE_VIEWS } = require("../src/shared/restorableViews");
|
||||
const { log } = require("../src/shared/log");
|
||||
|
||||
const TX_HASH =
|
||||
"0x85215772ed26ea8b39c2b3b18779030487efbe0b5fd7e882592b2f62b837be84";
|
||||
@@ -128,16 +129,24 @@ function waitStatusText() {
|
||||
return getElement("wait-tx-status").textContent;
|
||||
}
|
||||
|
||||
// Stands in for the popup's: aborting it is the popup closing.
|
||||
let pageClosed;
|
||||
|
||||
beforeEach(() => {
|
||||
jest.useFakeTimers();
|
||||
jest.setSystemTime(new Date("2026-08-11T12:00:00Z"));
|
||||
elements.clear();
|
||||
mockReceiptLookup.mockReset();
|
||||
log.errorf.mockClear();
|
||||
state.wallets = [];
|
||||
state.viewData = {};
|
||||
state.viewStack = [];
|
||||
state.currentView = null;
|
||||
txStatus.init({ doRefreshAndRender: jest.fn() });
|
||||
pageClosed = new AbortController();
|
||||
txStatus.init({
|
||||
doRefreshAndRender: jest.fn(),
|
||||
pageClosed: pageClosed.signal,
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
@@ -466,6 +475,30 @@ describe("WaitTx against an RPC that never answers", () => {
|
||||
});
|
||||
});
|
||||
|
||||
// In the popup a lookup its own closing cancelled fails as a lookup against an
|
||||
// RPC that cannot be reached does, and is not reported
|
||||
// (https://git.eeqj.de/sneak/AutistMask/issues/475).
|
||||
describe("WaitTx when the popup closes", () => {
|
||||
test("a lookup that fails while the popup is open is reported", async () => {
|
||||
mockReceiptLookup.mockRejectedValue(new TypeError("Failed to fetch"));
|
||||
txStatus.showWait(TX_INFO, TX_HASH);
|
||||
await jest.advanceTimersByTimeAsync(10000);
|
||||
expect(log.errorf).toHaveBeenCalledWith(
|
||||
"poll receipt failed:",
|
||||
"Failed to fetch",
|
||||
);
|
||||
});
|
||||
|
||||
test("a lookup that fails once the popup has closed is not", async () => {
|
||||
mockReceiptLookup.mockRejectedValue(new TypeError("Failed to fetch"));
|
||||
txStatus.showWait(TX_INFO, TX_HASH);
|
||||
pageClosed.abort();
|
||||
await jest.advanceTimersByTimeAsync(10000);
|
||||
expect(mockReceiptLookup).toHaveBeenCalledTimes(1);
|
||||
expect(log.errorf).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe("wait-tx is a view the popup may reopen onto", () => {
|
||||
// The resume feature is wired through RESTORABLE_VIEWS: restoreView()
|
||||
// refuses any view not in the set, so dropping "wait-tx" from it kills
|
||||
|
||||
Reference in New Issue
Block a user