fix: stabilize mac nordvpn state reporting

This commit is contained in:
Stefano Fiorini
2026-03-12 02:28:57 -05:00
parent 647828aa78
commit 60f425a4fc
2 changed files with 63 additions and 1 deletions

View File

@@ -21,6 +21,8 @@ module.exports = {
typeof getMacTailscalePath === "function" ? getMacTailscalePath : undefined,
isMacTailscaleActive:
typeof isMacTailscaleActive === "function" ? isMacTailscaleActive : undefined,
normalizeSuccessfulConnectState:
typeof normalizeSuccessfulConnectState === "function" ? normalizeSuccessfulConnectState : undefined,
shouldAttemptMacWireguardDisconnect:
typeof shouldAttemptMacWireguardDisconnect === "function" ? shouldAttemptMacWireguardDisconnect : undefined,
detectMacWireguardActiveFromIfconfig:
@@ -167,6 +169,39 @@ test("shouldAttemptMacWireguardDisconnect does not trust active=false when resid
);
});
test("normalizeSuccessfulConnectState marks the connect snapshot active after verified macOS wireguard connect", () => {
const { normalizeSuccessfulConnectState } = loadInternals();
assert.equal(typeof normalizeSuccessfulConnectState, "function");
const state = normalizeSuccessfulConnectState(
{
platform: "darwin",
controlMode: "wireguard",
connected: false,
wireguard: {
active: false,
endpoint: null,
},
},
{
backend: "wireguard",
server: {
hostname: "de1227.nordvpn.com",
},
},
{
ok: true,
ipInfo: {
country: "Germany",
},
}
);
assert.equal(state.connected, true);
assert.equal(state.wireguard.active, true);
assert.equal(state.wireguard.endpoint, "de1227.nordvpn.com:51820");
});
test("isMacTailscaleActive treats Running backend as active", () => {
const { isMacTailscaleActive } = loadInternals();
assert.equal(typeof isMacTailscaleActive, "function");