diff --git a/frontend/kesaseteli/employer/browser-tests/actions/application.actions.ts b/frontend/kesaseteli/employer/browser-tests/actions/application.actions.ts index 8f0604ff73..38edbe5222 100644 --- a/frontend/kesaseteli/employer/browser-tests/actions/application.actions.ts +++ b/frontend/kesaseteli/employer/browser-tests/actions/application.actions.ts @@ -69,12 +69,8 @@ export const fillEmploymentDetails = async ( const { employee_ssn, - target_group, - employee_home_city, - employee_postcode, employee_phone_number, employment_postcode, - employee_school, employment_start_date, employment_end_date, employment_work_hours, @@ -86,15 +82,10 @@ export const fillEmploymentDetails = async ( if (!expectedPreFill?.employee_ssn) { await step1Form.actions.fillSsn(employee_ssn ?? ''); } - const targetGroupKey = target_group ?? 'secondary_target_group'; - await step1Form.actions.selectTargetGroup(targetGroupKey); - await step1Form.actions.fillHomeCity(employee_home_city ?? ''); - await step1Form.actions.fillPostcode(String(employee_postcode ?? '')); await step1Form.actions.fillPhoneNumber(employee_phone_number ?? ''); await step1Form.actions.fillEmploymentPostcode( String(employment_postcode ?? '') ); - await step1Form.actions.fillSchool(employee_school ?? ''); await step1Form.actions.addEmploymentContractAttachment([ 'sample1.pdf', @@ -144,8 +135,6 @@ export const loginAndfillApplication = async ( expectedPreFill?: { employee_ssn?: string; employee_phone_number?: string; - employee_postcode?: string | number; - employee_school?: string; } ): Promise => { const urlUtils = getUrlUtils(t); diff --git a/frontend/kesaseteli/employer/browser-tests/application-page/application.mocks.ts b/frontend/kesaseteli/employer/browser-tests/application-page/application.mocks.ts index 853be6d7fb..745b9a44c4 100644 --- a/frontend/kesaseteli/employer/browser-tests/application-page/application.mocks.ts +++ b/frontend/kesaseteli/employer/browser-tests/application-page/application.mocks.ts @@ -8,8 +8,7 @@ export const MOCKED_EMPLOYEE_DATA = { employee_phone_number: '040 1234567', employee_home_city: 'Helsinki', employee_postcode: '00100', - employee_school: 'Testikoulu', - target_group: 'secondary_target_group', + employee_school: 'Test School', }; /** @@ -18,12 +17,10 @@ export const MOCKED_EMPLOYEE_DATA = { * from requests and restore them in responses to make tests work. */ const serialNumberFixes = new Map(); -const targetGroupFixes = new Map(); interface VoucherData { id: string; summer_voucher_serial_number?: string; - target_group?: string; } /** @@ -74,9 +71,6 @@ const cacheVoucherFixes = (vouchers?: VoucherData[]): void => { if (v.id && v.summer_voucher_serial_number) { serialNumberFixes.set(v.id, v.summer_voucher_serial_number); } - if (v.id && v.target_group) { - targetGroupFixes.set(v.id, v.target_group); - } }); }; @@ -88,22 +82,14 @@ const restoreVoucherData = ( v.summer_voucher_serial_number || requestVoucher?.summer_voucher_serial_number || serialNumberFixes.get(v.id); - const restoredTargetGroup = - v.target_group || - requestVoucher?.target_group || - targetGroupFixes.get(v.id); if (v.id && restoredSerialNumber) { serialNumberFixes.set(v.id, restoredSerialNumber); } - if (v.id && restoredTargetGroup) { - targetGroupFixes.set(v.id, restoredTargetGroup); - } return { ...v, summer_voucher_serial_number: restoredSerialNumber || '', - target_group: restoredTargetGroup || '', }; }; @@ -198,38 +184,6 @@ export const fetchEmployeeDataMock = RequestMock() }) .respond(handleEmployerApplicationsGet); -// Proxy target_groups requests to the real backend -export const targetGroupsMock = RequestMock() - .onRequestTo({ - url: /target_groups/, - method: 'GET', - }) - .respond( - async (req: MockRequest, res: MockResponse) => { - // eslint-disable-next-line no-console - console.log('MOCK GET target_groups hit:', req.url); - try { - const response = await axios.get(req.url, { - headers: req.headers, - }); - res.headers = getTestCafeHeaders(response.headers); - res.statusCode = response.status; - res.setBody(response.data as object); - } catch (error: unknown) { - if (axios.isAxiosError(error)) { - // eslint-disable-next-line no-console - console.error('Proxy GET target_groups failed', error); - res.statusCode = error.response?.status || 500; - res.setBody((error.response?.data as object) || {}); - } else { - res.statusCode = 500; - } - } - }, - 200, - { 'access-control-allow-origin': '*' } - ); - export const attachmentsMock = RequestMock() .onRequestTo({ url: /attachments/, diff --git a/frontend/kesaseteli/employer/browser-tests/application-page/application.testcafe.ts b/frontend/kesaseteli/employer/browser-tests/application-page/application.testcafe.ts index c1cdf0a026..6f8e627511 100644 --- a/frontend/kesaseteli/employer/browser-tests/application-page/application.testcafe.ts +++ b/frontend/kesaseteli/employer/browser-tests/application-page/application.testcafe.ts @@ -17,7 +17,6 @@ import { attachmentsMock, fetchEmployeeDataMock, MOCKED_EMPLOYEE_DATA, - targetGroupsMock, } from './application.mocks'; import { getStep1Components } from './step1.components'; import { getStep2Components } from './step2.components'; @@ -34,7 +33,6 @@ fixture('Application') requestLogger, new HttpRequestHook(url, getBackendDomain()), fetchEmployeeDataMock, - targetGroupsMock, attachmentsMock ) .beforeEach(async (t) => { @@ -118,7 +116,6 @@ test('Fills up employer form and preserves data when navigating back and forth', application.summer_vouchers[0] ); await step1Form.expectations.isEmploymentSupplementFulfilledWith({ - target_group: application.summer_vouchers[0].target_group, employment_start_date: convertToUIDateFormat( application.summer_vouchers[0].employment_start_date ), diff --git a/frontend/kesaseteli/employer/browser-tests/application-page/step1.components.ts b/frontend/kesaseteli/employer/browser-tests/application-page/step1.components.ts index 2ddf60583b..7ee1edc901 100644 --- a/frontend/kesaseteli/employer/browser-tests/application-page/step1.components.ts +++ b/frontend/kesaseteli/employer/browser-tests/application-page/step1.components.ts @@ -107,20 +107,6 @@ export const getStep1Components = (t: TestController) => { name: /^henkilötunnus/i, }); }, - targetGroupInput(value: string) { - // Target the label instead of the input to avoid overlap issues - return Selector(`label[for="summer_vouchers.0.target_group-${value}"]`); - }, - homeCityInput() { - return withinForm().findByRole('textbox', { - name: /^kotipaikka/i, - }); - }, - postcodeInput() { - return withinForm().findByRole('spinbutton', { - name: /^postinumero/i, - }); - }, phoneNumberInput() { return withinForm().findByRole('textbox', { name: /^puhelinnumero/i, @@ -131,11 +117,6 @@ export const getStep1Components = (t: TestController) => { name: /^työn suorituspaikan postinumero/i, }); }, - schoolInput() { - return withinForm().findByRole('textbox', { - name: /^koulun nimi/i, - }); - }, employmentContractAttachmentInput: () => withinForm().findByTestId('summer_vouchers.0.employment_contract'), payslipAttachmentInput: () => @@ -188,10 +169,6 @@ export const getStep1Components = (t: TestController) => { await t .expect(selectors.ssnInput().hasAttribute('disabled')) .notOk(await getErrorMessage(t)); - // Wait for at least one target group to appear to ensure dynamic content is loaded - await t - .expect(Selector('[data-testid*="target_group-"]').exists) - .ok('Target groups did not load in time', { timeout: 10_000 }); }, async isSsnFieldReadOnly() { await t @@ -228,13 +205,9 @@ export const getStep1Components = (t: TestController) => { async isEmploymentFulfilledWith({ employee_ssn, employee_phone_number, - employee_postcode, - employee_school, }: { employee_ssn?: string; employee_phone_number?: string; - employee_postcode?: string | number; - employee_school?: string; }) { await t.expect(formSelector().exists).ok(await getErrorMessage(t)); if (employee_ssn) { @@ -247,36 +220,16 @@ export const getStep1Components = (t: TestController) => { .expect(selectors.phoneNumberInput().value) .eql(employee_phone_number, await getErrorMessage(t)); } - if (employee_postcode) { - await t - .expect(selectors.postcodeInput().value) - .eql(String(employee_postcode), await getErrorMessage(t)); - } - if (employee_school) { - await t - .expect(selectors.schoolInput().value) - .eql(employee_school, await getErrorMessage(t)); - } }, async isEmploymentSupplementFulfilledWith({ - target_group, employment_start_date, employment_end_date, hired_without_voucher_assessment, }: { - target_group?: string; employment_start_date?: string; employment_end_date?: string; hired_without_voucher_assessment?: string; }) { - if (target_group) { - await t - .expect( - Selector(`input#summer_vouchers\\.0\\.target_group-${target_group}`) - .checked - ) - .ok(await getErrorMessage(t)); - } if (employment_start_date) { await t .expect(selectors.startDateInput().value) @@ -386,29 +339,6 @@ export const getStep1Components = (t: TestController) => { ssn ); }, - async selectTargetGroup(name: string) { - const selector = selectors.targetGroupInput(name); - await t - .expect(selector.exists) - .ok(await getErrorMessage(t), { timeout: 10_000 }); - await t.click(selector); - }, - fillHomeCity(city: string) { - return fillInput( - t, - 'summer_vouchers.0.employee_home_city', - selectors.homeCityInput(), - city - ); - }, - fillPostcode(postcode: string) { - return fillInput( - t, - 'summer_vouchers.0.employee_postcode', - selectors.postcodeInput(), - postcode - ); - }, fillPhoneNumber(phone: string) { return fillInput( t, @@ -425,14 +355,6 @@ export const getStep1Components = (t: TestController) => { postcode ); }, - fillSchool(school: string) { - return fillInput( - t, - 'summer_vouchers.0.employee_school', - selectors.schoolInput(), - school - ); - }, addEmploymentContractAttachment, addPayslipAttachments, fillStartDate(date: string) { diff --git a/frontend/kesaseteli/employer/browser-tests/application-page/summary.components.ts b/frontend/kesaseteli/employer/browser-tests/application-page/summary.components.ts index 1c4b1fb74b..e44e1d3292 100644 --- a/frontend/kesaseteli/employer/browser-tests/application-page/summary.components.ts +++ b/frontend/kesaseteli/employer/browser-tests/application-page/summary.components.ts @@ -127,7 +127,7 @@ export const getSummaryComponents = async (t: TestController) => { ); const expectTargetGroupHasValue = ( - field: 'target_group' | 'hired_without_voucher_assessment' + field: 'hired_without_voucher_assessment' ) => { const value = employment[field]; if (!value) { @@ -159,15 +159,10 @@ export const getSummaryComponents = async (t: TestController) => { .contains(employment.employee_name ?? '', await getErrorMessage(t)) .expect(header.textContent) .contains(employment.employee_ssn ?? '', await getErrorMessage(t)); - await expectTargetGroupHasValue('target_group'); - await expectEmploymentFieldhasValue('employee_postcode'); - await expectEmploymentFieldhasValue('employee_home_city'); await expectEmploymentFieldhasValue('employee_phone_number'); await expectEmploymentFieldhasValue('employment_postcode'); - await expectEmploymentFieldhasValue('employee_school'); await expectAttachments('employment_contract'); await expectAttachments('payslip'); - await expectEmploymentFieldhasValue('employee_school'); const { employment_start_date, employment_end_date } = employment; const dateRange = [employment_start_date, employment_end_date] .map((date) => convertToUIDateFormat(date)) diff --git a/frontend/kesaseteli/employer/browser-tests/utils/application.utils.ts b/frontend/kesaseteli/employer/browser-tests/utils/application.utils.ts index 466ee13bcd..3d7ffe5f11 100644 --- a/frontend/kesaseteli/employer/browser-tests/utils/application.utils.ts +++ b/frontend/kesaseteli/employer/browser-tests/utils/application.utils.ts @@ -10,7 +10,7 @@ import get from 'lodash/get'; import translations from '../../public/locales/fi/common.json'; export const getSelectionGroupTranslation = ( - type: 'target_group' | 'hired_without_voucher_assessment', + type: 'hired_without_voucher_assessment', value: EmploymentExceptionReason | EmployeeHiredWithoutVoucherAssessment ): string => get( diff --git a/frontend/kesaseteli/employer/src/components/application/steps/step1/EmploymentForm.tsx b/frontend/kesaseteli/employer/src/components/application/steps/step1/EmploymentForm.tsx index d86a047487..a335f87ef1 100644 --- a/frontend/kesaseteli/employer/src/components/application/steps/step1/EmploymentForm.tsx +++ b/frontend/kesaseteli/employer/src/components/application/steps/step1/EmploymentForm.tsx @@ -5,14 +5,13 @@ import SelectionGroup from 'kesaseteli/employer/components/application/form/Sele import type { TextInputProps } from 'kesaseteli/employer/components/application/form/TextInput'; import TextInput from 'kesaseteli/employer/components/application/form/TextInput'; import useApplicationApi from 'kesaseteli/employer/hooks/application/useApplicationApi'; -import useTargetGroupsQuery from 'kesaseteli/employer/hooks/backend/useTargetGroupsQuery'; import { useTranslation } from 'next-i18next'; import React, { useCallback, useEffect, useState } from 'react'; import { useFormContext, useWatch } from 'react-hook-form'; import FormSection from 'shared/components/forms/section/FormSection'; import FormSectionDivider from 'shared/components/forms/section/FormSectionDivider'; import FormSectionHeading from 'shared/components/forms/section/FormSectionHeading'; -import { CITY_REGEX, POSTAL_CODE_REGEX } from 'shared/constants'; +import { POSTAL_CODE_REGEX } from 'shared/constants'; import { EMPLOYEE_HIRED_WITHOUT_VOUCHER_ASSESSMENT } from 'shared/constants/employee-constants'; import Application from 'shared/types/application'; import DraftApplication from 'shared/types/draft-application'; @@ -124,11 +123,6 @@ const EmploymentForm: React.FC = ({ index }) => { useFetchEmployeeDataButtonState(index); const { isEmployeeDataFetched, handleGetEmployeeData } = useFetchEmployeeData(index); - const { data: targetGroups } = useTargetGroupsQuery(); - - const targetGroupValues = targetGroups?.map((tg) => tg.id) || []; - const getTargetGroupLabel = (value: string): string => - targetGroups?.find((tg) => tg.id === value)?.name || ''; const getId = (field: keyof Employment): TextInputProps['id'] => `summer_vouchers.${index}.${field}`; @@ -179,37 +173,7 @@ const EmploymentForm: React.FC = ({ index }) => { disabled={disableEmploymentFields} readOnly={isEmployeeDataFetched} /> - - - - + = ({ index }) => { disabled={disableEmploymentFields} /> - - = ({ index }) => { const { employee_name, employee_ssn, - target_group, employment_contract, payslip, employment_start_date, @@ -41,17 +40,6 @@ const EmploymentSummary: React.FC = ({ index }) => { as="h3" data-testid={`employee-heading-${index}`} /> - - {/* TODO: Remove Target Group as it is not a necessary field in employers UI. - Remove also the translations. */} - {t( - `common:application.form.selectionGroups.target_group.${ - target_group ?? '' - }` - )} - - - = ({ index }) => { fieldName="summer_voucher_serial_number" index={index} /> - {t(`common:application.form.inputs.employment_contract`)}:{' '} {getAttachmentsSummary(employment_contract)} diff --git a/frontend/kesaseteli/employer/src/hooks/application/useApplicationApi.ts b/frontend/kesaseteli/employer/src/hooks/application/useApplicationApi.ts index 6aa9e5eeb1..affd830361 100644 --- a/frontend/kesaseteli/employer/src/hooks/application/useApplicationApi.ts +++ b/frontend/kesaseteli/employer/src/hooks/application/useApplicationApi.ts @@ -218,7 +218,6 @@ const useApplicationApi = ( ApplicationPersistenceService.storeVoucherSupplement( voucher.id, { - target_group: formVoucher.target_group, employment_start_date: formVoucher.employment_start_date, employment_end_date: formVoucher.employment_end_date, hired_without_voucher_assessment: diff --git a/frontend/kesaseteli/employer/src/hooks/application/useApplicationFormField.ts b/frontend/kesaseteli/employer/src/hooks/application/useApplicationFormField.ts index cb4869b422..bf03e2b8bb 100644 --- a/frontend/kesaseteli/employer/src/hooks/application/useApplicationFormField.ts +++ b/frontend/kesaseteli/employer/src/hooks/application/useApplicationFormField.ts @@ -88,7 +88,6 @@ const useApplicationFormField = ( return message; } switch (fieldName) { - case 'target_group': case 'hired_without_voucher_assessment': return t(`common:application.form.errors.selectionGroups`); diff --git a/frontend/kesaseteli/employer/src/services/__tests__/ApplicationPersistenceService.test.ts b/frontend/kesaseteli/employer/src/services/__tests__/ApplicationPersistenceService.test.ts index da599e3ad1..edce4be9cd 100644 --- a/frontend/kesaseteli/employer/src/services/__tests__/ApplicationPersistenceService.test.ts +++ b/frontend/kesaseteli/employer/src/services/__tests__/ApplicationPersistenceService.test.ts @@ -8,133 +8,134 @@ const EMPLOYER_DATA_KEY = 'kesaseteli_employer_data'; const SUPPLEMENT_PREFIX = 'kesaseteli_voucher_supplement_'; describe('ApplicationPersistenceService', () => { - const mockEmployerData: Partial = { - contact_person_name: 'Teppo Testi', - contact_person_email: 'teppo@testi.com', - contact_person_phone_number: '0401234567', - street_address: 'Testikatu 1', - bank_account_number: 'FI1234567890', - }; - - const mockVoucherSupplement: Partial = { - target_group: 'secondary_target_group', - employee_ssn: '010101-0101', - }; - - beforeEach(() => { - sessionStorage.clear(); - jest.clearAllMocks(); + const mockEmployerData: Partial = { + contact_person_name: 'Teppo Testi', + contact_person_email: 'teppo@testi.com', + contact_person_phone_number: '0401234567', + street_address: 'Testikatu 1', + bank_account_number: 'FI1234567890', + }; + + const mockVoucherSupplement: Partial = { + employee_ssn: '010101-0101', + }; + + beforeEach(() => { + sessionStorage.clear(); + jest.clearAllMocks(); + }); + + describe('storeEmployerData and getEmployerData', () => { + it('should store and retrieve employer data', () => { + ApplicationPersistenceService.storeEmployerData(mockEmployerData); + const retrievedData = ApplicationPersistenceService.getEmployerData(); + expect(retrievedData).toEqual(mockEmployerData); }); - describe('storeEmployerData and getEmployerData', () => { - it('should store and retrieve employer data', () => { - ApplicationPersistenceService.storeEmployerData(mockEmployerData); - const retrievedData = ApplicationPersistenceService.getEmployerData(); - expect(retrievedData).toEqual(mockEmployerData); - }); - - it('should store data in obfuscated (Base64) format', () => { - ApplicationPersistenceService.storeEmployerData(mockEmployerData); - const storedRaw = sessionStorage.getItem(EMPLOYER_DATA_KEY); - - // Verify it's not JSON anymore - expect(() => { - JSON.parse(storedRaw || ''); - }).toThrow(); - - // Verify it can be decoded back to JSON - const decoded = atob(storedRaw || ''); - expect(JSON.parse(decoded)).toEqual(mockEmployerData); - }); - - it('should sanitize data before storing', () => { - const sensitiveData: Partial = { - ...mockEmployerData, - id: 'sensitive-id', - status: 'submitted', - } as unknown as Partial; - - ApplicationPersistenceService.storeEmployerData(sensitiveData); - const retrievedData = ApplicationPersistenceService.getEmployerData(); - - expect(retrievedData).toEqual(mockEmployerData); - expect(retrievedData).not.toHaveProperty('id'); - expect(retrievedData).not.toHaveProperty('status'); - }); - - it('should return null if no employer data is stored', () => { - expect(ApplicationPersistenceService.getEmployerData()).toBeNull(); - }); - - it('should return null if stored data is corrupted', () => { - sessionStorage.setItem(EMPLOYER_DATA_KEY, 'invalid-base64-!!!'); - expect(ApplicationPersistenceService.getEmployerData()).toBeNull(); - }); + it('should store data in obfuscated (Base64) format', () => { + ApplicationPersistenceService.storeEmployerData(mockEmployerData); + const storedRaw = sessionStorage.getItem(EMPLOYER_DATA_KEY); + + // Verify it's not JSON anymore + expect(() => { + JSON.parse(storedRaw || ''); + }).toThrow(); + + // Verify it can be decoded back to JSON + const decoded = atob(storedRaw || ''); + expect(JSON.parse(decoded)).toEqual(mockEmployerData); + }); + + it('should sanitize data before storing', () => { + const sensitiveData: Partial = { + ...mockEmployerData, + id: 'sensitive-id', + status: 'submitted', + } as unknown as Partial; + + ApplicationPersistenceService.storeEmployerData(sensitiveData); + const retrievedData = ApplicationPersistenceService.getEmployerData(); + + expect(retrievedData).toEqual(mockEmployerData); + expect(retrievedData).not.toHaveProperty('id'); + expect(retrievedData).not.toHaveProperty('status'); + }); + + it('should return null if no employer data is stored', () => { + expect(ApplicationPersistenceService.getEmployerData()).toBeNull(); }); - describe('storeVoucherSupplement and getVoucherSupplement', () => { - it('should store and retrieve voucher supplement', () => { - const voucherId = 'test-voucher-id'; - ApplicationPersistenceService.storeVoucherSupplement( - voucherId, - mockVoucherSupplement - ); - const retrievedData = - ApplicationPersistenceService.getVoucherSupplement(voucherId); - expect(retrievedData).toEqual(mockVoucherSupplement); - }); - - it('should store supplement in obfuscated (Base64) format', () => { - const voucherId = 'test-voucher-id'; - ApplicationPersistenceService.storeVoucherSupplement( - voucherId, - mockVoucherSupplement - ); - const storedRaw = sessionStorage.getItem(`${SUPPLEMENT_PREFIX}${voucherId}`); - - const decoded = atob(storedRaw || ''); - expect(JSON.parse(decoded)).toEqual(mockVoucherSupplement); - }); - - it('should return null if no voucher supplement is stored', () => { - expect( - ApplicationPersistenceService.getVoucherSupplement('non-existent') - ).toBeNull(); - }); + it('should return null if stored data is corrupted', () => { + sessionStorage.setItem(EMPLOYER_DATA_KEY, 'invalid-base64-!!!'); + expect(ApplicationPersistenceService.getEmployerData()).toBeNull(); }); + }); + + describe('storeVoucherSupplement and getVoucherSupplement', () => { + it('should store and retrieve voucher supplement', () => { + const voucherId = 'test-voucher-id'; + ApplicationPersistenceService.storeVoucherSupplement( + voucherId, + mockVoucherSupplement + ); + const retrievedData = + ApplicationPersistenceService.getVoucherSupplement(voucherId); + expect(retrievedData).toEqual(mockVoucherSupplement); + }); + + it('should store supplement in obfuscated (Base64) format', () => { + const voucherId = 'test-voucher-id'; + ApplicationPersistenceService.storeVoucherSupplement( + voucherId, + mockVoucherSupplement + ); + const storedRaw = sessionStorage.getItem( + `${SUPPLEMENT_PREFIX}${voucherId}` + ); + + const decoded = atob(storedRaw || ''); + expect(JSON.parse(decoded)).toEqual(mockVoucherSupplement); + }); + + it('should return null if no voucher supplement is stored', () => { + expect( + ApplicationPersistenceService.getVoucherSupplement('non-existent') + ).toBeNull(); + }); + }); + + describe('clearAll', () => { + it('should clear all persisted data', () => { + ApplicationPersistenceService.storeEmployerData(mockEmployerData); + ApplicationPersistenceService.storeVoucherSupplement( + 'v1', + mockVoucherSupplement + ); + ApplicationPersistenceService.storeVoucherSupplement( + 'v2', + mockVoucherSupplement + ); + + ApplicationPersistenceService.clearAll(); + + expect(ApplicationPersistenceService.getEmployerData()).toBeNull(); + expect( + ApplicationPersistenceService.getVoucherSupplement('v1') + ).toBeNull(); + expect( + ApplicationPersistenceService.getVoucherSupplement('v2') + ).toBeNull(); + }); + + it('should only clear application-related data from sessionStorage', () => { + sessionStorage.setItem('other_key', 'other_value'); + ApplicationPersistenceService.storeEmployerData(mockEmployerData); + + ApplicationPersistenceService.clearAll(); - describe('clearAll', () => { - it('should clear all persisted data', () => { - ApplicationPersistenceService.storeEmployerData(mockEmployerData); - ApplicationPersistenceService.storeVoucherSupplement( - 'v1', - mockVoucherSupplement - ); - ApplicationPersistenceService.storeVoucherSupplement( - 'v2', - mockVoucherSupplement - ); - - ApplicationPersistenceService.clearAll(); - - expect(ApplicationPersistenceService.getEmployerData()).toBeNull(); - expect( - ApplicationPersistenceService.getVoucherSupplement('v1') - ).toBeNull(); - expect( - ApplicationPersistenceService.getVoucherSupplement('v2') - ).toBeNull(); - }); - - it('should only clear application-related data from sessionStorage', () => { - sessionStorage.setItem('other_key', 'other_value'); - ApplicationPersistenceService.storeEmployerData(mockEmployerData); - - ApplicationPersistenceService.clearAll(); - - expect(sessionStorage.getItem('other_key')).toBe('other_value'); - expect(ApplicationPersistenceService.getEmployerData()).toBeNull(); - }); + expect(sessionStorage.getItem('other_key')).toBe('other_value'); + expect(ApplicationPersistenceService.getEmployerData()).toBeNull(); }); + }); }); /* eslint-enable scanjs-rules/identifier_sessionStorage */