Skip to content

Commit 0504331

Browse files
test: stabilize update notice root mock
Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1 parent 96e0e9b commit 0504331

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

test/update-notice.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
2+
import { dirname, resolve } from "node:path";
3+
import { fileURLToPath } from "node:url";
24

35
vi.mock("node:fs", () => ({
46
readFileSync: vi.fn(),
@@ -24,6 +26,7 @@ describe("update-notice", () => {
2426

2527
const packageRoot = "/tmp/node_modules/codex-multi-auth";
2628
const packageJsonPath = `${packageRoot}/package.json`;
29+
const actualPackageJsonPath = `${resolve(dirname(fileURLToPath(import.meta.url)), "..").replace(/\\/g, "/")}/package.json`;
2730
const cacheFilePath = "/tmp/codex-cache/update-check-cache.json";
2831
const mockPackageJson = { name: "codex-multi-auth", version: "4.12.0" };
2932
let cacheContents: string | null;
@@ -52,6 +55,7 @@ describe("update-notice", () => {
5255
const normalized = String(path).replace(/\\/g, "/");
5356
if (
5457
normalized === packageJsonPath ||
58+
normalized === actualPackageJsonPath ||
5559
normalized.endsWith("/codex-multi-auth-notice-only/package.json")
5660
) {
5761
return JSON.stringify(mockPackageJson);
@@ -68,6 +72,7 @@ describe("update-notice", () => {
6872
const normalized = String(path).replace(/\\/g, "/");
6973
return (
7074
normalized === packageJsonPath ||
75+
normalized === actualPackageJsonPath ||
7176
normalized.endsWith("/codex-multi-auth-notice-only/package.json") ||
7277
(normalized === cacheFilePath && cacheContents !== null)
7378
);

0 commit comments

Comments
 (0)