diff --git a/scripts/run-packaged-smoke.mjs b/scripts/run-packaged-smoke.mjs index 15f0d50e2..78fad4008 100644 --- a/scripts/run-packaged-smoke.mjs +++ b/scripts/run-packaged-smoke.mjs @@ -258,7 +258,10 @@ export function findForbiddenWindowsPackagingArtifacts(directoryPath) { const entryPath = path.join(currentDirectoryPath, entry.name); const normalizedName = entry.name.toLowerCase(); if ( - normalizedName.includes("squirrel") || + normalizedName === "squirrel.exe" || + normalizedName.includes("squirrel-windows") || + normalizedName.startsWith("fit-file-viewer-squirrel-") || + normalizedName.endsWith(".nupkg") || normalizedName.endsWith("_executionstub.exe") ) { matches.push(entryPath); @@ -285,7 +288,7 @@ function assertNoForbiddenWindowsPackagingArtifacts(directoryPath) { throw new Error( [ - "Packaged app contains forbidden Squirrel packaging artifacts:", + "Packaged app contains forbidden Squirrel.Windows packaging artifacts:", ...forbiddenArtifacts.map((filePath) => `- ${filePath}`), ].join("\n") ); diff --git a/tests/unit/packaging/runPackagedSmoke.test.ts b/tests/unit/packaging/runPackagedSmoke.test.ts index 7ea43c0d8..1ade97d61 100644 --- a/tests/unit/packaging/runPackagedSmoke.test.ts +++ b/tests/unit/packaging/runPackagedSmoke.test.ts @@ -134,43 +134,84 @@ describe("run-packaged-smoke script", () => { ).toThrow("Packaged Electron executable not found"); }); - it("rejects Squirrel artifacts or helper executables leaked into Windows packages", () => { - expect.assertions(3); + it("finds known Squirrel.Windows package artifacts", () => { + expect.assertions(1); + + const releaseDistPath = createTemporaryRoot(); + const forbiddenPaths = [ + path.join(releaseDistPath, "squirrel-windows"), + path.join( + releaseDistPath, + "win-unpacked", + "Fit File Viewer_ExecutionStub.exe" + ), + path.join(releaseDistPath, "win-unpacked", "Squirrel.exe"), + path.join(releaseDistPath, "FitFileViewer-30.0.1-full.nupkg"), + path.join( + releaseDistPath, + "Fit-File-Viewer-squirrel-x64-30.0.1.exe" + ), + ]; + mkdirSync(forbiddenPaths[0], { recursive: true }); + for (const forbiddenPath of forbiddenPaths.slice(1)) { + writeExecutable(forbiddenPath); + } + + expect( + findForbiddenWindowsPackagingArtifacts(releaseDistPath) + ).toStrictEqual(forbiddenPaths.sort()); + }); + + it("rejects Squirrel.Windows artifacts before launching an app", () => { + expect.assertions(2); const releaseDistPath = createTemporaryRoot(); - const squirrelDirectoryPath = path.join( - releaseDistPath, - "squirrel-windows" - ); const executablePath = path.join( releaseDistPath, "win-unpacked", "Fit File Viewer.exe" ); - const executionStubPath = path.join( - releaseDistPath, - "win-unpacked", - "Fit File Viewer_ExecutionStub.exe" - ); - mkdirSync(squirrelDirectoryPath, { recursive: true }); writeExecutable(executablePath); - writeExecutable(executionStubPath); - + writeExecutable( + path.join( + releaseDistPath, + "win-unpacked", + "Fit File Viewer_ExecutionStub.exe" + ) + ); const commandRunner = vi.fn(); - expect( - findForbiddenWindowsPackagingArtifacts(releaseDistPath) - ).toStrictEqual([executionStubPath, squirrelDirectoryPath].sort()); expect(() => runPackagedSmoke( ["--executable", executablePath], {}, commandRunner ) - ).toThrow("forbidden Squirrel packaging artifacts"); + ).toThrow("forbidden Squirrel.Windows packaging artifacts"); expect(commandRunner).not.toHaveBeenCalled(); }); + it("allows Electron's macOS Squirrel updater framework", () => { + expect.assertions(1); + + const releaseDistPath = createTemporaryRoot(); + mkdirSync( + path.join( + releaseDistPath, + "mac-arm64", + "Fit File Viewer.app", + "Contents", + "Frameworks", + "Squirrel.framework" + ), + { recursive: true } + ); + + expect( + findForbiddenWindowsPackagingArtifacts(releaseDistPath) + ).toStrictEqual([]); + }); + it("launches the packaged executable and treats timeout as a healthy startup", () => { expect.assertions(7);