11import { describe , it , expect , vi , beforeEach , afterEach } from "vitest" ;
2+ import { dirname , resolve } from "node:path" ;
3+ import { fileURLToPath } from "node:url" ;
24
35vi . 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