test(cli): add auto-update message tests and sync settings docs

This commit is contained in:
mkorwel
2026-03-19 20:56:15 -07:00
committed by Matt Korwel
parent f508722a93
commit 86f133a43e
2 changed files with 54 additions and 16 deletions
@@ -329,7 +329,7 @@ describe('handleAutoUpdate', () => {
});
});
it('should use the "@nightly" tag for nightly updates', async () => {
it('should use the "@nightly" tag for nightly updates in both command and message', async () => {
mockUpdateInfo = {
...mockUpdateInfo,
update: {
@@ -339,13 +339,18 @@ describe('handleAutoUpdate', () => {
};
mockGetInstallationInfo.mockReturnValue({
updateCommand: 'npm i -g @google/gemini-cli@latest',
updateMessage: 'This is an additional message.',
updateMessage: 'To update, run: npm i -g @google/gemini-cli@latest',
isGlobal: false,
packageManager: PackageManager.NPM,
});
handleAutoUpdate(mockUpdateInfo, mockSettings, '/root', mockSpawn);
expect(updateEventEmitter.emit).toHaveBeenCalledWith('update-received', {
message:
'An update is available!\nTo update, run: npm i -g @google/gemini-cli@nightly',
});
expect(mockSpawn).toHaveBeenCalledWith(
'npm i -g @google/gemini-cli@nightly',
{
@@ -356,6 +361,38 @@ describe('handleAutoUpdate', () => {
);
});
it('should use the version tag for stable updates in both command and message', async () => {
mockUpdateInfo = {
...mockUpdateInfo,
update: {
...mockUpdateInfo.update,
latest: '2.0.0',
},
};
mockGetInstallationInfo.mockReturnValue({
updateCommand: 'npm i -g @google/gemini-cli@latest',
updateMessage: 'To update, run: npm i -g @google/gemini-cli@latest',
isGlobal: false,
packageManager: PackageManager.NPM,
});
handleAutoUpdate(mockUpdateInfo, mockSettings, '/root', mockSpawn);
expect(updateEventEmitter.emit).toHaveBeenCalledWith('update-received', {
message:
'An update is available!\nTo update, run: npm i -g @google/gemini-cli@2.0.0',
});
expect(mockSpawn).toHaveBeenCalledWith(
'npm i -g @google/gemini-cli@2.0.0',
{
shell: true,
stdio: 'ignore',
detached: true,
},
);
});
it('should emit "update-success" when the update process succeeds', async () => {
await new Promise<void>((resolve) => {
mockGetInstallationInfo.mockReturnValue({