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

B 20010 int Add FF for HQ role #12984

Merged
merged 29 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
0471865
Merge branch 'main' of github.com:transcom/mymove into B-20010
r-mettler May 24, 2024
b84ee7a
adding HEADQUARTERS_ROLE FF
r-mettler May 29, 2024
4de9977
adjust hq ff checks
r-mettler May 29, 2024
dab0267
prevent safety moves privs for hq role
r-mettler May 29, 2024
7b705e9
updating safety moves check
r-mettler May 29, 2024
3b7e3a9
Merge branch 'main' of github.com:transcom/mymove into B-20010
r-mettler May 29, 2024
bfa932d
Merge branch 'main' of github.com:transcom/mymove into B-20010
r-mettler May 29, 2024
1fa862a
don't display HQ checkbox if FF on
r-mettler May 29, 2024
1e4146d
for now we hard code off HQ for Request Account
r-mettler Jun 5, 2024
c7d54c1
Merge branch 'main' of github.com:transcom/mymove into B-20010
r-mettler Jun 5, 2024
9c0b950
fix formatting errors
r-mettler Jun 5, 2024
2213792
Merge branch 'main' of github.com:transcom/mymove into B-20010
r-mettler Jun 6, 2024
fad195f
fixing bad merge changes
r-mettler Jun 6, 2024
a41e211
feature flag failures in js files, moved to admin page, removed offic…
r-mettler Jun 6, 2024
cc7c213
Merge branch 'main' of github.com:transcom/mymove into B-20010
r-mettler Jun 6, 2024
7c891c9
Merge branch 'B-20010' of github.com:transcom/mymove into B-20010-INT
r-mettler Jun 6, 2024
6fd72d9
Merge branch 'integrationTesting' into B-20010-INT
r-mettler Jun 7, 2024
99bad7b
fixing merge issue, duplicate if
r-mettler Jun 11, 2024
566d39d
Merge branch 'B-20010-INT' of github.com:transcom/mymove into B-20010…
r-mettler Jun 11, 2024
b6148a8
Merge branch 'integrationTesting' of github.com:transcom/mymove into …
r-mettler Jun 11, 2024
e4e3db0
Merge branch 'main' of github.com:transcom/mymove into B-20010
r-mettler Jun 12, 2024
e522dd5
Merge branch 'integrationTesting' of github.com:transcom/mymove into …
r-mettler Jun 12, 2024
cdb7046
Merge branch 'B-20010' of github.com:transcom/mymove into B-20010-INT
r-mettler Jun 12, 2024
057bf25
Merge branch 'integrationTesting' of github.com:transcom/mymove into …
r-mettler Jun 12, 2024
32f1e6d
use const for role and priv checks
r-mettler Jun 12, 2024
ebc996e
Merge branch 'main' of github.com:transcom/mymove into B-20010
r-mettler Jun 12, 2024
3938144
Merge branch 'integrationTesting' of github.com:transcom/mymove into …
r-mettler Jun 12, 2024
5c3da10
Merge branch 'B-20010' of github.com:transcom/mymove into B-20010-INT
r-mettler Jun 12, 2024
a77a607
Merge branch 'integrationTesting' into B-20010-INT
r-mettler Jun 12, 2024
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
2 changes: 2 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,7 @@ commands:
export FEATURE_FLAG_COAST_GUARD_EMPLID=true
export FEATURE_FLAG_MOVE_LOCK=false
export FEATURE_FLAG_OKTA_DODID_INPUT=false
export FEATURE_FLAG_HEADQUARTERS_ROLE=false
export FEATURE_FLAG_SAFETY_MOVE=false

# disable for speed, playwright tests can fail otherwise
Expand Down Expand Up @@ -905,6 +906,7 @@ commands:
FEATURE_FLAG_COAST_GUARD_EMPLID: 'true'
FEATURE_FLAG_MOVE_LOCK: 'false'
FEATURE_FLAG_OKTA_DODID_INPUT: 'false'
FEATURE_FLAG_HEADQUARTERS_ROLE: 'false'
FEATURE_FLAG_SAFETY_MOVE: 'false'
command: |
SHARD=$((${CIRCLE_NODE_INDEX}+1))
Expand Down
3 changes: 3 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ export FEATURE_FLAG_MOVE_LOCK=false
export FEATURE_FLAG_OKTA_DODID_INPUT=false
export FEATURE_FLAG_SAFETY_MOVE=true

# Feature flag to disable/enable headquarters role
export FEATURE_FLAG_HEADQUARTERS_ROLE=true

# Feature flags to disable certain shipment types
export FEATURE_FLAG_PPM=true
export FEATURE_FLAG_NTS=true
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 @@ -38,4 +38,5 @@ FEATURE_FLAG_VALIDATION_CODE_REQUIRED=false
FEATURE_FLAG_COAST_GUARD_EMPLID=false
FEATURE_FLAG_MOVE_LOCK=false
FEATURE_FLAG_OKTA_DODID_INPUT=false
FEATURE_FLAG_HEADQUARTERS_ROLE=false
FEATURE_FLAG_SAFETY_MOVE=false
1 change: 1 addition & 0 deletions config/env/demo.app.env
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ FEATURE_FLAG_VALIDATION_CODE_REQUIRED=false
FEATURE_FLAG_COAST_GUARD_EMPLID=false
FEATURE_FLAG_MOVE_LOCK=false
FEATURE_FLAG_OKTA_DODID_INPUT=false
FEATURE_FLAG_HEADQUARTERS_ROLE=false
FEATURE_FLAG_SAFETY_MOVE=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 @@ -38,4 +38,5 @@ FEATURE_FLAG_VALIDATION_CODE_REQUIRED=false
FEATURE_FLAG_COAST_GUARD_EMPLID=false
FEATURE_FLAG_MOVE_LOCK=false
FEATURE_FLAG_OKTA_DODID_INPUT=false
FEATURE_FLAG_HEADQUARTERS_ROLE=false
FEATURE_FLAG_SAFETY_MOVE=false
1 change: 1 addition & 0 deletions config/env/exp.app.env
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ FEATURE_FLAG_VALIDATION_CODE_REQUIRED=false
FEATURE_FLAG_COAST_GUARD_EMPLID=false
FEATURE_FLAG_MOVE_LOCK=false
FEATURE_FLAG_OKTA_DODID_INPUT=false
FEATURE_FLAG_HEADQUARTERS_ROLE=false
FEATURE_FLAG_SAFETY_MOVE=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 @@ -36,4 +36,5 @@ FEATURE_FLAG_VALIDATION_CODE_REQUIRED=false
FEATURE_FLAG_COAST_GUARD_EMPLID=false
FEATURE_FLAG_MOVE_LOCK=false
FEATURE_FLAG_OKTA_DODID_INPUT=false
FEATURE_FLAG_HEADQUARTERS_ROLE=false
FEATURE_FLAG_SAFETY_MOVE=false
1 change: 1 addition & 0 deletions config/env/loadtest.app.env
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,5 @@ FEATURE_FLAG_VALIDATION_CODE_REQUIRED=false
FEATURE_FLAG_COAST_GUARD_EMPLID=false
FEATURE_FLAG_MOVE_LOCK=false
FEATURE_FLAG_OKTA_DODID_INPUT=false
FEATURE_FLAG_HEADQUARTERS_ROLE=false
FEATURE_FLAG_SAFETY_MOVE=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 @@ -35,4 +35,5 @@ FEATURE_FLAG_VALIDATION_CODE_REQUIRED=false
FEATURE_FLAG_COAST_GUARD_EMPLID=false
FEATURE_FLAG_MOVE_LOCK=false
FEATURE_FLAG_OKTA_DODID_INPUT=false
FEATURE_FLAG_HEADQUARTERS_ROLE=false
FEATURE_FLAG_SAFETY_MOVE=false
1 change: 1 addition & 0 deletions config/env/prd.app.env
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@ FEATURE_FLAG_VALIDATION_CODE_REQUIRED=false
FEATURE_FLAG_COAST_GUARD_EMPLID=false
FEATURE_FLAG_MOVE_LOCK=false
FEATURE_FLAG_OKTA_DODID_INPUT=false
FEATURE_FLAG_HEADQUARTERS_ROLE=false
FEATURE_FLAG_SAFETY_MOVE=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 @@ -37,4 +37,5 @@ FEATURE_FLAG_VALIDATION_CODE_REQUIRED=false
FEATURE_FLAG_COAST_GUARD_EMPLID=false
FEATURE_FLAG_MOVE_LOCK=false
FEATURE_FLAG_OKTA_DODID_INPUT=false
FEATURE_FLAG_HEADQUARTERS_ROLE=false
FEATURE_FLAG_SAFETY_MOVE=false
1 change: 1 addition & 0 deletions config/env/stg.app.env
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ FEATURE_FLAG_VALIDATION_CODE_REQUIRED=false
FEATURE_FLAG_COAST_GUARD_EMPLID=false
FEATURE_FLAG_MOVE_LOCK=false
FEATURE_FLAG_OKTA_DODID_INPUT=false
FEATURE_FLAG_HEADQUARTERS_ROLE=false
FEATURE_FLAG_SAFETY_MOVE=false
8 changes: 8 additions & 0 deletions config/flipt/storage/development.features.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
version: "1.2"
namespace: development
flags:
- key: headquarters_role
name: Headquarters Role feature flag
type: BOOLEAN_FLAG_TYPE
enabled: true
rollouts:
- segment:
key: mil-app
value: true
- key: safety_move
name: Safety Move feature flag
type: BOOLEAN_FLAG_TYPE
Expand Down
3 changes: 2 additions & 1 deletion pkg/handlers/authentication/devlocal.go
Original file line number Diff line number Diff line change
Expand Up @@ -1141,7 +1141,8 @@ func loginUser(h devlocalAuthHandler, user *models.User, userType string, w http
}

func isOfficeUser(userType string) bool {
if userType == TOOOfficeUserType || userType == TIOOfficeUserType || userType == ServicesCounselorOfficeUserType || userType == QaeCsrOfficeUserType || userType == CustomerServiceRepresentativeOfficeUserType || userType == HQOfficeUserType {
if userType == TOOOfficeUserType || userType == TIOOfficeUserType || userType == ServicesCounselorOfficeUserType ||
userType == QaeCsrOfficeUserType || userType == CustomerServiceRepresentativeOfficeUserType || userType == HQOfficeUserType {
return true
}
return false
Expand Down
2 changes: 1 addition & 1 deletion pkg/handlers/authentication/permissions.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ var CustomerServiceRepresentative = RolePermissions{
},
}

var AllRolesPermissions = []RolePermissions{TOO, TIO, ServicesCounselor, QAECSR, HQ, CustomerServiceRepresentative}
var AllRolesPermissions = []RolePermissions{TOO, TIO, ServicesCounselor, QAECSR, CustomerServiceRepresentative, HQ}

// check if a [user.role] has permissions on a given object
func checkUserPermission(appCtx appcontext.AppContext, session *auth.Session, permission string) (bool, error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,6 @@ describe('RequestAccountForm component', () => {
const qsaCheckbox = screen.getByTestId('qualityAssuranceAndCustomerSupportCheckBox');
expect(qsaCheckbox).toBeInstanceOf(HTMLInputElement);
expect(qsaCheckbox).not.toBeChecked(false);

const hqCheckbox = screen.getByTestId('headquartersCheckBox');
expect(hqCheckbox).toBeInstanceOf(HTMLInputElement);
expect(hqCheckbox).not.toBeChecked(false);
});

it('cancels requesting office account when cancel button is clicked', async () => {
Expand Down Expand Up @@ -149,51 +145,6 @@ describe('RequestAccountForm component', () => {
expect(testProps.onSubmit).toHaveBeenCalled();
});

it('submits Headquarters office account form when submit button is clicked', async () => {
const mockOfficeId = '3210a533-19b8-4805-a564-7eb452afce10';
const mockHeadquartersOffice = {
address: {
city: 'Test City',
country: 'United States',
id: 'a13806fc-0e7d-4dc3-91ca-b802d9da50f1',
postalCode: '85309',
state: 'AZ',
streetAddress1: '7383 N Litchfield Rd',
streetAddress2: 'Rm 1122',
},
created_at: '2018-05-28T14:27:39.198Z',
gbloc: 'KKFA',
id: mockOfficeId,
name: 'Tester',
phone_lines: [],
updated_at: '2018-05-28T14:27:39.198Z',
};

const mockSearchHeadquartersOfficesOpen = () => Promise.resolve([mockHeadquartersOffice]);
searchTransportationOfficesOpen.mockImplementation(mockSearchHeadquartersOfficesOpen);

renderWithRouter(<RequestAccountForm {...testProps} />);

await userEvent.type(screen.getByLabelText('First Name'), 'Bob');
await userEvent.type(screen.getByLabelText('Last Name'), 'Banks');
await userEvent.type(screen.getByLabelText('Email'), '[email protected]');
await userEvent.type(screen.getByLabelText('Telephone'), '333-333-3333');
await userEvent.type(screen.getByTestId('officeAccountRequestEdipi'), '1111111111');
await userEvent.type(screen.getByTestId('officeAccountRequestOtherUniqueId'), '1111111111');

const transportationOfficeInput = screen.getByLabelText('Transportation Office');
fireEvent.change(transportationOfficeInput, { target: { value: 'Tester' } });
await act(() => selectEvent.select(transportationOfficeInput, /Tester/));

const tooCheckbox = screen.getByTestId('headquartersCheckBox');
await userEvent.click(tooCheckbox);

const submitButton = await screen.getByTestId('requestOfficeAccountSubmitButton');
await userEvent.click(submitButton);

expect(testProps.onSubmit).toHaveBeenCalled();
});

it('shows policy error when both TOO and TIO checkboxes are both selected, and goes away after unselecting one of them', async () => {
renderWithRouter(<RequestAccountForm {...testProps} />);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,6 @@ export const OfficeAccountRequestFields = ({ render }) => {
name="customerSupportRepresentativeCheckBox"
label="Customer Support Representative"
/>
<CheckboxField
id="headquartersCheckBox"
data-testid="headquartersCheckBox"
name="headquartersCheckBox"
label="Headquarters"
/>
</>,
)}
</Fieldset>
Expand Down
6 changes: 3 additions & 3 deletions src/pages/Office/RequestAccount/RequestAccount.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ export const RequestAccount = ({ setFlashMessage }) => {
roleType: 'qae_csr',
});
}
if (values.headquartersCheckBox) {
if (values.customerSupportRepresentativeCheckBox) {
Copy link
Contributor

@ajlusk ajlusk Jun 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hard to see in the default diff view but it looks like a weird merge thing caused this if block to be duplicated.
Screenshot 2024-06-10 at 2 43 47 PM

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha, figures. It didn't even flag it as a conflict. I'll go fix that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed it. Only did that on this INT branch. Thanks git *sigh

requestedRoles.push({
name: 'Headquarters',
roleType: 'headquarters',
name: 'Customer Service Representative',
roleType: 'customer_service_representative',
});
}
if (values.customerSupportRepresentativeCheckBox) {
Expand Down
40 changes: 38 additions & 2 deletions src/scenes/SystemAdmin/shared/RolesPrivilegesCheckboxes.jsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@
import React from 'react';
import React, { useState, useEffect } from 'react';
import { CheckboxGroupInput } from 'react-admin';

import { adminOfficeRoles } from 'constants/userRoles';
import { officeUserPrivileges } from 'constants/userPrivileges';
import { isBooleanFlagEnabled } from 'utils/featureFlags';

const RolesPrivilegesCheckboxInput = (props) => {
let rolesSelected = [];
let privilegesSelected = [];

const [isHeadquartersRoleFF, setHeadquartersRoleFF] = useState(false);

useEffect(() => {
isBooleanFlagEnabled('headquarters_role')?.then((enabled) => {
setHeadquartersRoleFF(enabled);
});
}, []);

const makeRoleTypeArray = (roles) => {
if (!roles || roles.length === 0) {
rolesSelected = [];
return undefined;
}
return roles.reduce((rolesArray, role) => {
if (role.roleType) {
rolesArray.push(role.roleType);
if (isHeadquartersRoleFF || (!isHeadquartersRoleFF && role.roleType !== 'headquarters')) {
rolesArray.push(role.roleType);
}
}

rolesSelected = rolesArray;
Expand All @@ -40,6 +51,22 @@ const RolesPrivilegesCheckboxInput = (props) => {
}
}

if (!isHeadquartersRoleFF && input.includes('headquarters')) {
r-mettler marked this conversation as resolved.
Show resolved Hide resolved
if (input.includes('headquarters')) {
index = input.indexOf('headquarters');
if (index !== -1) {
input.splice(index, 1);
}
}
} else if (isHeadquartersRoleFF && privilegesSelected.includes('safety')) {
if (input.includes('headquarters')) {
index = input.indexOf('headquarters');
if (index !== -1) {
input.splice(index, 1);
}
}
}

return input.reduce((rolesArray, role) => {
rolesArray.push(adminOfficeRoles.find((adminOfficeRole) => adminOfficeRole.roleType === role));
return rolesArray;
Expand Down Expand Up @@ -79,6 +106,15 @@ const RolesPrivilegesCheckboxInput = (props) => {
}
}

if (isHeadquartersRoleFF && rolesSelected.includes('headquarters')) {
if (input.includes('safety')) {
index = input.indexOf('safety');
if (index !== -1) {
input.splice(index, 1);
}
}
}

return input.reduce((privilegesArray, privilege) => {
privilegesArray.push(
officeUserPrivileges.find((officeUserPrivilege) => officeUserPrivilege.privilegeType === privilege),
Expand Down