From f428630f19fb2412f141d2fcc9ddc67659d34db8 Mon Sep 17 00:00:00 2001 From: Kawa Date: Fri, 27 Mar 2026 11:40:54 +0100 Subject: [PATCH] =?UTF-8?q?test(04-01):=20add=20SECU-03=20assertion=20to?= =?UTF-8?q?=20reducer.test.ts=20=E2=80=94=20storage=20never=20written?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Added vi to import for spy capability - SECU-03: dispatches all action types, asserts setItem never called on Storage.prototype (covers both localStorage and sessionStorage) - All 9 reducer tests GREEN --- src/store/reducer.test.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/store/reducer.test.ts b/src/store/reducer.test.ts index e13cda9..93850dc 100644 --- a/src/store/reducer.test.ts +++ b/src/store/reducer.test.ts @@ -1,4 +1,4 @@ -import { describe, it, expect } from 'vitest'; +import { describe, it, expect, vi } from 'vitest'; import { wizardReducer } from './reducer'; import { INITIAL_STATE, WizardState } from './types'; @@ -61,4 +61,17 @@ describe('wizardReducer', () => { wizardReducer(INITIAL_STATE, { type: 'SET_STEP', payload: 5 }); expect(INITIAL_STATE.currentStep).toBe(before.currentStep); }); + + it('SECU-03: never writes to localStorage or sessionStorage', () => { + const setItemSpy = vi.spyOn(Storage.prototype, 'setItem'); + // Dispatch every action type to cover all reducer branches + wizardReducer(INITIAL_STATE, { type: 'SET_STEP', payload: 1 }); + wizardReducer(INITIAL_STATE, { type: 'SET_BACKEND_TYPE', payload: 'azureblob' }); + wizardReducer(INITIAL_STATE, { type: 'SET_REMOTE_NAME', payload: 'test' }); + wizardReducer(INITIAL_STATE, { type: 'SET_REMOTE_PARAMS', payload: { key: 'val' } }); + wizardReducer(INITIAL_STATE, { type: 'SET_DEPLOYMENT', payload: { includeInstall: true } }); + wizardReducer(INITIAL_STATE, { type: 'RESET' }); + expect(setItemSpy).not.toHaveBeenCalled(); + setItemSpy.mockRestore(); + }); });