Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Legg til ff og utvid varseltekst #6514

Merged
merged 4 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions _mocks/featureToggles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,9 @@ export const featureTogglesFactory = () => [
{
key: 'NYE_NOKKELTALL',
value: process.env.VITE_NYE_NOKKELTALL,
},
{
key: 'UTVIDET_VARSELFELT',
value: process.env.VITE_UTVIDET_VARSELFELT,
}
];
2 changes: 2 additions & 0 deletions deploy/dev-fss-k9saksbehandling.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,5 @@ spec:
value: "true"
- name: NYE_NOKKELTALL
value: "true"
- name: UTVIDET_VARSELFELT
value: "true"
2 changes: 2 additions & 0 deletions deploy/prod-fss-k9saksbehandling.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,5 @@ spec:
value: "true"
- name: NYE_NOKKELTALL
value: "false"
- name: UTVIDET_VARSELFELT
value: "false"
4 changes: 4 additions & 0 deletions feature-toggles.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,9 @@
{
"key": "NYE_NOKKELTALL",
"value": "${NYE_NOKKELTALL}"
},
{
"key": "UTVIDET_VARSELFELT",
"value": "${UTVIDET_VARSELFELT}"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import styles from './avregningPanel.module.css';

const minLength3 = minLength(3);
const maxLength1500 = maxLength(1500);
const maxLength12000 = maxLength(12000);
const simuleringAksjonspunkter = [aksjonspunktCodes.VURDER_FEILUTBETALING];
const formName = 'AvregnigForm';
const IKKE_SEND = 'IKKE_SEND';
Expand Down Expand Up @@ -108,6 +109,7 @@ export class AvregningPanelImpl extends Component {
readOnly,
sprakkode,
featureVarseltekst,
featureUtvidetVarselfelt,
previewCallback,
hasOpenTilbakekrevingsbehandling,
...formProps
Expand Down Expand Up @@ -199,8 +201,8 @@ export class AvregningPanelImpl extends Component {
<TextAreaField
name="varseltekst"
label={{ id: 'Avregning.fritekst' }}
validate={[required, minLength3, maxLength1500, hasValidText]}
maxLength={1500}
validate={[required, minLength3, featureUtvidetVarselfelt ? maxLength12000 : maxLength1500, hasValidText]}
maxLength={featureUtvidetVarselfelt ? 12000 : 1500}
readOnly={readOnly}
id="avregningFritekst"
badges={[
Expand Down Expand Up @@ -338,6 +340,7 @@ const mapStateToPropsFactory = (initialState, ownPropsStatic) => {
initialValues: buildInitialValues(state, ownProps),
behandlingFormPrefix: getBehandlingFormPrefix(behandlingId, behandlingVersjon),
featureVarseltekst: erFrisinn || featureToggles?.VARSELTEKST,
featureUtvidetVarselfelt: featureToggles?.UTVIDET_VARSELFELT,
saksnummer: fagsak.saksnummer,
hasOpenTilbakekrevingsbehandling,
sprakkode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import { renderWithIntlAndReduxForm } from '@fpsak-frontend/utils-test/test-utils';
import { screen } from '@testing-library/react';
import TilbakekrevingEditerVedtaksbrevPanel from './TilbakekrevingEditerVedtaksbrevPanel';
import {K9sakApiKeys, requestApi} from "@k9-sak-web/sak-app/src/data/k9sakApi";

describe('<TilbakekrevingEditerVedtaksbrevPanel>', () => {
const vedtaksbrevAvsnitt = [
Expand Down Expand Up @@ -73,6 +74,7 @@ describe('<TilbakekrevingEditerVedtaksbrevPanel>', () => {
];

it('skal vise tekstfelt for begrunnelse og godkjenningsknapp', () => {
requestApi.mock(K9sakApiKeys.FEATURE_TOGGLE, [{ UTVIDET_VARSELTEKST: true }]);
renderWithIntlAndReduxForm(
<TilbakekrevingEditerVedtaksbrevPanel
vedtaksbrevAvsnitt={vedtaksbrevAvsnitt}
Expand All @@ -94,6 +96,7 @@ describe('<TilbakekrevingEditerVedtaksbrevPanel>', () => {
});

it('skal automatisk åpne panel som ikke har obligatorisk verdi utfylt', () => {
requestApi.mock(K9sakApiKeys.FEATURE_TOGGLE, [{ UTVIDET_VARSELTEKST: true }]);
renderWithIntlAndReduxForm(
<TilbakekrevingEditerVedtaksbrevPanel
vedtaksbrevAvsnitt={vedtaksbrevAvsnitt}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import React from 'react';
import { intlMock } from '../../../i18n';
import messages from '../../../i18n/nb_NO.json';
import { TilbakekrevingVedtakUtdypendeTekstPanel } from './TilbakekrevingVedtakUtdypendeTekstPanel';
import {K9sakApiKeys, requestApi} from "@k9-sak-web/sak-app/src/data/k9sakApi";

describe('<TilbakekrevingVedtakUtdypendeTekstPanel>', () => {
it('skal vise lenke for å skrive inn tekst når felt ikke har verdi og en ikke er i readonly-modus', () => {
requestApi.mock(K9sakApiKeys.FEATURE_TOGGLE, [{ UTVIDET_VARSELTEKST: true }]);
renderWithIntl(
<TilbakekrevingVedtakUtdypendeTekstPanel
intl={intlMock}
Expand All @@ -23,6 +25,7 @@ describe('<TilbakekrevingVedtakUtdypendeTekstPanel>', () => {
});

it('skal vise textarea når en har trykket på lenke', () => {
requestApi.mock(K9sakApiKeys.FEATURE_TOGGLE, [{ UTVIDET_VARSELTEKST: true }]);
renderWithIntlAndReduxForm(
<TilbakekrevingVedtakUtdypendeTekstPanel
intl={intlMock}
Expand All @@ -39,6 +42,7 @@ describe('<TilbakekrevingVedtakUtdypendeTekstPanel>', () => {
});

it('skal vise textarea når fritekst er påkrevet', () => {
requestApi.mock(K9sakApiKeys.FEATURE_TOGGLE, [{ UTVIDET_VARSELTEKST: true }]);
renderWithIntlAndReduxForm(
<TilbakekrevingVedtakUtdypendeTekstPanel
intl={intlMock}
Expand All @@ -55,6 +59,7 @@ describe('<TilbakekrevingVedtakUtdypendeTekstPanel>', () => {
});

it('skal ikke vise lenke eller textarea når verdi ikke finnes og en er i readonly-modus', () => {
requestApi.mock(K9sakApiKeys.FEATURE_TOGGLE, [{ UTVIDET_VARSELTEKST: true }]);
renderWithIntl(
<TilbakekrevingVedtakUtdypendeTekstPanel
intl={intlMock}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import addCircleIcon from '@fpsak-frontend/assets/images/add-circle.svg';
import { behandlingFormValueSelector, TextAreaField } from '@fpsak-frontend/form';
import { Image, VerticalSpacer } from '@fpsak-frontend/shared-components';
import {Image, useFeatureToggles, VerticalSpacer} from '@fpsak-frontend/shared-components';
import { hasValidText, maxLength, minLength, required } from '@fpsak-frontend/utils';
import { Detail } from '@navikt/ds-react';
import React, { useState } from 'react';
Expand All @@ -11,6 +11,7 @@ import styles from './tilbakekrevingVedtakUtdypendeTekstPanel.module.css';

const minLength3 = minLength(3);
const maxLength4000 = maxLength(4000);
const maxLength12000 = maxLength(12000);

const valideringsregler = [minLength3, hasValidText];
const valideringsreglerPakrevet = [required, minLength3, hasValidText];
Expand All @@ -31,9 +32,11 @@ export const TilbakekrevingVedtakUtdypendeTekstPanel = ({
fritekstPakrevet,
maximumLength,
}: OwnProps & WrappedComponentProps) => {
const [featureToggles] = useFeatureToggles()
const utvidetVarseltekst = featureToggles?.UTVIDET_VARSELTEKST
const [isTextfieldHidden, hideTextField] = useState(isEmpty && !fritekstPakrevet);
const valideringsRegler = fritekstPakrevet ? valideringsreglerPakrevet : valideringsregler;
valideringsRegler.push(maximumLength ? maxLength(maximumLength) : maxLength4000);
valideringsRegler.push(maximumLength ? maxLength(maximumLength) : (utvidetVarseltekst ? maxLength12000 : maxLength4000));
return (
<>
{isTextfieldHidden && !readOnly && (
Expand Down Expand Up @@ -69,7 +72,7 @@ export const TilbakekrevingVedtakUtdypendeTekstPanel = ({
name={type}
label={intl.formatMessage({ id: 'TilbakekrevingVedtakUtdypendeTekstPanel.UtdypendeTekst' })}
validate={valideringsRegler}
maxLength={maximumLength || 4000}
maxLength={maximumLength || (utvidetVarseltekst ? 12000 : 4000)}
readOnly={readOnly}
/>
</>
Expand Down