fix(agent-packages): show local inventory before refresh
This commit is contained in:
+11
-1
@@ -1805,6 +1805,7 @@ describe('registerIpcHandlers SSH hosts', () => {
|
||||
} as const
|
||||
const agentPackageManager = {
|
||||
getAllSnapshot: vi.fn(async () => agentPackageInventory),
|
||||
getAllInventory: vi.fn(async () => agentPackageInventory),
|
||||
forPlatform: vi.fn(() => agentPackageManager),
|
||||
download: vi.fn(
|
||||
async (
|
||||
@@ -1944,7 +1945,16 @@ describe('registerIpcHandlers SSH hosts', () => {
|
||||
).resolves.toEqual(agentPackageInventory)
|
||||
expect(
|
||||
agentPackageManager.getAllSnapshot
|
||||
).toHaveBeenCalledWith({ refresh: true })
|
||||
).toHaveBeenCalledWith({ refresh: true, localOnly: false })
|
||||
await expect(
|
||||
electronMocks.handlers.get(
|
||||
ipcChannels.sshHostsAgentPackageInventory
|
||||
)?.(event, { localOnly: true })
|
||||
).resolves.toEqual(agentPackageInventory)
|
||||
expect(agentPackageManager.getAllInventory).toHaveBeenCalledWith({
|
||||
refresh: false,
|
||||
localOnly: true
|
||||
})
|
||||
await expect(
|
||||
electronMocks.handlers.get(
|
||||
ipcChannels.sshHostsAgentPackageDownload
|
||||
|
||||
+3
-1
@@ -4855,7 +4855,9 @@ export function registerIpcHandlers(
|
||||
const request =
|
||||
agentPackageInventoryRequestSchema.parse(input ?? {})
|
||||
return agentPackageInventorySchema.parse(
|
||||
await agentPackageManager.getAllSnapshot(request)
|
||||
request.localOnly
|
||||
? await agentPackageManager.getAllInventory(request)
|
||||
: await agentPackageManager.getAllSnapshot(request)
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
@@ -300,6 +300,17 @@ export class AgentPackageManager {
|
||||
})
|
||||
}
|
||||
|
||||
async getAllInventory(options: { refresh?: boolean } = {}): Promise<AgentPackageInventory> {
|
||||
const linux = await this.forPlatform('linux').getInventory(options)
|
||||
const darwin = this.forPlatform('darwin')
|
||||
darwin.#catalogState = this.forPlatform('linux').#catalogState
|
||||
const mac = await darwin.getInventory(options)
|
||||
return agentPackageInventorySchema.parse({
|
||||
...linux,
|
||||
entries: [...linux.entries, ...mac.entries]
|
||||
})
|
||||
}
|
||||
|
||||
#select(catalog: AgentPackageCatalog, architecture: AgentArchitecture, desktopVersion: string) {
|
||||
return selectLatestCompatibleEntry(catalog, architecture, desktopVersion, this.#platform)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user