Skip to content

Commit 4e1cbd3

Browse files
committed
chore: remove unnecessary vscodeProposed mocks from tests
The vscodeProposed proxy already falls back to the vscode module (which is aliased to the test mock via vitest.config.ts), so explicitly mocking it is redundant. Also adds disableUpdateNotifications re-enable test.
1 parent 3a56ed2 commit 4e1cbd3

File tree

6 files changed

+18
-22
lines changed

6 files changed

+18
-22
lines changed

test/unit/core/binaryLock.test.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { beforeEach, describe, expect, it, vi } from "vitest";
2-
import * as vscode from "vscode";
32

43
import { BinaryLock } from "@/core/binaryLock";
54
import * as downloadProgress from "@/core/downloadProgress";
@@ -11,10 +10,6 @@ import {
1110

1211
vi.mock("vscode");
1312

14-
vi.mock("@/vscodeProposed", () => ({
15-
vscodeProposed: vscode,
16-
}));
17-
1813
// Mock proper-lockfile
1914
vi.mock("proper-lockfile", () => ({
2015
lock: vi.fn(),

test/unit/core/cliManager.concurrent.test.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import * as fs from "node:fs/promises";
1010
import * as os from "node:os";
1111
import * as path from "node:path";
1212
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
13-
import * as vscode from "vscode";
1413

1514
import { CliManager } from "@/core/cliManager";
1615
import * as cliUtils from "@/core/cliUtils";
@@ -27,10 +26,6 @@ import {
2726

2827
vi.mock("@/pgp");
2928

30-
vi.mock("@/vscodeProposed", () => ({
31-
vscodeProposed: vscode,
32-
}));
33-
3429
vi.mock("@/core/cliUtils", async () => {
3530
const actual = await vi.importActual<typeof cliUtils>("@/core/cliUtils");
3631
return {

test/unit/core/cliManager.test.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,6 @@ vi.mock("proper-lockfile", () => ({
5959

6060
vi.mock("@/pgp");
6161

62-
vi.mock("@/vscodeProposed", () => ({
63-
vscodeProposed: vscode,
64-
}));
65-
6662
vi.mock("@/core/cliUtils", async () => {
6763
const actual =
6864
await vi.importActual<typeof import("@/core/cliUtils")>("@/core/cliUtils");

test/unit/login/loginCoordinator.test.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,6 @@ vi.mock("@/promptUtils", () => ({
6767
maybeAskUrl: vi.fn(),
6868
}));
6969

70-
vi.mock("@/vscodeProposed", () => ({
71-
vscodeProposed: vscode,
72-
}));
73-
7470
// Mock CoderApi to control getAuthenticatedUser behavior
7571
const mockGetAuthenticatedUser = vi.hoisted(() => vi.fn());
7672
vi.mock("@/api/coderApi", async (importOriginal) => {

test/unit/uri/uriHandler.test.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ import type { LoginCoordinator, LoginOptions } from "@/login/loginCoordinator";
2121

2222
vi.mock("@/promptUtils", () => ({ maybeAskUrl: vi.fn() }));
2323

24-
vi.mock("@/vscodeProposed", () => ({
25-
vscodeProposed: vscode,
26-
}));
27-
2824
const TEST_URL = "https://coder.example.com";
2925
const TEST_HOSTNAME = "coder.example.com";
3026

test/unit/workspace/workspaceMonitor.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,24 @@ describe("WorkspaceMonitor", () => {
255255
);
256256
monitor.dispose();
257257
});
258+
259+
it("shows outdated notification after re-enabling", async () => {
260+
config.set("coder.disableUpdateNotifications", true);
261+
const { monitor, stream, client } = await createMonitor();
262+
monitor.markInitialSetupComplete();
263+
264+
stream.pushMessage(workspaceEvent(createWorkspace({ outdated: true })));
265+
expect(client.getTemplate).not.toHaveBeenCalled();
266+
267+
config.set("coder.disableUpdateNotifications", false);
268+
269+
stream.pushMessage(workspaceEvent(createWorkspace({ outdated: true })));
270+
271+
await vi.waitFor(() => {
272+
expect(client.getTemplate).toHaveBeenCalled();
273+
});
274+
monitor.dispose();
275+
});
258276
});
259277

260278
describe("disableNotifications", () => {

0 commit comments

Comments
 (0)