Skip to content

Commit

Permalink
Merge pull request #13883 from transcom/B-21436-Allow-AK-To-Be-Entered
Browse files Browse the repository at this point in the history
B-21436: Allow AK To Be Entered and FF
  • Loading branch information
cameroncaci authored Oct 14, 2024
2 parents 922b08d + 8a2f5f5 commit 4108a1c
Show file tree
Hide file tree
Showing 28 changed files with 128 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,7 @@ commands:
export FEATURE_FLAG_MANAGE_SUPPORTING_DOCS=false
export FEATURE_FLAG_THIRD_ADDRESS_AVAILABLE=false
export FEATURE_FLAG_QUEUE_MANAGEMENT=false
export FEATURE_FLAG_ENABLE_ALASKA=false
# disable for speed, playwright tests can fail otherwise
export DB_DEBUG=false
Expand Down Expand Up @@ -917,6 +918,7 @@ commands:
FEATURE_FLAG_MANAGE_SUPPORTING_DOCS: 'false'
FEATURE_FLAG_THIRD_ADDRESS_AVAILABLE: 'false'
FEATURE_FLAG_QUEUE_MANAGEMENT: 'false'
FEATURE_FLAG_ENABLE_ALASKA: 'false'
command: |
SHARD=$((${CIRCLE_NODE_INDEX}+1))
PLAYWRIGHT_JUNIT_OUTPUT_NAME=playwright-results.xml \
Expand Down
3 changes: 3 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ export FEATURE_FLAG_NTSR=true
export FEATURE_FLAG_BOAT=true
export FEATURE_FLAG_MOBILE_HOME=true

# Feature flag to allow AK to be entered as a state
export FEATURE_FLAG_ENABLE_ALASKA=false

# Feature flag to enable/disable customers needing to authenticate with CAC on registration
# When turned to true, this will require each customer user to have the value of true in cac_validated in the service_members table
export FEATURE_FLAG_CAC_VALIDATED_LOGIN=false
Expand Down
1 change: 1 addition & 0 deletions config/env/demo.app-client-tls.env
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,4 @@ FEATURE_FLAG_MANAGE_SUPPORTING_DOCS=false
FEATURE_FLAG_THIRD_ADDRESS_AVAILABLE=false
FEATURE_FLAG_QUEUE_MANAGEMENT=false
FEATURE_FLAG_DODID_UNIQUE=false
FEATURE_FLAG_ENABLE_ALASKA=false
1 change: 1 addition & 0 deletions config/env/demo.app.env
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,4 @@ FEATURE_FLAG_MANAGE_SUPPORTING_DOCS=false
FEATURE_FLAG_THIRD_ADDRESS_AVAILABLE=false
FEATURE_FLAG_QUEUE_MANAGEMENT=false
FEATURE_FLAG_DODID_UNIQUE=false
FEATURE_FLAG_ENABLE_ALASKA=false
1 change: 1 addition & 0 deletions config/env/exp.app-client-tls.env
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,4 @@ FEATURE_FLAG_MANAGE_SUPPORTING_DOCS=false
FEATURE_FLAG_THIRD_ADDRESS_AVAILABLE=false
FEATURE_FLAG_QUEUE_MANAGEMENT=false
FEATURE_FLAG_DODID_UNIQUE=false
FEATURE_FLAG_ENABLE_ALASKA=false
1 change: 1 addition & 0 deletions config/env/exp.app.env
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,4 @@ FEATURE_FLAG_MANAGE_SUPPORTING_DOCS=false
FEATURE_FLAG_THIRD_ADDRESS_AVAILABLE=false
FEATURE_FLAG_QUEUE_MANAGEMENT=false
FEATURE_FLAG_DODID_UNIQUE=false
FEATURE_FLAG_ENABLE_ALASKA=false
1 change: 1 addition & 0 deletions config/env/loadtest.app-client-tls.env
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@ FEATURE_FLAG_MANAGE_SUPPORTING_DOCS=false
FEATURE_FLAG_THIRD_ADDRESS_AVAILABLE=false
FEATURE_FLAG_QUEUE_MANAGEMENT=false
FEATURE_FLAG_DODID_UNIQUE=false
FEATURE_FLAG_ENABLE_ALASKA=false
1 change: 1 addition & 0 deletions config/env/loadtest.app.env
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,4 @@ FEATURE_FLAG_MANAGE_SUPPORTING_DOCS=false
FEATURE_FLAG_THIRD_ADDRESS_AVAILABLE=false
FEATURE_FLAG_QUEUE_MANAGEMENT=false
FEATURE_FLAG_DODID_UNIQUE=false
FEATURE_FLAG_ENABLE_ALASKA=false
1 change: 1 addition & 0 deletions config/env/prd.app-client-tls.env
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,4 @@ FEATURE_FLAG_MANAGE_SUPPORTING_DOCS=false
FEATURE_FLAG_THIRD_ADDRESS_AVAILABLE=false
FEATURE_FLAG_QUEUE_MANAGEMENT=false
FEATURE_FLAG_DODID_UNIQUE=false
FEATURE_FLAG_ENABLE_ALASKA=false
1 change: 1 addition & 0 deletions config/env/prd.app.env
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,4 @@ FEATURE_FLAG_MANAGE_SUPPORTING_DOCS=false
FEATURE_FLAG_THIRD_ADDRESS_AVAILABLE=false
FEATURE_FLAG_QUEUE_MANAGEMENT=false
FEATURE_FLAG_DODID_UNIQUE=false
FEATURE_FLAG_ENABLE_ALASKA=false
1 change: 1 addition & 0 deletions config/env/stg.app-client-tls.env
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,4 @@ FEATURE_FLAG_MANAGE_SUPPORTING_DOCS=false
FEATURE_FLAG_THIRD_ADDRESS_AVAILABLE=false
FEATURE_FLAG_QUEUE_MANAGEMENT=false
FEATURE_FLAG_DODID_UNIQUE=false
FEATURE_FLAG_ENABLE_ALASKA=false
1 change: 1 addition & 0 deletions config/env/stg.app.env
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,4 @@ FEATURE_FLAG_MANAGE_SUPPORTING_DOCS=false
FEATURE_FLAG_THIRD_ADDRESS_AVAILABLE=false
FEATURE_FLAG_QUEUE_MANAGEMENT=false
FEATURE_FLAG_DODID_UNIQUE=false
FEATURE_FLAG_ENABLE_ALASKA=false
8 changes: 8 additions & 0 deletions config/flipt/storage/development.features.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ flags:
- segment:
key: mil-app
value: true
- key: enable_alaska
name: Enable Alaska feature flag
type: BOOLEAN_FLAG_TYPE
enabled: false
rollouts:
- segment:
key: mil-app
value: false
- key: okta_dodid_input
name: Customer DODID input being pulled from Okta and disabling text input
type: BOOLEAN_FLAG_TYPE
Expand Down
14 changes: 13 additions & 1 deletion src/components/Customer/MtoShipmentForm/MtoShipmentForm.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
import { SHIPMENT_OPTIONS } from 'shared/constants';
import { renderWithRouter } from 'testUtils';
import { ORDERS_TYPE } from 'constants/orders';
import { isBooleanFlagEnabled } from 'utils/featureFlags';

const mockNavigate = jest.fn();
jest.mock('react-router-dom', () => ({
Expand All @@ -32,6 +33,11 @@ jest.mock('services/internalApi', () => ({
dateSelectionIsWeekendHoliday: jest.fn().mockImplementation(() => Promise.resolve()),
}));

jest.mock('utils/featureFlags', () => ({
...jest.requireActual('utils/featureFlags'),
isBooleanFlagEnabled: jest.fn().mockImplementation(() => Promise.resolve(false)),
}));

const moveId = uuidv4();

const defaultProps = {
Expand Down Expand Up @@ -64,7 +70,13 @@ const defaultProps = {

const reviewPath = generatePath(customerRoutes.MOVE_REVIEW_PATH, { moveId });

beforeEach(jest.resetAllMocks);
beforeEach(() => {
isBooleanFlagEnabled.mockImplementation(() => Promise.resolve(true));
});

afterEach(() => {
jest.clearAllMocks();
});

const renderMtoShipmentForm = (props) => {
return renderWithRouter(<MtoShipmentForm {...defaultProps} {...props} />, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ import userEvent from '@testing-library/user-event';

import AboutForm from 'components/Customer/PPM/Closeout/AboutForm/AboutForm';

jest.mock('utils/featureFlags', () => ({
...jest.requireActual('utils/featureFlags'),
isBooleanFlagEnabled: jest.fn().mockImplementation(() => Promise.resolve(false)),
}));

beforeEach(() => {
jest.clearAllMocks();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,20 @@ import { AddressFields } from 'components/form/AddressFields/AddressFields';
import ShipmentTag from 'components/ShipmentTag/ShipmentTag';
import { StorageFacilityAddressSchema } from 'components/Customer/MtoShipmentForm/validationSchemas';

export const EditFacilityInfoModal = ({ onClose, onSubmit, storageFacility, serviceOrderNumber, shipmentType }) => {
export const EditFacilityInfoModal = ({
onClose,
onSubmit,
storageFacility,
serviceOrderNumber,
shipmentType,
enabledAK,
}) => {
const editFacilityInfoSchema = Yup.object().shape({
serviceOrderNumber: Yup.string()
.required('Required')
.matches(/^[0-9a-zA-Z]+$/, 'Letters and numbers only'),
storageFacility: StorageFacilityAddressSchema,
enabledAK,
});

return (
Expand All @@ -37,6 +45,7 @@ export const EditFacilityInfoModal = ({ onClose, onSubmit, storageFacility, serv
initialValues={{
storageFacility,
serviceOrderNumber,
enabledAK,
}}
>
{({ isValid }) => {
Expand Down
14 changes: 13 additions & 1 deletion src/components/Office/ShipmentDetails/ShipmentDetailsSidebar.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React, { useEffect, useState } from 'react';
import { useParams, generatePath, useNavigate } from 'react-router-dom';
import * as PropTypes from 'prop-types';
import { Button } from '@trussworks/react-uswds';
Expand All @@ -15,6 +15,7 @@ import { OrdersLOAShape } from 'types/order';
import { tooRoutes } from 'constants/routes';
import Restricted from 'components/Restricted/Restricted';
import { permissionTypes } from 'constants/permissions';
import { isBooleanFlagEnabled } from 'utils/featureFlags';

const ShipmentDetailsSidebar = ({
className,
Expand All @@ -36,6 +37,7 @@ const ShipmentDetailsSidebar = ({
const [isEditFacilityInfoModalVisible, setIsEditFacilityInfoModalVisible] = useState(false);
const [isSonModalVisible, setIsSonModalVisible] = useState(false);
const [isAccountingCodesModalVisible, setIsAccountingCodesModalVisible] = useState(false);
const [enabledAK, setEnabledAK] = useState(false);

const handleShowEditFacilityInfoModal = () => {
setIsEditFacilityInfoModalVisible(true);
Expand All @@ -51,6 +53,15 @@ const ShipmentDetailsSidebar = ({
setIsAccountingCodesModalVisible(true);
};

useEffect(() => {
const fetchData = async () => {
isBooleanFlagEnabled('enabled_alaska').then((enabled) => {
setEnabledAK(enabled);
});
};
fetchData();
}, []);

return (
<div className={className}>
<ConnectedEditFacilityInfoModal
Expand All @@ -65,6 +76,7 @@ const ShipmentDetailsSidebar = ({
storageFacility={shipment.storageFacility}
serviceOrderNumber={shipment.serviceOrderNumber}
shipmentType={shipment.shipmentType}
enabledAK={enabledAK}
/>

<ConnectedServiceOrderNumberModal
Expand Down
17 changes: 15 additions & 2 deletions src/constants/states.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { isBooleanFlagEnabled } from 'utils/featureFlags';

// List of states
export const statesList = [
{ value: 'AL', key: 'AL' },
Expand Down Expand Up @@ -53,7 +55,18 @@ export const statesList = [
{ value: 'WY', key: 'WY' },
];

export const unSupportedStates = [
{ value: 'AK', key: 'AK' },
export const unSupportedStates = [{ value: 'HI', key: 'HI' }];
export const unSupportedStatesDisabledAlaska = [
{ value: 'HI', key: 'HI' },
{ value: 'AK', key: 'AK' },
];

export const getUnSupportedStates = async () => {
const enableAKFlag = await isBooleanFlagEnabled('enable_alaska');

if (!enableAKFlag) {
return unSupportedStatesDisabledAlaska;
}

return unSupportedStates;
};
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ jest.mock('react-router-dom', () => ({
useParams: () => ({ moveId: mockMoveId, mtoShipmentId: mockMTOShipmentId }),
}));

jest.mock('utils/featureFlags', () => ({
...jest.requireActual('utils/featureFlags'),
isBooleanFlagEnabled: jest.fn().mockImplementation(() => Promise.resolve(false)),
}));

const shipmentEditPath = generatePath(customerRoutes.SHIPMENT_EDIT_PATH, {
moveId: mockMoveId,
mtoShipmentId: mockMTOShipmentId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ jest.mock('react-router-dom', () => ({
useParams: () => ({ moveId: mockMoveId, mtoShipmentId: mockMTOShipmentId }),
}));

jest.mock('utils/featureFlags', () => ({
...jest.requireActual('utils/featureFlags'),
isBooleanFlagEnabled: jest.fn().mockImplementation(() => Promise.resolve(false)),
}));

const shipmentEditPath = generatePath(customerRoutes.SHIPMENT_EDIT_PATH, {
moveId: mockMoveId,
mtoShipmentId: mockMTOShipmentId,
Expand Down
8 changes: 8 additions & 0 deletions src/pages/MyMove/PPM/Closeout/About/About.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { MockProviders } from 'testUtils';
import { SHIPMENT_OPTIONS } from 'shared/constants';
import { shipmentStatuses } from 'constants/shipments';
import { shipment } from 'shared/Entities/schema';
import { isBooleanFlagEnabled } from 'utils/featureFlags';

const mockMoveId = v4();
const mockMTOShipmentId = v4();
Expand All @@ -26,6 +27,12 @@ const mockRoutingConfig = {
mtoShipmentId: mockMTOShipmentId,
},
};

jest.mock('utils/featureFlags', () => ({
...jest.requireActual('utils/featureFlags'),
isBooleanFlagEnabled: jest.fn().mockImplementation(() => Promise.resolve()),
}));

const mockNavigate = jest.fn();
jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
Expand Down Expand Up @@ -277,6 +284,7 @@ describe('About page', () => {
});

it('displays an error when the patch shipment API fails', async () => {
isBooleanFlagEnabled.mockResolvedValue(true);
const mockErrorMsg = 'Error Updating';
await getMTOShipmentsForMove.mockResolvedValueOnce(shipment);
await patchMTOShipment.mockRejectedValue(mockErrorMsg);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/MyMove/Profile/BackupAddress.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ describe('BackupAddress page', () => {
await userEvent.type(getByLabelText(/Address 1/), fakeAddress.streetAddress1);
await userEvent.type(getByLabelText(/Address 2/), fakeAddress.streetAddress2);
await userEvent.type(getByLabelText(/City/), fakeAddress.city);
await userEvent.selectOptions(getByLabelText(/State/), 'AK');
await userEvent.selectOptions(getByLabelText(/State/), 'HI');
await userEvent.type(getByLabelText(/ZIP/), fakeAddress.postalCode);
await userEvent.tab();

Expand Down
5 changes: 5 additions & 0 deletions src/pages/MyMove/Profile/EditContactInfo.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ jest.mock('services/internalApi', () => ({
patchServiceMember: jest.fn(),
}));

jest.mock('utils/featureFlags', () => ({
...jest.requireActual('utils/featureFlags'),
isBooleanFlagEnabled: jest.fn().mockImplementation(() => Promise.resolve(false)),
}));

beforeEach(() => {
jest.resetAllMocks();
});
Expand Down
2 changes: 1 addition & 1 deletion src/pages/MyMove/Profile/ResidentialAddress.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ describe('ResidentialAddress page', () => {
await userEvent.type(screen.getByLabelText(/Address 1/), fakeAddress.streetAddress1);
await userEvent.type(screen.getByLabelText(/Address 2/), fakeAddress.streetAddress2);
await userEvent.type(screen.getByLabelText(/City/), fakeAddress.city);
await userEvent.selectOptions(screen.getByLabelText(/State/), 'AK');
await userEvent.selectOptions(screen.getByLabelText(/State/), 'HI');
await userEvent.type(screen.getByLabelText(/ZIP/), fakeAddress.postalCode);
await userEvent.tab();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ describe('CreateCustomerForm', () => {
expect(saveBtn).toBeEnabled();
});

await userEvent.selectOptions(getByTestId('backup-add-state'), 'AK');
await userEvent.selectOptions(getByTestId('backup-add-state'), 'HI');
await userEvent.tab();

const msg = getByText('Moves to this state are not supported at this time.');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
useNavigate: () => mockNavigate,
}));

jest.mock('utils/featureFlags', () => ({
...jest.requireActual('utils/featureFlags'),
isBooleanFlagEnabled: jest.fn().mockImplementation(() => Promise.resolve(false)),
}));

const mockRoutingParams = { moveCode: 'move123', shipmentId: 'shipment123' };
const mockRoutingConfig = { path: servicesCounselingRoutes.BASE_SHIPMENT_EDIT_PATH, params: mockRoutingParams };
const mockTransportationOffice = [
Expand Down
5 changes: 5 additions & 0 deletions src/pages/PrimeUI/Shipment/PrimeUIShipmentCreate.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ jest.mock('services/primeApi', () => ({
createPrimeMTOShipmentV3: jest.fn().mockImplementation(() => Promise.resolve()),
}));

jest.mock('utils/featureFlags', () => ({
...jest.requireActual('utils/featureFlags'),
isBooleanFlagEnabled: jest.fn().mockImplementation(() => Promise.resolve(false)),
}));

const moveDetailsURL = generatePath(primeSimulatorRoutes.VIEW_MOVE_PATH, { moveCodeOrID: moveId });

const mockedComponent = (
Expand Down
15 changes: 12 additions & 3 deletions src/utils/validation.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as Yup from 'yup';

import { unSupportedStates } from '../constants/states';
import { getUnSupportedStates, unSupportedStates, unSupportedStatesDisabledAlaska } from '../constants/states';

import { ValidateZipRateData } from 'shared/api';

Expand Down Expand Up @@ -52,10 +52,19 @@ export const validatePostalCode = async (value, postalCodeType, errMsg = Unsuppo
};

export const UnsupportedStateErrorMsg = 'Moves to this state are not supported at this time.';
export const IsSupportedState = async (value) => {
export const IsSupportedState = async (value, context) => {
const selectedState = value;

const found = unSupportedStates.find((unsupportedState) => unsupportedState.key === selectedState);
const enableAK = 'enabledAK';

let unsupportedStates;
if (enableAK in context.options.context) {
unsupportedStates = context.options.context.enabledAK ? unSupportedStates : unSupportedStatesDisabledAlaska;
} else {
unsupportedStates = await getUnSupportedStates();
}

const found = unsupportedStates.find((unsupportedState) => unsupportedState.key === selectedState);

if (found) {
return false;
Expand Down

0 comments on commit 4108a1c

Please sign in to comment.