diff --git a/frontend/src/rack/__tests__/store.test.ts b/frontend/src/rack/__tests__/store.test.ts index a25634b..55ffb0e 100644 --- a/frontend/src/rack/__tests__/store.test.ts +++ b/frontend/src/rack/__tests__/store.test.ts @@ -423,6 +423,19 @@ describe('cables', () => { expect(store().importCablesFromNetwork(demoNetworkLinks())).toBe(0) }) + it('stays available after an import that matched nothing', () => { + // Nothing racked for these hints yet: the run creates nothing, and the user + // is told to rack the devices first — so the button has to survive it. + expect(store().importCablesFromNetwork([ + { from: 'node-nowhere-a', to: 'node-nowhere-b', type: 'ethernet' }, + ])).toBe(0) + expect(store().networkImportDone).toBe(false) + + store().mountFromInventory('inv-sw8', 'rack-main', { uStart: 4 }) + expect(store().importCablesFromNetwork(demoNetworkLinks())).toBeGreaterThan(0) + expect(store().networkImportDone).toBe(true) + }) + it('skips hints whose devices are not racked', () => { // inv-jbod is never mounted in the demo, so its hint cannot resolve. store().importCablesFromNetwork(demoNetworkLinks()) diff --git a/frontend/src/rack/store.ts b/frontend/src/rack/store.ts index 3fb0fc2..6ad60ac 100644 --- a/frontend/src/rack/store.ts +++ b/frontend/src/rack/store.ts @@ -673,7 +673,10 @@ export const useRackStore = create((set, get) => { ) if (id) created++ } - set({ networkImportDone: true }) + // Only latch on success. An import run before anything is racked matches + // nothing and says so — disabling the button then would kill the retry the + // toast just asked for. + if (created > 0) set({ networkImportDone: true }) return created },