Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions packages/cli/src/__tests__/digitalocean-token.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,12 @@ describe("doApi 401 OAuth recovery", () => {
state.token = "expired-token";
let callCount = 0;
globalThis.fetch = mock((url: string | URL | Request) => {
callCount++;
const urlStr = String(url);
// Ignore background telemetry calls (PostHog) that leak from other test files
if (!urlStr.includes("digitalocean")) {
return Promise.resolve(new Response("ok"));
}
callCount++;
// First call: the actual API call returning 401
if (callCount === 1) {
return Promise.resolve(
Expand Down Expand Up @@ -147,7 +151,12 @@ describe("doApi 401 OAuth recovery", () => {
state.token = "expired-token";
_testHelpers.recovering401 = true;
let callCount = 0;
globalThis.fetch = mock(() => {
globalThis.fetch = mock((url: string | URL | Request) => {
const urlStr = String(url);
// Ignore background telemetry calls (PostHog) that leak from other test files
if (!urlStr.includes("digitalocean")) {
return Promise.resolve(new Response("ok"));
}
callCount++;
return Promise.resolve(
new Response("Unauthorized", {
Expand Down
7 changes: 6 additions & 1 deletion packages/cli/src/__tests__/hetzner-cov.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,12 @@ describe("hetzner/createServer", () => {
},
};
let callCount = 0;
global.fetch = mock(() => {
global.fetch = mock((url: string | URL | Request) => {
const urlStr = String(url instanceof Request ? url.url : url);
// Ignore background telemetry calls (PostHog) that leak from other test files
if (!urlStr.includes("hetzner.cloud")) {
return Promise.resolve(new Response("ok"));
}
callCount++;
if (callCount <= 1) {
// Token validation
Expand Down
Loading