@@ -2877,6 +2877,51 @@ describe("update-cli", () => {
|
2877 | 2877 | expect(updateCall?.beforeGitMutation).toEqual(expect.any(Function)); |
2878 | 2878 | }); |
2879 | 2879 | |
| 2880 | +it("stops a managed gateway rooted at the git checkout when switching package installs to dev", async () => { |
| 2881 | +const packageRoot = createCaseDir("openclaw-update-package-root"); |
| 2882 | +const gitRoot = await createTrackedTempDir("openclaw-update-git-service-root-"); |
| 2883 | +const serviceEntrypoint = path.join(gitRoot, "dist", "index.js"); |
| 2884 | +await fs.mkdir(path.join(gitRoot, ".git"), { recursive: true }); |
| 2885 | +await fs.mkdir(path.dirname(serviceEntrypoint), { recursive: true }); |
| 2886 | +await fs.writeFile( |
| 2887 | +path.join(gitRoot, "package.json"), |
| 2888 | +JSON.stringify({ name: "openclaw", version: "2026.4.21" }), |
| 2889 | +"utf-8", |
| 2890 | +); |
| 2891 | +await fs.writeFile(serviceEntrypoint, "export {};\n", "utf-8"); |
| 2892 | +mockPackageInstallStatus(packageRoot); |
| 2893 | +pathExists.mockImplementation(async (candidate: string) => candidate === gitRoot); |
| 2894 | +serviceReadCommand.mockResolvedValue({ |
| 2895 | +programArguments: ["node", serviceEntrypoint, "gateway", "run"], |
| 2896 | +environment: { |
| 2897 | +OPENCLAW_SERVICE_MARKER: "openclaw", |
| 2898 | +OPENCLAW_SERVICE_KIND: "gateway", |
| 2899 | +}, |
| 2900 | +}); |
| 2901 | +serviceLoaded.mockResolvedValue(true); |
| 2902 | +serviceReadRuntime.mockResolvedValue({ |
| 2903 | +status: "running", |
| 2904 | +pid: 4242, |
| 2905 | +state: "running", |
| 2906 | +}); |
| 2907 | +mockGitUpdateAfterMutation( |
| 2908 | +makeOkUpdateResult({ |
| 2909 | +mode: "git", |
| 2910 | +root: gitRoot, |
| 2911 | +}), |
| 2912 | +); |
| 2913 | + |
| 2914 | +await withEnvAsync({ OPENCLAW_GIT_DIR: gitRoot }, async () => { |
| 2915 | +await updateCommand({ channel: "dev", yes: true }); |
| 2916 | +}); |
| 2917 | + |
| 2918 | +expect(serviceStop).toHaveBeenCalledTimes(1); |
| 2919 | +expect(runGatewayUpdate).toHaveBeenCalledTimes(1); |
| 2920 | +const updateCall = vi.mocked(runGatewayUpdate).mock.calls[0]?.[0]; |
| 2921 | +expect(updateCall?.cwd).toBe(gitRoot); |
| 2922 | +expect(updateCall?.beforeGitMutation).toEqual(expect.any(Function)); |
| 2923 | +}); |
| 2924 | + |
2880 | 2925 | it("does not stop or restart a managed gateway owned by another git checkout", async () => { |
2881 | 2926 | const otherRoot = await createTrackedTempDir("openclaw-update-other-service-root-"); |
2882 | 2927 | const otherEntrypoint = path.join(otherRoot, "dist", "index.js"); |
|